config_context 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,8 +12,7 @@ module ConfigContext
12
12
 
13
13
  if( method.to_s =~ /(.+)=$/ )
14
14
 
15
- config_key = method.to_s.delete( '=' ).to_sym
16
- @config[config_key] = (arguments.length == 1) ? arguments[0] : arguments
15
+ @config[method.to_s.delete( '=' ).to_sym] = (arguments.length == 1) ? arguments[0] : arguments
17
16
  elsif( method.to_s =~ /(.+)\?$/ )
18
17
 
19
18
  @config.has_key?( method.to_s.delete( '?' ).to_sym )
@@ -23,25 +22,39 @@ module ConfigContext
23
22
  end
24
23
  end
25
24
 
26
- def configure; yield self; end
27
-
28
- def []( key ) return @config[key]; end
29
-
30
- def[]=( key, value ) @config[key] = value; end
31
-
32
- def all; @config; end
33
-
34
- def keys; @config.keys; end
35
-
36
-
37
25
  def load( config_file, options = { :allow_collisions => true } )
38
26
 
39
27
  if( options[:allow_collisions] )
40
28
  @config.merge!( YAML.load_file( config_file ) )
41
29
  else
42
- @config.merge!( YAML.load_file( config_file ) ) { |key, original_value, new_value| original_value }
30
+ @config.merge!( YAML.load_file( config_file ) ) { |k, ov, nv| ov }
43
31
  end
44
32
  rescue Exception => e
45
33
  raise ConfigContext::Error.new( e.message )
46
34
  end
35
+
36
+ def configure()
37
+
38
+ yield self
39
+ end
40
+
41
+ def []( key )
42
+
43
+ @config[key]
44
+ end
45
+
46
+ def []=( key, value )
47
+
48
+ @config[key] = value
49
+ end
50
+
51
+ def all()
52
+
53
+ @config
54
+ end
55
+
56
+ def keys
57
+
58
+ @config.keys
59
+ end
47
60
  end
@@ -1,12 +1,11 @@
1
- module ConfigContext
2
- module Version
3
- INFO = {
4
- :major =>0,
5
- :minor =>3,
6
- :patch =>1
7
- }
1
+ module Version
2
+ INFO = {
3
+ :major =>0,
4
+ :minor =>3,
5
+ :patch =>3
6
+ }
8
7
 
9
- NAME = 'config_context'
10
- VERSION = INFO.values.join( '.' )
11
- end
12
- end
8
+ NAME = 'config_context'
9
+ VERSION = [INFO[:major], INFO[:minor], INFO[:patch]].join( '.' )
10
+ end
11
+
@@ -66,7 +66,10 @@ class TestConfigContext < Test::Unit::TestCase
66
66
 
67
67
  should "retrieve all property keys" do
68
68
 
69
- assert_equal( ConfigContext.keys, [ :mysymbol, :mylist, :myhash, :othersymbol, 'string' ] )
69
+ [ :mysymbol, :mylist, :myhash, 'string', :othersymbol ].each do |key|
70
+
71
+ assert( ConfigContext.keys.include?( key ) )
72
+ end
70
73
  end
71
74
 
72
75
  should "load a Yaml file without keys collisions" do
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_context
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
5
+ version: 0.3.3
11
6
  platform: ruby
12
7
  authors:
13
8
  - Javier Juarez
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-03-28 00:00:00 +02:00
19
- default_executable:
13
+ date: 2011-04-27 00:00:00 Z
20
14
  dependencies: []
21
15
 
22
16
  description: My config DSL
@@ -30,9 +24,8 @@ extra_rdoc_files:
30
24
  files:
31
25
  - lib/config_context.rb
32
26
  - lib/version.rb
33
- - test/unit/tc_config_context.rb
27
+ - test/unit/test_config_context.rb
34
28
  - README.rdoc
35
- has_rdoc: true
36
29
  homepage: http://github.com/jjuarez/config_context
37
30
  licenses:
38
31
  - MIT
@@ -46,25 +39,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
39
  requirements:
47
40
  - - ">="
48
41
  - !ruby/object:Gem::Version
49
- hash: 3
50
- segments:
51
- - 0
52
42
  version: "0"
53
43
  required_rubygems_version: !ruby/object:Gem::Requirement
54
44
  none: false
55
45
  requirements:
56
46
  - - ">="
57
47
  - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
48
  version: "0"
62
49
  requirements: []
63
50
 
64
51
  rubyforge_project: http://github.com/jjuarez/config_context
65
- rubygems_version: 1.6.2
52
+ rubygems_version: 1.7.2
66
53
  signing_key:
67
54
  specification_version: 3
68
55
  summary: A Config Context for little applications
69
56
  test_files:
70
- - test/unit/tc_config_context.rb
57
+ - test/unit/test_config_context.rb