twig 1.1 → 1.2
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 +11 -0
- data/README.md +7 -3
- data/bin/twig +5 -1
- data/bin/twig-gh-open +3 -30
- data/bin/twig-gh-open-issue +1 -31
- data/bin/twig-gh-update +1 -31
- data/lib/twig.rb +24 -9
- data/lib/twig/cli.rb +97 -36
- data/lib/twig/display.rb +2 -2
- data/lib/twig/github.rb +36 -0
- data/lib/twig/options.rb +24 -7
- data/lib/twig/version.rb +1 -1
- data/spec/twig/cli_spec.rb +248 -140
- data/spec/twig/display_spec.rb +19 -15
- data/spec/twig/options_spec.rb +33 -25
- data/spec/twig_spec.rb +55 -8
- data/twig.gemspec +1 -1
- metadata +8 -7
data/spec/twig/display_spec.rb
CHANGED
@@ -172,30 +172,34 @@ describe Twig::Display do
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
describe '#
|
176
|
-
it '
|
177
|
-
|
175
|
+
describe '#unformat_string' do
|
176
|
+
it 'unformats a plain text string' do
|
177
|
+
string = 'foo'
|
178
|
+
@twig.unformat_string(string).should == string
|
178
179
|
end
|
179
180
|
|
180
|
-
it '
|
181
|
-
string =
|
182
|
-
string
|
181
|
+
it 'unformats a string with color' do
|
182
|
+
string = 'foo'
|
183
|
+
formatted_string = @twig.format_string(string, :color => :red)
|
184
|
+
formatted_string.size.should > 3 # Precondition
|
183
185
|
|
184
|
-
@twig.
|
186
|
+
@twig.unformat_string(formatted_string).should == string
|
185
187
|
end
|
186
188
|
|
187
|
-
it '
|
188
|
-
string =
|
189
|
-
string
|
189
|
+
it 'unformats a string with weight' do
|
190
|
+
string = 'foo'
|
191
|
+
formatted_string = @twig.format_string(string, :weight => :bold)
|
192
|
+
formatted_string.size.should > 3 # Precondition
|
190
193
|
|
191
|
-
@twig.
|
194
|
+
@twig.unformat_string(formatted_string).should == string
|
192
195
|
end
|
193
196
|
|
194
|
-
it '
|
195
|
-
string =
|
196
|
-
string
|
197
|
+
it 'unformats a string with color and weight' do
|
198
|
+
string = 'foo'
|
199
|
+
formatted_string = @twig.format_string(string, :color => :red, :weight => :bold)
|
200
|
+
formatted_string.size.should > 3 # Precondition
|
197
201
|
|
198
|
-
@twig.
|
202
|
+
@twig.unformat_string(formatted_string).should == string
|
199
203
|
end
|
200
204
|
end
|
201
205
|
end
|
data/spec/twig/options_spec.rb
CHANGED
@@ -31,28 +31,36 @@ describe Twig::Options do
|
|
31
31
|
File.should_receive(:open).with(Twig::CONFIG_FILE).and_yield(file)
|
32
32
|
file.should_receive(:read).and_return([
|
33
33
|
'branch: test',
|
34
|
-
'
|
35
|
-
'only-branch: test-only',
|
34
|
+
'header-style: green bold',
|
36
35
|
'max-days-old: 30.5',
|
37
|
-
'
|
36
|
+
'except-branch: test-except-branch',
|
37
|
+
'only-branch: test-only-branch',
|
38
|
+
'except-foo: test-except-foo',
|
39
|
+
'only-foo: test-only-foo'
|
38
40
|
].join("\n"))
|
39
41
|
|
40
42
|
# Check preconditions
|
41
43
|
@twig.options[:branch].should be_nil
|
42
|
-
@twig.options[:branch_except].should be_nil
|
43
|
-
@twig.options[:branch_only].should be_nil
|
44
|
-
@twig.options[:max_days_old].should be_nil
|
45
44
|
@twig.options[:header_color].should == Twig::DEFAULT_HEADER_COLOR
|
46
45
|
@twig.options[:header_weight].should be_nil
|
46
|
+
@twig.options[:max_days_old].should be_nil
|
47
|
+
@twig.options[:property_except].should be_nil
|
48
|
+
@twig.options[:property_only].should be_nil
|
47
49
|
|
48
50
|
@twig.read_config_file!
|
49
51
|
|
50
52
|
@twig.options[:branch].should == 'test'
|
51
|
-
@twig.options[:branch_except].should == /test-except/
|
52
|
-
@twig.options[:branch_only].should == /test-only/
|
53
|
-
@twig.options[:max_days_old].should == 30.5
|
54
53
|
@twig.options[:header_color].should == :green
|
55
54
|
@twig.options[:header_weight].should == :bold
|
55
|
+
@twig.options[:max_days_old].should == 30.5
|
56
|
+
@twig.options[:property_except].should == {
|
57
|
+
:branch => /test-except-branch/,
|
58
|
+
:foo => /test-except-foo/
|
59
|
+
}
|
60
|
+
@twig.options[:property_only].should == {
|
61
|
+
:branch => /test-only-branch/,
|
62
|
+
:foo => /test-only-foo/
|
63
|
+
}
|
56
64
|
end
|
57
65
|
|
58
66
|
it 'skips comments' do
|
@@ -82,13 +90,13 @@ describe Twig::Options do
|
|
82
90
|
].join("\n"))
|
83
91
|
|
84
92
|
# Check preconditions
|
85
|
-
@twig.options[:
|
86
|
-
@twig.options[:
|
93
|
+
@twig.options[:property_except].should be_nil
|
94
|
+
@twig.options[:property_only].should be_nil
|
87
95
|
|
88
96
|
@twig.read_config_file!
|
89
97
|
|
90
|
-
@twig.options[:
|
91
|
-
@twig.options[:
|
98
|
+
@twig.options[:property_except].should == { :branch => /test-except/ }
|
99
|
+
@twig.options[:property_only].should == { :branch => /test-only/ }
|
92
100
|
end
|
93
101
|
|
94
102
|
it 'fails gracefully if the config file is not readable' do
|
@@ -125,18 +133,6 @@ describe Twig::Options do
|
|
125
133
|
end
|
126
134
|
end
|
127
135
|
|
128
|
-
it 'sets a :branch_except option' do
|
129
|
-
@twig.options[:branch_except].should be_nil # Precondition
|
130
|
-
@twig.set_option(:branch_except, 'unwanted_prefix_')
|
131
|
-
@twig.options[:branch_except].should == /unwanted_prefix_/
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'sets a :branch_only option' do
|
135
|
-
@twig.options[:branch_only].should be_nil # Precondition
|
136
|
-
@twig.set_option(:branch_only, 'important_prefix_')
|
137
|
-
@twig.options[:branch_only].should == /important_prefix_/
|
138
|
-
end
|
139
|
-
|
140
136
|
it 'sets a :header_style option' do
|
141
137
|
style = 'red bold'
|
142
138
|
@twig.should_receive(:set_header_style_option).with(style)
|
@@ -165,6 +161,18 @@ describe Twig::Options do
|
|
165
161
|
end
|
166
162
|
end
|
167
163
|
|
164
|
+
it 'sets a :property_except option' do
|
165
|
+
@twig.options[:property_except].should be_nil # Precondition
|
166
|
+
@twig.set_option(:property_except, :branch => 'unwanted_prefix_')
|
167
|
+
@twig.options[:property_except].should == { :branch => /unwanted_prefix_/ }
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'sets a :property_only option' do
|
171
|
+
@twig.options[:property_only].should be_nil # Precondition
|
172
|
+
@twig.set_option(:property_only, :branch => 'important_prefix_')
|
173
|
+
@twig.options[:property_only].should == { :branch => /important_prefix_/ }
|
174
|
+
end
|
175
|
+
|
168
176
|
it 'sets an :unset_property option' do
|
169
177
|
@twig.options[:unset_property].should be_nil # Precondition
|
170
178
|
@twig.set_option(:unset_property, 'unwanted_property')
|
data/spec/twig_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
2
3
|
|
3
4
|
describe Twig do
|
4
5
|
describe '#initialize' do
|
@@ -72,16 +73,19 @@ describe Twig do
|
|
72
73
|
fix_some_of_the_things
|
73
74
|
fix_some_other_of_the_things
|
74
75
|
fix_nothing
|
76
|
+
fix_everything
|
75
77
|
]
|
76
78
|
commit_times = [
|
77
79
|
Twig::CommitTime.new(Time.now - 86400 * 10, '10 days ago'),
|
78
80
|
Twig::CommitTime.new(Time.now - 86400 * 20, '20 days ago'),
|
79
|
-
Twig::CommitTime.new(Time.now - 86400 * 30, '30 days ago')
|
81
|
+
Twig::CommitTime.new(Time.now - 86400 * 30, '30 days ago'),
|
82
|
+
Twig::CommitTime.new(Time.now - 86400 * 40, '40 days ago')
|
80
83
|
]
|
81
84
|
@branches = [
|
82
85
|
Twig::Branch.new(branch_names[0], :last_commit_time => commit_times[0]),
|
83
86
|
Twig::Branch.new(branch_names[1], :last_commit_time => commit_times[1]),
|
84
|
-
Twig::Branch.new(branch_names[2], :last_commit_time => commit_times[2])
|
87
|
+
Twig::Branch.new(branch_names[2], :last_commit_time => commit_times[2]),
|
88
|
+
Twig::Branch.new(branch_names[3], :last_commit_time => commit_times[3])
|
85
89
|
]
|
86
90
|
@twig.stub(:all_branches => @branches)
|
87
91
|
end
|
@@ -90,22 +94,44 @@ describe Twig do
|
|
90
94
|
@twig.branches.should == @branches
|
91
95
|
end
|
92
96
|
|
93
|
-
it 'returns only branches
|
94
|
-
@twig.set_option(:
|
97
|
+
it 'returns only branches below a certain age' do
|
98
|
+
@twig.set_option(:max_days_old, 25)
|
95
99
|
@twig.branches.map { |branch| branch.name }.
|
96
100
|
should == [@branches[0].name, @branches[1].name]
|
97
101
|
end
|
98
102
|
|
99
103
|
it 'returns all branches except those matching a name pattern' do
|
100
|
-
@twig.set_option(:
|
101
|
-
@twig.branches.map { |branch| branch.name }.
|
104
|
+
@twig.set_option(:property_except, :branch => /fix_some/)
|
105
|
+
@twig.branches.map { |branch| branch.name }.
|
106
|
+
should == [@branches[2].name, @branches[3].name]
|
102
107
|
end
|
103
108
|
|
104
|
-
it 'returns only branches
|
105
|
-
@twig.set_option(:
|
109
|
+
it 'returns only branches matching a name pattern' do
|
110
|
+
@twig.set_option(:property_only, :branch => /fix_some/)
|
106
111
|
@twig.branches.map { |branch| branch.name }.
|
107
112
|
should == [@branches[0].name, @branches[1].name]
|
108
113
|
end
|
114
|
+
|
115
|
+
context 'with property filtering' do
|
116
|
+
before :each do
|
117
|
+
@branches[0].stub(:get_property).with('foo') { 'bar1' }
|
118
|
+
@branches[1].stub(:get_property).with('foo') { 'bar2' }
|
119
|
+
@branches[2].stub(:get_property).with('foo') { 'baz' }
|
120
|
+
@branches[3].stub(:get_property).with('foo') { nil }
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'returns all branches except those matching a property pattern' do
|
124
|
+
@twig.set_option(:property_except, :foo => /bar/)
|
125
|
+
@twig.branches.map { |branch| branch.name }.
|
126
|
+
should == [@branches[2].name, @branches[3].name]
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'returns only branches matching a property pattern' do
|
130
|
+
@twig.set_option(:property_only, :foo => /bar/)
|
131
|
+
@twig.branches.map { |branch| branch.name }.
|
132
|
+
should == [@branches[0].name, @branches[1].name]
|
133
|
+
end
|
134
|
+
end
|
109
135
|
end
|
110
136
|
|
111
137
|
describe '#branch_names' do
|
@@ -211,4 +237,25 @@ describe Twig do
|
|
211
237
|
end
|
212
238
|
end
|
213
239
|
|
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
|
214
261
|
end
|
data/twig.gemspec
CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.required_ruby_version = '>= 1.8.7'
|
35
35
|
spec.add_runtime_dependency 'json', '~> 1.7.5'
|
36
36
|
spec.add_development_dependency 'rake', '~> 0.9.2'
|
37
|
-
spec.add_development_dependency 'rspec', '~> 2.
|
37
|
+
spec.add_development_dependency 'rspec', '~> 2.13.0'
|
38
38
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 2
|
9
|
+
version: "1.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ron DeVera
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-03-
|
17
|
+
date: 2013-03-21 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -57,12 +57,12 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - ~>
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
60
|
+
hash: 59
|
61
61
|
segments:
|
62
62
|
- 2
|
63
|
-
-
|
63
|
+
- 13
|
64
64
|
- 0
|
65
|
-
version: 2.
|
65
|
+
version: 2.13.0
|
66
66
|
type: :development
|
67
67
|
version_requirements: *id003
|
68
68
|
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.
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/twig/cli.rb
|
102
102
|
- lib/twig/commit_time.rb
|
103
103
|
- lib/twig/display.rb
|
104
|
+
- lib/twig/github.rb
|
104
105
|
- lib/twig/options.rb
|
105
106
|
- lib/twig/util.rb
|
106
107
|
- lib/twig/version.rb
|