rprogram 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,8 +1,16 @@
1
+ ### 0.2.3 / 2011-03-30
2
+
3
+ * Require env ~> 0.1, >= 0.1.2.
4
+ * Automatically search for programs with a `.exe` suffix, when running on
5
+ Windows.
6
+ * {RProgram::Compat.find_program} and {RProgram::Compat.find_program_by_names}
7
+ now return a `Pathname` object.
8
+
1
9
  ### 0.2.2 / 2011-01-22
2
10
 
3
11
  * Deprecated {RProgram::Compat.platform}.
4
12
  * Use `File::PATH_SEPARATOR` to separate the `PATH` environment variable
5
- in {RProgram::Compat.paths}.
13
+ in `RProgram::Compat.paths`.
6
14
 
7
15
  ### 0.2.1 / 2010-10-27
8
16
 
@@ -38,7 +46,7 @@
38
46
 
39
47
  * Use Hoe 2.2.0.
40
48
  * Removed requirement for 'open3'.
41
- * Renamed PRogram::Compat.PATHS to {RProgram::Compat.paths}.
49
+ * Renamed PRogram::Compat.PATHS to `RProgram::Compat.paths`.
42
50
  * Refactored {RProgram::Option#arguments}.
43
51
  * Removed `RProgram::Option#format`.
44
52
  * Refactored {RProgram::NonOption#arguments}.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  * [Source](http://github.com/postmodern/rprogram)
4
4
  * [Issues](http://github.com/postmodern/rprogram/issues)
5
5
  * [Documentation](http://rubydoc.info/gems/rprogram)
6
- * Postmodern (postmodern.mod3 at gmail.com)
6
+ * [Email](mailto:postmodern.mod3 at gmail.com)
7
7
 
8
8
  ## Description
9
9
 
@@ -92,11 +92,16 @@ Finally, run your program with options or a block:
92
92
  end
93
93
  # => true
94
94
 
95
+ ## Requirements
96
+
97
+ * [env](http://github.com/postmodern/env) ~> 0.1, >= 0.1.2
98
+
95
99
  ## Install
96
100
 
97
101
  $ sudo gem install rprogram
98
102
 
99
103
  ## License
100
104
 
101
- See {file:LICENSE.txt} for license information.
105
+ Copyright (c) 2007-2011 Hal Brodigan
102
106
 
107
+ See {file:LICENSE.txt} for license information.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'ore-tasks', '~> 0.3.0'
5
+ gem 'ore-tasks', '~> 0.4'
6
6
  require 'ore/tasks'
7
7
 
8
8
  Ore::Tasks.new
@@ -12,7 +12,7 @@ rescue LoadError => e
12
12
  end
13
13
 
14
14
  begin
15
- gem 'rspec', '~> 2.4.0'
15
+ gem 'rspec', '~> 2.4'
16
16
  require 'rspec/core/rake_task'
17
17
 
18
18
  RSpec::Core::RakeTask.new
data/gemspec.yml CHANGED
@@ -13,7 +13,10 @@ email: postmodern.mod3@gmail.com
13
13
  homepage: http://github.com/postmodern/rprogram
14
14
  has_yard: true
15
15
 
16
+ dependencies:
17
+ env: ~> 0.1, >= 0.1.2
18
+
16
19
  development_dependencies:
17
- ore-tasks: ~> 0.3.0
18
- rspec: ~> 2.4.0
20
+ ore-tasks: ~> 0.4
21
+ rspec: ~> 2.4
19
22
  yard: ~> 0.6.0
@@ -1,7 +1,12 @@
1
1
  require 'rprogram/exceptions/program_not_found'
2
+ require 'rprogram/rprogram'
3
+
4
+ require 'env/variables'
2
5
 
3
6
  module RProgram
4
7
  module Compat
8
+ extend Env::Variables
9
+
5
10
  #
6
11
  # Determines the native platform.
7
12
  #
@@ -17,40 +22,29 @@ module RProgram
17
22
  RUBY_PLATFORM.split('-').last
18
23
  end
19
24
 
20
- #
21
- # Determines the contents of the `PATH` environment variable.
22
- #
23
- # @return [Array]
24
- # The contents of the `PATH` environment variable.
25
- #
26
- # @example
27
- # Compat.paths #=> ["/bin", "/usr/bin"]
28
- #
29
- def Compat.paths
30
- if ENV['PATH']
31
- ENV['PATH'].split(File::PATH_SEPARATOR)
32
- else
33
- []
34
- end
35
- end
36
-
37
25
  #
38
26
  # Finds the full-path of the program with the matching name.
39
27
  #
40
28
  # @param [String] name
41
29
  # The name of the program to find.
42
30
  #
43
- # @return [String, nil]
31
+ # @return [Pathname, nil]
44
32
  # The full-path of the desired program.
45
33
  #
46
34
  # @example
47
- # Compat.find_program('as') #=> "/usr/bin/as"
35
+ # Compat.find_program('as')
36
+ # #=> #<Pathname:/usr/bin/as>
48
37
  #
49
38
  def Compat.find_program(name)
50
- Compat.paths.each do |dir|
51
- full_path = File.expand_path(File.join(dir,name))
39
+ # add the `.exe` suffix to the name, if running on Windows
40
+ if platform =~ /mswin/
41
+ name = "#{name}.exe"
42
+ end
43
+
44
+ paths.each do |dir|
45
+ full_path = dir.join(name).expand_path
52
46
 
53
- return full_path if File.file?(full_path)
47
+ return full_path if full_path.file?
54
48
  end
55
49
 
56
50
  return nil
@@ -62,14 +56,20 @@ module RProgram
62
56
  # @param [Array] names
63
57
  # The names of the program to use while searching for the program.
64
58
  #
65
- # @return [String, nil]
59
+ # @return [Pathname, nil]
66
60
  # The first full-path for the program.
67
61
  #
68
62
  # @example
69
63
  # Compat.find_program_by_names("gas","as") #=> "/usr/bin/as"
70
64
  #
71
65
  def Compat.find_program_by_names(*names)
72
- names.map { |name| Compat.find_program(name) }.compact.first
66
+ names.each do |name|
67
+ if (path = find_program(name))
68
+ return path
69
+ end
70
+ end
71
+
72
+ return nil
73
73
  end
74
74
 
75
75
  #
@@ -112,13 +112,13 @@ module RProgram
112
112
  # @since 0.1.8
113
113
  #
114
114
  def Compat.sudo(path,*args)
115
- sudo_path = Compat.find_program('sudo')
115
+ sudo_path = find_program('sudo')
116
116
 
117
117
  unless sudo_path
118
118
  raise(ProgramNotFound,'could not find the "sudo" program',caller)
119
119
  end
120
120
 
121
- return Compat.run(sudo_path,path,*args)
121
+ return run(sudo_path,path,*args)
122
122
  end
123
123
  end
124
124
  end
@@ -17,10 +17,9 @@ module RProgram
17
17
  attr_reader :sub_options
18
18
 
19
19
  #
20
- # Creates a new Option object with. If a _block_
21
- # is given it will be used for the custom formating of the option. If a
22
- # _block_ is not given, the option will use the default_format when
23
- # generating the arguments.
20
+ # Creates a new Option object with. If a block is given it will be
21
+ # used for the custom formatting of the option. If a block is not given,
22
+ # the option will use the default_format when generating the arguments.
24
23
  #
25
24
  # @param [Hash] options
26
25
  # Additional options.
@@ -1,4 +1,4 @@
1
1
  module RProgram
2
2
  # Version of RProgram
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'rubygems'
2
- gem 'rspec', '~> 2.4.0'
1
+ gem 'rspec', '~> 2.4'
3
2
  require 'rspec'
4
3
 
5
4
  require 'rprogram/version'
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rprogram
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 2
9
- version: 0.2.2
4
+ prerelease:
5
+ version: 0.2.3
10
6
  platform: ruby
11
7
  authors:
12
8
  - Postmodern
@@ -14,56 +10,59 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-22 00:00:00 -08:00
13
+ date: 2011-03-30 00:00:00 -04:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
- name: ore-tasks
17
+ name: env
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
24
20
  none: false
25
21
  requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.1.2
26
25
  - - ~>
27
26
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 3
31
- - 0
32
- version: 0.3.0
33
- type: :development
27
+ version: "0.1"
28
+ type: :runtime
34
29
  version_requirements: *id001
35
30
  - !ruby/object:Gem::Dependency
36
- name: rspec
31
+ name: ore-tasks
37
32
  prerelease: false
38
33
  requirement: &id002 !ruby/object:Gem::Requirement
39
34
  none: false
40
35
  requirements:
41
36
  - - ~>
42
37
  - !ruby/object:Gem::Version
43
- segments:
44
- - 2
45
- - 4
46
- - 0
47
- version: 2.4.0
38
+ version: "0.4"
48
39
  type: :development
49
40
  version_requirements: *id002
50
41
  - !ruby/object:Gem::Dependency
51
- name: yard
42
+ name: rspec
52
43
  prerelease: false
53
44
  requirement: &id003 !ruby/object:Gem::Requirement
54
45
  none: false
55
46
  requirements:
56
47
  - - ~>
57
48
  - !ruby/object:Gem::Version
58
- segments:
59
- - 0
60
- - 6
61
- - 0
62
- version: 0.6.0
49
+ version: "2.4"
63
50
  type: :development
64
51
  version_requirements: *id003
52
+ - !ruby/object:Gem::Dependency
53
+ name: yard
54
+ prerelease: false
55
+ requirement: &id004 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: 0.6.0
61
+ type: :development
62
+ version_requirements: *id004
65
63
  description: RProgram is a library for creating wrappers around command-line programs. RProgram provides a Rubyful interface to programs and all their options or non-options. RProgram can also search for programs installed on a system. files without having to use YAML or define classes named like the file.
66
- email: postmodern.mod3@gmail.com
64
+ email:
65
+ - postmodern.mod3@gmail.com
67
66
  executables: []
68
67
 
69
68
  extensions: []
@@ -128,30 +127,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
127
  requirements:
129
128
  - - ">="
130
129
  - !ruby/object:Gem::Version
131
- segments:
132
- - 0
133
130
  version: "0"
134
131
  required_rubygems_version: !ruby/object:Gem::Requirement
135
132
  none: false
136
133
  requirements:
137
134
  - - ">="
138
135
  - !ruby/object:Gem::Version
139
- segments:
140
- - 0
141
136
  version: "0"
142
137
  requirements: []
143
138
 
144
139
  rubyforge_project: rprogram
145
- rubygems_version: 1.3.7
140
+ rubygems_version: 1.6.2
146
141
  signing_key:
147
142
  specification_version: 3
148
143
  summary: A library for creating wrappers around command-line programs.
149
144
  test_files:
150
- - spec/nameable_spec.rb
151
- - spec/program_spec.rb
152
145
  - spec/rprogram_spec.rb
146
+ - spec/nameable_spec.rb
147
+ - spec/option_list_spec.rb
153
148
  - spec/non_option_spec.rb
149
+ - spec/task_spec.rb
154
150
  - spec/compat_spec.rb
155
- - spec/option_list_spec.rb
151
+ - spec/program_spec.rb
156
152
  - spec/option_spec.rb
157
- - spec/task_spec.rb