figleaf 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9587314be7114b5e08704a3f1e2364f41cf90f926c890554b8dd31582dbd7c2
4
- data.tar.gz: 7f1731a8135590e9992ff1a2e40382fd36f11f9bb3739d6006546a40069ee948
3
+ metadata.gz: 37549d550c5b5f23f930cbbe09f7c94f554be0d61175ffd3c100da8d4da57132
4
+ data.tar.gz: 13de48551a3e5ba8b0ef24a8b206ad2e4ecbbe509bfacabc733d65c1e2d7fa57
5
5
  SHA512:
6
- metadata.gz: '03471397a014e702344505aee3ebe6289b110278d662ed121fcc634c8a63a20f9207e90b1ca08ec7d6d693246f61b1dede83cec44af33694dae4621b4e892b56'
7
- data.tar.gz: 76a9bdcec7177c4485273a93748c454b886f3adb22b12e4dfe485ea7359d9f7d418a15509f7ce7747b0b5225ff0fc896598f877c29354ea67d8090a4a03ee238
6
+ metadata.gz: 99e014709696659c0c0cdded8e7e1ee79ac485fe82cea11d5f4d4dd63acddcaf8605a30e748d19beb477eb7a7eb9ec4bf13fb41eda39dca00e61ee5aee36d13a
7
+ data.tar.gz: 539305c3f50e86711a6d921a8a49962b131905b3939c619805d062ef00897af43295526a0ad3a6fd3cdee176124bfe838e945e300a1514906028086680ae850b
data/CHANGELOG.md CHANGED
@@ -1,28 +1,40 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.3.1 (2024/04/24)
4
+
5
+ - Allow loading regexps
6
+
3
7
  ## 0.3.0 (2024/04/05)
8
+
4
9
  - Use YAML.safe_load to support versions of Psych >4
5
10
  - Target modern rubies
6
11
  - Take advantage of Ruby 3's single line methods
7
12
  - Use standardrb to auto format all files
8
13
 
9
14
  ## 0.2.7, 0.2.8 and 0.2.9 (2017/09/28)
10
- Bugfixes
15
+
16
+ - Bugfixes
11
17
 
12
18
  ## 0.2.6 (2017/09/28)
13
- Add ability to write config files in ruby
19
+
20
+ - Add ability to write config files in ruby
14
21
 
15
22
  ## 0.2.5 (2017/09/28)
16
- Add support for `default` options
23
+
24
+ - Add support for `default` options
17
25
 
18
26
  ## 0.2.4 (2017/08/25)
19
- Relax active support version dependency
27
+
28
+ - Relax active support version dependency
20
29
 
21
30
  ## 0.2.3 (2017/03/09)
22
- Include original error along with file that failed loading
31
+
32
+ - Include original error along with file that failed loading
23
33
 
24
34
  ## 0.2.2 (2017/03/08)
25
- Report what file failed loading on startup
35
+
36
+ - Report what file failed loading on startup
26
37
 
27
38
  ## 0.2.1
28
- Fixes for rails 4
39
+
40
+ - Fixes for rails 4
@@ -58,11 +58,11 @@ module Figleaf
58
58
  end
59
59
 
60
60
  def load_file(file, env_to_load = env)
61
+ property_name = File.basename(file, ".*")
62
+
61
63
  if file.end_with?(".rb")
62
- property_name = File.basename(file, ".rb")
63
64
  config = load_rb_file(file) or return nil
64
65
  else
65
- property_name = File.basename(file, ".yml")
66
66
  config = load_yaml_file(file) or return nil
67
67
  end
68
68
 
@@ -84,7 +84,7 @@ module Figleaf
84
84
  end
85
85
 
86
86
  def load_yaml_file(file_path)
87
- YAML.safe_load(ERB.new(IO.read(file_path)).result, aliases: true)
87
+ YAML.safe_load(ERB.new(IO.read(file_path)).result, aliases: true, permitted_classes: [Regexp])
88
88
  rescue Psych::SyntaxError => e
89
89
  raise InvalidYAML, "#{file_path} has invalid YAML\n" + e.message
90
90
  end
@@ -95,7 +95,11 @@ module Figleaf
95
95
  end
96
96
 
97
97
  def default_file_pattern
98
- [root.join("config/settings/*.yml"), root.join("config/settings/*.rb")]
98
+ [
99
+ root.join("config", "settings", "*.yml"),
100
+ root.join("config", "settings", "*.yaml"),
101
+ root.join("config", "settings", "*.rb")
102
+ ]
99
103
  end
100
104
 
101
105
  def env
@@ -1,3 +1,3 @@
1
1
  module Figleaf
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -8,12 +8,12 @@ describe Figleaf::Settings do
8
8
  end
9
9
  it "should auto define methods and set initial value when setter used" do
10
10
  described_class.fictional_feature_enabled = :on
11
- described_class.fictional_feature_enabled.should == :on
11
+ expect(described_class.fictional_feature_enabled).to eq(:on)
12
12
  end
13
13
 
14
14
  it "should return result of proc when set as a proc" do
15
15
  described_class.call_this_proc = -> { 3 }
16
- described_class.call_this_proc.should == 3
16
+ expect(described_class.call_this_proc).to eq(3)
17
17
  end
18
18
  end
19
19
 
@@ -25,15 +25,15 @@ describe Figleaf::Settings do
25
25
  end
26
26
 
27
27
  it "should not auto defined setters and getters" do
28
- expect { described_class.undefined_setting = :raises_error }.to raise_error
29
- expect { described_class.undefined_setting }.to raise_error
28
+ expect { described_class.undefined_setting = :raises_error }.to raise_error(NoMethodError)
29
+ expect { described_class.undefined_setting }.to raise_error(NoMethodError)
30
30
  end
31
31
 
32
32
  it "should set/get previous defined attributes" do
33
- described_class.fictional_feature_enabled.should eq(:on)
33
+ expect(described_class.fictional_feature_enabled).to eq(:on)
34
34
 
35
35
  described_class.fictional_feature_enabled = :off
36
- described_class.fictional_feature_enabled.should eq(:off)
36
+ expect(described_class.fictional_feature_enabled).to eq(:off)
37
37
  end
38
38
  end
39
39
  end
@@ -45,8 +45,8 @@ describe Figleaf::Settings do
45
45
  s.enable_fictional_activity_feed = true
46
46
  end
47
47
 
48
- described_class.another_fictional_feature_mode.should eq(:admin)
49
- described_class.enable_fictional_activity_feed.should be true
48
+ expect(described_class.another_fictional_feature_mode).to eq(:admin)
49
+ expect(described_class.enable_fictional_activity_feed).to be true
50
50
  end
51
51
  end
52
52
 
@@ -56,8 +56,8 @@ describe Figleaf::Settings do
56
56
  s.some_boolean = true
57
57
  end
58
58
 
59
- described_class.some_boolean.should be true
60
- described_class.some_boolean?.should be true
59
+ expect(described_class.some_boolean).to be true
60
+ expect(described_class.some_boolean?).to be true
61
61
  end
62
62
 
63
63
  it "should define predicate methods for false value" do
@@ -65,8 +65,8 @@ describe Figleaf::Settings do
65
65
  s.another_boolean = false
66
66
  end
67
67
 
68
- described_class.another_boolean.should be false
69
- described_class.another_boolean?.should be false
68
+ expect(described_class.another_boolean).to be false
69
+ expect(described_class.another_boolean?).to be false
70
70
  end
71
71
 
72
72
  it "should evaluate presence predicate methods for string value" do
@@ -74,7 +74,7 @@ describe Figleaf::Settings do
74
74
  s.not_a_boolean = "Hello, world!"
75
75
  end
76
76
 
77
- described_class.not_a_boolean?.should be true
77
+ expect(described_class.not_a_boolean?).to be true
78
78
  end
79
79
 
80
80
  it "should return false for empty string" do
@@ -82,7 +82,7 @@ describe Figleaf::Settings do
82
82
  s.empty_string = ""
83
83
  end
84
84
 
85
- described_class.empty_string?.should be false
85
+ expect(described_class.empty_string?).to be false
86
86
  end
87
87
 
88
88
  it "return true for lists" do
@@ -90,7 +90,7 @@ describe Figleaf::Settings do
90
90
  s.not_a_boolean = %w[1 2 3]
91
91
  end
92
92
 
93
- described_class.not_a_boolean?.should be true
93
+ expect(described_class.not_a_boolean?).to be true
94
94
  end
95
95
  end
96
96
 
@@ -105,7 +105,7 @@ describe Figleaf::Settings do
105
105
  s.fictional_feature_enabled = :off
106
106
  end
107
107
 
108
- described_class.fictional_feature_enabled.should == :off
108
+ expect(described_class.fictional_feature_enabled).to eq(:off)
109
109
  end
110
110
 
111
111
  it "should only allow setting of values for previously defined attributes" do
@@ -113,7 +113,7 @@ describe Figleaf::Settings do
113
113
  described_class.configure do |s|
114
114
  s.undefined_setting = :should_raise_error
115
115
  end
116
- }.to raise_error
116
+ }.to raise_error(NoMethodError)
117
117
  end
118
118
  end
119
119
  end
@@ -3,23 +3,23 @@ require "spec_helper"
3
3
  describe Figleaf::Fighash do
4
4
  describe "#to_hash" do
5
5
  it "should return class Hash" do
6
- subject.to_hash.class.should == Hash
6
+ expect(subject.to_hash.class).to eq(Hash)
7
7
  end
8
8
 
9
9
  context "should have symbols as keys" do
10
10
  it "for symbol keys" do
11
11
  subject = described_class.new({a: :b, c: 1, d: "foo"})
12
- subject.to_hash.should == {a: :b, c: 1, d: "foo"}
12
+ expect(subject.to_hash).to eq({a: :b, c: 1, d: "foo"})
13
13
  end
14
14
 
15
15
  it "for string keys" do
16
16
  subject = described_class.new({"a" => :b, "c" => 1, "d" => "foo"})
17
- subject.to_hash.should == {a: :b, c: 1, d: "foo"}
17
+ expect(subject.to_hash).to eq({a: :b, c: 1, d: "foo"})
18
18
  end
19
19
 
20
20
  it "should have symbols as keys inside two levels" do
21
21
  subject = described_class.new({a: {b: :d}})
22
- subject.to_hash.should == {a: {b: :d}}
22
+ expect(subject.to_hash).to eq({a: {b: :d}})
23
23
  end
24
24
  end
25
25
  end
@@ -51,8 +51,12 @@ describe Figleaf::Settings do
51
51
  expect(described_class.erb.bar).to be_nil
52
52
  end
53
53
 
54
+ it "and for regexp values" do
55
+ expect(described_class.regexp.some_matcher).to eq(/\Amatcher\z/)
56
+ end
57
+
54
58
  it "raise exception when loading an undefined value" do
55
- YAML.stub(:load_yaml_file).and_return({"test" => {}})
59
+ allow(YAML).to receive(:load_yaml_file).and_return({"test" => {}})
56
60
  described_class.load_settings
57
61
  expect { described_class.service.blah }.to raise_error NoMethodError
58
62
  end
@@ -106,7 +110,7 @@ describe Figleaf::Settings do
106
110
  end
107
111
 
108
112
  it "overrides values" do
109
- expect(described_class.default.foo).to eq("overriden")
113
+ expect(described_class.default.foo).to eq("overridden")
110
114
  end
111
115
 
112
116
  it "respects values set in default" do
@@ -121,7 +125,7 @@ describe Figleaf::Settings do
121
125
  end
122
126
 
123
127
  it "overrides values" do
124
- expect(described_class.default_anchor.foo).to eq("overriden")
128
+ expect(described_class.default_anchor.foo).to eq("overridden")
125
129
  end
126
130
 
127
131
  it "respects values set in default_anchor" do
@@ -130,6 +134,17 @@ describe Figleaf::Settings do
130
134
  end
131
135
  end
132
136
 
137
+ context "load yaml files" do
138
+ before do
139
+ fixtures_path = File.expand_path("../../fixtures/*.yaml", __FILE__)
140
+ described_class.load_settings(fixtures_path, "test")
141
+ end
142
+
143
+ it "reads them just fine" do
144
+ expect(described_class.yaml.works).to eq("here")
145
+ end
146
+ end
147
+
133
148
  context "load ruby files" do
134
149
  before do
135
150
  fixtures_path = File.expand_path("../../fixtures/extra/*.rb", __FILE__)
@@ -169,5 +184,9 @@ describe Figleaf::Settings do
169
184
  it "and for ENV values" do
170
185
  expect(described_class.code.from_env).to eq("foo")
171
186
  end
187
+
188
+ it "and for regexp values" do
189
+ expect(described_class.regexp.value).to eq(/\Amatcher\z/)
190
+ end
172
191
  end
173
192
  end
@@ -3,4 +3,4 @@ default:
3
3
  bar: baz
4
4
 
5
5
  test:
6
- foo: overriden
6
+ foo: overridden
@@ -4,4 +4,4 @@ default: &default
4
4
 
5
5
  test:
6
6
  <<: *default
7
- foo: overriden
7
+ foo: overridden
@@ -0,0 +1,3 @@
1
+ default do
2
+ value %r{\Amatcher\z}
3
+ end
@@ -0,0 +1,2 @@
1
+ default:
2
+ some_matcher: !ruby/regexp /\Amatcher\z/
@@ -0,0 +1,3 @@
1
+ ---
2
+ test:
3
+ works: here
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan C. Müller
@@ -75,9 +75,12 @@ files:
75
75
  - spec/fixtures/extra/code.rb
76
76
  - spec/fixtures/extra/default.yml
77
77
  - spec/fixtures/extra/default_anchor.yml
78
+ - spec/fixtures/extra/regexp.rb
78
79
  - spec/fixtures/extra/service.yml
80
+ - spec/fixtures/regexp.yml
79
81
  - spec/fixtures/service.yml
80
82
  - spec/fixtures/string.yml
83
+ - spec/fixtures/yaml.yaml
81
84
  - spec/spec_helper.rb
82
85
  homepage: http://github.com/jcmuller/figleaf
83
86
  licenses: []