dead_simple_conf 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a87ddd9d150a950b3cb917f3abe5d0b1046c65b
4
+ data.tar.gz: 27c699aff7fd23de51c9556155c31a1d79504dc9
5
+ SHA512:
6
+ metadata.gz: 670b596e32aa97aa583d377ff1e18f768790aff4d6b69c9ab8d362757ec9f92db4bceb2afd2bdeb9b15face728b12603fcd92bfe3c545dfd8292ca433e85c6a2
7
+ data.tar.gz: 43f910a966769f8b0530fdd9e7d7525721f3be2435eec93aefe672b1d80002602daa9e8a594a9185f2c8be96a008317cae0e57a5de0ee24e465e52e43ead1209
data/README.md CHANGED
@@ -6,6 +6,13 @@ too complicated.
6
6
  I decided to extract this code in a proper gem when I got tired of copying it over
7
7
  and over in my projects.
8
8
 
9
+ # Continuous integration ([![Build Status](https://secure.travis-ci.org/schmurfy/dead_simple_conf.png)](http://travis-ci.org/schmurfy/dead_simple_conf))
10
+
11
+ This gem is tested against these ruby by travis-ci.org:
12
+
13
+ - mri 1.9.2
14
+ - mri 1.8.7
15
+
9
16
  # What this gem provides
10
17
 
11
18
  My requirements for a config parser are:
data/Rakefile CHANGED
@@ -1,8 +1,14 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ task :default => :test
4
+
3
5
  task :test do
4
6
  require 'bacon'
5
- ENV['COVERAGE'] = "1"
7
+
8
+ # do not generate coverage report from travis
9
+ unless ENV['TRAVIS']
10
+ ENV['COVERAGE'] = "1"
11
+ end
6
12
 
7
13
  # Bacon.summary_on_exit
8
14
 
@@ -17,10 +17,10 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- specs/*`.split("\n")
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_development_dependency 'schmurfy-bacon', '~> 1.2'
21
- s.add_development_dependency 'guard-bacon', '~> 1.0.2'
20
+ s.add_development_dependency 'schmurfy-bacon', '> 1.2'
21
+ s.add_development_dependency 'guard-bacon', '> 1.0.2'
22
22
  s.add_development_dependency "growl", '~> 1.0.3'
23
- s.add_development_dependency "rb-fsevent", '~> 0.4.3'
23
+ s.add_development_dependency "rb-fsevent", '> 0.4.3'
24
24
  s.add_development_dependency "mocha", '~> 0.10.0'
25
25
  s.add_development_dependency "simplecov", '~> 0.5.3'
26
26
  s.add_development_dependency "rake", '~> 0.9.2'
@@ -12,6 +12,15 @@ module DeadSimpleConf
12
12
  end
13
13
  end
14
14
 
15
+ def self.sub_array(name, klass)
16
+ attr_reader(name)
17
+
18
+ define_method("#{name}=") do |arr|
19
+ res = arr.map{|itm| klass.new(itm) }
20
+ instance_variable_set("@#{name}", res)
21
+ end
22
+ end
23
+
15
24
  def initialize(attributes)
16
25
  _load_data(attributes)
17
26
  end
@@ -1,3 +1,3 @@
1
1
  module DeadSimpleConf
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -44,6 +44,47 @@ describe 'DeadSimpleConf' do
44
44
  end
45
45
  end
46
46
 
47
+ describe 'array subsections' do
48
+ before do
49
+ @conf_data = YAML.load(%{
50
+ login: user_login
51
+ path: /tmp
52
+
53
+ servers:
54
+ - address: 127.0.0.1
55
+ port: 5000
56
+ - address: 1.2.3.4
57
+ port: 42
58
+ })
59
+ end
60
+
61
+ should 'parse it with correct loader' do
62
+ class ServersSectionBlock < DeadSimpleConf::ConfigBlock
63
+ attr_accessor :address, :port
64
+ end
65
+
66
+ main_block = Class.new(DeadSimpleConf::ConfigBlock) do
67
+ attr_accessor :login, :path
68
+ sub_array :servers, ServersSectionBlock
69
+ end
70
+
71
+ data = main_block.new(@conf_data)
72
+ data.login.should == "user_login"
73
+ data.path.should == "/tmp"
74
+
75
+ data.servers.size.should == 2
76
+ data.servers[0].tap do |s|
77
+ s.address.should == '127.0.0.1'
78
+ s.port.should == 5000
79
+ end
80
+
81
+ data.servers[1].tap do |s|
82
+ s.address.should == '1.2.3.4'
83
+ s.port.should == 42
84
+ end
85
+ end
86
+ end
87
+
47
88
  describe 'multi level config' do
48
89
  before do
49
90
  @conf_data = YAML.load(%{
metadata CHANGED
@@ -1,101 +1,121 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_simple_conf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Julien Ammous
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-10-08 00:00:00.000000000Z
11
+ date: 2017-08-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: schmurfy-bacon
16
- requirement: &70347746200320 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - ">"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.2'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *70347746200320
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: guard-bacon
27
- requirement: &70347746199760 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - ">"
31
32
  - !ruby/object:Gem::Version
32
33
  version: 1.0.2
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *70347746199760
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.2
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: growl
38
- requirement: &70347746198860 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ~>
45
+ - - "~>"
42
46
  - !ruby/object:Gem::Version
43
47
  version: 1.0.3
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70347746198860
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.3
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rb-fsevent
49
- requirement: &70347746197820 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ~>
59
+ - - ">"
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.4.3
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *70347746197820
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.3
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: mocha
60
- requirement: &70347746196760 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ~>
73
+ - - "~>"
64
74
  - !ruby/object:Gem::Version
65
75
  version: 0.10.0
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *70347746196760
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: simplecov
71
- requirement: &70347746195140 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
- - - ~>
87
+ - - "~>"
75
88
  - !ruby/object:Gem::Version
76
89
  version: 0.5.3
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *70347746195140
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.3
80
97
  - !ruby/object:Gem::Dependency
81
98
  name: rake
82
- requirement: &70347746194040 !ruby/object:Gem::Requirement
83
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
84
100
  requirements:
85
- - - ~>
101
+ - - "~>"
86
102
  - !ruby/object:Gem::Version
87
103
  version: 0.9.2
88
104
  type: :development
89
105
  prerelease: false
90
- version_requirements: *70347746194040
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.2
91
111
  description: YAML Config loader
92
112
  email: []
93
113
  executables: []
94
114
  extensions: []
95
115
  extra_rdoc_files: []
96
116
  files:
97
- - .gitignore
98
- - .travis.yml
117
+ - ".gitignore"
118
+ - ".travis.yml"
99
119
  - Gemfile
100
120
  - Guardfile
101
121
  - LICENSE
@@ -110,27 +130,26 @@ files:
110
130
  - specs/lib/dead_simple_conf_spec.rb
111
131
  homepage: ''
112
132
  licenses: []
133
+ metadata: {}
113
134
  post_install_message:
114
135
  rdoc_options: []
115
136
  require_paths:
116
137
  - lib
117
138
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
139
  requirements:
120
- - - ! '>='
140
+ - - ">="
121
141
  - !ruby/object:Gem::Version
122
142
  version: '0'
123
143
  required_rubygems_version: !ruby/object:Gem::Requirement
124
- none: false
125
144
  requirements:
126
- - - ! '>='
145
+ - - ">="
127
146
  - !ruby/object:Gem::Version
128
147
  version: '0'
129
148
  requirements: []
130
149
  rubyforge_project: dead_simple_conf
131
- rubygems_version: 1.8.11
150
+ rubygems_version: 2.5.1
132
151
  signing_key:
133
- specification_version: 3
152
+ specification_version: 4
134
153
  summary: Config loader
135
154
  test_files:
136
155
  - specs/common.rb