twig 1.0.0 → 1.0.1

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/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *.gem
2
+ .rvmrc
2
3
  Gemfile.lock
3
4
  _site/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
data/CONTRIBUTING.md CHANGED
@@ -13,7 +13,9 @@ If you want to hack on some code, even better! Here are the basics:
13
13
  for stable builds only.
14
14
  3. Run the tests to make sure that they pass on your machine: `bundle && rake`
15
15
  4. Add one or more failing tests for your feature or bug fix.
16
- 5. Write your feature or bug fix to make the test(s) pass.
16
+ 5. Write your feature or bug fix to make the test(s) pass. Tests should pass in
17
+ the latest **Ruby 1.8.7** and **Ruby 1.9.3**, which you can do with
18
+ [rvm][rvm] or [rbenv][rbenv].
17
19
  6. Test the change manually:
18
20
  1. `gem build twig.gemspec`
19
21
  2. `gem install twig-x.y.z.gem` (fill in the current version number)
@@ -24,3 +26,5 @@ Thanks for contributing!
24
26
  [issues]: https://github.com/rondevera/twig/issues
25
27
  [twitter]: https://twitter.com/ronalddevera
26
28
  [dev branch]: https://github.com/rondevera/twig/commits/development
29
+ [rvm]: https://rvm.io/
30
+ [rbenv]: http://rbenv.org/
data/HISTORY.md CHANGED
@@ -1,6 +1,20 @@
1
1
  Twig
2
2
  ====
3
3
 
4
- 1.0
5
- ---
4
+ 1.0.1 (2013-02-13)
5
+ ------------------
6
+ * ENHANCEMENT: Add Travis CI integration for running tests in multiple versions
7
+ of Ruby.
8
+ * FIX: Gracefully handle Git config settings where the value is missing.
9
+ (GH-1. Thanks [chrismanderson](https://github.com/chrismanderson)!)
10
+ * FIX: Fix failing test in Ruby 1.9.3.
11
+ (GH-7. Thanks [joelmoss](https://github.com/joelmoss)!)
12
+ * FIX: Suppress `which` errors.
13
+ (GH-9. Thanks [badboy](https://github.com/badboy)!)
14
+ * FIX: Exit with a non-zero status when trying to get a branch property that
15
+ doesn't exist.
16
+ * FIX: In list view, render line breaks (in properties) as spaces.
17
+
18
+ 1.0 (2013-02-05)
19
+ ----------------
6
20
  * Initial release.
data/README.md CHANGED
@@ -212,16 +212,16 @@ it to the [Twig wiki][wiki]!
212
212
  More info
213
213
  =========
214
214
 
215
- - **Requirements:** Tested with Git 1.6.5 and Ruby 1.8.7. Probably works with
216
- older software, but it's not guaranteed.
217
- - **Contributing:** Found a bug or have a suggestion? [Please open an
215
+ * **Requirements:** Tested with Git 1.6.5 and Ruby 1.8.7/1.9.2/1.9.3. Probably
216
+ works with older software, but it's not guaranteed.
217
+ * **Contributing:** Found a bug or have a suggestion? [Please open an
218
218
  issue][issues] or ping [@ronalddevera on Twitter][twitter]. If you want to
219
219
  hack on some features or contribute a subcommand you've written, feel free to
220
220
  fork and send a pull request for the **[development branch][dev branch]**.
221
221
  (The master branch is for stable builds only.) See the full details in the
222
222
  [Contributing][contributing] instructions.
223
- - **History:** [History/changelog for Twig][history]
224
- - **License:** Twig is released under the [MIT License][license].
223
+ * **History:** [History/changelog for Twig][history]
224
+ * **License:** Twig is released under the [MIT License][license].
225
225
 
226
226
  [issues]: https://github.com/rondevera/twig/issues
227
227
  [wiki]: https://github.com/rondevera/twig/wiki
data/bin/twig-gh-update CHANGED
@@ -70,7 +70,7 @@ TwigGithubRepo.new do |gh_repo|
70
70
  issues[issue_data['number']] = issue_data
71
71
  end
72
72
  else
73
- puts "\nERROR: Couldn't get open issues from GitHub. " <<
73
+ abort "\nERROR: Couldn't get open issues from GitHub. " <<
74
74
  "(Response: #{response.code})"
75
75
  end
76
76
  end
data/lib/twig/branch.rb CHANGED
@@ -12,7 +12,9 @@ class Twig
12
12
 
13
13
  properties = config_lines.map do |line|
14
14
  # Split by rightmost `=`, allowing branch names to contain `=`:
15
- key, value = line.match(/(.+)=(.+)/)[1..2]
15
+ key = value = nil
16
+ line.match(/(.+)=(.+)/).tap { |m| key, value = m[1..2] if m }
17
+ next if key.nil?
16
18
 
17
19
  key_parts = key.split('.')
18
20
  key_parts.last if key_parts[0] == 'branch' && key_parts.size > 2
data/lib/twig/cli.rb CHANGED
@@ -134,7 +134,7 @@ class Twig
134
134
  if args.any?
135
135
  # Run subcommand binary, if any, and exit here
136
136
  possible_subcommand_name = args[0]
137
- command_path = Twig.run("which twig-#{possible_subcommand_name}")
137
+ command_path = Twig.run("which twig-#{possible_subcommand_name} 2>/dev/null")
138
138
  unless command_path.empty?
139
139
  command = ([command_path] + args[1..-1]).join(' ')
140
140
  exec(command)
@@ -161,7 +161,7 @@ class Twig
161
161
  if value && !value.empty?
162
162
  puts value
163
163
  else
164
- puts %{The branch "#{branch_name}" does not have the property "#{property_name}".}
164
+ abort %{The branch "#{branch_name}" does not have the property "#{property_name}".}
165
165
  end
166
166
  end
167
167
  elsif property_to_unset
data/lib/twig/display.rb CHANGED
@@ -77,6 +77,7 @@ class Twig
77
77
  properties = Twig::Branch.all_properties.inject({}) do |result, property_name|
78
78
  property = get_branch_property(branch.name, property_name).strip
79
79
  property = column(EMPTY_BRANCH_PROPERTY_INDICATOR) if property.empty?
80
+ property.gsub!(/[\n\r]+/, ' ')
80
81
  result.merge(property_name => property)
81
82
  end
82
83
 
data/lib/twig/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Twig
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -49,6 +49,13 @@ describe Twig::Branch do
49
49
  result.should == %w[eqproperty test0 test1 test2]
50
50
  end
51
51
 
52
+ it 'skips path values with an equal sign but no value' do
53
+ @config << 'foo_path='
54
+ Twig.should_receive(:run).with('git config --list').and_return(@config)
55
+ result = Twig::Branch.all_properties
56
+ result.should_not include 'foo_path'
57
+ end
58
+
52
59
  it 'memoizes the result' do
53
60
  Twig.should_receive(:run).once.and_return(@config)
54
61
  2.times { Twig::Branch.all_properties }
@@ -146,22 +146,34 @@ describe Twig::Cli do
146
146
  context 'running a subcommand' do
147
147
  before :each do
148
148
  Twig.stub(:run)
149
- @twig.stub(:current_branch_name => 'test')
150
- @twig.stub(:puts)
149
+ @branch_name = 'test'
150
+ @twig.stub(:current_branch_name => @branch_name)
151
151
  end
152
152
 
153
153
  it 'recognizes a subcommand' do
154
154
  command_path = '/path/to/bin/twig-subcommand'
155
- Twig.should_receive(:run).with('which twig-subcommand').
155
+ Twig.should_receive(:run).with('which twig-subcommand 2>/dev/null').
156
156
  and_return(command_path)
157
- @twig.should_receive(:exec).with(command_path)
157
+ @twig.should_receive(:exec).with(command_path) { exit }
158
+
159
+ # Since we're stubbing `exec` (with an expectation), we still need it
160
+ # to exit early like the real implementation. The following handles the
161
+ # exit somewhat gracefully.
162
+ expected_exception = nil
163
+ begin
164
+ @twig.read_cli_args!(['subcommand'])
165
+ rescue SystemExit => exception
166
+ expected_exception = exception
167
+ end
158
168
 
159
- @twig.read_cli_args!(['subcommand'])
169
+ expected_exception.should_not be_nil
170
+ expected_exception.status.should == 0
160
171
  end
161
172
 
162
173
  it 'does not recognize a subcommand' do
163
- Twig.should_receive(:run).with('which twig-subcommand').and_return('')
174
+ Twig.should_receive(:run).with('which twig-subcommand 2>/dev/null').and_return('')
164
175
  @twig.should_not_receive(:exec)
176
+ @twig.stub(:abort)
165
177
 
166
178
  @twig.read_cli_args!(['subcommand'])
167
179
  end
@@ -190,8 +202,8 @@ describe Twig::Cli do
190
202
  it 'shows an error if getting a property that is not set' do
191
203
  @twig.should_receive(:get_branch_property).
192
204
  with(@branch_name, @property_name).and_return('')
193
- @twig.should_receive(:puts) do |error|
194
- error.should include(
205
+ @twig.should_receive(:abort) do |message|
206
+ message.should include(
195
207
  %{The branch "#{@branch_name}" does not have the property "#{@property_name}"}
196
208
  )
197
209
  end
@@ -217,8 +229,8 @@ describe Twig::Cli do
217
229
  it 'shows an error if getting a property that is not set' do
218
230
  @twig.should_receive(:get_branch_property).
219
231
  with(@branch_name, @property_name).and_return('')
220
- @twig.should_receive(:puts) do |error|
221
- error.should include(
232
+ @twig.should_receive(:abort) do |message|
233
+ message.should include(
222
234
  %{The branch "#{@branch_name}" does not have the property "#{@property_name}"}
223
235
  )
224
236
  end
@@ -59,7 +59,7 @@ describe Twig::Display do
59
59
  describe '#branch_list_line' do
60
60
  before :each do
61
61
  @current_branch_name = 'my-branch'
62
- Twig::Branch.stub(:all_properties => ['foo', 'bar'])
62
+ Twig::Branch.stub(:all_properties => %w[foo bar])
63
63
  @twig.should_receive(:get_branch_property).
64
64
  with(anything, 'foo').and_return('foo!')
65
65
  @twig.should_receive(:get_branch_property).
@@ -89,6 +89,18 @@ describe Twig::Display do
89
89
 
90
90
  result.should =~ /2000-01-01\s+foo!\s+bar!\s+#{Regexp.escape(branch.name)}/
91
91
  end
92
+
93
+ it 'changes line break characters to spaces' do
94
+ branch = Twig::Branch.new('my-branch')
95
+ branch.should_receive(:last_commit_time).and_return(@commit_time)
96
+ Twig::Branch.stub(:all_properties => %w[foo bar linebreaks])
97
+ @twig.should_receive(:get_branch_property).
98
+ with(anything, 'linebreaks').and_return("line\r\nbreaks!")
99
+
100
+ result = @twig.branch_list_line(branch)
101
+
102
+ result.should include('line breaks')
103
+ end
92
104
  end
93
105
 
94
106
  describe '#format_string' do
data/spec/twig_spec.rb CHANGED
@@ -158,7 +158,7 @@ describe Twig do
158
158
  end
159
159
 
160
160
  it 'returns a message if all branches were filtered out by options' do
161
- @twig.stub(:all_branches => %[foo bar])
161
+ @twig.stub(:all_branches => %w[foo bar])
162
162
  @twig.stub(:branches => [])
163
163
 
164
164
  @twig.list_branches.should include(
data/twig.gemspec CHANGED
@@ -6,15 +6,15 @@ require 'twig/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'twig'
8
8
  spec.version = Twig::VERSION
9
- spec.date = '2012-12-13'
10
9
  spec.authors = ['Ron DeVera']
11
10
  spec.email = ["hello@rondevera.com"]
12
- spec.homepage = 'https://github.com/rondevera/twig'
13
- spec.summary = %{Track progress on your Git branches.}
11
+ spec.homepage = 'http://rondevera.github.com/twig'
12
+ spec.summary = %{Your personal Git branch assistant.}
14
13
  spec.description =
15
- 'Twig is a command-line tool for tracking progress on your Git ' <<
16
- 'branches, remembering ticket ids for each branch, and more. Twig ' <<
17
- 'supports subcommands for managing branches however you want.'
14
+ 'Twig is your personal Git branch assistant. It\'s a command-line tool ' <<
15
+ 'for tracking progress on your branches, remembering ticket ids for ' <<
16
+ 'each branch, and more. Twig supports subcommands for managing branches ' <<
17
+ 'however you want.'
18
18
  spec.post_install_message =
19
19
  "\n**************************************************************" <<
20
20
  "\n* *" <<
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twig
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ron DeVera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-13 00:00:00 -08:00
18
+ date: 2013-02-13 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: 2.11.0
67
67
  type: :development
68
68
  version_requirements: *id003
69
- description: Twig is a command-line tool for tracking progress on your Git branches, remembering ticket ids for each branch, and more. Twig supports subcommands for managing branches however you want.
69
+ 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
70
  email:
71
71
  - hello@rondevera.com
72
72
  executables:
@@ -80,7 +80,7 @@ extra_rdoc_files: []
80
80
 
81
81
  files:
82
82
  - .gitignore
83
- - .rvmrc
83
+ - .travis.yml
84
84
  - CONTRIBUTING.md
85
85
  - Gemfile
86
86
  - HISTORY.md
@@ -91,7 +91,6 @@ files:
91
91
  - bin/twig-gh-open
92
92
  - bin/twig-gh-update
93
93
  - bin/twig-help
94
- - install
95
94
  - lib/twig.rb
96
95
  - lib/twig/branch.rb
97
96
  - lib/twig/cli.rb
@@ -110,7 +109,7 @@ files:
110
109
  - spec/twig_spec.rb
111
110
  - twig.gemspec
112
111
  has_rdoc: true
113
- homepage: https://github.com/rondevera/twig
112
+ homepage: http://rondevera.github.com/twig
114
113
  licenses: []
115
114
 
116
115
  post_install_message: |+
@@ -154,7 +153,7 @@ rubyforge_project:
154
153
  rubygems_version: 1.5.2
155
154
  signing_key:
156
155
  specification_version: 3
157
- summary: Track progress on your Git branches.
156
+ summary: Your personal Git branch assistant.
158
157
  test_files:
159
158
  - spec/spec_helper.rb
160
159
  - spec/twig/branch_spec.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use ruby-1.8.7-p358@twig --create
data/install DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- twig_bin_path = File.expand_path(File.dirname(__FILE__)) + '/bin/**/twig*'
4
- twig_bins = Dir.glob(twig_bin_path)
5
- user_bin_path = '~/bin'
6
-
7
- twig_bins.each do |bin|
8
- `ln -fs #{bin} #{user_bin_path}`
9
- end
10
-
11
- if `which twig` && $?.success?
12
- puts 'All set! Run `twig` to list your local branches.'
13
- puts 'For more info, run `twig --help`.'
14
- else
15
- puts 'Argh! Something went wrong. Please try symlinking the files in '
16
- puts '`./bin/` to `~/bin/` and ensure that `~/bin/` is in your `$PATH`, or '
17
- puts 'contact rondevera on GitHub.'
18
- end