visionmedia-commander 3.2.4 → 3.2.5

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.
@@ -1,4 +1,8 @@
1
1
 
2
+ === 3.2.5 / 2009-04-02
3
+
4
+ * Added #ask_editor
5
+
2
6
  === 3.2.4 / 2009-04-02
3
7
 
4
8
  * Added #enable_paging [#9]
@@ -147,6 +147,12 @@ simplify common tasks using the following methods:
147
147
  # Enable paging of output after this point
148
148
  enable_paging
149
149
 
150
+ # Ask editor for input (EDITOR or TextMate by default)
151
+ ask_editor
152
+
153
+ # Ask editor, supplying initial text
154
+ ask_editor 'previous data to update'
155
+
150
156
  == Commander Goodies
151
157
 
152
158
  === Option Defaults
@@ -284,7 +290,7 @@ http://visionmedia.lighthouseapp.com/projects/27643-commander
284
290
 
285
291
  == Known Issues
286
292
 
287
- * None
293
+ * ask_editor has been tested with TextMate only
288
294
 
289
295
  == License
290
296
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{commander}
5
- s.version = "3.2.4"
5
+ s.version = "3.2.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
@@ -35,6 +35,28 @@ module Commander
35
35
  say '%15s %s' % [action, args.join(' ')]
36
36
  end
37
37
 
38
+ ##
39
+ # Prompt +editor+ for input. Optionally supply initial
40
+ # +input+ which is written to the editor.
41
+ #
42
+ # The +editor+ defaults to the EDITOR environment variable
43
+ # when present, or 'mate' for TextMate.
44
+ #
45
+ # === Examples
46
+ #
47
+ # ask_editor # => prompts EDITOR with no input
48
+ # ask_editor('foo') # => prompts EDITOR with default text of 'foo'
49
+ # ask_editor('foo', :mate) # => prompts TextMate with default text of 'foo'
50
+ #
51
+
52
+ def ask_editor input = nil, editor = ENV['EDITOR'] || 'mate'
53
+ IO.popen(editor.to_s, 'w+') do |pipe|
54
+ pipe.puts input.to_s unless input.nil?
55
+ pipe.close_write
56
+ pipe.read
57
+ end
58
+ end
59
+
38
60
  ##
39
61
  # Enable paging of output after called.
40
62
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Commander
3
- VERSION = '3.2.4'
3
+ VERSION = '3.2.5'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk