rcoli 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rcoli (0.5.4)
4
+ rcoli (0.5.5)
5
5
  highline (~> 1.6.11)
6
6
 
7
7
  GEM
data/lib/rcoli/model.rb CHANGED
@@ -56,7 +56,7 @@ module RCoLi
56
56
  target = self.parent ? :options : :global_options
57
57
  option.keys.each{|key| result.send(target)[key] = value}
58
58
  else
59
- raise InvalidCommand, "#'{arg}' is not a valid option"
59
+ raise InvalidCommand, "'#{arg}' is not a valid option"
60
60
  end
61
61
  else
62
62
  if (cmd = find_command(arg))
@@ -184,13 +184,26 @@ module RCoLi
184
184
  put_default_values(result)
185
185
  parse_args(args, result)
186
186
  if result.command
187
+
188
+ # command has to have the action block
187
189
  action = result.command.get_action
188
190
  raise "Invalid configuration. Missing action block." unless action
191
+
192
+ # enable/disable logging level DEBUG
193
+ if (result.global_options['debug'])
194
+ context.instance_exec do
195
+ @log.level = Logger::DEBUG
196
+ end
197
+ end
198
+
199
+ # execution of the pre block
189
200
  context.instance_exec(result.global_options, result.options, result.arguments, &@pre_action) if (@pre_action and !result.command.solitaire?)
201
+ # execution of the main block
190
202
  context.instance_exec(result.global_options, result.options, result.arguments, &action)
203
+ # execution of the post block
191
204
  context.instance_exec(result.global_options, result.options, result.arguments, &@post_action) if (@post_action and !result.command.solitaire?)
192
205
  else
193
- say "Display UI"
206
+ say "This feature is comming soon. Now you should execute '#{value_of_name} help'"
194
207
  end
195
208
  end
196
209
 
@@ -0,0 +1,25 @@
1
+ require 'logger'
2
+ require 'singleton'
3
+
4
+ module RCoLi
5
+
6
+ class ApplicationContext
7
+
8
+ include Singleton
9
+
10
+ attr_accessor :debug
11
+
12
+ end
13
+
14
+ end
15
+
16
+ @log = Logger.new(STDOUT)
17
+ @log.level = Logger::INFO
18
+ @log.formatter = proc do |severity, datetime, progname, msg|
19
+ "#{msg}\n"
20
+ end
21
+
22
+ def log
23
+ @log
24
+ end
25
+
data/lib/rcoli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module RCoLi
2
2
 
3
- VERSION = '0.5.4'
3
+ VERSION = '0.5.5'
4
4
 
5
5
  end
data/lib/rcoli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'highline/import'
2
+ require 'rcoli/utils'
2
3
  require 'rcoli/extensions'
3
4
  require 'rcoli/help'
4
5
  require 'rcoli/model'
@@ -8,6 +9,11 @@ require 'rcoli/model'
8
9
 
9
10
  def application(id, &block)
10
11
  @program.name id
12
+
13
+ @program.switch long: 'debug' do |s|
14
+ s.description "Turn on debugging"
15
+ end
16
+
11
17
  @program.command(:help) do |c|
12
18
  c.description "Display help documentation"
13
19
  c.solitaire
@@ -15,14 +21,16 @@ def application(id, &block)
15
21
  @program.help args
16
22
  end
17
23
  end
24
+
18
25
  @program.instance_eval &block
26
+
19
27
  end
20
28
 
21
29
  at_exit {
22
30
  begin
23
31
  @program.execute(ARGV, self)
24
32
  rescue InvalidCommand => e
25
- say "#{@program.value_of_name}: #{e.message}. See '#{@program.value_of_name} --help'"
33
+ say "#{@program.value_of_name}: #{e.message}. See '#{@program.value_of_name} help'"
26
34
  end
27
35
 
28
36
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcoli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-26 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
@@ -61,6 +61,7 @@ files:
61
61
  - lib/rcoli/model.rb
62
62
  - lib/rcoli/templates/help.erb
63
63
  - lib/rcoli/templates/help_command.erb
64
+ - lib/rcoli/utils.rb
64
65
  - lib/rcoli/version.rb
65
66
  - rcoli.gemspec
66
67
  homepage: https://github.com/jiripisa/rcoli
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
78
  version: '0'
78
79
  segments:
79
80
  - 0
80
- hash: 697050310254203007
81
+ hash: -3657344483658858464
81
82
  required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  none: false
83
84
  requirements:
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  segments:
88
89
  - 0
89
- hash: 697050310254203007
90
+ hash: -3657344483658858464
90
91
  requirements: []
91
92
  rubyforge_project:
92
93
  rubygems_version: 1.8.24