figleaf 0.2.9 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ec9ac4b9f179b8da23d4fe6fd4f89573ad041f40
4
- data.tar.gz: 6d35c13f543461265cc76ca339335f392fcdf03f
2
+ SHA256:
3
+ metadata.gz: 37549d550c5b5f23f930cbbe09f7c94f554be0d61175ffd3c100da8d4da57132
4
+ data.tar.gz: 13de48551a3e5ba8b0ef24a8b206ad2e4ecbbe509bfacabc733d65c1e2d7fa57
5
5
  SHA512:
6
- metadata.gz: 80c139d2c4a5b3cb77999e9101940248ecb2b82ec9dc83420d89f7fc7462fe7875de2c61c9b7ba868be611500a5fa6b27dc53e707c3d730784741f740a551e4f
7
- data.tar.gz: 4bb3aefcc80e712dcb231a413f3b3e867004248ca4a36491d8c56e2f9b29889a98a7dc8d6fb304043d914ab7919a486c87478b9b02ed783d8dfc932bfb4f6d6c
6
+ metadata.gz: 99e014709696659c0c0cdded8e7e1ee79ac485fe82cea11d5f4d4dd63acddcaf8605a30e748d19beb477eb7a7eb9ec4bf13fb41eda39dca00e61ee5aee36d13a
7
+ data.tar.gz: 539305c3f50e86711a6d921a8a49962b131905b3939c619805d062ef00897af43295526a0ad3a6fd3cdee176124bfe838e945e300a1514906028086680ae850b
data/CHANGELOG.md CHANGED
@@ -1,22 +1,40 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.3.1 (2024/04/24)
4
+
5
+ - Allow loading regexps
6
+
7
+ ## 0.3.0 (2024/04/05)
8
+
9
+ - Use YAML.safe_load to support versions of Psych >4
10
+ - Target modern rubies
11
+ - Take advantage of Ruby 3's single line methods
12
+ - Use standardrb to auto format all files
13
+
3
14
  ## 0.2.7, 0.2.8 and 0.2.9 (2017/09/28)
4
- Bugfixes
15
+
16
+ - Bugfixes
5
17
 
6
18
  ## 0.2.6 (2017/09/28)
7
- Add ability to write config files in ruby
19
+
20
+ - Add ability to write config files in ruby
8
21
 
9
22
  ## 0.2.5 (2017/09/28)
10
- Add support for `default` options
23
+
24
+ - Add support for `default` options
11
25
 
12
26
  ## 0.2.4 (2017/08/25)
13
- Relax active support version dependency
27
+
28
+ - Relax active support version dependency
14
29
 
15
30
  ## 0.2.3 (2017/03/09)
16
- Include original error along with file that failed loading
31
+
32
+ - Include original error along with file that failed loading
17
33
 
18
34
  ## 0.2.2 (2017/03/08)
19
- Report what file failed loading on startup
35
+
36
+ - Report what file failed loading on startup
20
37
 
21
38
  ## 0.2.1
22
- Fixes for rails 4
39
+
40
+ - Fixes for rails 4
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
@@ -13,13 +13,15 @@ group :development do
13
13
  gem "rb-fsevent", require: false
14
14
  gem "rb-inotify", require: false
15
15
 
16
- gem 'guard-bundler', :require => false
17
- gem 'guard-livereload', :require => false
18
- gem 'guard-rspec', :require => false
19
- gem 'libnotify', :require => false # linux notifications
20
- gem 'ruby_gntp', :require => false # os x notifications
21
- gem "terminal-notifier-guard", :require => false
16
+ gem "guard-bundler", require: false
17
+ gem "guard-livereload", require: false
18
+ gem "guard-rspec", require: false
19
+ gem "libnotify", require: false # linux notifications
20
+ gem "ruby_gntp", require: false # os x notifications
21
+ gem "terminal-notifier-guard", require: false
22
22
 
23
- gem "pry"
24
- gem "pry-debugger", platforms: :ruby_19
23
+ gem "pry", require: false
24
+ gem "pry-byebug", require: false
25
+
26
+ gem "standard", require: false
25
27
  end
data/Guardfile CHANGED
@@ -1,19 +1,19 @@
1
1
  platform = RUBY_PLATFORM.match(/(linux|darwin)/)[0].to_sym
2
2
  notification case platform
3
- when :darwin
4
- :gntp
5
- when :linux
6
- require 'libnotify'
7
- :libnotify
8
- end
3
+ when :darwin
4
+ :gntp
5
+ when :linux
6
+ require "libnotify"
7
+ :libnotify
8
+ end
9
9
 
10
10
  guard :bundler do
11
- require 'guard/bundler'
12
- require 'guard/bundler/verify'
11
+ require "guard/bundler"
12
+ require "guard/bundler/verify"
13
13
  helper = Guard::Bundler::Verify.new
14
14
 
15
- files = ['Gemfile']
16
- files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
15
+ files = ["Gemfile"]
16
+ files += Dir["*.gemspec"] if files.any? { |f| helper.uses_gemspec?(f) }
17
17
 
18
18
  # Assume files are symlinked from somewhere
19
19
  files.each { |file| watch(helper.real_path(file)) }
data/Rakefile CHANGED
@@ -18,4 +18,4 @@ task :clean do
18
18
  end
19
19
 
20
20
  desc "Run rspec by default"
21
- task :default => :spec
21
+ task default: :spec
data/figleaf.gemspec CHANGED
@@ -1,19 +1,17 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/figleaf/version', __FILE__)
1
+ require File.expand_path("../lib/figleaf/version", __FILE__)
3
2
 
4
3
  Gem::Specification.new do |gem|
5
- gem.authors = ["Juan C. Müller"]
6
- gem.email = ["jcmuller@gmail.com"]
7
- gem.description = %q{YAML based DRY settings manager.}
8
- gem.summary = %q{YAML based DRY settings manager.}
9
- gem.homepage = "http://github.com/jcmuller/figleaf"
4
+ gem.authors = ["Juan C. Müller"]
5
+ gem.email = ["jcmuller@gmail.com"]
6
+ gem.description = "YAML based DRY settings manager."
7
+ gem.summary = "YAML based DRY settings manager."
8
+ gem.homepage = "http://github.com/jcmuller/figleaf"
10
9
 
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "figleaf"
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
12
+ gem.name = "figleaf"
15
13
  gem.require_paths = ["lib"]
16
- gem.version = Figleaf::VERSION
14
+ gem.version = Figleaf::VERSION
17
15
 
18
16
  gem.add_dependency "activesupport", ">= 3"
19
17
  gem.add_dependency "hashie", ">= 2"
@@ -1,47 +1,37 @@
1
1
  module Figleaf
2
2
  # Convert a ruby block to nested hash
3
3
  class Config
4
- def initialize
5
- @property = LazyBlockHash.new
6
- end
4
+ def initialize = @property = LazyBlockHash.new
7
5
 
8
- def call(&block)
9
- instance_eval(&block)
6
+ def call(&)
7
+ instance_eval(&)
10
8
 
11
9
  property
12
- rescue Exception => e
10
+ rescue => e
13
11
  raise Settings::InvalidRb, "Configuration has invalid Ruby\n" + e.message
14
12
  end
15
13
 
16
- def method_missing(method_name, *args, &block)
17
- process_method(method_name, *args, &block)
18
- end
14
+ def method_missing(method_name, *, &) = process_method(method_name, *, &)
19
15
 
20
- def test(&block)
21
- process_method(:test, [], &block)
22
- end
16
+ def test(&) = process_method(:test, [], &)
23
17
 
24
18
  def process_method(method_name, *args, &block)
25
19
  @property[method_name.to_s] =
26
- if block_given?
20
+ if block
27
21
  obj = self.class.new
28
- Proc.new { obj.call(&block) }
22
+ proc { obj.call(&block) }
23
+ elsif args.count == 1
24
+ args[0]
29
25
  else
30
- if args.count == 1
31
- args[0]
32
- else
33
- args
34
- end
26
+ args
35
27
  end
36
28
  end
37
29
 
38
- def respond_to_missing?(method_name, *args)
39
- true
40
- end
30
+ def respond_to_missing?(method_name, *args) = true
41
31
 
42
32
  private
43
33
 
44
- attr_reader :property
34
+ attr_reader :property
45
35
  end
46
36
 
47
37
  class LazyBlockHash < Hash
@@ -10,7 +10,7 @@ module Figleaf
10
10
  # Public - configure pre-defined attributes
11
11
  #
12
12
  def configure
13
- self.auto_define.tap do |cached_auto_define|
13
+ auto_define.tap do |cached_auto_define|
14
14
  self.auto_define = false
15
15
  yield self
16
16
  self.auto_define = cached_auto_define
@@ -20,13 +20,13 @@ module Figleaf
20
20
  # Public - configure auto defined settings attributes
21
21
  # and load yaml settings from confing/settings directory
22
22
  #
23
- def configure!(&block)
23
+ def configure!(&)
24
24
  load_settings
25
- configure_with_auto_define(&block)
25
+ configure_with_auto_define(&)
26
26
  end
27
27
 
28
28
  def configure_with_auto_define
29
- self.auto_define.tap do |cached_auto_define|
29
+ auto_define.tap do |cached_auto_define|
30
30
  self.auto_define = true
31
31
  yield self
32
32
  self.auto_define = cached_auto_define
@@ -46,23 +46,23 @@ module Figleaf
46
46
 
47
47
  next if property.nil?
48
48
 
49
- if self.respond_to?(property_name) &&
50
- self.send(property_name).respond_to?(:merge) &&
49
+ if respond_to?(property_name) &&
50
+ send(property_name).respond_to?(:merge) &&
51
51
  property.respond_to?(:merge)
52
- property = self.send(property_name).merge(property)
52
+ property = send(property_name).merge(property)
53
53
  end
54
54
 
55
- self.send("#{property_name}=", property)
55
+ send(:"#{property_name}=", property)
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
60
  def load_file(file, env_to_load = env)
61
- if file.end_with?('.rb')
62
- property_name = File.basename(file, '.rb')
61
+ property_name = File.basename(file, ".*")
62
+
63
+ if file.end_with?(".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,23 +84,27 @@ module Figleaf
84
84
  end
85
85
 
86
86
  def load_yaml_file(file_path)
87
- YAML.load(ERB.new(IO.read(file_path)).result)
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
91
91
 
92
92
  def root
93
93
  return Rails.root if defined?(Rails)
94
- Pathname.new('.')
94
+ Pathname.new(".")
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
102
106
  return Rails.env if defined?(Rails)
103
- ENV['ENVIRONMENT']
107
+ ENV["ENVIRONMENT"]
104
108
  end
105
109
 
106
110
  def use_hashie_if_hash(property)
@@ -109,20 +113,20 @@ module Figleaf
109
113
  end
110
114
 
111
115
  def override_with_local!(local_file)
112
- #this file (i.e. test.local.rb) is an optional place to put settings
116
+ # this file (i.e. test.local.rb) is an optional place to put settings
113
117
  local_file.tap do |local_settings_path|
114
- eval(IO.read(local_settings_path), binding) if File.exists?(local_settings_path)
118
+ eval(IO.read(local_settings_path), binding) if File.exist?(local_settings_path)
115
119
  end
116
120
  end
117
121
 
118
122
  def method_missing(method_name, *args)
119
123
  getter_name, modifier = extract_getter_name_and_modifier(method_name)
120
124
 
121
- if self.auto_define && modifier == '=' && args.length == 1
122
- self.define_cattr_methods(getter_name)
123
- self.send(method_name, args.shift)
124
- elsif modifier == '?' && args.empty?
125
- self.send(getter_name).present?
125
+ if auto_define && modifier == "=" && args.length == 1
126
+ define_cattr_methods(getter_name)
127
+ send(method_name, args.shift)
128
+ elsif modifier == "?" && args.empty?
129
+ send(getter_name).present?
126
130
  else
127
131
  super
128
132
  end
@@ -136,11 +140,10 @@ module Figleaf
136
140
  def define_cattr_methods(getter_name)
137
141
  cattr_writer getter_name
138
142
  define_singleton_method(getter_name) do
139
- result = class_variable_get "@@#{getter_name}"
143
+ result = class_variable_get :"@@#{getter_name}"
140
144
  result.respond_to?(:call) ? result.call : result
141
145
  end
142
146
  end
143
-
144
147
  end
145
148
  end
146
149
  end
@@ -1,3 +1,3 @@
1
1
  module Figleaf
2
- VERSION = '0.2.9'
2
+ VERSION = "0.3.1"
3
3
  end
data/lib/figleaf.rb CHANGED
@@ -1,15 +1,15 @@
1
- require 'active_support/concern'
2
- require 'active_support/core_ext/class/attribute'
3
- require 'active_support/core_ext/module/attribute_accessors'
1
+ require "active_support/concern"
2
+ require "active_support/core_ext/class/attribute"
3
+ require "active_support/core_ext/module/attribute_accessors"
4
4
  require "active_support/core_ext/object/blank"
5
- require 'hashie'
6
- require 'pathname'
7
- require 'yaml'
8
- require 'erb'
5
+ require "erb"
6
+ require "hashie"
7
+ require "pathname"
8
+ require "yaml"
9
9
 
10
10
  module Figleaf
11
- autoload :Config, 'figleaf/config'
12
- autoload :Fighash, 'figleaf/fighash'
13
- autoload :Settings, 'figleaf/settings'
14
- autoload :VERSION, 'figleaf/version'
11
+ autoload :Config, "figleaf/config"
12
+ autoload :Fighash, "figleaf/fighash"
13
+ autoload :Settings, "figleaf/settings"
14
+ autoload :VERSION, "figleaf/version"
15
15
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  module Figleaf
4
4
  RSpec.describe Config do
@@ -30,13 +30,13 @@ module Figleaf
30
30
  describe "#call" do
31
31
  subject(:called) { config.call(&code) }
32
32
  it "stores first level keywords as keys" do
33
- expect(called.keys).to contain_exactly(*%w(
33
+ expect(called.keys).to contain_exactly(*%w[
34
34
  default
35
35
  failer
36
36
  production
37
37
  setting_set_on_root
38
38
  test
39
- ))
39
+ ])
40
40
  end
41
41
 
42
42
  it "expands default" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Figleaf::Settings do
4
4
  describe "setters and getters" do
@@ -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,15 +82,15 @@ 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
89
89
  described_class.configure_with_auto_define do |s|
90
- s.not_a_boolean = %w(1 2 3)
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,8 +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
-
120
119
  end
@@ -1,25 +1,25 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
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
- subject = described_class.new({ a: :b, c: 1, d: "foo" })
12
- subject.to_hash.should == { a: :b, c: 1, d: "foo" }
11
+ subject = described_class.new({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
- subject = described_class.new({ "a" => :b, "c" => 1, "d" => "foo" })
17
- subject.to_hash.should == { a: :b, c: 1, d: "foo" }
16
+ subject = described_class.new({"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
- subject = described_class.new({ a: { b: :d } })
22
- subject.to_hash.should == { a: { b: :d } }
21
+ subject = described_class.new({a: {b: :d}})
22
+ expect(subject.to_hash).to eq({a: {b: :d}})
23
23
  end
24
24
  end
25
25
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Figleaf::Settings do
4
4
  describe "self.load_settings" do
@@ -47,12 +47,16 @@ describe Figleaf::Settings do
47
47
  end
48
48
 
49
49
  it "and for erb values" do
50
- expect(described_class.erb.foo).to eq('foo')
50
+ expect(described_class.erb.foo).to eq("foo")
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
@@ -62,8 +66,8 @@ describe Figleaf::Settings do
62
66
  let(:overload) { File.expand_path("../../fixtures/errors/*.yml", __FILE__) }
63
67
 
64
68
  it "reports the file that has errors" do
65
- expect { described_class.load_settings(overload, "test") }.
66
- to raise_error(described_class::InvalidYAML)
69
+ expect { described_class.load_settings(overload, "test") }
70
+ .to raise_error(described_class::InvalidYAML)
67
71
  end
68
72
  end
69
73
 
@@ -71,8 +75,8 @@ describe Figleaf::Settings do
71
75
  let(:overload) { File.expand_path("../../fixtures/errors/*.rb", __FILE__) }
72
76
 
73
77
  it "reports the file that has errors" do
74
- expect { described_class.load_settings(overload, "test") }.
75
- to raise_error(described_class::InvalidRb)
78
+ expect { described_class.load_settings(overload, "test") }
79
+ .to raise_error(described_class::InvalidRb)
76
80
  end
77
81
  end
78
82
  end
@@ -84,8 +88,8 @@ describe Figleaf::Settings do
84
88
  end
85
89
 
86
90
  it "merge values for matching env" do
87
- expect(described_class.service.foo).to eq 'overridden'
88
- expect(described_class.service.extra).to eq 'extra'
91
+ expect(described_class.service.foo).to eq "overridden"
92
+ expect(described_class.service.extra).to eq "extra"
89
93
  expect(described_class.service.bool_false).to eq(false)
90
94
  expect(described_class.service.bool_true).to eq(true)
91
95
  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__)
@@ -167,7 +182,11 @@ describe Figleaf::Settings do
167
182
  end
168
183
 
169
184
  it "and for ENV values" do
170
- expect(described_class.code.from_env).to eq('foo')
185
+ expect(described_class.code.from_env).to eq("foo")
186
+ end
187
+
188
+ it "and for regexp values" do
189
+ expect(described_class.regexp.value).to eq(/\Amatcher\z/)
171
190
  end
172
191
  end
173
192
  end
@@ -17,5 +17,5 @@ test do
17
17
  bool_false false
18
18
  array 1, 2, 3, 4
19
19
  array_alt [1, 2, 3, 4]
20
- from_env ENV['FIGLEAF_TEST_FOO']
20
+ from_env ENV["FIGLEAF_TEST_FOO"]
21
21
  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
data/spec/spec_helper.rb CHANGED
@@ -19,5 +19,5 @@ RSpec.configure do |config|
19
19
  config.order = "random"
20
20
  end
21
21
 
22
- ENV['FIGLEAF_TEST_FOO'] ||= 'foo'
22
+ ENV["FIGLEAF_TEST_FOO"] ||= "foo"
23
23
  # ENV['FIGLEAF_TEST_BAR'] intentionally left blank
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figleaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan C. Müller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2024-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -75,14 +75,17 @@ 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: []
84
87
  metadata: {}
85
- post_install_message:
88
+ post_install_message:
86
89
  rdoc_options: []
87
90
  require_paths:
88
91
  - lib
@@ -97,27 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
100
  - !ruby/object:Gem::Version
98
101
  version: '0'
99
102
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.6.11
102
- signing_key:
103
+ rubygems_version: 3.4.19
104
+ signing_key:
103
105
  specification_version: 4
104
106
  summary: YAML based DRY settings manager.
105
- test_files:
106
- - spec/figleaf/config_spec.rb
107
- - spec/figleaf/configuration_spec.rb
108
- - spec/figleaf/fighash_spec.rb
109
- - spec/figleaf/settings_spec.rb
110
- - spec/fixtures/array.yml
111
- - spec/fixtures/boolean.yml
112
- - spec/fixtures/erb.yml
113
- - spec/fixtures/errors/bad_file.rb
114
- - spec/fixtures/errors/bad_file.yml
115
- - spec/fixtures/extra/array.yml
116
- - spec/fixtures/extra/boolean.yml
117
- - spec/fixtures/extra/code.rb
118
- - spec/fixtures/extra/default.yml
119
- - spec/fixtures/extra/default_anchor.yml
120
- - spec/fixtures/extra/service.yml
121
- - spec/fixtures/service.yml
122
- - spec/fixtures/string.yml
123
- - spec/spec_helper.rb
107
+ test_files: []