config-me 0.0.7 → 0.0.8

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 611505843fc8c52a8798938c099ee38bb22bfa12
4
+ data.tar.gz: 194e761d6607ff82d62ab56bd6c6670fcb85106f
5
+ SHA512:
6
+ metadata.gz: fe74fd92762087e1c321d3f0b4402b7703cd16eec95b546411de714f7b2fcca2420876c87dd4e25aaa243f5275c40687e6e05f7e1335b4646a6938e87243d9a8
7
+ data.tar.gz: f940f02df499c5b1e7c05f0a02678bb9c19a6a59f09921dd66abcf05238ce6230c7867f5e31830379ed79edf0799ede8d6d898f9b392141aa702aa6a0a856c7a
@@ -0,0 +1,39 @@
1
+ Feature: if setting value is proc then it should be called automatically when it is asks
2
+
3
+ Scenario: define configuration
4
+ assign proc to one of the setting
5
+ then ask this setting and make sure that proc is called automatically
6
+ Given an empty configuration
7
+ When I define configuration below:
8
+ """
9
+ ConfigMe do
10
+ foo proc { 'bar' }
11
+ end
12
+ """
13
+ Then setting "ConfigMe.foo" should be equal to "bar"
14
+
15
+ Scenario: define configuration
16
+ assign proc to one of the setting
17
+ then ask this setting with params and make sure that proc is called with params automatically
18
+ Given an empty configuration
19
+ When I define configuration below:
20
+ """
21
+ ConfigMe do
22
+ foo proc { |first, second| (first - second).times.map{ 'bar' }.join('-') }
23
+ end
24
+ """
25
+ Then setting "ConfigMe.foo(5, 3)" should be equal to "bar-bar"
26
+
27
+ Scenario: define configuration
28
+ disable procs autocalling
29
+ assign proc to one of the setting
30
+ then ask this setting and make sure that proc is not called automatically
31
+ Given an empty configuration
32
+ And disabled proc auto calling
33
+ When I define configuration below:
34
+ """
35
+ ConfigMe do
36
+ foo proc { 'bar' }
37
+ end
38
+ """
39
+ Then setting "ConfigMe.foo" should be a kind of "Proc"
@@ -0,0 +1,66 @@
1
+ Feature: defining configuration using blocks
2
+
3
+ Scenario: set 1st level setting
4
+ Given an empty configuration
5
+ When I define configuration below:
6
+ """
7
+ ConfigMe do
8
+ foo 'bar'
9
+ end
10
+ """
11
+ Then setting "ConfigMe.foo" should be equal to "bar"
12
+
13
+ Scenario: set 2nd level setting
14
+ Given an empty configuration
15
+ When I define configuration below:
16
+ """
17
+ ConfigMe do
18
+ foo do
19
+ bar 'foo'
20
+ end
21
+ end
22
+ """
23
+ Then setting "ConfigMe.foo.bar" should be equal to "foo"
24
+
25
+ Scenario: set 3rd level setting
26
+ Given an empty configuration
27
+ When I define configuration below:
28
+ """
29
+ ConfigMe do
30
+ foo do
31
+ bar do
32
+ sample 'bar'
33
+ end
34
+ end
35
+ end
36
+ """
37
+ Then setting "ConfigMe.foo.bar.sample" should be equal to "bar"
38
+
39
+ Scenario Outline: set different types of values and make sure that they are not change
40
+ Given an empty configuration
41
+ When I define configuration below:
42
+ """
43
+ ConfigMe do
44
+ foo <value>
45
+ end
46
+ """
47
+ Then setting "ConfigMe.foo" should be of type "<type>"
48
+
49
+ Examples:
50
+ | value | type |
51
+ | 'foo' | String |
52
+ | 100500 | Fixnum |
53
+ | 4.3 | Float |
54
+ | true | TrueClass |
55
+ | proc { 'foo' } | Proc |
56
+ | Time.now | Time |
57
+ | Date.today | Date |
58
+
59
+ Scenario: try to get setting before defining any configuration
60
+ Given an empty configuration
61
+ And I ask for an "ConfigMe.foo" setting
62
+ Then It should raise error "ConfigMe::ConfigurationNotDefined" with message:
63
+ """
64
+ Configuration :production not defined
65
+ """
66
+
@@ -0,0 +1,60 @@
1
+ Feature: defining configuration in different namespaces
2
+
3
+ Scenario: define configuration in namespace and check that it accessible through namespace name
4
+ Given an empty configuration
5
+ When I define configuration below:
6
+ """
7
+ ConfigMe :development do
8
+ foo 'bar'
9
+ end
10
+ """
11
+ Then setting "ConfigMe(:development).foo" should be equal to "bar"
12
+
13
+ Scenario: define configuration without namespace and check that it accessible through default namespace
14
+ Given an empty configuration
15
+ When I define configuration below:
16
+ """
17
+ ConfigMe do
18
+ foo 'bar'
19
+ end
20
+ """
21
+ Then setting "ConfigMe(:production).foo" should be equal to "bar"
22
+
23
+ Scenario: try to get setting from not existing configuration and make sure that proper error raise
24
+ Given an empty configuration
25
+ When I define configuration below:
26
+ """
27
+ ConfigMe do
28
+ foo 'bar'
29
+ end
30
+ """
31
+ And I ask for an "ConfigMe(:test).foo.bar.good" setting
32
+ Then It should raise error "ConfigMe::ConfigurationNotDefined" with message:
33
+ """
34
+ Configuration :test not defined
35
+ """
36
+
37
+ Scenario: define configuration in several scopes
38
+ Given an empty configuration
39
+ When I define configuration below:
40
+ """
41
+ ConfigMe do
42
+ foo 'test'
43
+ end
44
+ """
45
+ When I define configuration below:
46
+ """
47
+ ConfigMe :bar do
48
+ foo 'bar'
49
+ end
50
+ """
51
+ When I define configuration below:
52
+ """
53
+ ConfigMe :foo do
54
+ foo 'foo'
55
+ end
56
+ """
57
+ Then setting "ConfigMe.foo" should be equal to "test"
58
+ Then setting "ConfigMe(:foo).foo" should be equal to "foo"
59
+ And setting "ConfigMe(:bar).foo" should be equal to "bar"
60
+ And setting "ConfigMe.foo" should be equal to "test"
@@ -0,0 +1,47 @@
1
+ Feature: dump config data to hash
2
+
3
+ Scenario: define config and then dump node to hash
4
+ Given an empty configuration
5
+ When I define configuration below:
6
+ """
7
+ ConfigMe do
8
+ foo do
9
+ bar do
10
+ sample 'test'
11
+ end
12
+ end
13
+ end
14
+ """
15
+ And I dump config node "ConfigMe.foo" to hash
16
+ Then It should be a hash like:
17
+ """
18
+ {
19
+ :bar => {
20
+ :sample => 'test'
21
+ }
22
+ }
23
+ """
24
+
25
+ Scenario: define config and then dump all config to hash
26
+ Given an empty configuration
27
+ When I define configuration below:
28
+ """
29
+ ConfigMe do
30
+ foo do
31
+ bar do
32
+ sample 'test'
33
+ end
34
+ end
35
+ end
36
+ """
37
+ And I dump whole config to hash
38
+ Then It should be a hash like:
39
+ """
40
+ {
41
+ :foo => {
42
+ :bar => {
43
+ :sample => 'test'
44
+ }
45
+ }
46
+ }
47
+ """
@@ -0,0 +1,67 @@
1
+ Feature: raising error on undefined setting
2
+
3
+ Scenario Outline: try to get not defined setting and make sure that exception raise
4
+ Given an empty configuration
5
+ When I define configuration below:
6
+ """
7
+ ConfigMe do
8
+ foo 'bar'
9
+ end
10
+ """
11
+ And I ask for an "ConfigMe.<key>" setting
12
+ Then It should raise error "ConfigMe::UndefinedSetting" with message:
13
+ """
14
+ Undefined setting "ConfigMe.bar"
15
+ """
16
+
17
+ Examples:
18
+ | key |
19
+ | bar |
20
+ | bar.foo |
21
+ | bar.foo.bar |
22
+
23
+ Scenario: try to get not defined setting and make sure that breadcrumbs is correct
24
+ Given an empty configuration
25
+ When I define configuration below:
26
+ """
27
+ ConfigMe do
28
+ foo do
29
+ bar do
30
+ sample 'test'
31
+ end
32
+ end
33
+ end
34
+ """
35
+ And I ask for an "ConfigMe.foo.bar.good" setting
36
+ Then It should raise error "ConfigMe::UndefinedSetting" with message:
37
+ """
38
+ Undefined setting "ConfigMe.foo.bar.good"
39
+ """
40
+
41
+
42
+ Scenario: there are several configuration exists,
43
+ try to get not defined setting and make sure that breadcrumbs is correct
44
+ Given an empty configuration
45
+ When I define configuration below:
46
+ """
47
+ ConfigMe do
48
+ foo 'test' do
49
+ bar 'good'
50
+ end
51
+
52
+ cool 'test'
53
+ end
54
+
55
+ ConfigMe :test do
56
+ foo 'test' do
57
+ bar 'good'
58
+ end
59
+ end
60
+ """
61
+ Then setting "ConfigMe.cool" should be equal to "test"
62
+ And I ask for an "ConfigMe(:test).cool.bar" setting
63
+ Then It should raise error "ConfigMe::UndefinedSetting" with message:
64
+ """
65
+ Undefined setting "ConfigMe.cool"
66
+ """
67
+
@@ -0,0 +1,21 @@
1
+ Feature: import configuration from hash
2
+
3
+ Background:
4
+ Given an configuration hash:
5
+ """
6
+ @hash = { :foo => { :bar => 'test' }, :sample => '42' }
7
+ """
8
+
9
+ Scenario: import configuration from hash
10
+ When I read configuration from this hash:
11
+ """
12
+ ConfigMe(:hash => @hash)
13
+ """
14
+ Then setting "ConfigMe.sample" should be equal to "42"
15
+ And setting "ConfigMe.foo.bar" should be equal to "test"
16
+
17
+ When I ask for an "ConfigMe.foo.good" setting
18
+ Then It should raise error "ConfigMe::UndefinedSetting" with message:
19
+ """
20
+ Undefined setting "ConfigMe.foo.good"
21
+ """
@@ -0,0 +1,18 @@
1
+ Feature: import configuration from yaml
2
+ Background:
3
+ Given an yaml file with configuration below:
4
+ """
5
+ ---
6
+ development:
7
+ adapter: postgresql
8
+ user: postgres
9
+ """
10
+ And an empty configuration
11
+
12
+ Scenario: import configuration from yaml file
13
+ When I read configuration from this yaml file:
14
+ """
15
+ ConfigMe(:yaml => @yaml)
16
+ """
17
+ Then setting "ConfigMe.development.adapter" should be equal to "postgresql"
18
+ And setting "ConfigMe.development.user" should be equal to "postgres"
@@ -0,0 +1,45 @@
1
+ Feature: possibility to rewrite existing setting
2
+
3
+ Scenario: define config and then rewrite existing setting
4
+ Given an empty configuration
5
+ When I define configuration below:
6
+ """
7
+ ConfigMe do
8
+ foo 'bar'
9
+ end
10
+ """
11
+ And I rewrite setting with using code below:
12
+ """
13
+ ConfigMe.foo = 'foo'
14
+ """
15
+ Then setting "ConfigMe.foo" should be equal to "foo"
16
+
17
+ Scenario: define config and try add new setting to existing node
18
+ Given an empty configuration
19
+ When I define configuration below:
20
+ """
21
+ ConfigMe do
22
+ foo 'bar'
23
+ end
24
+ """
25
+ And I rewrite setting with using code below:
26
+ """
27
+ ConfigMe.bar = 'foo'
28
+ """
29
+ Then setting "ConfigMe.bar" should be equal to "foo"
30
+
31
+ Scenario: define config and try rewrite whole node
32
+ Given an empty configuration
33
+ When I define configuration below:
34
+ """
35
+ ConfigMe do
36
+ foo 'bar'
37
+ end
38
+ """
39
+ And I rewrite setting with using code below:
40
+ """
41
+ ConfigMe.foo do
42
+ bar 'foo'
43
+ end
44
+ """
45
+ Then setting "ConfigMe.foo.bar" should be equal to "foo"
@@ -0,0 +1,81 @@
1
+ Given /^an empty configuration$/ do
2
+ ConfigMe::Base.clear!
3
+ end
4
+
5
+ When /^I define configuration below:$/ do |code_string|
6
+ eval code_string
7
+ end
8
+
9
+ Then /^setting "([^"]*)" should be equal to "([^"]*)"$/ do |code_string, value|
10
+ eval(code_string).should == value
11
+ end
12
+
13
+ Then /^setting "([^"]*)" should be of type "([^"]*)"$/ do |code_string, klass|
14
+ eval(code_string).class.name.should == klass
15
+ end
16
+
17
+ When /^I ask for an "([^"]*)" setting$/ do |code_string|
18
+ begin
19
+ @setting = eval(code_string)
20
+ rescue Exception => e
21
+ @error = e
22
+ end
23
+ end
24
+
25
+ Then /^It should raise error "([^"]*)"$/ do |klass|
26
+ @error.class.name.should == klass
27
+ end
28
+
29
+ Then /^It should raise error "([^"]*)" with message:$/ do |klass, message|
30
+ step %(It should raise error "#{klass}")
31
+ @error.message.should =~ %r(#{message})
32
+ end
33
+
34
+ When /^I rewrite setting with using code below:$/ do |code_string|
35
+ eval code_string
36
+ end
37
+
38
+ When /^I dump config node "([^"]*)" to hash$/ do |code_string|
39
+ @hash = eval(code_string).to_hash
40
+ end
41
+
42
+ Then /^It should be a hash like:$/ do |string_with_hash|
43
+ @hash.should == eval(string_with_hash)
44
+ end
45
+
46
+ When /^I dump whole config to hash$/ do
47
+ @hash = ConfigMe.to_hash
48
+ end
49
+
50
+ Given /^an yaml file with configuration below:$/ do |string|
51
+ require 'tempfile'
52
+ @yaml_file = Tempfile.new('yaml')
53
+ @yaml_file.write string
54
+ @yaml_file.close
55
+
56
+ @yaml = @yaml_file.path
57
+ end
58
+
59
+ When /^I read configuration from this yaml file:$/ do |string|
60
+ eval string
61
+ end
62
+
63
+ When /^I read configuration from this yaml string:$/ do |string|
64
+ eval string
65
+ end
66
+
67
+ Given /^an configuration hash:$/ do |string|
68
+ eval string
69
+ end
70
+
71
+ When /^I read configuration from this hash:$/ do |string|
72
+ eval string
73
+ end
74
+
75
+ Then /^setting "([^"]*)" should be a kind of "([^"]*)"$/ do |string, klass|
76
+ eval(string).class.name.should == klass
77
+ end
78
+
79
+ Given /^disabled proc auto calling$/ do
80
+ ConfigMe::Defaults.proc_auto_calling = false
81
+ end
@@ -0,0 +1,9 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'config-me'
5
+ require 'rspec/matchers'
6
+
7
+ After do
8
+ ConfigMe::Base.clear!
9
+ end
@@ -1,16 +1,16 @@
1
+ require 'yaml'
1
2
  require 'active_support/dependencies/autoload'
2
3
  require 'active_support/core_ext/class/attribute_accessors'
3
4
 
4
5
  module ConfigMe
6
+ extend ActiveSupport::Autoload
7
+
5
8
  autoload :Base, 'config-me/base'
6
9
  autoload :Defaults, 'config-me/defaults'
7
10
  autoload :DefinitionsParser, 'config-me/definitions_parser'
8
11
  autoload :Importer, 'config-me/importer'
9
12
  autoload :Node, 'config-me/node'
10
13
  autoload :Runner, 'config-me/runner'
11
- autoload :VERSION, 'config-me/version'
12
-
13
- # Errors
14
14
  autoload :UnrecognizedError, 'config-me/errors'
15
15
  autoload :UndefinedSetting, 'config-me/errors'
16
16
  autoload :ConfigurationNotDefined, 'config-me/errors'
@@ -21,7 +21,6 @@ module ConfigMe
21
21
  def self.method_missing method, *args, &block
22
22
  ConfigMe::Base.delegate_to_current_configuration method, *args, &block
23
23
  end
24
-
25
24
  end
26
25
 
27
26
  def ConfigMe namespace_or_options = ConfigMe::Defaults.namespace, &definitions
metadata CHANGED
@@ -1,64 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ivan Garmatenko
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-30 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: cucumber
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
- - - ~>
31
+ - - '>='
20
32
  - !ruby/object:Gem::Version
21
- version: '1.1'
33
+ version: 1.3.8
22
34
  type: :development
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
- - - ~>
38
+ - - '>='
28
39
  - !ruby/object:Gem::Version
29
- version: '1.1'
40
+ version: 1.3.8
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rspec
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ~>
45
+ - - '>='
36
46
  - !ruby/object:Gem::Version
37
- version: '2.9'
47
+ version: '2.14'
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ~>
52
+ - - '>='
44
53
  - !ruby/object:Gem::Version
45
- version: '2.9'
54
+ version: '2.14'
46
55
  - !ruby/object:Gem::Dependency
47
- name: activesupport
56
+ name: coveralls
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ~>
59
+ - - '>='
52
60
  - !ruby/object:Gem::Version
53
- version: '3.0'
54
- type: :runtime
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
55
77
  prerelease: false
56
78
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
79
  requirements:
59
- - - ~>
80
+ - - '>='
60
81
  - !ruby/object:Gem::Version
61
- version: '3.0'
82
+ version: '0'
62
83
  description: Provides convenient tool for storing configuration
63
84
  email:
64
85
  - cheef.che@gmail.com
@@ -66,37 +87,55 @@ executables: []
66
87
  extensions: []
67
88
  extra_rdoc_files: []
68
89
  files:
69
- - lib/config-me/version.rb
70
- - lib/config-me/importer.rb
71
- - lib/config-me/errors.rb
72
- - lib/config-me/definitions_parser.rb
73
- - lib/config-me/defaults.rb
74
90
  - lib/config-me/base.rb
91
+ - lib/config-me/defaults.rb
92
+ - lib/config-me/definitions_parser.rb
93
+ - lib/config-me/errors.rb
94
+ - lib/config-me/importer.rb
75
95
  - lib/config-me/node.rb
76
96
  - lib/config-me/runner.rb
77
97
  - lib/config-me.rb
98
+ - features/autocalling_procs.feature
99
+ - features/define_with_blocks.feature
100
+ - features/defining_in_namespaces.feature
101
+ - features/dump_to_hash.feature
102
+ - features/handling_missed_keys.feature
103
+ - features/import_from_hash.feature
104
+ - features/import_from_yaml.feature
105
+ - features/rewrite_setting.feature
106
+ - features/step_definitions/config_me_steps.rb
107
+ - features/support.rb/env.rb
78
108
  homepage: http://github.com/cheef/config-me
79
109
  licenses: []
110
+ metadata: {}
80
111
  post_install_message:
81
112
  rdoc_options: []
82
113
  require_paths:
83
114
  - lib
84
115
  required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
116
  requirements:
87
- - - ! '>='
117
+ - - '>='
88
118
  - !ruby/object:Gem::Version
89
119
  version: '0'
90
120
  required_rubygems_version: !ruby/object:Gem::Requirement
91
- none: false
92
121
  requirements:
93
- - - ! '>='
122
+ - - '>='
94
123
  - !ruby/object:Gem::Version
95
124
  version: '0'
96
125
  requirements: []
97
- rubyforge_project: config-me
98
- rubygems_version: 1.8.24
126
+ rubyforge_project:
127
+ rubygems_version: 2.0.6
99
128
  signing_key:
100
- specification_version: 3
129
+ specification_version: 4
101
130
  summary: Provides convenient tool for storing configuration
102
- test_files: []
131
+ test_files:
132
+ - features/autocalling_procs.feature
133
+ - features/define_with_blocks.feature
134
+ - features/defining_in_namespaces.feature
135
+ - features/dump_to_hash.feature
136
+ - features/handling_missed_keys.feature
137
+ - features/import_from_hash.feature
138
+ - features/import_from_yaml.feature
139
+ - features/rewrite_setting.feature
140
+ - features/step_definitions/config_me_steps.rb
141
+ - features/support.rb/env.rb
@@ -1,3 +0,0 @@
1
- module ConfigMe
2
- VERSION = "0.0.7"
3
- end