rprogram 0.3.1 → 0.3.2
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.
- data/ChangeLog.md +9 -1
- data/LICENSE.txt +1 -1
- data/README.md +6 -10
- data/gemspec.yml +1 -2
- data/lib/rprogram/argument.rb +31 -0
- data/lib/rprogram/non_option.rb +6 -36
- data/lib/rprogram/option.rb +32 -43
- data/lib/rprogram/program.rb +9 -10
- data/lib/rprogram/rprogram.rb +6 -4
- data/lib/rprogram/system.rb +38 -31
- data/lib/rprogram/task.rb +14 -12
- data/lib/rprogram/version.rb +1 -1
- data/rprogram.gemspec +38 -83
- data/spec/classes/aliased_program.rb +2 -0
- data/spec/classes/named_program.rb +2 -0
- data/spec/non_option_spec.rb +10 -12
- data/spec/option_examples.rb +3 -5
- data/spec/option_list_spec.rb +7 -11
- data/spec/option_spec.rb +31 -33
- data/spec/program_spec.rb +8 -7
- data/spec/rprogram_spec.rb +7 -7
- data/spec/system_spec.rb +3 -2
- data/spec/task_spec.rb +43 -36
- metadata +5 -34
- data/lib/rprogram/yard.rb +0 -1
data/spec/program_spec.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
require 'rprogram/program'
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
require 'classes/named_program'
|
5
3
|
require 'classes/aliased_program'
|
6
4
|
require 'classes/ls_program'
|
7
5
|
|
6
|
+
require 'rprogram/program'
|
7
|
+
|
8
8
|
describe Program do
|
9
|
-
subject {
|
9
|
+
subject { described_class.new('/usr/bin/cc') }
|
10
|
+
|
10
11
|
after(:all) { LS.path = nil }
|
11
12
|
|
12
13
|
describe "named program" do
|
@@ -104,18 +105,18 @@ describe Program do
|
|
104
105
|
|
105
106
|
it "should raise an exception for invalid paths" do
|
106
107
|
lambda {
|
107
|
-
|
108
|
+
described_class.new('/totally/doesnt/exist')
|
108
109
|
}.should raise_error(ProgramNotFound)
|
109
110
|
end
|
110
111
|
|
111
112
|
it "should find a program from a path" do
|
112
|
-
prog =
|
113
|
+
prog = described_class.find_with_path('/usr/bin/cc')
|
113
114
|
|
114
115
|
prog.should_not be_nil
|
115
116
|
end
|
116
117
|
|
117
118
|
it "should find a program from given paths" do
|
118
|
-
prog =
|
119
|
+
prog = described_class.find_with_paths(['/usr/bin/ls','/bin/ls'])
|
119
120
|
|
120
121
|
prog.should_not be_nil
|
121
122
|
end
|
@@ -128,7 +129,7 @@ describe Program do
|
|
128
129
|
|
129
130
|
it "should raise a ProgramNotFound exception if no path/name is valid" do
|
130
131
|
lambda {
|
131
|
-
|
132
|
+
described_class.find
|
132
133
|
}.should raise_error(ProgramNotFound)
|
133
134
|
end
|
134
135
|
|
data/spec/rprogram_spec.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
require 'rprogram/version'
|
2
4
|
require 'rprogram/rprogram'
|
3
5
|
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
6
|
describe RProgram do
|
7
7
|
it "should have a VERSION constant" do
|
8
|
-
|
8
|
+
subject.const_defined?('VERSION').should == true
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should have a debug mode" do
|
12
|
-
|
13
|
-
|
12
|
+
subject.debug = true
|
13
|
+
subject.debug.should be_true
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
subject.debug = false
|
16
|
+
subject.debug.should be_false
|
17
17
|
end
|
18
18
|
end
|
data/spec/system_spec.rb
CHANGED
@@ -31,11 +31,12 @@ describe System do
|
|
31
31
|
describe "run" do
|
32
32
|
let(:scripts_dir) { File.join(File.dirname(__FILE__),'scripts') }
|
33
33
|
|
34
|
-
let(:fail_script)
|
34
|
+
let(:fail_script) { File.join(scripts_dir,'fail.rb') }
|
35
35
|
let(:success_script) { File.join(scripts_dir,'success.rb') }
|
36
36
|
|
37
37
|
let(:print_script) { File.join(scripts_dir,'print.rb') }
|
38
|
-
let(:echo_script)
|
38
|
+
let(:echo_script) { File.join(scripts_dir,'echo.rb') }
|
39
|
+
|
39
40
|
let(:data) { 'hello' }
|
40
41
|
|
41
42
|
it "should return true when programs succeed" do
|
data/spec/task_spec.rb
CHANGED
@@ -1,85 +1,92 @@
|
|
1
|
-
require 'rprogram/task'
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
require 'classes/ls_task'
|
5
3
|
require 'classes/ls_selinux_task'
|
6
4
|
|
5
|
+
require 'rprogram/task'
|
6
|
+
|
7
7
|
describe Task do
|
8
8
|
describe "flag_namify" do
|
9
|
+
subject { described_class }
|
10
|
+
|
9
11
|
it "should downcase all characters" do
|
10
|
-
|
12
|
+
subject.flag_namify('-SHORT-option').should == 'short_option'
|
11
13
|
end
|
12
14
|
|
13
15
|
it "should replace dashes with underscores" do
|
14
|
-
|
16
|
+
subject.flag_namify('-short-option').should == 'short_option'
|
15
17
|
end
|
16
18
|
|
17
19
|
it "should replace dots with underscores" do
|
18
|
-
|
20
|
+
subject.flag_namify('-short.option').should == 'short_option'
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should replace spaces with underscores" do
|
22
|
-
|
24
|
+
subject.flag_namify('-short option').should == 'short_option'
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should replace multiple underscores with one underscore" do
|
26
|
-
|
28
|
+
subject.flag_namify('-short__option').should == 'short_option'
|
27
29
|
end
|
28
30
|
|
29
31
|
it "should namify short options" do
|
30
|
-
|
32
|
+
subject.flag_namify('-short-option').should == 'short_option'
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should namify long options" do
|
34
|
-
|
36
|
+
subject.flag_namify('--long-option').should == 'long_option'
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
|
39
|
-
@task = LSTask.new
|
40
|
-
end
|
40
|
+
subject { LSTask.new }
|
41
41
|
|
42
42
|
it "should have no arguments by default" do
|
43
|
-
|
43
|
+
subject.arguments.should be_empty
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should define reader and writter methods for options" do
|
47
|
-
|
47
|
+
subject.all.should be_nil
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
subject.all = true
|
50
|
+
subject.all.should == true
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should default the value of multi-options to an empty Array" do
|
54
|
-
|
54
|
+
subject.hide.should be_empty
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should define reader and writter methods for non-options" do
|
58
|
-
|
58
|
+
subject.files.should be_empty
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
subject.files << 'file.txt'
|
61
|
+
subject.files.should == ['file.txt']
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
LSTask
|
66
|
-
end
|
64
|
+
describe "class methods" do
|
65
|
+
subject { LSTask }
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
it "should provide access to the defined options" do
|
68
|
+
subject.options.should_not be_empty
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
it "should provide access to the defined non-options" do
|
72
|
+
subject.non_options.should_not be_empty
|
73
|
+
end
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
it "should default the name of long options to the flag" do
|
76
|
+
subject.options[:author].flag.should == '--author'
|
77
|
+
end
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
it "should allow the name of long options to be overridden" do
|
80
|
+
subject.options[:group_dirs_first].flag.should == '--group-directories-first'
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when inherited" do
|
84
|
+
subject { LSSELinuxTask }
|
85
|
+
|
86
|
+
it "should allow options to be inherited" do
|
87
|
+
subject.has_option?(:all).should == true
|
88
|
+
subject.has_option?(:security_context).should == true
|
89
|
+
end
|
90
|
+
end
|
84
91
|
end
|
85
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rprogram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: env
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0.1'
|
22
|
-
- - ! '>='
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0.1.2
|
25
|
-
type: :runtime
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0.1'
|
33
|
-
- - ! '>='
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 0.1.2
|
36
14
|
- !ruby/object:Gem::Dependency
|
37
15
|
name: rubygems-tasks
|
38
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +82,7 @@ files:
|
|
104
82
|
- Rakefile
|
105
83
|
- gemspec.yml
|
106
84
|
- lib/rprogram.rb
|
85
|
+
- lib/rprogram/argument.rb
|
107
86
|
- lib/rprogram/exceptions.rb
|
108
87
|
- lib/rprogram/exceptions/program_not_found.rb
|
109
88
|
- lib/rprogram/non_option.rb
|
@@ -116,7 +95,6 @@ files:
|
|
116
95
|
- lib/rprogram/system.rb
|
117
96
|
- lib/rprogram/task.rb
|
118
97
|
- lib/rprogram/version.rb
|
119
|
-
- lib/rprogram/yard.rb
|
120
98
|
- rprogram.gemspec
|
121
99
|
- spec/classes/aliased_program.rb
|
122
100
|
- spec/classes/ls_program.rb
|
@@ -148,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
126
|
requirements:
|
149
127
|
- - ! '>='
|
150
128
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
129
|
+
version: 1.8.7
|
152
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
131
|
none: false
|
154
132
|
requirements:
|
@@ -161,11 +139,4 @@ rubygems_version: 1.8.24
|
|
161
139
|
signing_key:
|
162
140
|
specification_version: 3
|
163
141
|
summary: A library for creating wrappers around command-line programs.
|
164
|
-
test_files:
|
165
|
-
- spec/non_option_spec.rb
|
166
|
-
- spec/option_list_spec.rb
|
167
|
-
- spec/option_spec.rb
|
168
|
-
- spec/program_spec.rb
|
169
|
-
- spec/rprogram_spec.rb
|
170
|
-
- spec/system_spec.rb
|
171
|
-
- spec/task_spec.rb
|
142
|
+
test_files: []
|
data/lib/rprogram/yard.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'rprogram/yard/handlers'
|