jewelbox 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jewelbox/config.rb +32 -1
- data/lib/jewelbox/version.rb +1 -1
- metadata +3 -9
data/lib/jewelbox/config.rb
CHANGED
@@ -42,16 +42,47 @@ module Jewelbox
|
|
42
42
|
|
43
43
|
# === Description
|
44
44
|
# Configuration object that represents ALL configuration items
|
45
|
-
# to be used by the current
|
45
|
+
# to be used by the current process.
|
46
46
|
#
|
47
47
|
class Config
|
48
48
|
|
49
49
|
# === Description
|
50
50
|
# Read the given YAML file, and add its content to Jewelbox.config.
|
51
|
+
# For example, if you had the following in the YAML file:
|
52
|
+
#
|
53
|
+
# ---
|
54
|
+
# section1:
|
55
|
+
# directive1: true
|
56
|
+
# directive2: false
|
57
|
+
# section2:
|
58
|
+
# directive1: "hello"
|
59
|
+
# directive2: "good-bye"
|
60
|
+
#
|
61
|
+
# The following config items are available:
|
62
|
+
#
|
63
|
+
# Jewelbox.config.section1.directive1 # => true
|
64
|
+
# Jewelbox.config.section1.directive2 # => true
|
65
|
+
# Jewelbox.config.section1.directive1 # => "hello"
|
66
|
+
# Jewelbox.config.section2.directive2 # => "there"
|
67
|
+
#
|
68
|
+
# === Parameters
|
69
|
+
# yml_path:: [String] absolute or relative path to the YAML file
|
51
70
|
#
|
52
71
|
def self.load(yml_path)
|
53
72
|
abs_path = File.expand_path(yml_path)
|
54
73
|
h = YAML::load(File.read(yml_path))
|
74
|
+
load_hash(h)
|
75
|
+
end
|
76
|
+
|
77
|
+
# === Description
|
78
|
+
# Load hash object into the global configuration space.
|
79
|
+
# See Config.load API, which has example hash object.
|
80
|
+
#
|
81
|
+
# === Parameters
|
82
|
+
# h:: [Hash] Hash object that contains 2-level configuration organization
|
83
|
+
# (section/directive) to load into Jewelbox.config space.
|
84
|
+
#
|
85
|
+
def self.load_hash(h)
|
55
86
|
h.each do |section, inner|
|
56
87
|
inner.each do |directive, v|
|
57
88
|
Jewelbox.config.add(section, directive, v)
|
data/lib/jewelbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jewelbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-debug19
|
16
|
-
requirement: &
|
16
|
+
requirement: &19426280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19426280
|
25
25
|
description: A set of useful Ruby functions to be used when creating a new service
|
26
26
|
or rails application
|
27
27
|
email:
|
@@ -58,18 +58,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- - ! '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
hash: -1874784024432894432
|
64
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
62
|
none: false
|
66
63
|
requirements:
|
67
64
|
- - ! '>='
|
68
65
|
- !ruby/object:Gem::Version
|
69
66
|
version: '0'
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
hash: -1874784024432894432
|
73
67
|
requirements: []
|
74
68
|
rubyforge_project:
|
75
69
|
rubygems_version: 1.8.11
|