tg_cli 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tg_cli/base.rb +5 -0
- data/lib/tg_cli/main.rb +7 -0
- data/lib/tg_cli/version.rb +1 -1
- data/spec/lib/tg_cli/base_spec.rb +8 -0
- data/spec/lib/tg_cli/main_spec.rb +38 -9
- data/tg_cli.gemspec +6 -6
- metadata +36 -36
data/lib/tg_cli/base.rb
CHANGED
data/lib/tg_cli/main.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
require 'thor'
|
2
4
|
|
3
5
|
module TechnoGate
|
@@ -51,6 +53,11 @@ module TechnoGate
|
|
51
53
|
# newly defined method/subcommand:
|
52
54
|
map opts[:alias] => name
|
53
55
|
end
|
56
|
+
|
57
|
+
if opts[:default]
|
58
|
+
# This command is to be set as the default task.
|
59
|
+
default_task name
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|
56
63
|
end
|
data/lib/tg_cli/version.rb
CHANGED
@@ -4,34 +4,63 @@ module TgCli
|
|
4
4
|
describe Main do
|
5
5
|
subject { Main }
|
6
6
|
|
7
|
+
let(:base) do
|
8
|
+
Class.new(Base) do
|
9
|
+
def execute
|
10
|
+
true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:group_base) { Class.new(GroupBase) }
|
16
|
+
|
7
17
|
context "#registering" do
|
18
|
+
before(:each) do
|
19
|
+
# Make the default task (help) return false
|
20
|
+
class Main
|
21
|
+
no_tasks do
|
22
|
+
alias :orig_help :help
|
23
|
+
def help
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:each) do
|
31
|
+
class Main
|
32
|
+
no_tasks do
|
33
|
+
alias :help :orig_help
|
34
|
+
undef :orig_help
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
8
39
|
it {should respond_to :register }
|
9
40
|
|
10
41
|
it "should register a base command as a single invokable" do
|
11
|
-
base = Class.new(Base)
|
12
42
|
name = "__test_registering_single_subcommand"
|
13
43
|
subject.register(base, name, name, "A description")
|
14
44
|
expect { subject.tasks[name] }.should_not raise_error
|
15
45
|
end
|
16
46
|
|
17
47
|
it "should register a group base as a subcommand" do
|
18
|
-
base = Class.new(GroupBase)
|
19
48
|
name = "_test_registering_single_group"
|
20
|
-
subject.register(
|
49
|
+
subject.register(group_base, name, name, "A description")
|
21
50
|
subject.subcommands.should include(name)
|
22
51
|
end
|
23
52
|
|
24
53
|
it "should alias methods if the alias option is given" do
|
25
|
-
base = Class.new(Base) do
|
26
|
-
def execute
|
27
|
-
true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
54
|
name = "__test_registering_with_alias"
|
32
55
|
subject.register(base, name, name, "A description", :alias => "--ALIAS")
|
33
56
|
subject.start(["--ALIAS"]).should be_true
|
34
57
|
end
|
58
|
+
|
59
|
+
it "should make the method as the default command if the default option is given" do
|
60
|
+
name = "__test_registering_as_default"
|
61
|
+
subject.register(base, name, name, "A description", :default => true)
|
62
|
+
subject.start([]).should be_true
|
63
|
+
end
|
35
64
|
end
|
36
65
|
end
|
37
66
|
end
|
data/tg_cli.gemspec
CHANGED
@@ -32,12 +32,12 @@ Gem::Specification.new do |s|
|
|
32
32
|
####
|
33
33
|
|
34
34
|
# Guard
|
35
|
-
s.add_development_dependency 'guard'
|
36
|
-
s.add_development_dependency 'guard-bundler'
|
37
|
-
s.add_development_dependency 'guard-rspec'
|
35
|
+
s.add_development_dependency 'guard'
|
36
|
+
s.add_development_dependency 'guard-bundler'
|
37
|
+
s.add_development_dependency 'guard-rspec'
|
38
38
|
|
39
39
|
# Documentation
|
40
|
-
s.add_development_dependency 'yard'
|
40
|
+
s.add_development_dependency 'yard'
|
41
41
|
|
42
42
|
####
|
43
43
|
# Development / Test dependencies
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
s.add_development_dependency 'rspec', '~>2.6.0'
|
48
48
|
|
49
49
|
# Mocha
|
50
|
-
s.add_development_dependency 'mocha'
|
50
|
+
s.add_development_dependency 'mocha'
|
51
51
|
|
52
52
|
# Rake
|
53
53
|
s.add_development_dependency 'rake'
|
@@ -55,5 +55,5 @@ Gem::Specification.new do |s|
|
|
55
55
|
####
|
56
56
|
# Debugging
|
57
57
|
####
|
58
|
-
s.add_development_dependency 'pry'
|
58
|
+
s.add_development_dependency 'pry'
|
59
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tg_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &10026120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10026120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &10025580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,54 +32,54 @@ dependencies:
|
|
32
32
|
version: 0.14.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10025580
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: guard
|
38
|
-
requirement: &
|
38
|
+
requirement: &10025060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0
|
43
|
+
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10025060
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard-bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &10024320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10024320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &10023600 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ! '>='
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0
|
65
|
+
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10023600
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &10022960 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ! '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
76
|
+
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *10022960
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &10022140 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,21 +87,21 @@ dependencies:
|
|
87
87
|
version: 2.6.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *10022140
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: mocha
|
93
|
-
requirement: &
|
93
|
+
requirement: &10021700 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0
|
98
|
+
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *10021700
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rake
|
104
|
-
requirement: &
|
104
|
+
requirement: &10021240 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,18 +109,18 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *10021240
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: pry
|
115
|
-
requirement: &
|
115
|
+
requirement: &10020700 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - ! '>='
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0
|
120
|
+
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *10020700
|
124
124
|
description: Helpers around Thor extracted from the Vagrant gem.
|
125
125
|
email:
|
126
126
|
- wael.nasreddine@gmail.com
|
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
segments:
|
161
161
|
- 0
|
162
|
-
hash:
|
162
|
+
hash: 2395173680454455049
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
none: false
|
165
165
|
requirements:
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
segments:
|
170
170
|
- 0
|
171
|
-
hash:
|
171
|
+
hash: 2395173680454455049
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
174
|
rubygems_version: 1.8.11
|