figleaf 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -1
- data/Gemfile +5 -0
- data/Gemfile.lock +13 -1
- data/README.md +2 -0
- data/figleaf.gemspec +1 -1
- data/lib/figleaf/configuration.rb +11 -4
- data/lib/figleaf/version.rb +1 -1
- data/spec/settings_spec.rb +44 -0
- metadata +18 -8
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
figleaf (0.0.
|
4
|
+
figleaf (0.0.5)
|
5
5
|
activesupport
|
6
6
|
hashie
|
7
7
|
|
@@ -12,6 +12,14 @@ GEM
|
|
12
12
|
i18n (~> 0.6)
|
13
13
|
multi_json (~> 1.0)
|
14
14
|
coderay (1.0.7)
|
15
|
+
columnize (0.3.6)
|
16
|
+
debugger (1.1.4)
|
17
|
+
columnize (>= 0.3.1)
|
18
|
+
debugger-linecache (~> 1.1.1)
|
19
|
+
debugger-ruby_core_source (~> 1.1.3)
|
20
|
+
debugger-linecache (1.1.2)
|
21
|
+
debugger-ruby_core_source (>= 1.1.1)
|
22
|
+
debugger-ruby_core_source (1.1.3)
|
15
23
|
diff-lcs (1.1.3)
|
16
24
|
hashie (1.2.0)
|
17
25
|
i18n (0.6.0)
|
@@ -21,6 +29,9 @@ GEM
|
|
21
29
|
coderay (~> 1.0.5)
|
22
30
|
method_source (~> 0.8)
|
23
31
|
slop (~> 3.3.1)
|
32
|
+
pry-debugger (0.2.0)
|
33
|
+
debugger (~> 1.1.3)
|
34
|
+
pry (~> 0.9.9)
|
24
35
|
rake (0.9.2.2)
|
25
36
|
rspec (2.11.0)
|
26
37
|
rspec-core (~> 2.11.0)
|
@@ -38,5 +49,6 @@ PLATFORMS
|
|
38
49
|
DEPENDENCIES
|
39
50
|
figleaf!
|
40
51
|
pry
|
52
|
+
pry-debugger
|
41
53
|
rake
|
42
54
|
rspec
|
data/README.md
CHANGED
@@ -47,6 +47,8 @@ end
|
|
47
47
|
```
|
48
48
|
etc...
|
49
49
|
|
50
|
+
Then, in your app, you can reference `Figleaf::Setting.some_awesome_flag?`.
|
51
|
+
|
50
52
|
Also, it provides the ability for you to define all your environment dependent
|
51
53
|
settings in just one YAML file inside `config/settings/`. The anatomy of these
|
52
54
|
files should be:
|
data/figleaf.gemspec
CHANGED
@@ -32,17 +32,24 @@ module Figleaf
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def method_missing(method_name, *args)
|
35
|
-
|
36
|
-
|
35
|
+
getter_name, modifier = extract_getter_name_and_modifier(method_name)
|
36
|
+
|
37
|
+
if self.auto_define && modifier == '=' && args.length == 1
|
38
|
+
self.define_cattr_methods(getter_name)
|
37
39
|
self.send(method_name, args.shift)
|
40
|
+
elsif modifier == '?' && args.empty?
|
41
|
+
self.send(getter_name).present?
|
38
42
|
else
|
39
43
|
super
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
43
|
-
def
|
44
|
-
|
47
|
+
def extract_getter_name_and_modifier(method_name)
|
48
|
+
match = method_name.to_s.match(/(?<name>.*?)(?<modifier>[?=]?)$/)
|
49
|
+
[match[:name], match[:modifier]]
|
50
|
+
end
|
45
51
|
|
52
|
+
def define_cattr_methods(getter_name)
|
46
53
|
cattr_writer getter_name
|
47
54
|
define_singleton_method(getter_name) do
|
48
55
|
result = class_variable_get "@@#{getter_name}"
|
data/lib/figleaf/version.rb
CHANGED
data/spec/settings_spec.rb
CHANGED
@@ -56,6 +56,50 @@ describe Figleaf::Settings do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
describe "predicate methods for boolean values" do
|
60
|
+
it "should define predicate methods for true value" do
|
61
|
+
described_class.configure_with_auto_define do |s|
|
62
|
+
s.some_boolean = true
|
63
|
+
end
|
64
|
+
|
65
|
+
described_class.some_boolean.should be_true
|
66
|
+
described_class.some_boolean?.should be_true
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should define predicate methods for false value" do
|
70
|
+
described_class.configure_with_auto_define do |s|
|
71
|
+
s.another_boolean = false
|
72
|
+
end
|
73
|
+
|
74
|
+
described_class.another_boolean.should be_false
|
75
|
+
described_class.another_boolean?.should be_false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should evaluate presence predicate methods for string value" do
|
79
|
+
described_class.configure_with_auto_define do |s|
|
80
|
+
s.not_a_boolean = "Hello, world!"
|
81
|
+
end
|
82
|
+
|
83
|
+
described_class.not_a_boolean?.should be_true
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should return false for empty string" do
|
87
|
+
described_class.configure_with_auto_define do |s|
|
88
|
+
s.empty_string = ""
|
89
|
+
end
|
90
|
+
|
91
|
+
described_class.empty_string?.should be_false
|
92
|
+
end
|
93
|
+
|
94
|
+
it "return true for lists" do
|
95
|
+
described_class.configure_with_auto_define do |s|
|
96
|
+
s.not_a_boolean = %w(1 2 3)
|
97
|
+
end
|
98
|
+
|
99
|
+
described_class.not_a_boolean?.should be_true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
59
103
|
describe "self.configure" do
|
60
104
|
before(:each) do
|
61
105
|
described_class.auto_define = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: figleaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry-debugger
|
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'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: activesupport
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,18 +143,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
143
|
- - ! '>='
|
128
144
|
- !ruby/object:Gem::Version
|
129
145
|
version: '0'
|
130
|
-
segments:
|
131
|
-
- 0
|
132
|
-
hash: 4046133761030384592
|
133
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
147
|
none: false
|
135
148
|
requirements:
|
136
149
|
- - ! '>='
|
137
150
|
- !ruby/object:Gem::Version
|
138
151
|
version: '0'
|
139
|
-
segments:
|
140
|
-
- 0
|
141
|
-
hash: 4046133761030384592
|
142
152
|
requirements: []
|
143
153
|
rubyforge_project:
|
144
154
|
rubygems_version: 1.8.24
|