config-parser 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
- == Config parser gem
1
+ ## Config parser gem
2
2
 
3
3
  Parsing an options.yml file into a Hash with convenience methods like
4
4
  overwriting variables per Rails environment and overwriting variables with a local
5
5
  options_local.yml file.
6
6
 
7
- === Installation
7
+ ### Installation
8
8
 
9
9
  The best way to install is with RubyGems:
10
10
 
@@ -14,12 +14,12 @@ Or better still, just add it to your Gemfile:
14
14
 
15
15
  gem 'config-parser'
16
16
 
17
- === Defaults
17
+ ### Defaults
18
18
 
19
19
  Per default the parser will search for the config file at config/options.yml and config/options-local.yml.
20
20
 
21
21
 
22
- === Example
22
+ ### Example
23
23
 
24
24
  Example config file:
25
25
 
@@ -35,8 +35,19 @@ When running in the production environment, the mailer_delivery_method will be s
35
35
  would have the same layout.
36
36
  When used from a Rails app, just include in your application.rb:
37
37
 
38
- OPTS = Common::Options.new
38
+ ```ruby
39
+ OPTS = Common::Options.new
40
+ ```
39
41
 
40
42
  and you can use the config variables like:
41
43
 
42
- OPTS.<variable_name>
44
+ ```ruby
45
+ OPTS.<variable_name>
46
+ ```
47
+
48
+ Also, you can pass main config and local config location as well as environment to load
49
+ That allows you to use config-parser outside Rails env.
50
+
51
+ ```ruby
52
+ OPTS = Common::Options.new('path/to/options.yml', 'path/to/options-local.yml', :development)
53
+ ```
@@ -9,7 +9,7 @@ options_local.yml file."
9
9
  gem.files = `git ls-files`.split("\n")
10
10
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
11
11
  gem.require_paths = ['lib']
12
- gem.version = '0.1'
12
+ gem.version = '0.2.0'
13
13
  end
14
14
 
15
15
 
@@ -27,10 +27,11 @@ module Common
27
27
 
28
28
  class Options
29
29
 
30
- def initialize
30
+ def initialize(cfg_file = 'config/options.yml', local_cfg_file = 'config/options-local.yml', load_env = nil)
31
31
  Common::Utils::suppress_warnings do
32
- @cfg_file = 'config/options.yml'
33
- @local_cfg_file = 'config/options-local.yml'
32
+ @load_env = load_env
33
+ @cfg_file = cfg_file
34
+ @local_cfg_file = local_cfg_file
34
35
  @tmp_cmdl_file = 'tmp/options-cmd-line.yml'
35
36
  @persistent_local_cfg_file = '/etc/options.yml'
36
37
  if defined? Rails
@@ -57,7 +58,11 @@ module Common
57
58
  end
58
59
  end
59
60
 
60
- cmd_line_args['environment'] = Rails.env.to_s if defined? Rails
61
+ if defined? Rails
62
+ cmd_line_args['environment'] = Rails.env.to_s
63
+ else
64
+ cmd_line_args['environment'] = @load_env.to_s
65
+ end
61
66
 
62
67
  if cmd_line_args['environment'] == 'test' and cmd_line_args['verbose'].nil?
63
68
  cmd_line_args['verbose'] = 'silent'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.2.0
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-08-22 00:00:00.000000000 Z
13
+ date: 2013-07-01 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: ! 'Parsing an options.yml file into a Hash with convenience methods like
16
16
 
@@ -24,7 +24,7 @@ extra_rdoc_files: []
24
24
  files:
25
25
  - .gitignore
26
26
  - LICENSE
27
- - README.rdoc
27
+ - README.markdown
28
28
  - config-parser.gemspec
29
29
  - lib/common/options.rb
30
30
  - lib/common/utils.rb
@@ -49,8 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  version: '0'
50
50
  requirements: []
51
51
  rubyforge_project:
52
- rubygems_version: 1.8.11
52
+ rubygems_version: 1.8.23
53
53
  signing_key:
54
54
  specification_version: 3
55
55
  summary: Parsing an options.yml file into a Hash with convenience.
56
56
  test_files: []
57
+ has_rdoc: