ruby-unix-now 0.0.1 → 0.1.0

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.
Files changed (3) hide show
  1. data/README.md +2 -2
  2. data/lib/ruby-unix-now.rb +6 -11
  3. metadata +13 -6
data/README.md CHANGED
@@ -32,7 +32,7 @@ The equivalent run command to the one above would be
32
32
 
33
33
  options = {}
34
34
  options.merge!(:z, :h) if condition_x_
35
- run :rsync, :r, :progress, options, --from from_path, --to to_path
35
+ run :rsync, :r, :progress, options, :from => from_path, :to => to_path
36
36
 
37
37
  Nore more embedding variables in string, no more arbitrary spaces to make
38
38
  strings glue together correctly.
@@ -45,7 +45,7 @@ Normal commands
45
45
  `rm -r -f #{to`
46
46
  `cp -r, #{from} #{to}`
47
47
 
48
- With Run
48
+ With run
49
49
 
50
50
  run :mkdir, :p, xapian_path
51
51
  run :rm, :r, :f, to
@@ -4,10 +4,11 @@ def log(msg, level = 0)
4
4
  end
5
5
 
6
6
  def run(*arguments)
7
- options = (arguments.last.is_a?(Hash) && arguments.pop) || {}
7
+ options = (arguments.last.is_a?(Hash) && arguments.last) || {}
8
+ sync = options.delete(:sync)
8
9
  cmd = expand_cmd(*arguments)
9
10
  log(cmd)
10
- result = if options[:sync]
11
+ result = if sync
11
12
  `#{cmd}`
12
13
  else
13
14
  system(cmd)
@@ -20,7 +21,7 @@ end
20
21
 
21
22
  def expand_cmd(*arguments)
22
23
  command = arguments.shift.to_s
23
- cmd = command + ' ' + arguments.map{|a| a.to_cmd_opt}.join(' ')
24
+ cmd = command + ' ' + arguments.map{|a| a.respond_to?(:to_cmd_opt) ? a.to_cmd_opt : a.to_s}.join(' ')
24
25
  end
25
26
 
26
27
  class Symbol
@@ -36,19 +37,13 @@ end
36
37
 
37
38
  class Array
38
39
  def to_cmd_opt
39
- map{|a| a.to_cmd_opt}.join(' ')
40
- end
41
- end
42
-
43
- class String
44
- def to_cmd_opt
45
- self
40
+ map{|a| a.respond_to?(:to_cmd_opt) ? a.to_cmd_opt : a.to_s}.join(' ')
46
41
  end
47
42
  end
48
43
 
49
44
  class Hash
50
45
  def to_cmd_opt(style = :gnu)
51
- map do |key, value|
46
+ map do |key, value|
52
47
  prefix = ((style == :gnu && key.to_s.size > 1) ? '--' : '-')
53
48
  assignment = (key.to_s.size == 1 || style == :unix) ? ' ' : '='
54
49
  value.is_a?(TrueClass) ? "#{prefix}#{key}" : "#{prefix}#{key}#{assignment}#{value}"
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-unix-now
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Tor Erik Linnerud
@@ -9,11 +14,11 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-26 00:00:00 +00:00
17
+ date: 2010-04-27 00:00:00 +01:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
16
- description: A one file library which bridges the gap between ruby code and system commands. No more string concatenation to build up commands.
21
+ description: A one file library bridging the gap between ruby code and system commands. No more string concatenation to build up commands.
17
22
  email: tel@jklm.no
18
23
  executables: []
19
24
 
@@ -37,18 +42,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
42
  requirements:
38
43
  - - ">="
39
44
  - !ruby/object:Gem::Version
45
+ segments:
46
+ - 0
40
47
  version: "0"
41
- version:
42
48
  required_rubygems_version: !ruby/object:Gem::Requirement
43
49
  requirements:
44
50
  - - ">="
45
51
  - !ruby/object:Gem::Version
52
+ segments:
53
+ - 0
46
54
  version: "0"
47
- version:
48
55
  requirements: []
49
56
 
50
57
  rubyforge_project:
51
- rubygems_version: 1.3.5
58
+ rubygems_version: 1.3.6
52
59
  signing_key:
53
60
  specification_version: 3
54
61
  summary: "Run system commands using the best of ruby syntax: symbols, hashes and arrays."