scripting 0.1.0 → 0.1.1
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/Gemfile +1 -1
- data/Gemfile.lock +3 -1
- data/VERSION +1 -1
- data/lib/scripting/app_defaults.rb +2 -1
- data/lib/scripting/application.rb +17 -4
- data/lib/scripting/parser.rb +1 -1
- data/scripting.gemspec +8 -7
- data/spec/app_defaults_spec.rb +62 -0
- data/spec/application_spec.rb +1 -37
- data/spec/spec_helper.rb +8 -1
- metadata +25 -18
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
|
|
3
3
|
# Add dependencies to develop your gem here.
|
4
4
|
# Include everything needed to run rake, tests, features, etc.
|
5
5
|
group :development do
|
6
|
-
gem "rspec", ">=
|
6
|
+
gem "rspec", ">= 2.5.0"
|
7
7
|
gem "jeweler", "~> 1.5.2"
|
8
8
|
gem "rcov", ">= 0"
|
9
9
|
end
|
data/Gemfile.lock
CHANGED
@@ -9,6 +9,7 @@ GEM
|
|
9
9
|
rake
|
10
10
|
rake (0.8.7)
|
11
11
|
rcov (0.9.9)
|
12
|
+
rcov (0.9.9-java)
|
12
13
|
rspec (2.5.0)
|
13
14
|
rspec-core (~> 2.5.0)
|
14
15
|
rspec-expectations (~> 2.5.0)
|
@@ -19,9 +20,10 @@ GEM
|
|
19
20
|
rspec-mocks (2.5.0)
|
20
21
|
|
21
22
|
PLATFORMS
|
23
|
+
java
|
22
24
|
ruby
|
23
25
|
|
24
26
|
DEPENDENCIES
|
25
27
|
jeweler (~> 1.5.2)
|
26
28
|
rcov
|
27
|
-
rspec (>=
|
29
|
+
rspec (>= 2.5.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -8,11 +8,12 @@ module Scripting
|
|
8
8
|
extend Pluggable
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
clear_switches!
|
12
|
+
clear_options!
|
13
|
+
clear_work!
|
14
14
|
end
|
15
15
|
|
16
|
+
|
16
17
|
def context
|
17
18
|
self
|
18
19
|
end
|
@@ -22,16 +23,28 @@ module Scripting
|
|
22
23
|
self
|
23
24
|
end
|
24
25
|
|
26
|
+
def clear_switches!
|
27
|
+
@switches = Parser.new(self)
|
28
|
+
end
|
29
|
+
|
25
30
|
def switches &blk
|
26
31
|
@switches.instance_eval &blk if block_given?
|
27
32
|
@switches
|
28
33
|
end
|
29
34
|
|
35
|
+
def clear_options!
|
36
|
+
@options = Options.new
|
37
|
+
end
|
38
|
+
|
30
39
|
def options &blk
|
31
40
|
@options.describe &blk if block_given?
|
32
41
|
@options
|
33
42
|
end
|
34
43
|
|
44
|
+
def clear_work!
|
45
|
+
@work = []
|
46
|
+
end
|
47
|
+
|
35
48
|
def work &blk
|
36
49
|
@work << blk if block_given?
|
37
50
|
@work
|
@@ -71,4 +84,4 @@ module Scripting
|
|
71
84
|
app.describe &blk
|
72
85
|
app
|
73
86
|
end
|
74
|
-
end
|
87
|
+
end
|
data/lib/scripting/parser.rb
CHANGED
data/scripting.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{scripting}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["sdeming"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-07}
|
13
13
|
s.description = %q{Simplified command line scripting tool}
|
14
14
|
s.email = %q{sdeming@makefile.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"lib/scripting/parser.rb",
|
32
32
|
"lib/scripting/pluggable.rb",
|
33
33
|
"scripting.gemspec",
|
34
|
+
"spec/app_defaults_spec.rb",
|
34
35
|
"spec/application_spec.rb",
|
35
36
|
"spec/options_spec.rb",
|
36
37
|
"spec/spec_helper.rb"
|
@@ -38,30 +39,30 @@ Gem::Specification.new do |s|
|
|
38
39
|
s.homepage = %q{http://github.com/sdeming/scripting}
|
39
40
|
s.licenses = ["MIT"]
|
40
41
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.
|
42
|
+
s.rubygems_version = %q{1.5.2}
|
42
43
|
s.summary = %q{Simplified command line scripting tool}
|
43
44
|
s.test_files = [
|
44
45
|
"examples/simple.rb",
|
46
|
+
"spec/app_defaults_spec.rb",
|
45
47
|
"spec/application_spec.rb",
|
46
48
|
"spec/options_spec.rb",
|
47
49
|
"spec/spec_helper.rb"
|
48
50
|
]
|
49
51
|
|
50
52
|
if s.respond_to? :specification_version then
|
51
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
53
|
s.specification_version = 3
|
53
54
|
|
54
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_development_dependency(%q<rspec>, [">=
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
|
56
57
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
57
58
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
58
59
|
else
|
59
|
-
s.add_dependency(%q<rspec>, [">=
|
60
|
+
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
60
61
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
61
62
|
s.add_dependency(%q<rcov>, [">= 0"])
|
62
63
|
end
|
63
64
|
else
|
64
|
-
s.add_dependency(%q<rspec>, [">=
|
65
|
+
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
65
66
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
66
67
|
s.add_dependency(%q<rcov>, [">= 0"])
|
67
68
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Scripting::AppDefaults do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@stdout = ''
|
7
|
+
STDOUT.stub(:write) { |*args| @stdout << args.join }
|
8
|
+
|
9
|
+
@stderr = ''
|
10
|
+
STDERR.stub(:write) { |*args| @stderr << args.join }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should define default options when using AppDefaults plugin" do
|
14
|
+
app = Scripting::create_application do
|
15
|
+
plugin Scripting::AppDefaults
|
16
|
+
uses :default_options
|
17
|
+
end
|
18
|
+
app.options.verbose.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should define default switches when using AppDefaults plugin" do
|
22
|
+
app = Scripting::create_application do
|
23
|
+
plugin Scripting::AppDefaults
|
24
|
+
uses :default_switches
|
25
|
+
end
|
26
|
+
app.options.verbose.should be_nil
|
27
|
+
app.parse! ["-v"]
|
28
|
+
app.options.verbose.should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should define both default options and switches when using AppDefaults plugin" do
|
32
|
+
app1 = Scripting::create_application do
|
33
|
+
plugin Scripting::AppDefaults
|
34
|
+
uses :default_switches
|
35
|
+
uses :default_options
|
36
|
+
end
|
37
|
+
app1.options.verbose.should be_false
|
38
|
+
app1.parse! ["-v"]
|
39
|
+
app1.options.verbose.should be_true
|
40
|
+
|
41
|
+
app2 = Scripting::create_application do
|
42
|
+
plugin Scripting::AppDefaults
|
43
|
+
uses :default_switches, :default_options
|
44
|
+
end
|
45
|
+
app2.options.verbose.should be_false
|
46
|
+
app2.parse! ["-v"]
|
47
|
+
app2.options.verbose.should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should terminate command line processing and clear work when -h is passed with default switches" do
|
51
|
+
app = Scripting::create_application do
|
52
|
+
plugin Scripting::AppDefaults
|
53
|
+
uses :default_switches, :default_options
|
54
|
+
work { puts 7 * 6 }
|
55
|
+
end
|
56
|
+
@stderr.should be_empty
|
57
|
+
app.work.should_not be_empty
|
58
|
+
app.parse! ["-h"]
|
59
|
+
@stderr.should_not be_empty
|
60
|
+
app.work.should be_empty
|
61
|
+
end
|
62
|
+
end
|
data/spec/application_spec.rb
CHANGED
@@ -37,40 +37,4 @@ describe Scripting::Application do
|
|
37
37
|
app.options.action.should == "digest"
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
app = Scripting::create_application do
|
42
|
-
plugin Scripting::AppDefaults
|
43
|
-
uses :default_options
|
44
|
-
end
|
45
|
-
app.options.verbose.should be_false
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should define default switches when using AppDefaults plugin" do
|
49
|
-
app = Scripting::create_application do
|
50
|
-
plugin Scripting::AppDefaults
|
51
|
-
uses :default_switches
|
52
|
-
end
|
53
|
-
app.options.verbose.should be_nil
|
54
|
-
app.parse! ["-v"]
|
55
|
-
app.options.verbose.should be_true
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should define both default options and switches when using AppDefaults plugin" do
|
59
|
-
app1 = Scripting::create_application do
|
60
|
-
plugin Scripting::AppDefaults
|
61
|
-
uses :default_switches
|
62
|
-
uses :default_options
|
63
|
-
end
|
64
|
-
app1.options.verbose.should be_false
|
65
|
-
app1.parse! ["-v"]
|
66
|
-
app1.options.verbose.should be_true
|
67
|
-
|
68
|
-
app2 = Scripting::create_application do
|
69
|
-
plugin Scripting::AppDefaults
|
70
|
-
uses :default_switches, :default_options
|
71
|
-
end
|
72
|
-
app2.options.verbose.should be_false
|
73
|
-
app2.parse! ["-v"]
|
74
|
-
app2.options.verbose.should be_true
|
75
|
-
end
|
76
|
-
end
|
40
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scripting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- sdeming
|
@@ -14,52 +15,55 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-07 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rspec
|
22
|
-
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
24
|
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 27
|
27
29
|
segments:
|
28
|
-
-
|
29
|
-
-
|
30
|
+
- 2
|
31
|
+
- 5
|
30
32
|
- 0
|
31
|
-
version:
|
32
|
-
type: :development
|
33
|
+
version: 2.5.0
|
33
34
|
prerelease: false
|
34
|
-
|
35
|
+
type: :development
|
36
|
+
requirement: *id001
|
35
37
|
- !ruby/object:Gem::Dependency
|
36
38
|
name: jeweler
|
37
|
-
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
40
42
|
- - ~>
|
41
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
42
45
|
segments:
|
43
46
|
- 1
|
44
47
|
- 5
|
45
48
|
- 2
|
46
49
|
version: 1.5.2
|
47
|
-
type: :development
|
48
50
|
prerelease: false
|
49
|
-
|
51
|
+
type: :development
|
52
|
+
requirement: *id002
|
50
53
|
- !ruby/object:Gem::Dependency
|
51
54
|
name: rcov
|
52
|
-
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
56
|
none: false
|
54
57
|
requirements:
|
55
58
|
- - ">="
|
56
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
57
61
|
segments:
|
58
62
|
- 0
|
59
63
|
version: "0"
|
60
|
-
type: :development
|
61
64
|
prerelease: false
|
62
|
-
|
65
|
+
type: :development
|
66
|
+
requirement: *id003
|
63
67
|
description: Simplified command line scripting tool
|
64
68
|
email: sdeming@makefile.com
|
65
69
|
executables: []
|
@@ -84,6 +88,7 @@ files:
|
|
84
88
|
- lib/scripting/parser.rb
|
85
89
|
- lib/scripting/pluggable.rb
|
86
90
|
- scripting.gemspec
|
91
|
+
- spec/app_defaults_spec.rb
|
87
92
|
- spec/application_spec.rb
|
88
93
|
- spec/options_spec.rb
|
89
94
|
- spec/spec_helper.rb
|
@@ -101,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
106
|
requirements:
|
102
107
|
- - ">="
|
103
108
|
- !ruby/object:Gem::Version
|
104
|
-
hash:
|
109
|
+
hash: 3
|
105
110
|
segments:
|
106
111
|
- 0
|
107
112
|
version: "0"
|
@@ -110,18 +115,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
115
|
requirements:
|
111
116
|
- - ">="
|
112
117
|
- !ruby/object:Gem::Version
|
118
|
+
hash: 3
|
113
119
|
segments:
|
114
120
|
- 0
|
115
121
|
version: "0"
|
116
122
|
requirements: []
|
117
123
|
|
118
124
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.
|
125
|
+
rubygems_version: 1.5.2
|
120
126
|
signing_key:
|
121
127
|
specification_version: 3
|
122
128
|
summary: Simplified command line scripting tool
|
123
129
|
test_files:
|
124
130
|
- examples/simple.rb
|
131
|
+
- spec/app_defaults_spec.rb
|
125
132
|
- spec/application_spec.rb
|
126
133
|
- spec/options_spec.rb
|
127
134
|
- spec/spec_helper.rb
|