CoffeeTags 0.0.1.7 → 0.0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/lib/CoffeeTags/formatter.rb +14 -18
- data/lib/CoffeeTags/version.rb +1 -1
- data/lib/CoffeeTags.rb +26 -22
- data/spec/coffeetags_spec.rb +32 -1
- data/spec/fixtures/out.test-two.ctags +21 -0
- data/spec/fixtures/out.test.ctags +13 -0
- metadata +9 -4
data/.travis.yml
ADDED
data/lib/CoffeeTags/formatter.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
module Coffeetags
|
2
2
|
class Formatter
|
3
|
-
|
3
|
+
def self.header
|
4
|
+
return [
|
5
|
+
"!_TAG_FILE_FORMAT 2 /extended format/",
|
6
|
+
"!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/",
|
7
|
+
"!_TAG_PROGRAM_AUTHOR #{::Coffeetags::AUTHOR}",
|
8
|
+
"!_TAG_PROGRAM_NAME #{::Coffeetags::NAME} //",
|
9
|
+
"!_TAG_PROGRAM_URL #{::Coffeetags::URL} /GitHub repository/",
|
10
|
+
"!_TAG_PROGRAM_VERSION #{::Coffeetags::VERSION} //"
|
11
|
+
].map { |h| "#{h}\n"}.join ''
|
12
|
+
end
|
4
13
|
|
5
14
|
def initialize file, tree =[]
|
6
15
|
@file = file
|
@@ -13,8 +22,10 @@ module Coffeetags
|
|
13
22
|
'o' => 'type:object',
|
14
23
|
'v' => 'type:var'
|
15
24
|
}
|
25
|
+
@header = Formatter.header
|
16
26
|
end
|
17
27
|
|
28
|
+
|
18
29
|
def regex_line line
|
19
30
|
"/#{line}/;\""
|
20
31
|
end
|
@@ -36,29 +47,14 @@ module Coffeetags
|
|
36
47
|
|
37
48
|
def parse_tree
|
38
49
|
@lines = @tree.map do | content|
|
39
|
-
|
50
|
+
line_to_string content unless content[:line].nil? or content[:name].blank?
|
40
51
|
end.reject{|l| l.nil? }
|
41
52
|
end
|
42
53
|
|
43
54
|
|
44
55
|
def tags
|
45
|
-
@lines.map { |l| "#{l}\n"}
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_file
|
49
|
-
self.header + tags
|
56
|
+
@lines.map { |l| "#{l}\n"}.join ''
|
50
57
|
end
|
51
58
|
|
52
|
-
def self.header
|
53
|
-
|
54
|
-
header = [
|
55
|
-
"!_TAG_FILE_FORMAT 2 /extended format/",
|
56
|
-
"!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/",
|
57
|
-
"!_TAG_PROGRAM_AUTHOR #{Coffeetags::AUTHOR}",
|
58
|
-
"!_TAG_PROGRAM_NAME #{Coffeetags::NAME} //",
|
59
|
-
"!_TAG_PROGRAM_URL #{Coffeetags::URL} /GitHub repository/",
|
60
|
-
"!_TAG_PROGRAM_VERSION #{Coffeetags::VERSION} //"
|
61
|
-
].map { |h| "#{h}\n"}
|
62
|
-
end
|
63
59
|
end
|
64
60
|
end
|
data/lib/CoffeeTags/version.rb
CHANGED
data/lib/CoffeeTags.rb
CHANGED
@@ -30,6 +30,28 @@ combine --vim-conf and --include-vars to create a config which adds '--include-v
|
|
30
30
|
HELP
|
31
31
|
}
|
32
32
|
class Utils
|
33
|
+
def self.tagbar_conf include_vars
|
34
|
+
<<-CONF
|
35
|
+
" Add this type definition to your vimrc
|
36
|
+
" or do
|
37
|
+
" coffeetags --vim-conf >> <PATH TO YOUR VIMRC>
|
38
|
+
" if you want your tags to include vars/objects do:
|
39
|
+
" coffeetags --vim-conf --include-vars
|
40
|
+
let g:tagbar_type_coffee = {
|
41
|
+
\\ 'kinds' : [
|
42
|
+
\\ 'f:functions',
|
43
|
+
\\ 'o:object'
|
44
|
+
\\ ],
|
45
|
+
\\ 'kind2scope' : {
|
46
|
+
\\ 'f' : 'object',
|
47
|
+
\\ 'o' : 'object'
|
48
|
+
\\},
|
49
|
+
\\ 'sro' : ".",
|
50
|
+
\\ 'ctagsbin' : 'coffeetags',
|
51
|
+
\\ 'ctagsargs' : '#{include_vars ? "--include-vars" : "" } ',
|
52
|
+
\\}
|
53
|
+
CONF
|
54
|
+
end
|
33
55
|
|
34
56
|
def self.option_parser args
|
35
57
|
args = ['--version', '--help'] if args.empty?
|
@@ -60,6 +82,8 @@ HELP
|
|
60
82
|
|
61
83
|
|
62
84
|
def self.run output, include_vars, files
|
85
|
+
|
86
|
+
files = [files] if files.is_a? String
|
63
87
|
__out = if output.nil?
|
64
88
|
STDOUT
|
65
89
|
else
|
@@ -80,29 +104,9 @@ HELP
|
|
80
104
|
__out << formatter.tags
|
81
105
|
end
|
82
106
|
__out.close if __out.respond_to? :close
|
83
|
-
end
|
84
107
|
|
85
|
-
|
86
|
-
<<-CONF
|
87
|
-
" Add this type definition to your vimrc
|
88
|
-
" or do
|
89
|
-
" coffeetags --vim-conf >> <PATH TO YOUR VIMRC>
|
90
|
-
" if you want your tags to include vars/objects do:
|
91
|
-
" coffeetags --vim-conf --include-vars
|
92
|
-
let g:tagbar_type_coffee = {
|
93
|
-
\\ 'kinds' : [
|
94
|
-
\\ 'f:functions',
|
95
|
-
\\ 'o:object'
|
96
|
-
\\ ],
|
97
|
-
\\ 'kind2scope' : {
|
98
|
-
\\ 'f' : 'object',
|
99
|
-
\\ 'o' : 'object'
|
100
|
-
\\},
|
101
|
-
\\ 'sro' : ".",
|
102
|
-
\\ 'ctagsbin' : 'coffeetags',
|
103
|
-
\\ 'ctagsargs' : '#{include_vars ? "--include-vars" : "" } ',
|
104
|
-
\\}
|
105
|
-
CONF
|
108
|
+
__out.join("\n") if __out.is_a? Array
|
106
109
|
end
|
110
|
+
|
107
111
|
end
|
108
112
|
end
|
data/spec/coffeetags_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require File.expand_path('lib/CoffeeTags')
|
2
2
|
include Coffeetags
|
3
3
|
describe Utils do
|
4
4
|
context 'Argument parsing' do
|
@@ -59,4 +59,35 @@ FF
|
|
59
59
|
|
60
60
|
end
|
61
61
|
|
62
|
+
context "Complete output" do
|
63
|
+
it "genrates tags for given file" do
|
64
|
+
|
65
|
+
files = "spec/fixtures/test.coffee"
|
66
|
+
|
67
|
+
output = "test.out"
|
68
|
+
|
69
|
+
Coffeetags::Utils.run output, nil, files
|
70
|
+
|
71
|
+
File.read("test.out").should == File.read("./spec/fixtures/out.test.ctags")
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
it "genrates tags for given files" do
|
77
|
+
|
78
|
+
files = [ "spec/fixtures/test.coffee", 'spec/fixtures/campfire.coffee']
|
79
|
+
|
80
|
+
output = "test.out"
|
81
|
+
|
82
|
+
Coffeetags::Utils.run output, nil, files
|
83
|
+
|
84
|
+
File.read("test.out").should == File.read("./spec/fixtures/out.test-two.ctags")
|
85
|
+
|
86
|
+
end
|
87
|
+
after :each do
|
88
|
+
STDERR << "DELETING!"
|
89
|
+
`rm test.out`
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
62
93
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format/
|
2
|
+
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
!_TAG_PROGRAM_AUTHOR Łukasz Korecki /lukasz@coffeesounds.com/
|
4
|
+
!_TAG_PROGRAM_NAME CoffeeTags //
|
5
|
+
!_TAG_PROGRAM_URL https://github.com/lukaszkorecki/CoffeeTags /GitHub repository/
|
6
|
+
!_TAG_PROGRAM_VERSION 0.0.1.7 //
|
7
|
+
bump spec/fixtures/test.coffee /bump/;" f lineno:1 object:window type:function
|
8
|
+
ho spec/fixtures/test.coffee /ho/;" f lineno:5 object:Wat type:function
|
9
|
+
bump spec/fixtures/test.coffee /bump/;" f lineno:10 object:Wat.ho.@lolWat type:function
|
10
|
+
bump_up spec/fixtures/test.coffee /bump_up/;" f lineno:12 object:Wat.ho.@lolWat type:function
|
11
|
+
@filter spec/fixtures/test.coffee /@filter/;" f lineno:14 object:Wat.ho type:function
|
12
|
+
_loop spec/fixtures/test.coffee /_loop/;" f lineno:19 object:window type:function
|
13
|
+
bound_func spec/fixtures/test.coffee /bound_func/;" f lineno:41 object:window type:function
|
14
|
+
constructor spec/fixtures/campfire.coffee /constructor/;" f lineno:8 object:Campfire type:function
|
15
|
+
handlers spec/fixtures/campfire.coffee /handlers/;" f lineno:14 object:Campfire type:function
|
16
|
+
onSuccess spec/fixtures/campfire.coffee /onSuccess/;" f lineno:16 object:Campfire.handlers.resp type:function
|
17
|
+
onFailure spec/fixtures/campfire.coffee /onFailure/;" f lineno:24 object:Campfire.handlers.resp type:function
|
18
|
+
rooms spec/fixtures/campfire.coffee /rooms/;" f lineno:29 object:Campfire type:function
|
19
|
+
roomInfo spec/fixtures/campfire.coffee /roomInfo/;" f lineno:34 object:Campfire type:function
|
20
|
+
recent spec/fixtures/campfire.coffee /recent/;" f lineno:40 object:Campfire type:function
|
21
|
+
bump spec/fixtures/campfire.coffee /bump/;" f lineno:46 object:Test type:function
|
@@ -0,0 +1,13 @@
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format/
|
2
|
+
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
!_TAG_PROGRAM_AUTHOR Łukasz Korecki /lukasz@coffeesounds.com/
|
4
|
+
!_TAG_PROGRAM_NAME CoffeeTags //
|
5
|
+
!_TAG_PROGRAM_URL https://github.com/lukaszkorecki/CoffeeTags /GitHub repository/
|
6
|
+
!_TAG_PROGRAM_VERSION 0.0.1.7 //
|
7
|
+
bump spec/fixtures/test.coffee /bump/;" f lineno:1 object:window type:function
|
8
|
+
ho spec/fixtures/test.coffee /ho/;" f lineno:5 object:Wat type:function
|
9
|
+
bump spec/fixtures/test.coffee /bump/;" f lineno:10 object:Wat.ho.@lolWat type:function
|
10
|
+
bump_up spec/fixtures/test.coffee /bump_up/;" f lineno:12 object:Wat.ho.@lolWat type:function
|
11
|
+
@filter spec/fixtures/test.coffee /@filter/;" f lineno:14 object:Wat.ho type:function
|
12
|
+
_loop spec/fixtures/test.coffee /_loop/;" f lineno:19 object:window type:function
|
13
|
+
bound_func spec/fixtures/test.coffee /bound_func/;" f lineno:41 object:window type:function
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CoffeeTags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 91
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 1
|
10
|
-
-
|
11
|
-
version: 0.0.1.
|
10
|
+
- 8
|
11
|
+
version: 0.0.1.8
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- "\xC5\x81ukasz Korecki"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
19
|
+
date: 2012-01-02 00:00:00 +00:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -32,6 +32,7 @@ extra_rdoc_files: []
|
|
32
32
|
files:
|
33
33
|
- .gitignore
|
34
34
|
- .rvmrc
|
35
|
+
- .travis.yml
|
35
36
|
- CoffeeTags.gemspec
|
36
37
|
- Gemfile
|
37
38
|
- Guardfile
|
@@ -46,6 +47,8 @@ files:
|
|
46
47
|
- spec/fixtures/campfire.coffee
|
47
48
|
- spec/fixtures/campfire.js
|
48
49
|
- spec/fixtures/campfire.js.tags
|
50
|
+
- spec/fixtures/out.test-two.ctags
|
51
|
+
- spec/fixtures/out.test.ctags
|
49
52
|
- spec/fixtures/test.coffee
|
50
53
|
- spec/fixtures/test_tree.yaml
|
51
54
|
- spec/fixtures/tree.yaml
|
@@ -91,6 +94,8 @@ test_files:
|
|
91
94
|
- spec/fixtures/campfire.coffee
|
92
95
|
- spec/fixtures/campfire.js
|
93
96
|
- spec/fixtures/campfire.js.tags
|
97
|
+
- spec/fixtures/out.test-two.ctags
|
98
|
+
- spec/fixtures/out.test.ctags
|
94
99
|
- spec/fixtures/test.coffee
|
95
100
|
- spec/fixtures/test_tree.yaml
|
96
101
|
- spec/fixtures/tree.yaml
|