twig 1.2.1 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.md +14 -1
- data/README.md +11 -5
- data/bin/twig +2 -2
- data/bin/twig-gh-open +3 -2
- data/bin/twig-gh-open-issue +2 -1
- data/lib/twig.rb +13 -12
- data/lib/twig/cli.rb +77 -33
- data/lib/twig/display.rb +55 -33
- data/lib/twig/github.rb +10 -7
- data/lib/twig/options.rb +59 -7
- data/lib/twig/util.rb +4 -0
- data/lib/twig/version.rb +1 -1
- data/spec/twig/cli_spec.rb +106 -13
- data/spec/twig/display_spec.rb +131 -23
- data/spec/twig/github_spec.rb +299 -0
- data/spec/twig/options_spec.rb +108 -7
- data/spec/twig/util_spec.rb +24 -0
- data/spec/twig_spec.rb +41 -27
- data/twig.gemspec +4 -3
- metadata +26 -9
data/spec/twig/util_spec.rb
CHANGED
@@ -13,4 +13,28 @@ describe Twig::Util do
|
|
13
13
|
Twig::Util.numeric?({}).should be_false
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
describe '.truthy?' do
|
18
|
+
it 'returns true if an object is truthy' do
|
19
|
+
Twig::Util.truthy?('true').should be_true
|
20
|
+
Twig::Util.truthy?('TRUE').should be_true
|
21
|
+
Twig::Util.truthy?(true).should be_true
|
22
|
+
Twig::Util.truthy?('yes').should be_true
|
23
|
+
Twig::Util.truthy?('YES').should be_true
|
24
|
+
Twig::Util.truthy?('y').should be_true
|
25
|
+
Twig::Util.truthy?('Y').should be_true
|
26
|
+
Twig::Util.truthy?('on').should be_true
|
27
|
+
Twig::Util.truthy?('ON').should be_true
|
28
|
+
Twig::Util.truthy?('1').should be_true
|
29
|
+
Twig::Util.truthy?(1).should be_true
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns false if an object is falsy' do
|
33
|
+
Twig::Util.truthy?('false').should be_false
|
34
|
+
Twig::Util.truthy?(false).should be_false
|
35
|
+
Twig::Util.truthy?('yep').should be_false
|
36
|
+
Twig::Util.truthy?('sure, why not').should be_false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
16
40
|
end
|
data/spec/twig_spec.rb
CHANGED
@@ -2,6 +2,27 @@ require 'spec_helper'
|
|
2
2
|
require 'tmpdir'
|
3
3
|
|
4
4
|
describe Twig do
|
5
|
+
describe '.repo?' do
|
6
|
+
it 'is true when the working directory is a git repository' do
|
7
|
+
Dir.chdir(File.dirname(__FILE__)) do
|
8
|
+
Twig.should be_repo
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'is false when the working directory is not a git repository' do
|
13
|
+
Dir.mktmpdir do |tmpdir|
|
14
|
+
Dir.chdir(tmpdir) do
|
15
|
+
Twig.should_not be_repo
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'captures stderr' do
|
21
|
+
Twig.should_receive(:run).with(/2>&1/)
|
22
|
+
Twig.repo?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
5
26
|
describe '#initialize' do
|
6
27
|
it 'creates a Twig instance' do
|
7
28
|
twig = Twig.new
|
@@ -16,9 +37,9 @@ describe Twig do
|
|
16
37
|
twig = Twig.new
|
17
38
|
branch_name = 'fix_all_the_things'
|
18
39
|
Twig.should_receive(:run).
|
19
|
-
with('git
|
40
|
+
with('git rev-parse --abbrev-ref HEAD').
|
20
41
|
once. # Should memoize
|
21
|
-
and_return(
|
42
|
+
and_return(branch_name)
|
22
43
|
|
23
44
|
2.times { twig.current_branch_name.should == branch_name }
|
24
45
|
end
|
@@ -134,14 +155,14 @@ describe Twig do
|
|
134
155
|
end
|
135
156
|
end
|
136
157
|
|
137
|
-
describe '#
|
138
|
-
it 'returns an array of branch names' do
|
158
|
+
describe '#all_branch_names' do
|
159
|
+
it 'returns an array of all branch names' do
|
139
160
|
twig = Twig.new
|
140
161
|
branch_names = %w[foo bar baz]
|
141
162
|
branches = branch_names.map { |name| Twig::Branch.new(name) }
|
142
|
-
twig.should_receive(:
|
163
|
+
twig.should_receive(:all_branches).and_return(branches)
|
143
164
|
|
144
|
-
twig.
|
165
|
+
twig.all_branch_names.should == branch_names
|
145
166
|
end
|
146
167
|
end
|
147
168
|
|
@@ -171,12 +192,26 @@ describe Twig do
|
|
171
192
|
and_return(@branch_lines[0])
|
172
193
|
@twig.should_receive(:branch_list_line).with(@branches[1]).
|
173
194
|
and_return(@branch_lines[1])
|
195
|
+
|
174
196
|
result = @twig.list_branches
|
175
197
|
|
176
198
|
result.should == "\n" + @list_headers +
|
177
199
|
@branch_lines[1] + "\n" + @branch_lines[0]
|
178
200
|
end
|
179
201
|
|
202
|
+
it 'returns a list of branches, least recently modified first' do
|
203
|
+
@twig.set_option(:reverse, true)
|
204
|
+
@twig.stub(:branches) { @branches }
|
205
|
+
@twig.stub(:branch_list_headers) { @list_headers }
|
206
|
+
@twig.stub(:branch_list_line).with(@branches[0]) { @branch_lines[0] }
|
207
|
+
@twig.stub(:branch_list_line).with(@branches[1]) { @branch_lines[1] }
|
208
|
+
|
209
|
+
result = @twig.list_branches
|
210
|
+
|
211
|
+
result.should == "\n" + @list_headers +
|
212
|
+
@branch_lines[0] + "\n" + @branch_lines[1]
|
213
|
+
end
|
214
|
+
|
180
215
|
it 'returns a message if all branches were filtered out by options' do
|
181
216
|
@twig.stub(:all_branches => %w[foo bar])
|
182
217
|
@twig.stub(:branches => [])
|
@@ -237,25 +272,4 @@ describe Twig do
|
|
237
272
|
end
|
238
273
|
end
|
239
274
|
|
240
|
-
describe '#repo?' do
|
241
|
-
it 'is true when the working directory is a git repository' do
|
242
|
-
Dir.chdir(File.dirname(__FILE__)) do
|
243
|
-
Twig.new.should be_repo
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'is false when the working directory is not a git repository' do
|
248
|
-
Dir.mktmpdir do |tmpdir|
|
249
|
-
Dir.chdir(tmpdir) do
|
250
|
-
Twig.new.should_not be_repo
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
it 'captures stderr' do
|
256
|
-
Twig.should_receive(:run).with(/2>&1/)
|
257
|
-
twig = Twig.new
|
258
|
-
twig.repo?
|
259
|
-
end
|
260
|
-
end
|
261
275
|
end
|
data/twig.gemspec
CHANGED
@@ -33,7 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.test_files = spec.files.grep(%r{^spec/})
|
34
34
|
|
35
35
|
spec.required_ruby_version = '>= 1.8.7'
|
36
|
-
spec.add_runtime_dependency 'json',
|
37
|
-
spec.
|
38
|
-
spec.add_development_dependency '
|
36
|
+
spec.add_runtime_dependency 'json', '~> 1.7.5'
|
37
|
+
spec.add_runtime_dependency 'launchy', '~> 2.3.0'
|
38
|
+
spec.add_development_dependency 'rake', '~> 0.9.2'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 2.13.0'
|
39
40
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 1.2.1
|
8
|
+
- 3
|
9
|
+
version: "1.3"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Ron DeVera
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2013-05-
|
17
|
+
date: 2013-05-22 00:00:00 -07:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -35,9 +34,25 @@ dependencies:
|
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
37
|
+
name: launchy
|
39
38
|
prerelease: false
|
40
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 3
|
48
|
+
- 0
|
49
|
+
version: 2.3.0
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rake
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
56
|
none: false
|
42
57
|
requirements:
|
43
58
|
- - ~>
|
@@ -49,11 +64,11 @@ dependencies:
|
|
49
64
|
- 2
|
50
65
|
version: 0.9.2
|
51
66
|
type: :development
|
52
|
-
version_requirements: *
|
67
|
+
version_requirements: *id003
|
53
68
|
- !ruby/object:Gem::Dependency
|
54
69
|
name: rspec
|
55
70
|
prerelease: false
|
56
|
-
requirement: &
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
72
|
none: false
|
58
73
|
requirements:
|
59
74
|
- - ~>
|
@@ -65,7 +80,7 @@ dependencies:
|
|
65
80
|
- 0
|
66
81
|
version: 2.13.0
|
67
82
|
type: :development
|
68
|
-
version_requirements: *
|
83
|
+
version_requirements: *id004
|
69
84
|
description: Twig is your personal Git branch assistant. It's a command-line tool for tracking progress on your branches, remembering ticket ids for each branch, and more. Twig supports subcommands for managing branches however you want.
|
70
85
|
email:
|
71
86
|
- hello@rondevera.com
|
@@ -112,6 +127,7 @@ files:
|
|
112
127
|
- spec/twig/cli_spec.rb
|
113
128
|
- spec/twig/commit_time_spec.rb
|
114
129
|
- spec/twig/display_spec.rb
|
130
|
+
- spec/twig/github_spec.rb
|
115
131
|
- spec/twig/options_spec.rb
|
116
132
|
- spec/twig/util_spec.rb
|
117
133
|
- spec/twig_spec.rb
|
@@ -168,6 +184,7 @@ test_files:
|
|
168
184
|
- spec/twig/cli_spec.rb
|
169
185
|
- spec/twig/commit_time_spec.rb
|
170
186
|
- spec/twig/display_spec.rb
|
187
|
+
- spec/twig/github_spec.rb
|
171
188
|
- spec/twig/options_spec.rb
|
172
189
|
- spec/twig/util_spec.rb
|
173
190
|
- spec/twig_spec.rb
|