params 0.0.8 → 0.0.9

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.
Files changed (3) hide show
  1. data/lib/params/version.rb +1 -1
  2. data/lib/params.rb +17 -8
  3. metadata +3 -3
@@ -1,5 +1,5 @@
1
1
  module BBFS
2
2
  module Params
3
- VERSION = "0.0.8" # Parser updated in params.rb
3
+ VERSION = "0.0.9" # Parser updated in params.rb
4
4
  end
5
5
  end
data/lib/params.rb CHANGED
@@ -78,6 +78,10 @@ module BBFS
78
78
  # be made for Float parameters which are set with integer values.
79
79
  # 4. Check will be skipped for nil value.
80
80
  def value_type_check(value)
81
+ if value.nil?
82
+ return value
83
+ end
84
+
81
85
  case( @type )
82
86
  when 'Integer' then
83
87
  if not @value.nil?
@@ -213,16 +217,21 @@ module BBFS
213
217
  @init_debug_messages = []
214
218
  results = parse_command_line_arguments(args)
215
219
  if not results['conf_file'].nil?
216
- @init_debug_messages << "Configuration file was overridden. New path:'#{results['conf_file']}'"
217
- Params['conf_file'] = results['conf_file']
220
+ Params['conf_file'] = File.expand_path(results['conf_file'])
218
221
  end
219
222
 
220
- #load yml params
221
- if (not Params['conf_file'].nil?) and (File.exist?(File.expand_path Params['conf_file']))
222
- @init_debug_messages << 'Configuration file path exists. Loading file parameters.'
223
- read_yml_params(File.open(Params['conf_file'], 'r'))
223
+ #load yml params if path is provided and exists
224
+ if Params['conf_file'].nil?
225
+ @init_debug_messages << 'Configuration file was not provided.' + \
226
+ 'Skipping loading file parameters.'
224
227
  else
225
- @init_debug_messages << 'Configuration file path does not exist. Skipping loading file parameters.'
228
+ if File.exist?(Params['conf_file'])
229
+ @init_debug_messages << "Loading parameters from configuration file:'#{Params['conf_file']}'"
230
+ read_yml_params(File.open(Params['conf_file'], 'r'))
231
+ else
232
+ @init_debug_messages << "Configuration file path:'#{Params['conf_file']}' does not exist. " + \
233
+ "Skipping loading file parameters."
234
+ end
226
235
  end
227
236
 
228
237
  #override command line argument
@@ -310,7 +319,7 @@ module BBFS
310
319
  end
311
320
  #define default params:
312
321
  # 1. configuration file
313
- Params.string('conf_file', File.expand_path("~/.bbfs/conf/#{executable_name}.conf"), 'Default configuration file.')
322
+ Params.string('conf_file', nil, 'Configuration file path.')
314
323
  # 2. Print params to stdout
315
324
  Params.boolean('print_params_to_stdout', false, 'print_params_to_stdout or not during Params.init')
316
325
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-02 00:00:00.000000000 Z
13
+ date: 2012-09-13 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Dynamically stores, parses and providers params. Uses module local readers.
16
16
  email: kolmanv@gmail.com
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  version: '0'
43
43
  requirements: []
44
44
  rubyforge_project:
45
- rubygems_version: 1.8.23
45
+ rubygems_version: 1.8.24
46
46
  signing_key:
47
47
  specification_version: 3
48
48
  summary: Dynamically stores, parses and providers params.