rb_tags 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -1
- data/bin/rb_tags +2 -0
- data/lib/rb_tags/concerns/yaml_tasks.rb +8 -4
- data/lib/rb_tags/tags.rb +20 -8
- data/lib/rb_tags/version.rb +1 -1
- data/lib/rb_tags.rb +11 -14
- data/rb_tags.gemspec +2 -0
- data/spec/rb_tags/concerns/yaml_tasks_spec.rb +30 -7
- data/spec/rb_tags/tags_spec.rb +31 -8
- data/spec/rb_tags_spec.rb +6 -6
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da7bf6d417ead19868348089b51f7860b796c7ff
|
4
|
+
data.tar.gz: 51576d365b56280e9da7887d07fb7e7b05cdccc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e61f72619aaa01e06efe28510e0833624e0c4cbe3c5b16d91db36df07f903813dfc5e0031978b8b74d47bc530bc980f2e6c44cee0e669f45e570a6abd4ad8c4
|
7
|
+
data.tar.gz: d7461496821da150d5d8f8b6a42eea1b9948d98bb1c050427ff7a09c5c33b60903eed85f0ffa5aa1e5403c3ff3a0d3c77e5ee487591f3034424409665d792fd2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rb_tags (0.
|
4
|
+
rb_tags (0.3.0)
|
5
5
|
awesome_print
|
6
6
|
bundler
|
7
7
|
colorize
|
@@ -15,8 +15,11 @@ GEM
|
|
15
15
|
specs:
|
16
16
|
awesome_print (1.6.1)
|
17
17
|
blankslate (3.1.3)
|
18
|
+
byebug (5.0.0)
|
19
|
+
columnize (= 0.9.0)
|
18
20
|
coderay (1.1.0)
|
19
21
|
colorize (0.7.7)
|
22
|
+
columnize (0.9.0)
|
20
23
|
diff-lcs (1.2.5)
|
21
24
|
docile (1.1.5)
|
22
25
|
ffi (1.9.10)
|
@@ -57,6 +60,9 @@ GEM
|
|
57
60
|
coderay (~> 1.1.0)
|
58
61
|
method_source (~> 0.8.1)
|
59
62
|
slop (~> 3.4)
|
63
|
+
pry-byebug (3.2.0)
|
64
|
+
byebug (~> 5.0)
|
65
|
+
pry (~> 0.10)
|
60
66
|
rake (10.4.2)
|
61
67
|
rb-fsevent (0.9.5)
|
62
68
|
rb-inotify (0.9.5)
|
@@ -90,6 +96,8 @@ PLATFORMS
|
|
90
96
|
DEPENDENCIES
|
91
97
|
guard-bundler
|
92
98
|
guard-rspec
|
99
|
+
pry
|
100
|
+
pry-byebug
|
93
101
|
rb-fsevent
|
94
102
|
rb_tags!
|
95
103
|
rspec
|
data/bin/rb_tags
CHANGED
@@ -36,6 +36,8 @@ command :tag do |c|
|
|
36
36
|
# switches
|
37
37
|
c.desc 'tag also bundled gems'
|
38
38
|
c.switch [:gems], :default_value => false
|
39
|
+
c.desc 'forces deleting of tag file before tagging'
|
40
|
+
c.switch [:force], :default_value => false
|
39
41
|
|
40
42
|
c.action do |global_options,options,args|
|
41
43
|
generate(options)
|
@@ -2,13 +2,17 @@ module YamlTasks
|
|
2
2
|
# # WRITE
|
3
3
|
def write_to_yaml(dir: nil, this: {})
|
4
4
|
db = YAML::Store.new(store(dir), thread_safe: true)
|
5
|
-
db.transaction { db["tags"] = this }
|
5
|
+
db.transaction { db["tags"] = this }
|
6
6
|
end
|
7
7
|
|
8
8
|
# # READ
|
9
|
-
def
|
10
|
-
|
11
|
-
|
9
|
+
def read_from_yaml(dir: nil)
|
10
|
+
begin
|
11
|
+
db = YAML::Store.new(store(dir), thread_safe: true)
|
12
|
+
db.transaction { db.fetch("tags") }
|
13
|
+
rescue Exception => e
|
14
|
+
end
|
15
|
+
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
data/lib/rb_tags/tags.rb
CHANGED
@@ -4,16 +4,16 @@ class Tags
|
|
4
4
|
|
5
5
|
attr_reader :dir, :tags, :names
|
6
6
|
|
7
|
-
def initialize(dir
|
8
|
-
@dir = dir
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
7
|
+
def initialize(dir: Dir.getwd, force: false)
|
8
|
+
@dir = check(dir)
|
9
|
+
|
10
|
+
self.delete if force
|
11
|
+
self.read
|
13
12
|
end
|
14
13
|
|
15
14
|
def tag
|
16
15
|
FileUtils.cd(@dir) { |dir| @tags = find_expressions(dir, @mask) }
|
16
|
+
save
|
17
17
|
end
|
18
18
|
|
19
19
|
def add(tags)
|
@@ -31,11 +31,23 @@ class Tags
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def read
|
34
|
-
@tags =
|
35
|
-
tag if @tags.nil?
|
34
|
+
@tags = read_from_yaml(dir: @dir)
|
35
|
+
tag if @tags.nil? || @tags.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete
|
39
|
+
tag_file = File.join(@dir,".tags")
|
40
|
+
FileUtils.rm(tag_file) if File.exist?(tag_file)
|
36
41
|
end
|
37
42
|
|
38
43
|
def names
|
39
44
|
@tags.keys
|
40
45
|
end
|
46
|
+
|
47
|
+
def check(dir)
|
48
|
+
return dir if Dir.exist?(dir)
|
49
|
+
FileUtils.mkdir_p(dir)
|
50
|
+
|
51
|
+
dir
|
52
|
+
end
|
41
53
|
end
|
data/lib/rb_tags/version.rb
CHANGED
data/lib/rb_tags.rb
CHANGED
@@ -31,7 +31,7 @@ module RbTags
|
|
31
31
|
def generate(options={})
|
32
32
|
default_options(options)
|
33
33
|
|
34
|
-
tags = Tags.new(@options[:dir])
|
34
|
+
tags = Tags.new(dir: @options[:dir], force: (@options[:gems] || @options[:force]))
|
35
35
|
tags.tag
|
36
36
|
if @options[:gems]
|
37
37
|
result = tag_bundled_gems
|
@@ -45,29 +45,24 @@ module RbTags
|
|
45
45
|
gem_list = build_gem_list
|
46
46
|
results = ::Parallel.map(gem_list.each_slice(number_of_processors),
|
47
47
|
in_processes: number_of_processors) do |dir_list|
|
48
|
-
|
48
|
+
|
49
|
+
gem_list = Tags.new(dir: dir_list.shift)
|
49
50
|
gem_list.tag
|
50
51
|
|
51
52
|
dir_list.each do |dir|
|
52
|
-
gem_tags = Tags.new(dir
|
53
|
-
|
54
|
-
|
55
|
-
gem_tags.save
|
56
|
-
say_tagging(gem_tags.dir)
|
57
|
-
end
|
53
|
+
gem_tags = Tags.new(dir: dir)
|
54
|
+
say_tagging(gem_tags.dir)
|
55
|
+
# p gem_tags.tags.length
|
58
56
|
gem_list.add(gem_tags.tags)
|
59
57
|
end
|
60
|
-
|
61
58
|
gem_list
|
62
59
|
end
|
63
|
-
|
64
60
|
results
|
65
61
|
end
|
66
62
|
|
67
63
|
def say_tagging(dir)
|
68
64
|
$stdout.print "tag gem: ".blue
|
69
|
-
$stdout.print "#{dir}".colorize(:yellow_light)
|
70
|
-
$stdout.print " first time\n".blue
|
65
|
+
$stdout.print "#{dir}\n".colorize(:yellow_light)
|
71
66
|
end
|
72
67
|
|
73
68
|
#
|
@@ -76,7 +71,7 @@ module RbTags
|
|
76
71
|
|
77
72
|
# get list of all names of methods/classes/modules
|
78
73
|
def tags
|
79
|
-
@tags ||= Tags.new(
|
74
|
+
@tags ||= Tags.new(force: false)
|
80
75
|
@tags.names
|
81
76
|
end
|
82
77
|
|
@@ -129,7 +124,7 @@ module RbTags
|
|
129
124
|
end
|
130
125
|
|
131
126
|
def defaults
|
132
|
-
{ gems: false }
|
127
|
+
{ gems: false, force: false }
|
133
128
|
end
|
134
129
|
|
135
130
|
def default_dir
|
@@ -140,6 +135,8 @@ module RbTags
|
|
140
135
|
# :nocov:
|
141
136
|
file_line = "#{selected[:line]} #{selected[:path]}"
|
142
137
|
case editor
|
138
|
+
when 'atom'
|
139
|
+
`atom #{file_line}`
|
143
140
|
when 'mate'
|
144
141
|
`mate -l #{file_line}`
|
145
142
|
when 'emacs'
|
data/rb_tags.gemspec
CHANGED
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "guard-bundler"
|
27
27
|
spec.add_development_dependency "rb-fsevent"
|
28
28
|
spec.add_development_dependency "terminal-notifier-guard"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
spec.add_development_dependency "pry-byebug"
|
29
31
|
|
30
32
|
spec.add_runtime_dependency "awesome_print"
|
31
33
|
spec.add_runtime_dependency "bundler"
|
@@ -1,20 +1,43 @@
|
|
1
1
|
describe YamlTasks do
|
2
|
+
after(:each) do
|
3
|
+
tag_file = File.join(Dir.getwd,'.tags')
|
4
|
+
FileUtils.rm(tag_file) if File.exist?(tag_file)
|
5
|
+
end
|
6
|
+
|
2
7
|
subject { described_class }
|
3
8
|
|
4
9
|
it { expect(subject.name).to eq 'YamlTasks' }
|
5
10
|
|
6
|
-
describe '
|
11
|
+
describe 'include methods' do
|
7
12
|
subject { Class.include described_class }
|
8
|
-
describe 'default dir' do
|
9
|
-
let(:store) { subject.send(:store) }
|
10
13
|
|
11
|
-
|
14
|
+
describe '#write_to_yaml' do
|
15
|
+
it { expect{ subject.write_to_yaml(this: {}) }.not_to raise_error }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#read_from_yaml' do
|
19
|
+
|
20
|
+
it { expect{ subject.read_from_yaml }.not_to raise_error }
|
21
|
+
it 'does something' do
|
22
|
+
subject.write_to_yaml(this: {foo: "bar"} )
|
23
|
+
expect{ subject.read_from_yaml }.not_to raise_error
|
24
|
+
expect(subject.read_from_yaml).not_to be nil
|
25
|
+
end
|
12
26
|
end
|
13
27
|
|
14
|
-
describe '
|
15
|
-
|
28
|
+
describe '#store' do
|
29
|
+
describe 'default dir' do
|
30
|
+
let(:store) { subject.send(:store) }
|
31
|
+
|
32
|
+
it { expect(store).to eq File.join(Dir.getwd,'.tags') }
|
33
|
+
end
|
16
34
|
|
17
|
-
|
35
|
+
describe 'dir given' do
|
36
|
+
let(:store) { subject.send(:store, '/somewhere') }
|
37
|
+
|
38
|
+
it { expect(store).to eq File.join('/somewhere',".tags") }
|
39
|
+
end
|
18
40
|
end
|
19
41
|
end
|
42
|
+
|
20
43
|
end
|
data/spec/rb_tags/tags_spec.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Tags do
|
2
|
-
after(:
|
2
|
+
after(:each) do
|
3
3
|
tag_file = File.join(Dir.getwd,'.tags')
|
4
4
|
FileUtils.rm(tag_file) if File.exist?(tag_file)
|
5
5
|
end
|
@@ -14,11 +14,20 @@ describe Tags do
|
|
14
14
|
|
15
15
|
describe 'defaults' do
|
16
16
|
it { expect(subject.dir).to eq Dir.getwd }
|
17
|
-
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
describe '#check dir' do
|
19
|
+
let(:to_create_dir) { File.join(Dir.getwd, 'spec','what') }
|
20
|
+
|
21
|
+
it 'create dirs' do
|
22
|
+
subject.check(to_create_dir)
|
23
|
+
expect(Dir.exist?(to_create_dir)).to be true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'with params' do
|
28
|
+
subject { Tags.new(dir: './wo')}
|
29
|
+
it { expect(subject.dir).to eq './wo' }
|
30
|
+
end
|
22
31
|
end
|
23
32
|
|
24
33
|
describe '#tag' do
|
@@ -32,7 +41,7 @@ describe Tags do
|
|
32
41
|
end
|
33
42
|
|
34
43
|
it 'tags specified directory' do
|
35
|
-
subject = Tags.new(FileUtils.pwd)
|
44
|
+
subject = Tags.new(dir: FileUtils.pwd)
|
36
45
|
subject.tag
|
37
46
|
expect(subject.tags.length).to be > 1
|
38
47
|
expect(subject.tags).to be_a Hash
|
@@ -54,7 +63,6 @@ describe Tags do
|
|
54
63
|
it { expect { subject.read }.not_to raise_error }
|
55
64
|
it 'do it' do
|
56
65
|
subject.tag
|
57
|
-
subject.save
|
58
66
|
tag_file = File.join(subject.dir, '.tags')
|
59
67
|
expect(File.exist?(tag_file)).to eq true
|
60
68
|
object = Tags.new
|
@@ -75,7 +83,7 @@ describe Tags do
|
|
75
83
|
|
76
84
|
it 'has greater length, if not equal' do
|
77
85
|
dir = Bundler.load.specs.map(&:full_gem_path).last
|
78
|
-
compare = Tags.new(dir)
|
86
|
+
compare = Tags.new(dir: dir)
|
79
87
|
subject.tag
|
80
88
|
compare.tag
|
81
89
|
subject.add(compare.tags)
|
@@ -88,4 +96,19 @@ describe Tags do
|
|
88
96
|
it { expect(subject.names).to be_a Array }
|
89
97
|
it { expect(subject.names.first).to be_a String }
|
90
98
|
end
|
99
|
+
|
100
|
+
describe '#delete' do
|
101
|
+
before do
|
102
|
+
subject = Tags.new(dir: FileUtils.pwd)
|
103
|
+
subject.tag
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'tag file' do
|
107
|
+
expect(subject).to receive(:delete)
|
108
|
+
subject.delete
|
109
|
+
tag_file = File.join(subject.dir, '.tags')
|
110
|
+
|
111
|
+
expect(Dir.exist?(tag_file)).to be false
|
112
|
+
end
|
113
|
+
end
|
91
114
|
end
|
data/spec/rb_tags_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe RbTags do
|
|
42
42
|
before { foo.tags }
|
43
43
|
|
44
44
|
describe '#tags' do
|
45
|
-
let(:tag_tags) { Tags.new(
|
45
|
+
let(:tag_tags) { Tags.new(force: true).names}
|
46
46
|
|
47
47
|
it 'has tags' do
|
48
48
|
expect(foo.tags).to eq tag_tags
|
@@ -50,7 +50,7 @@ describe RbTags do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#complete_tag' do
|
53
|
-
let(:tag) { Tags.new(
|
53
|
+
let(:tag) { Tags.new(force: true).tags}
|
54
54
|
let(:arg) { tag.first.first }
|
55
55
|
|
56
56
|
before do
|
@@ -64,7 +64,7 @@ describe RbTags do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
describe '#found' do
|
67
|
-
let(:tag) { Tags.new(
|
67
|
+
let(:tag) { Tags.new(force: true).tags.first}
|
68
68
|
let(:key) { tag.first }
|
69
69
|
|
70
70
|
it 'does something' do
|
@@ -96,7 +96,7 @@ describe RbTags do
|
|
96
96
|
describe 'defaults' do
|
97
97
|
let(:tags) { foo.send(:default_options, {})}
|
98
98
|
let(:defaults) { foo.send(:defaults) }
|
99
|
-
let(:default) { {gems: false, dir: Dir.getwd} }
|
99
|
+
let(:default) { {gems: false, dir: Dir.getwd, force: false} }
|
100
100
|
|
101
101
|
it { expect { tags }.to_not raise_error }
|
102
102
|
it { expect(tags).to eq default }
|
@@ -108,7 +108,7 @@ describe RbTags do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
describe 'set gems' do
|
111
|
-
let(:options) { {gems: true, dir: '/somewhere'} }
|
111
|
+
let(:options) { {gems: true, dir: '/somewhere', force: false} }
|
112
112
|
let(:tag_w_options) { foo.send(:default_options, options)}
|
113
113
|
it { expect(tag_w_options).to eq options }
|
114
114
|
end
|
@@ -116,7 +116,7 @@ describe RbTags do
|
|
116
116
|
describe 'from gli' do
|
117
117
|
let(:income) { { "dir" => "..", :dir => "..", "save" => true, :save => true, "gems" => true, :read => false } }
|
118
118
|
let(:options) { foo.send(:default_options, income)}
|
119
|
-
let(:expected) { { :dir => "..", :save => true, :gems => true, :read => false } }
|
119
|
+
let(:expected) { { :dir => "..", :save => true, :gems => true, :read => false, force: false } }
|
120
120
|
|
121
121
|
it { expect(options).to eq expected }
|
122
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeFnord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: awesome_print
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|