rcoli 0.5.3 → 0.5.4

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.3)
4
+ rcoli (0.5.4)
5
5
  highline (~> 1.6.11)
6
6
 
7
7
  GEM
@@ -6,7 +6,11 @@ def setter(name)
6
6
 
7
7
  define_method("value_of_#{name}") do
8
8
  ivar = "@#{name}"
9
- instance_variable_get(ivar).to_s
9
+ if (instance_variable_get(ivar))
10
+ instance_variable_get(ivar).to_s
11
+ else
12
+ nil
13
+ end
10
14
  end
11
15
 
12
16
  end
data/lib/rcoli/model.rb CHANGED
@@ -61,6 +61,7 @@ module RCoLi
61
61
  else
62
62
  if (cmd = find_command(arg))
63
63
  result.command = cmd
64
+ cmd.put_default_values(result)
64
65
  cmd.parse_args(args, result)
65
66
  elsif (commands.empty?)
66
67
  result.arguments << arg
@@ -71,6 +72,13 @@ module RCoLi
71
72
  parse_args(args, result)
72
73
  end
73
74
 
75
+ def put_default_values(result)
76
+ options.find_all{|option| option.respond_to? :value_of_default_value and option.value_of_default_value}.each do |option|
77
+ target = self.parent ? :options : :global_options
78
+ option.keys.each{|key| result.send(target)[key] = option.value_of_default_value}
79
+ end
80
+ end
81
+
74
82
  def find_command(name)
75
83
  commands.find{|command| command.value_of_name.eql? name}
76
84
  end
@@ -173,6 +181,7 @@ module RCoLi
173
181
 
174
182
  def execute(args, context)
175
183
  result = ParsedArgs.new
184
+ put_default_values(result)
176
185
  parse_args(args, result)
177
186
  if result.command
178
187
  action = result.command.get_action
data/lib/rcoli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module RCoLi
2
2
 
3
- VERSION = '0.5.3'
3
+ VERSION = '0.5.4'
4
4
 
5
5
  end
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.3
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -77,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  segments:
79
79
  - 0
80
- hash: 4363719608537841093
80
+ hash: 697050310254203007
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  none: false
83
83
  requirements:
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  segments:
88
88
  - 0
89
- hash: 4363719608537841093
89
+ hash: 697050310254203007
90
90
  requirements: []
91
91
  rubyforge_project:
92
92
  rubygems_version: 1.8.24