2 * (c) Oleg Puchinin 2008
3 * graycardinalster@gmail.com
11 #include <gclib/gclib.h>
12 #include <gclib/gclib_c.h>
17 extern "C" DArray
* plugin_init (struct env_t
*env
);
18 int ruby_ctags (char * f_name
, FILE * of
);
19 int ruby_kinds_file (char * f_name
);
33 void ruby_set_rkinds (char *S
)
38 rkinds
|= Ruby::Class
;
41 rkinds
|= Ruby::Module
;
44 rkinds
|= Ruby::Function
;
51 char ruby_kinds_opt (DArray
* d_opts
, int * pos
)
53 if (! d_opts
|| ! pos
)
56 if (EQ (d_opts
->get (*pos
), "--ruby")) {
57 ENV
->language
= (char *) "Ruby";
61 if (NE (ENV
->language
, "Ruby"))
64 if (EQ (d_opts
->get (*pos
), "--kinds")) {
65 if (++(*pos
) >= d_opts
->get_size ())
73 char ruby_kinds_opt2 (DArray
* d_opts
, int * pos
)
75 if (EQ (d_opts
->get (*pos
), "--kinds")) {
76 if (++(*pos
) >= d_opts
->get_size ())
78 ruby_set_rkinds (d_opts
->get(*pos
));
86 int ruby_kinds_scan_line (const char *S
)
92 ptr
= strchr (S
, '#');
96 if (strstr (S
, "class "))
98 if (strstr (S
, "module "))
100 if (strstr (S
, "def "))
101 return Ruby::Function
;
106 char * ruby_kinds_tag (char * str
)
109 S
= ruby_last_word (str
);
121 files
= ENV
->d_files
;
122 for (i
= 0; i
< files
->get_size (); ++i
)
123 ruby_kinds_file (files
->get (i
));
128 int ruby_kinds_file (char * f_name
)
136 myfile
= fopen (f_name
, "r");
141 buf
= CNEW (char, 4096);
142 while (fgets (buf
, 4096, myfile
)) {
144 kind
= ruby_kinds_scan_line (buf
);
148 S
= ruby_kinds_tag (buf
);
158 void ruby_kinds_short_info ()
160 printf ("Ruby kinds plugin.");
163 void ruby_kinds_long_info ()
165 printf ("Ruby kinds plugin.\n");
166 printf ("Version: 1.0\n");
167 printf ("options: --kinds\n");
168 printf ("Usage: bob_ruby <files> --kinds <kinds>\n"
169 "\t\t kinds: c - class, f - function, m - module\n ");
172 DArray
* plugin_init (struct env_t
*env
)
177 Ret
= new DArray (1);
178 plug
= CNEW (mod_t
, 1);
179 memset (plug
, 0, sizeof (mod_t
));
181 plug
->Version
= strdup ("1.0");
182 plug
->short_info
= ruby_kinds_short_info
;
183 plug
->long_info
= ruby_kinds_long_info
;
184 plug
->opt
= ruby_kinds_opt
;
185 plug
->opt2
= ruby_kinds_opt2
;
187 ENV
->listOptions
->add ( "--ruby");
189 Ret
->add (LPCHAR (plug
));