Permalink
Browse files

Use Kernel.exec for editing files

  • Loading branch information...
oscardelben committed Apr 8, 2012
1 parent b6595ba commit bda8d3d50166384bee10cff9aedf84be4023b6df
Showing with 10 additions and 6 deletions.
  1. +1 −1 bin/sheet
  2. +7 −3 lib/sheet.rb
  3. +1 −1 lib/sheet/write.rb
  4. +1 −1 spec/sheet/write_spec.rb
View
2 bin/sheet 100644 → 100755
@@ -2,4 +2,4 @@
require File.join(File.dirname(__FILE__), '../lib/sheet')
-Sheet.new(ARGV)
+Sheet.new(ARGV).process
View
@@ -17,8 +17,12 @@ def write(message)
end
# Utility to execute system commands
- def exec(cmd)
- %x!#{cmd}!
+ def exec(cmd, replace_current_process=false)
+ if replace_current_process
+ Kernel.exec cmd
+ else
+ %x!#{cmd}!
+ end
end
# @param [String] name the sheet name
@@ -64,7 +68,7 @@ def open_command
# Creates a new instance of Sheet, usually followed by a call to {#process}
# @param [Array] args command line options
def initialize(*args)
- @args = args
+ @args = args.flatten
end
# Where the dispatching really happens. We check to see what the user
View
@@ -10,7 +10,7 @@ def initialize(name)
def write
create_dir_if_doesnt_exist
if editor_is_set?
- Sheet.exec("#{Sheet.editor} #{Sheet.sheet_path(name)}")
+ Sheet.exec("#{Sheet.editor} #{Sheet.sheet_path(name)}", true)
else
Sheet.write "Please set the $EDITOR variable to write files"
end
View
@@ -6,7 +6,7 @@
it 'opens a new file for writing' do
cmd = "#{editor} #{Sheet.sheet_path('tmux')}"
- Sheet.should_receive(:exec).with(cmd)
+ Sheet.should_receive(:exec).with(cmd, true)
Sheet.stub(:editor) { editor }

0 comments on commit bda8d3d

Please sign in to comment.