yamlig 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +60 -0
- data/LICENSE.md +22 -0
- data/lib/yamlig.rb +4 -0
- data/lib/yamlig/config.rb +37 -0
- data/spec/lib/yamlig/config_spec.rb +31 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/test_config.yml +2 -0
- data/yamlig.gemspec +21 -0
- metadata +155 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
yamlig (0.0.1)
|
5
|
+
id
|
6
|
+
optional
|
7
|
+
yajl-ruby
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (4.0.0)
|
13
|
+
activesupport (= 4.0.0)
|
14
|
+
builder (~> 3.1.0)
|
15
|
+
activesupport (4.0.0)
|
16
|
+
i18n (~> 0.6, >= 0.6.4)
|
17
|
+
minitest (~> 4.2)
|
18
|
+
multi_json (~> 1.3)
|
19
|
+
thread_safe (~> 0.1)
|
20
|
+
tzinfo (~> 0.3.37)
|
21
|
+
atomic (1.1.10)
|
22
|
+
builder (3.1.4)
|
23
|
+
diff-lcs (1.2.4)
|
24
|
+
i18n (0.6.4)
|
25
|
+
id (0.0.11)
|
26
|
+
activemodel
|
27
|
+
activesupport
|
28
|
+
money
|
29
|
+
optional
|
30
|
+
minitest (4.7.5)
|
31
|
+
money (5.1.1)
|
32
|
+
i18n (~> 0.6.0)
|
33
|
+
multi_json (1.7.7)
|
34
|
+
optional (0.0.7)
|
35
|
+
rake (10.1.0)
|
36
|
+
rspec (2.13.0)
|
37
|
+
rspec-core (~> 2.13.0)
|
38
|
+
rspec-expectations (~> 2.13.0)
|
39
|
+
rspec-mocks (~> 2.13.0)
|
40
|
+
rspec-core (2.13.1)
|
41
|
+
rspec-expectations (2.13.0)
|
42
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
43
|
+
rspec-mocks (2.13.1)
|
44
|
+
simplecov (0.7.1)
|
45
|
+
multi_json (~> 1.0)
|
46
|
+
simplecov-html (~> 0.7.1)
|
47
|
+
simplecov-html (0.7.1)
|
48
|
+
thread_safe (0.1.0)
|
49
|
+
atomic
|
50
|
+
tzinfo (0.3.37)
|
51
|
+
yajl-ruby (1.1.0)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
rake
|
58
|
+
rspec
|
59
|
+
simplecov
|
60
|
+
yamlig!
|
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Russell Dunphy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/yamlig.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Yamlig
|
2
|
+
module Config
|
3
|
+
include Id::Model
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
Id::Model.included(base)
|
7
|
+
|
8
|
+
base.class_eval do
|
9
|
+
include Singleton
|
10
|
+
class << self
|
11
|
+
alias_method :property, :field
|
12
|
+
|
13
|
+
def method_missing(name, *args, &block)
|
14
|
+
instance.send name, *args, &block
|
15
|
+
end
|
16
|
+
|
17
|
+
def path filename, env=nil
|
18
|
+
@filename = filename
|
19
|
+
@env = Option[env].map(&:to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :filename, :env
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
end
|
27
|
+
|
28
|
+
def data
|
29
|
+
@data ||= self.class.env.match do |m|
|
30
|
+
m.some { |env| YAML.load_file(self.class.filename)[env] }
|
31
|
+
m.none { YAML.load_file(self.class.filename) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Fails
|
4
|
+
def self.env
|
5
|
+
:test
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class TestConfig
|
10
|
+
include Yamlig::Config
|
11
|
+
|
12
|
+
property :domain, default: 'localhost'
|
13
|
+
property :mongos
|
14
|
+
|
15
|
+
path 'spec/support/test_config.yml', Fails.env
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
module Yamlig
|
20
|
+
describe Config do
|
21
|
+
|
22
|
+
it 'allows default values' do
|
23
|
+
TestConfig.domain.should eq 'localhost'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'reads from the config file' do
|
27
|
+
TestConfig.mongos.should eq 3
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/yamlig.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'yamlig'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2013-07-05'
|
5
|
+
s.summary = "Simple wrapper around YAML config"
|
6
|
+
s.description = "Just an easy way to load config"
|
7
|
+
s.authors = ["Russell Dunphy"]
|
8
|
+
s.email = ['rssll@rsslldnphy.com']
|
9
|
+
s.files = `git ls-files`.split($\)
|
10
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.homepage = 'http://github.com/rsslldnphy/yamlig'
|
13
|
+
|
14
|
+
s.add_dependency "id"
|
15
|
+
s.add_dependency "optional"
|
16
|
+
s.add_dependency "yajl-ruby"
|
17
|
+
s.add_development_dependency "rake"
|
18
|
+
s.add_development_dependency "rspec"
|
19
|
+
s.add_development_dependency "simplecov"
|
20
|
+
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yamlig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Russell Dunphy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: id
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: optional
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yajl-ruby
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Just an easy way to load config
|
111
|
+
email:
|
112
|
+
- rssll@rsslldnphy.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- Gemfile
|
119
|
+
- Gemfile.lock
|
120
|
+
- LICENSE.md
|
121
|
+
- lib/yamlig.rb
|
122
|
+
- lib/yamlig/config.rb
|
123
|
+
- spec/lib/yamlig/config_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
- spec/support/test_config.yml
|
126
|
+
- yamlig.gemspec
|
127
|
+
homepage: http://github.com/rsslldnphy/yamlig
|
128
|
+
licenses: []
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 1.8.25
|
148
|
+
signing_key:
|
149
|
+
specification_version: 3
|
150
|
+
summary: Simple wrapper around YAML config
|
151
|
+
test_files:
|
152
|
+
- spec/lib/yamlig/config_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
- spec/support/test_config.yml
|
155
|
+
has_rdoc:
|