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 CHANGED
@@ -94,6 +94,11 @@ module TechnoGate
94
94
  def self.extract_name_from_usage(usage)
95
95
  /^([-_a-zA-Z0-9]+)(\s+(.+?))?$/.match(usage).to_a[1]
96
96
  end
97
+
98
+ # Call the help method of the main clas
99
+ def help
100
+ Main.help self
101
+ end
97
102
  end
98
103
  end
99
104
  end
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
@@ -2,7 +2,7 @@ module TechnoGate
2
2
  module TgCli
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
  PRE = ''
7
7
 
8
8
  def self.version
@@ -13,5 +13,13 @@ module TgCli
13
13
  subject.send(:extract_name_from_usage, "ssh-config").should == "ssh-config"
14
14
  end
15
15
  end
16
+
17
+ context "Printing the help" do
18
+ base = Base.new
19
+
20
+ Main.expects(:help).with(base).once
21
+
22
+ base.send :help
23
+ end
16
24
  end
17
25
  end
@@ -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(base, name, name, "A description")
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', '~>0.8.4'
36
- s.add_development_dependency 'guard-bundler', '~>0.1.3'
37
- s.add_development_dependency 'guard-rspec', '~>0.4.5'
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', '~>0.7.2'
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', '~>0.10.0'
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', '~>0.9.6.2'
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.3
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-25 00:00:00.000000000 Z
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: &20708800 !ruby/object:Gem::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: *20708800
24
+ version_requirements: *10026120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &20708140 !ruby/object:Gem::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: *20708140
35
+ version_requirements: *10025580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard
38
- requirement: &20707180 !ruby/object:Gem::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.8.4
43
+ version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *20707180
46
+ version_requirements: *10025060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-bundler
49
- requirement: &20706440 !ruby/object:Gem::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.1.3
54
+ version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *20706440
57
+ version_requirements: *10024320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &20705760 !ruby/object:Gem::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.4.5
65
+ version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *20705760
68
+ version_requirements: *10023600
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &20734860 !ruby/object:Gem::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.7.2
76
+ version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *20734860
79
+ version_requirements: *10022960
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &20733980 !ruby/object:Gem::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: *20733980
90
+ version_requirements: *10022140
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: mocha
93
- requirement: &20733080 !ruby/object:Gem::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.10.0
98
+ version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *20733080
101
+ version_requirements: *10021700
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rake
104
- requirement: &20732420 !ruby/object:Gem::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: *20732420
112
+ version_requirements: *10021240
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: pry
115
- requirement: &20731220 !ruby/object:Gem::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.9.6.2
120
+ version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *20731220
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: 1878927294025944268
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: 1878927294025944268
171
+ hash: 2395173680454455049
172
172
  requirements: []
173
173
  rubyforge_project:
174
174
  rubygems_version: 1.8.11