commander 4.1.3 → 4.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,4 +3,5 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  .rvmrc
6
- coverage/*
6
+ .ruby-version
7
+ coverage/*
@@ -1,3 +1,9 @@
1
+ === 4.1.4 / 2013-07-21
2
+
3
+ * Improve help formatting for multiline program and command descriptions
4
+ * Add ability to set speaking rate (@kethomassen)
5
+ * Clean up examples in docs (@parkr)
6
+
1
7
  === 4.1.3 / 2012-12-15
2
8
 
3
9
  * Remove use of eval in Array.parse
@@ -72,7 +72,7 @@ as well as an object, specifying a method to call, so view the RDoc for more inf
72
72
  $ foobar bar
73
73
  # => (bar)
74
74
 
75
- $ foobar bar --suffix '{' --prefix '}'
75
+ $ foobar bar --suffix '}' --prefix '{'
76
76
  # => {bar}
77
77
 
78
78
  == HighLine
@@ -159,6 +159,7 @@ following methods to simplify common tasks:
159
159
  speak 'What is your favorite food? '
160
160
  food = ask 'favorite food?: '
161
161
  speak "Wow, I like #{food} too. We have so much in common."
162
+ speak "I like #{food} as well!", "Victoria", 190
162
163
 
163
164
  # Execute arbitrary applescript
164
165
  applescript 'foo'
@@ -192,16 +193,12 @@ growl is auto-imported by Commander when available, no need to require.
192
193
  # Display an 'ok' status notification
193
194
  notify_ok 'Gems updated'
194
195
 
195
- # Display a 'warning' status notification
196
+ # Display a 'warning' status notification
196
197
  notify_warning '1 gem failed installation'
197
198
 
198
199
  # Display an 'error' status notification
199
200
  notify_error "Gem #{name} failed"
200
201
 
201
- growlnotify can also be installed via homebrew[http://mxcl.github.com/homebrew/]:
202
-
203
- $ brew install growlnotify
204
-
205
202
  == Commander Goodies
206
203
 
207
204
  === Option Defaults
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require "bundler/gem_tasks"
4
4
  desc "Run specs"
5
5
  RSpec::Core::RakeTask.new do |t|
6
6
  t.verbose = false
7
- t.rspec_opts = '--color'
7
+ t.rspec_opts = '--color --order random'
8
8
  end
9
9
 
10
10
  task :default => :spec
@@ -4,5 +4,10 @@ module Commander
4
4
  autoload :Base, 'commander/help_formatters/base'
5
5
  autoload :Terminal, 'commander/help_formatters/terminal'
6
6
  autoload :TerminalCompact, 'commander/help_formatters/terminal_compact'
7
+
8
+ module_function
9
+ def indent amount, text
10
+ text.gsub("\n", "\n" + (' ' * amount))
11
+ end
7
12
  end
8
- end
13
+ end
@@ -12,7 +12,7 @@
12
12
 
13
13
  <%= $terminal.color "DESCRIPTION", :bold %>:
14
14
 
15
- <%= @description || @summary || 'No description.' -%>
15
+ <%= Commander::HelpFormatter.indent 4, (@description || @summary || 'No description.') -%>
16
16
 
17
17
  <% unless @examples.empty? -%>
18
18
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= $terminal.color "DESCRIPTION", :bold %>:
6
6
 
7
- <%= program :description %>
7
+ <%= Commander::HelpFormatter.indent 4, program(:description) %>
8
8
 
9
9
  <%= $terminal.color "COMMANDS", :bold %>:
10
10
  <% for name, command in @commands.sort -%>
@@ -119,22 +119,25 @@ module Commander
119
119
  end
120
120
 
121
121
  ##
122
- # Speak _message_ using _voice_ which defaults
123
- # to 'Alex', which is one of the better voices.
122
+ # Speak _message_ using _voice_ at a speaking rate of _rate_
123
+ #
124
+ # Voice defaults to 'Alex', which is one of the better voices.
125
+ # Speaking rate defaults to 175 words per minute
124
126
  #
125
127
  # === Examples
126
128
  #
127
129
  # speak 'What is your favorite food? '
128
130
  # food = ask 'favorite food?: '
129
- # speak "wow, I like #{food} too. We have so much alike."
131
+ # speak "Wow, I like #{food} too. We have so much in common."
132
+ # speak "I like #{food} as well!", "Victoria", 190
130
133
  #
131
134
  # === Notes
132
135
  #
133
136
  # * MacOS only
134
137
  #
135
138
 
136
- def speak message, voice = :Alex
137
- Thread.new { applescript "say #{message.inspect} using #{voice.to_s.inspect}" }
139
+ def speak message, voice = :Alex, rate = 175
140
+ Thread.new { applescript "say #{message.inspect} using #{voice.to_s.inspect} speaking rate #{rate}" }
138
141
  end
139
142
 
140
143
  ##
@@ -1,3 +1,3 @@
1
1
  module Commander
2
- VERSION = '4.1.3'
2
+ VERSION = '4.1.4'
3
3
  end
@@ -353,18 +353,24 @@ describe Commander do
353
353
 
354
354
  describe "#valid_command_names_from" do
355
355
  it "should return array of valid command names" do
356
- command('foo bar') {}
357
- command('foo bar foo') {}
358
- command_runner.valid_command_names_from('foo', 'bar', 'foo').sort.should eq(['foo bar', 'foo bar foo'])
356
+ new_command_runner do
357
+ command('foo bar') {}
358
+ command('foo bar foo') {}
359
+ command_runner.valid_command_names_from('foo', 'bar', 'foo').sort.should eq(['foo bar', 'foo bar foo'])
360
+ end
359
361
  end
360
362
 
361
363
  it "should return empty array when no possible command names exist" do
362
- command_runner.valid_command_names_from('fake', 'command', 'name').should eq([])
364
+ new_command_runner do
365
+ command_runner.valid_command_names_from('fake', 'command', 'name').should eq([])
366
+ end
363
367
  end
364
368
 
365
369
  it "should match exact commands only" do
366
- command('foo') {}
367
- command_runner.valid_command_names_from('foobar').should eq([])
370
+ new_command_runner do
371
+ command('foo') {}
372
+ command_runner.valid_command_names_from('foobar').should eq([])
373
+ end
368
374
  end
369
375
  end
370
376
 
@@ -1,13 +1,29 @@
1
1
  require 'rubygems'
2
+ require 'stringio'
2
3
  require 'simplecov'
3
4
  SimpleCov.start
4
5
 
5
- # prevent paging (through less) from actually occurring in test environment
6
- ENV['PAGER'] = 'cat'
7
-
6
+ # Unshift so that local files load instead of something in gems
8
7
  $:.unshift File.dirname(__FILE__) + '/../lib'
9
- require 'commander/import'
10
- require 'stringio'
8
+
9
+ # This basically replicates the behavior of `require 'commander/import'`
10
+ # but without adding an `at_exit` hook, which interferes with exit code
11
+ require 'commander'
12
+ require 'commander/delegates'
13
+
14
+ include Commander::UI
15
+ include Commander::UI::AskForClass
16
+ include Commander::Delegates
17
+
18
+ # prevent paging from actually occurring in test environment
19
+
20
+ module Commander
21
+ module UI
22
+ def enable_paging
23
+ return
24
+ end
25
+ end
26
+ end
11
27
 
12
28
  # Mock terminal IO streams so we can spec against them
13
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.3
4
+ version: 4.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-16 00:00:00.000000000 Z
13
+ date: 2013-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: highline