sb-config 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +6 -2
- data/bin/config +2 -12
- data/config.gemspec +2 -0
- data/lib/config.rb +26 -0
- data/lib/config/version.rb +1 -1
- metadata +29 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 777e42fd6adb45e6c539485b8c81e8b5f3b12d15c61abd2555b4bb977468c88e
|
4
|
+
data.tar.gz: 04c66358c5aed1f2b67acab86f8f82c1fb79311e1b82f68f7d41aa016948524e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b7748b98b6dce7d3cb58ec744e5483361826c7804e1fc26d191ae82b0c7e6ce51c141a4e37f016988acfcd8d6333bc1830d476729b7098b2ec00aeb6636b71
|
7
|
+
data.tar.gz: 7e2d425e3dd4e92dd5f82b0af4c8e4232ec4315b624406322b1f2078c7cc6648f4023779bcfee50c0b28d60c64604c3f5e71f759c0aa95b83a58a9a1d0021abf
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
config (0.1.0)
|
4
|
+
sb-config (0.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
json (2.3.0)
|
9
10
|
rake (10.5.0)
|
11
|
+
yaml (0.1.0)
|
10
12
|
|
11
13
|
PLATFORMS
|
12
14
|
ruby
|
13
15
|
|
14
16
|
DEPENDENCIES
|
15
17
|
bundler (~> 2.0)
|
16
|
-
|
18
|
+
json
|
17
19
|
rake (~> 10.0)
|
20
|
+
sb-config!
|
21
|
+
yaml
|
18
22
|
|
19
23
|
BUNDLED WITH
|
20
24
|
2.0.2
|
data/bin/config
CHANGED
@@ -3,15 +3,5 @@
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "config"
|
5
5
|
|
6
|
-
Config.
|
7
|
-
|
8
|
-
'two' => 2,
|
9
|
-
'three' => {
|
10
|
-
'n' => 3
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
puts Config.store
|
15
|
-
puts Config['one']
|
16
|
-
puts Config.store
|
17
|
-
puts Config['three']['n']
|
6
|
+
Config.load './test/c.yaml'
|
7
|
+
puts Config.store
|
data/config.gemspec
CHANGED
data/lib/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'json'
|
1
3
|
require "config/version"
|
2
4
|
|
3
5
|
module Config
|
@@ -9,6 +11,19 @@ module Config
|
|
9
11
|
|
10
12
|
@@store = {}
|
11
13
|
|
14
|
+
def self.load path, type=nil
|
15
|
+
# infer type if nil
|
16
|
+
|
17
|
+
fmt = path.split('.').last
|
18
|
+
fmt ||= type
|
19
|
+
|
20
|
+
if fmt.nil?
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
|
24
|
+
@@store = send("load_#{fmt}", path)
|
25
|
+
end
|
26
|
+
|
12
27
|
def self.store=(v)
|
13
28
|
@@store = v if v.is_a? Hash
|
14
29
|
end
|
@@ -20,4 +35,15 @@ module Config
|
|
20
35
|
def self.[](k)
|
21
36
|
@@store[k]
|
22
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def self.load_yaml path
|
41
|
+
YAML.load_file path
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.load_json path
|
45
|
+
c = File.read path
|
46
|
+
puts c
|
47
|
+
JSON.parse c
|
48
|
+
end
|
23
49
|
end
|
data/lib/config/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sb-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iodevel
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.3.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.3.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yaml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.3
|
41
69
|
description:
|
42
70
|
email:
|
43
71
|
- cbrandt92@gmail.com
|