global 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
 - data/LICENSE.txt +1 -1
 - data/README.md +24 -2
 - data/global.gemspec +2 -2
 - data/lib/global/configuration.rb +7 -1
 - data/lib/global/version.rb +1 -1
 - data/spec/files/bool_config.yml +5 -0
 - data/spec/files/nested_config.yml +11 -0
 - data/spec/global/configuration_spec.rb +7 -1
 - data/spec/global_spec.rb +20 -7
 - metadata +9 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a948818df60cb23dc3695891852506c443ca6130
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8765c67649a429336e040cbbbe000736474646bf
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8b3eaf9cbcb32138af748b51943733026142df18a673bb1bd7a6928aa238d5b5b6b28f59a534eb058110725094e00876257485bb11e77310b2780f841f6a64b6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ca9b019175be4a8e5eccaa6a76e04025022dbde9cb0df498a59747f7e1166df86db231df9340d539b1ffca2d8100e8af3e2a18f82f3cd478c892b775564c4c84
         
     | 
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -91,9 +91,31 @@ production: 
     | 
|
| 
       91 
91 
     | 
    
         | 
| 
       92 
92 
     | 
    
         
             
            Data from default section uses until it's overridden in specific environment.
         
     | 
| 
       93 
93 
     | 
    
         | 
| 
      
 94 
     | 
    
         
            +
            ### Nested configurations
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            Config file `global/nested.yml` with:
         
     | 
| 
      
 97 
     | 
    
         
            +
            ```yml
         
     | 
| 
      
 98 
     | 
    
         
            +
            test:
         
     | 
| 
      
 99 
     | 
    
         
            +
              group:
         
     | 
| 
      
 100 
     | 
    
         
            +
                key: "test value"
         
     | 
| 
      
 101 
     | 
    
         
            +
            development:
         
     | 
| 
      
 102 
     | 
    
         
            +
              group:
         
     | 
| 
      
 103 
     | 
    
         
            +
                key: "development value"
         
     | 
| 
      
 104 
     | 
    
         
            +
            production:
         
     | 
| 
      
 105 
     | 
    
         
            +
              group:
         
     | 
| 
      
 106 
     | 
    
         
            +
                key: "production value"
         
     | 
| 
      
 107 
     | 
    
         
            +
            ```
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            Access to nested options provides like: 
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 112 
     | 
    
         
            +
            > Global.nested.group.key
         
     | 
| 
      
 113 
     | 
    
         
            +
            => "development value"
         
     | 
| 
      
 114 
     | 
    
         
            +
            ```
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
       94 
116 
     | 
    
         
             
            ### ERB support
         
     | 
| 
       95 
117 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
            Config file  
     | 
| 
      
 118 
     | 
    
         
            +
            Config file `global/file_name.yml` with:
         
     | 
| 
       97 
119 
     | 
    
         | 
| 
       98 
120 
     | 
    
         
             
            ```yml
         
     | 
| 
       99 
121 
     | 
    
         
             
            test:
         
     | 
| 
         @@ -129,6 +151,6 @@ As a result in development environment we have: 
     | 
|
| 
       129 
151 
     | 
    
         | 
| 
       130 
152 
     | 
    
         
             
            ## Copyright
         
     | 
| 
       131 
153 
     | 
    
         | 
| 
       132 
     | 
    
         
            -
            Copyright (c) 2013  
     | 
| 
      
 154 
     | 
    
         
            +
            Copyright (c) 2013 Railsware LLC. See LICENSE.txt for
         
     | 
| 
       133 
155 
     | 
    
         
             
            further details.
         
     | 
| 
       134 
156 
     | 
    
         | 
    
        data/global.gemspec
    CHANGED
    
    | 
         @@ -4,8 +4,8 @@ require "global/version" 
     | 
|
| 
       4 
4 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       5 
5 
     | 
    
         
             
              s.name = "global"
         
     | 
| 
       6 
6 
     | 
    
         
             
              s.version = Global::VERSION
         
     | 
| 
       7 
     | 
    
         
            -
              s.authors = [" 
     | 
| 
       8 
     | 
    
         
            -
              s.email = " 
     | 
| 
      
 7 
     | 
    
         
            +
              s.authors = ["Railsware LLC"]
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.email = "contact@railsware.com"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.rubyforge_project = "global"
         
     | 
| 
       11 
11 
     | 
    
         | 
    
        data/lib/global/configuration.rb
    CHANGED
    
    | 
         @@ -16,7 +16,13 @@ module Global 
     | 
|
| 
       16 
16 
     | 
    
         
             
                protected
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                def method_missing(method, *args, &block)
         
     | 
| 
       19 
     | 
    
         
            -
                   
     | 
| 
      
 19 
     | 
    
         
            +
                  method = method.to_s[0..-2] if method.to_s[-1] == '?'
         
     | 
| 
      
 20 
     | 
    
         
            +
                  if key?(method)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    value = hash[method]
         
     | 
| 
      
 22 
     | 
    
         
            +
                    value.kind_of?(Hash) ? Global::Configuration.new(value) : value
         
     | 
| 
      
 23 
     | 
    
         
            +
                  else
         
     | 
| 
      
 24 
     | 
    
         
            +
                    super
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
       20 
26 
     | 
    
         
             
                end
         
     | 
| 
       21 
27 
     | 
    
         
             
              end
         
     | 
| 
       22 
28 
     | 
    
         
             
            end
         
     | 
    
        data/lib/global/version.rb
    CHANGED
    
    
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            describe Global::Configuration do
         
     | 
| 
       4 
     | 
    
         
            -
              let(:hash){ { "key" => "value" } }
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:hash){ { "key" => "value", "nested" => { "key" => "value" } } }
         
     | 
| 
       5 
5 
     | 
    
         
             
              let(:configuration){ described_class.new hash }
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
              describe "#hash" do
         
     | 
| 
         @@ -54,5 +54,11 @@ describe Global::Configuration do 
     | 
|
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
                  it{ lambda { subject }.should raise_error(NoMethodError) }
         
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                context "with nested hash" do
         
     | 
| 
      
 59 
     | 
    
         
            +
                  subject{ configuration.nested.key }
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  it{ should == "value" }
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
       57 
63 
     | 
    
         
             
              end
         
     | 
| 
       58 
64 
     | 
    
         
             
            end
         
     | 
    
        data/spec/global_spec.rb
    CHANGED
    
    | 
         @@ -8,7 +8,7 @@ describe Global do 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              describe ".environment" do
         
     | 
| 
       10 
10 
     | 
    
         
             
                subject{ described_class.environment }
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       12 
12 
     | 
    
         
             
                it{ should == "test" }
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                context "when undefined" do
         
     | 
| 
         @@ -20,12 +20,12 @@ describe Global do 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              describe ".config_directory" do
         
     | 
| 
       22 
22 
     | 
    
         
             
                subject{ described_class.config_directory }
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       24 
24 
     | 
    
         
             
                it{ should ==  File.join(Dir.pwd, "spec/files")}
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                context "when undefined" do
         
     | 
| 
       27 
27 
     | 
    
         
             
                  before{ described_class.config_directory = nil }
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       29 
29 
     | 
    
         
             
                  it{ lambda{ subject }.should raise_error("config_directory should be defined") }
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
       31 
31 
     | 
    
         
             
              end
         
     | 
| 
         @@ -36,18 +36,23 @@ describe Global do 
     | 
|
| 
       36 
36 
     | 
    
         
             
                it{ should be_instance_of(Global::Configuration) }
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                context "when load from directory" do
         
     | 
| 
       39 
     | 
    
         
            -
                  its("rspec_config.to_hash"){ should == {"default_value"=>"default value", "test_value"=>"test value"} } 
     | 
| 
      
 39 
     | 
    
         
            +
                  its("rspec_config.to_hash"){ should == {"default_value"=>"default value", "test_value"=>"test value"} }
         
     | 
| 
       40 
40 
     | 
    
         
             
                end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                context "when load from file" do
         
     | 
| 
       43 
43 
     | 
    
         
             
                  before{ described_class.config_directory = File.join(Dir.pwd, "spec/files/rspec_config") }
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                  its("rspec_config.to_hash"){ should == {"default_value"=>"default value", "test_value"=>"test value"} } 
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                  its("rspec_config.to_hash"){ should == {"default_value"=>"default value", "test_value"=>"test value"} }
         
     | 
| 
       46 
46 
     | 
    
         
             
                end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
                context "when nested directories" do
         
     | 
| 
       49 
49 
     | 
    
         
             
                  it{ subject.rspec["config"].to_hash.should == {"default_value"=>"default nested value", "test_value"=>"test nested value"} }
         
     | 
| 
       50 
50 
     | 
    
         
             
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                context "when boolean" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  it{ subject.bool_config.works.should == true }
         
     | 
| 
      
 54 
     | 
    
         
            +
                  it{ subject.bool_config.works?.should == true }
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
       51 
56 
     | 
    
         
             
              end
         
     | 
| 
       52 
57 
     | 
    
         | 
| 
       53 
58 
     | 
    
         
             
              context ".reload!" do
         
     | 
| 
         @@ -64,7 +69,7 @@ describe Global do 
     | 
|
| 
       64 
69 
     | 
    
         
             
                end
         
     | 
| 
       65 
70 
     | 
    
         | 
| 
       66 
71 
     | 
    
         
             
                it{ should be_instance_of(Global::Configuration) }
         
     | 
| 
       67 
     | 
    
         
            -
                its("rspec_config.to_hash"){ should == {"default_value"=>"default value", "test_value"=>"development value"} } 
     | 
| 
      
 72 
     | 
    
         
            +
                its("rspec_config.to_hash"){ should == {"default_value"=>"default value", "test_value"=>"development value"} }
         
     | 
| 
       68 
73 
     | 
    
         
             
              end
         
     | 
| 
       69 
74 
     | 
    
         | 
| 
       70 
75 
     | 
    
         
             
              describe ".method_missing" do
         
     | 
| 
         @@ -79,5 +84,13 @@ describe Global do 
     | 
|
| 
       79 
84 
     | 
    
         | 
| 
       80 
85 
     | 
    
         
             
                  it{ lambda{ subject }.should raise_error(NoMethodError) }
         
     | 
| 
       81 
86 
     | 
    
         
             
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                context "when file with nested hash" do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  subject{ described_class.nested_config }
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  it{ should be_kind_of(Global::Configuration) }
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
       82 
94 
     | 
    
         
             
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
       83 
96 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: global
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
     | 
    
         
            -
            -  
     | 
| 
      
 7 
     | 
    
         
            +
            - Railsware LLC
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013-07 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-12-07 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rspec
         
     | 
| 
         @@ -67,7 +67,7 @@ dependencies: 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       69 
69 
     | 
    
         
             
            description: Simple way to load your configs from yaml
         
     | 
| 
       70 
     | 
    
         
            -
            email:  
     | 
| 
      
 70 
     | 
    
         
            +
            email: contact@railsware.com
         
     | 
| 
       71 
71 
     | 
    
         
             
            executables: []
         
     | 
| 
       72 
72 
     | 
    
         
             
            extensions: []
         
     | 
| 
       73 
73 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
         @@ -85,6 +85,8 @@ files: 
     | 
|
| 
       85 
85 
     | 
    
         
             
            - lib/global/base.rb
         
     | 
| 
       86 
86 
     | 
    
         
             
            - lib/global/configuration.rb
         
     | 
| 
       87 
87 
     | 
    
         
             
            - lib/global/version.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            - spec/files/bool_config.yml
         
     | 
| 
      
 89 
     | 
    
         
            +
            - spec/files/nested_config.yml
         
     | 
| 
       88 
90 
     | 
    
         
             
            - spec/files/rspec/config.yml
         
     | 
| 
       89 
91 
     | 
    
         
             
            - spec/files/rspec_config.yml
         
     | 
| 
       90 
92 
     | 
    
         
             
            - spec/global/configuration_spec.rb
         
     | 
| 
         @@ -110,11 +112,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       110 
112 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       111 
113 
     | 
    
         
             
            requirements: []
         
     | 
| 
       112 
114 
     | 
    
         
             
            rubyforge_project: global
         
     | 
| 
       113 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 115 
     | 
    
         
            +
            rubygems_version: 2.1.11
         
     | 
| 
       114 
116 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       115 
117 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       116 
118 
     | 
    
         
             
            summary: Simple way to load your configs from yaml
         
     | 
| 
       117 
119 
     | 
    
         
             
            test_files:
         
     | 
| 
      
 120 
     | 
    
         
            +
            - spec/files/bool_config.yml
         
     | 
| 
      
 121 
     | 
    
         
            +
            - spec/files/nested_config.yml
         
     | 
| 
       118 
122 
     | 
    
         
             
            - spec/files/rspec/config.yml
         
     | 
| 
       119 
123 
     | 
    
         
             
            - spec/files/rspec_config.yml
         
     | 
| 
       120 
124 
     | 
    
         
             
            - spec/global/configuration_spec.rb
         
     |