sexy_settings 0.0.2 → 0.1.0
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +10 -0
- data/.travis.yml +3 -4
- data/Gemfile +0 -5
- data/LICENSE_MIT +1 -1
- data/README.md +11 -5
- data/Rakefile +1 -2
- data/lib/sexy_settings.rb +0 -1
- data/lib/sexy_settings/base.rb +45 -23
- data/lib/sexy_settings/configuration.rb +0 -1
- data/lib/sexy_settings/core.rb +0 -2
- data/lib/sexy_settings/exceptions.rb +4 -0
- data/lib/sexy_settings/printable.rb +0 -1
- data/lib/sexy_settings/sensitive_data_protector.rb +1 -2
- data/lib/sexy_settings/version.rb +1 -2
- data/sexy_settings.gemspec +3 -2
- data/spec/_config/blank_custom.yml +3 -0
- data/spec/_config/blank_default.yml +3 -0
- data/spec/_config/config.yaml +7 -0
- data/spec/sexy_settings/base_spec.rb +178 -86
- data/spec/sexy_settings/configuration_spec.rb +0 -1
- data/spec/sexy_settings/core_spec.rb +0 -1
- data/spec/sexy_settings/version_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -1
- metadata +26 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4a5887e8614a93b21480bf04d3db3ab170ee5b6
|
4
|
+
data.tar.gz: 2b59f6be2fe5763e44038d22f8411bff69167276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b6068bb39e71e1da784e0b27812655bb20f40dc5d53d45c0e39d7f7b5db83f58111198ceff99af51251377e49d57acdfbfac2b65b6b02650e4e64e18172477e
|
7
|
+
data.tar.gz: 76f41644a7518861956b3d363bec04aa66e6e552a0260163e41cf587fa76971938076a9ebb296ff788dc46ef8f174fb5bdca90fae8bf71806806f04a95d55f61
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
AllCops:
|
5
5
|
TargetRubyVersion: 2.3
|
6
|
+
DisplayCopNames: true
|
6
7
|
|
7
8
|
LineLength:
|
8
9
|
Max: 120
|
@@ -21,3 +22,12 @@ Style/CaseEquality:
|
|
21
22
|
|
22
23
|
MethodLength:
|
23
24
|
Max: 30
|
25
|
+
|
26
|
+
Metrics/ClassLength:
|
27
|
+
Max: 120
|
28
|
+
|
29
|
+
Metrics/BlockLength:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Style/FrozenStringLiteralComment:
|
33
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE_MIT
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,13 @@ It is a Ruby-based library used to specify application settings in different way
|
|
16
16
|
* Using the YAML file (default and custom settings).
|
17
17
|
* Using the command line.
|
18
18
|
|
19
|
+
### What's new in 0.1.0
|
20
|
+
|
21
|
+
- Stop supporting Ruby < 2.2.2
|
22
|
+
- Validate missing defaults for all settings
|
23
|
+
- Fix issue [Exception on empty custom.yml](https://github.com/romikoops/sexy_settings/issues/6)
|
24
|
+
- Fix issue [Raise error instead of nil on missing setting](https://github.com/romikoops/sexy_settings/issues/7)
|
25
|
+
|
19
26
|
### What's new in 0.0.2
|
20
27
|
|
21
28
|
- Ability to override delimiter on fly for command line settings
|
@@ -26,7 +33,7 @@ It is a Ruby-based library used to specify application settings in different way
|
|
26
33
|
|
27
34
|
### Prerequisites
|
28
35
|
|
29
|
-
|
36
|
+
Ruby 2.2.2+
|
30
37
|
|
31
38
|
### Installation
|
32
39
|
|
@@ -58,10 +65,9 @@ config\
|
|
58
65
|
|
59
66
|
### Usage
|
60
67
|
|
61
|
-
There are
|
62
|
-
|
68
|
+
There are 3 possible settings values. The priority ranks with respect to the settings location are as follows:
|
63
69
|
|
64
|
-
> **command line** < **custom** < **default**
|
70
|
+
> **command line** < **custom** < **default**
|
65
71
|
|
66
72
|
Thus, specifying some setting in the command line will override the same setting value specified in the <_default config file_> or <_custom config file_>
|
67
73
|
|
@@ -131,6 +137,6 @@ community](https://github.com/romikoops/sexy_settings/graphs/contributors).
|
|
131
137
|
License
|
132
138
|
-------
|
133
139
|
|
134
|
-
SexySettngs is Copyright © 2011-
|
140
|
+
SexySettngs is Copyright © 2011-2017 Roman Parashchenko. It is free
|
135
141
|
software, and may be redistributed under the terms specified in the
|
136
142
|
[LICENSE](/LICENSE_MIT) file.
|
data/Rakefile
CHANGED
data/lib/sexy_settings.rb
CHANGED
data/lib/sexy_settings/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require 'singleton'
|
3
2
|
require 'yaml'
|
4
3
|
require_relative 'printable'
|
4
|
+
require_relative 'exceptions'
|
5
5
|
|
6
6
|
module SexySettings
|
7
7
|
# This class represents core functionality
|
@@ -11,12 +11,18 @@ module SexySettings
|
|
11
11
|
include Singleton
|
12
12
|
include Printable
|
13
13
|
|
14
|
-
# Priorities: command_line > custom.yml > default.yml
|
14
|
+
# Priorities: command_line > custom.yml > default.yml
|
15
15
|
def initialize
|
16
|
-
@default =
|
17
|
-
@custom =
|
16
|
+
@default = load_default_settings
|
17
|
+
@custom = load_custom_settings
|
18
18
|
init_command_line_settings
|
19
19
|
init_all_settings
|
20
|
+
validate_default_settings
|
21
|
+
define_dynamic_methods
|
22
|
+
end
|
23
|
+
|
24
|
+
def inspect
|
25
|
+
'SexySettings::Base'
|
20
26
|
end
|
21
27
|
|
22
28
|
private
|
@@ -25,30 +31,46 @@ module SexySettings
|
|
25
31
|
SexySettings.configuration
|
26
32
|
end
|
27
33
|
|
28
|
-
def
|
29
|
-
|
34
|
+
def define_dynamic_methods
|
35
|
+
@default.keys.each do |setting|
|
36
|
+
self.class.instance_eval do
|
37
|
+
define_method(setting) { @all[setting] }
|
38
|
+
define_method("#{setting}=") do |value|
|
39
|
+
@all[setting] = value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate_default_settings
|
46
|
+
incorrect_settings = @all.keys - @default.keys
|
47
|
+
return if incorrect_settings.empty?
|
48
|
+
path = config.path_to_default_settings
|
49
|
+
raise SexySettings::MissingDefaultError, "Please specify defaults in '#{path}' config file:\n" +
|
50
|
+
incorrect_settings.map { |el| "\t\t#{el}: someValue" }.join("\n")
|
51
|
+
end
|
52
|
+
|
53
|
+
def load_default_settings
|
54
|
+
path = config.path_to_default_settings
|
55
|
+
YAML.load_file(path) || {}
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_custom_settings
|
59
|
+
path = config.path_to_custom_settings
|
60
|
+
return {} unless File.exist?(path)
|
61
|
+
YAML.load_file(path) || {}
|
30
62
|
end
|
31
63
|
|
32
64
|
# Parse the compound setting.
|
33
65
|
# Parts of this config_parser must be defined earlier.
|
34
66
|
# You can define an option as option=${another_option_name}/something
|
35
67
|
def get_compound_value(value)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
value
|
44
|
-
end
|
45
|
-
|
46
|
-
def method_missing(name, *args)
|
47
|
-
if name.to_s =~ /=$/
|
48
|
-
@all[name.to_s] = args[0] if @all.key?(name.to_s)
|
49
|
-
else
|
50
|
-
@all[name.to_s]
|
51
|
-
end
|
68
|
+
return value unless /\$\{(.*?)\}/ =~ value.to_s
|
69
|
+
var = /\$\{(.*?)\}/.match(value.to_s)[1]
|
70
|
+
exist_var = @all[var]
|
71
|
+
raise ArgumentError, "Did you define this setting '#{var}' before?" if exist_var.nil?
|
72
|
+
value["${#{var}}"] = exist_var.to_s if var
|
73
|
+
get_compound_value(value)
|
52
74
|
end
|
53
75
|
|
54
76
|
# Try to convert a value from String to other types (int, boolean, float)
|
@@ -95,7 +117,7 @@ module SexySettings
|
|
95
117
|
value = value.chomp.strip if value
|
96
118
|
new_value = ''
|
97
119
|
if value
|
98
|
-
new_value =
|
120
|
+
new_value = value =~ /^["](.*)["]$/ ? Regexp.last_match(1) : value
|
99
121
|
end
|
100
122
|
new_value = try_convert_value(new_value) if new_value.class == String
|
101
123
|
[param.chomp.strip, new_value]
|
data/lib/sexy_settings/core.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
module SexySettings
|
3
2
|
# This class holds logic sensitive data hiding
|
4
3
|
class SensitiveDataProtector
|
@@ -24,7 +23,7 @@ module SexySettings
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def hide_protected_data_in_url(value)
|
27
|
-
return value if value.nil? ||
|
26
|
+
return value if value.nil? || URL_REGEXP !~ value
|
28
27
|
userpass = URL_REGEXP.match(value)[:userpass]
|
29
28
|
return value if userpass.nil? || userpass.empty?
|
30
29
|
value.sub(userpass, protected_userpass(userpass))
|
data/sexy_settings.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
# frozen_string_literal: true
|
3
1
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
4
2
|
require 'sexy_settings/version'
|
5
3
|
|
@@ -12,6 +10,8 @@ Gem::Specification.new do |s|
|
|
12
10
|
s.summary = 'Flexible specifying of application settings'
|
13
11
|
s.description = 'Library for flexible specifying of application settings different ways'
|
14
12
|
s.rubyforge_project = 'sexy_settings'
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.required_ruby_version = '>= 2.2.2'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency 'rspec', '~>3.5'
|
21
21
|
s.add_development_dependency('rake')
|
22
22
|
s.add_development_dependency('yard')
|
23
|
+
s.add_development_dependency('rubocop')
|
23
24
|
end
|
data/spec/_config/config.yaml
CHANGED
@@ -14,3 +14,10 @@ test2_url: http://${email}@host/wd/hub
|
|
14
14
|
test3_url: http://:${user_pass}@host:80/wd/hub
|
15
15
|
test4_url:
|
16
16
|
test5_url: http://host/wd/hub
|
17
|
+
string: 'default'
|
18
|
+
int: 'default'
|
19
|
+
float: 'default'
|
20
|
+
boolean_true: 'default'
|
21
|
+
boolean_false: 'default'
|
22
|
+
symbol: 'default'
|
23
|
+
reference: 'default'
|
@@ -1,136 +1,228 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
RSpec.describe 'Base' do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
context 'when default and custom settings exists and not blank' do
|
5
|
+
before :all do
|
6
|
+
SexySettings.configure do |config|
|
7
|
+
config.path_to_default_settings =
|
8
|
+
File.expand_path('config.yaml', File.join(File.dirname(__FILE__), '..', '_config'))
|
9
|
+
config.path_to_custom_settings =
|
10
|
+
File.expand_path('overwritten.yaml', File.join(File.dirname(__FILE__), '..', '_config'))
|
11
|
+
config.path_to_project = File.dirname(__FILE__)
|
12
|
+
config.env_variable_with_options = 'OPTIONS'
|
13
|
+
end
|
14
|
+
@original_options = if ENV.key?(SexySettings.configuration.env_variable_with_options)
|
15
|
+
ENV[SexySettings.configuration.env_variable_with_options]
|
16
|
+
else
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
ENV[SexySettings.configuration.env_variable_with_options] = 'console_property=console CONSOLE value'
|
20
|
+
@settings ||= settings
|
13
21
|
end
|
14
|
-
@original_options = if ENV.key?(SexySettings.configuration.env_variable_with_options)
|
15
|
-
ENV[SexySettings.configuration.env_variable_with_options]
|
16
|
-
else
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
ENV[SexySettings.configuration.env_variable_with_options] = 'console_property=console CONSOLE value'
|
20
|
-
@settings ||= settings
|
21
|
-
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
after :all do
|
24
|
+
@original_options = ENV[SexySettings.configuration.env_variable_with_options]
|
25
|
+
unless @original_options
|
26
|
+
ENV[SexySettings.configuration.env_variable_with_options] = @original_options
|
27
|
+
end
|
27
28
|
end
|
28
|
-
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
it 'should be singleton object' do
|
31
|
+
expect(SexySettings::Base.respond_to?(:instance)).to be_truthy
|
32
|
+
expect(SexySettings::Base.instance).to be_a(SexySettings::Base)
|
33
|
+
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
it 'should have getter for default setting' do
|
36
|
+
expect(@settings).to be_respond_to(:default)
|
37
|
+
expected_default_settings = {
|
38
|
+
'default_property' => 'default DEFAULT value',
|
39
|
+
'overwritten_property' => 'default OVERWRITTEN value',
|
40
|
+
'console_property' => 'default CONSOLE value'
|
41
|
+
}
|
42
|
+
expect(@settings.default).to include(expected_default_settings)
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
it 'should have getter for custom setting' do
|
46
|
+
expect(@settings).to be_respond_to(:default)
|
47
|
+
expected_custom_settings = {
|
48
|
+
'overwritten_property' => 'overwritten OVERWRITTEN value',
|
49
|
+
'console_property' => 'overwritten CONSOLE value'
|
50
|
+
}
|
51
|
+
expect(@settings.custom).to eq(expected_custom_settings)
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
it 'should have getter for all setting' do
|
55
|
+
expect(@settings).to be_respond_to(:default)
|
56
|
+
expected_all_settings = {
|
57
|
+
'default_property' => 'default DEFAULT value',
|
58
|
+
'overwritten_property' => 'overwritten OVERWRITTEN value',
|
59
|
+
'console_property' => 'console CONSOLE value'
|
60
|
+
}
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
expect(@settings.all).to include(expected_all_settings)
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
it 'should return specified pretty formatted settings for output' do
|
66
|
+
# rubocop:disable Lint/EmptyInterpolation
|
67
|
+
# rubocop:disable Lint/EmptyExpression
|
68
|
+
# rubocop:disable Style/IndentHeredoc
|
69
|
+
expected = <<-TXT
|
68
70
|
#######################################################
|
69
71
|
# All Settings #
|
70
72
|
#######################################################
|
71
73
|
|
72
74
|
api_key = ********2333
|
73
75
|
api_token = ********23ef
|
76
|
+
boolean_false = default
|
77
|
+
boolean_true = default
|
74
78
|
console_property = console CONSOLE value
|
75
79
|
default_property = default DEFAULT value
|
76
80
|
email = user@example.com
|
81
|
+
float = default
|
82
|
+
int = default
|
77
83
|
my_secret = ********vqww
|
78
84
|
overwritten_property = overwritten OVERWRITTEN value
|
79
85
|
pass = ********
|
80
86
|
passenger_name = Ivan Petrov
|
81
87
|
password_confirmation = ********pass
|
88
|
+
reference = default
|
89
|
+
string = default
|
90
|
+
symbol = default
|
82
91
|
test1_url = http://********.com:********orld@host:80/wd/hub
|
83
92
|
test2_url = http://********.com@host/wd/hub
|
84
93
|
test3_url = http://********:********orld@host:80/wd/hub
|
85
94
|
test4_url = #{}
|
86
95
|
test5_url = http://host/wd/hub
|
87
96
|
user_pass = ********orld
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
context 'command line' do
|
94
|
-
let(:clone_settings) { settings.class.clone.instance }
|
95
|
-
before do
|
96
|
-
SexySettings.configure.env_variable_with_options = 'SEXY_SETTINGS'
|
97
|
-
ENV['SEXY_SETTINGS'] = 'string=Test, int=1, float=1.09, boolean_true=true,' \
|
98
|
-
' boolean_false=false, symbol=:foo, reference = ${string}'
|
97
|
+
TXT
|
98
|
+
# rubocop:enable Lint/EmptyInterpolation
|
99
|
+
# rubocop:enable Lint/EmptyExpression
|
100
|
+
# rubocop:enable Style/IndentHeredoc
|
101
|
+
expect(@settings.as_formatted_text).to eq(expected)
|
99
102
|
end
|
100
103
|
|
101
|
-
|
102
|
-
|
104
|
+
context 'command line' do
|
105
|
+
let(:clone_settings) { settings.class.clone.instance }
|
106
|
+
before do
|
107
|
+
SexySettings.configure.env_variable_with_options = 'SEXY_SETTINGS'
|
108
|
+
ENV['SEXY_SETTINGS'] = 'string=Test, int=1, float=1.09, boolean_true=true,' \
|
109
|
+
' boolean_false=false, symbol=:foo, reference = ${string}'
|
110
|
+
end
|
111
|
+
|
112
|
+
after do
|
113
|
+
SexySettings.configure.env_variable_with_options = 'OPTIONS'
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should convert command line string value to String type' do
|
117
|
+
expect(clone_settings.string).to eq('Test')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should convert command line integer value to Integer type' do
|
121
|
+
expect(clone_settings.int).to eq(1)
|
122
|
+
expect(clone_settings.int).to be_a(Integer)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should convert command line float value to Float type' do
|
126
|
+
expect(clone_settings.float).to eq(1.09)
|
127
|
+
expect(clone_settings.float.class).to eq(Float)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should convert command line true value to TrueClass type' do
|
131
|
+
expect(clone_settings.boolean_true).to be_truthy
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should convert command line false value to FalseClass type' do
|
135
|
+
expect(clone_settings.boolean_false).to be_falsy
|
136
|
+
expect(clone_settings.boolean_false.class).to eq(FalseClass)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should convert command line symbol value to Symbol type' do
|
140
|
+
expect(clone_settings.symbol).to eq(:foo)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should replace command line reference to correct value' do
|
144
|
+
expect(clone_settings.reference).to eq('Test')
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when some settings without defaults' do
|
148
|
+
before do
|
149
|
+
ENV['SEXY_SETTINGS'] = 'options_without_default1=1, options_without_default2=2'
|
150
|
+
end
|
151
|
+
it 'raises error related with missing default settings' do
|
152
|
+
file = File.expand_path('config.yaml', File.join(File.dirname(__FILE__), '..', '_config'))
|
153
|
+
expect { clone_settings }.to raise_error(
|
154
|
+
SexySettings::MissingDefaultError,
|
155
|
+
"Please specify defaults in '#{file}' config file:\n" \
|
156
|
+
"\t\toptions_without_default1: someValue\n" \
|
157
|
+
"\t\toptions_without_default2: someValue"
|
158
|
+
)
|
159
|
+
end
|
160
|
+
end
|
103
161
|
end
|
104
162
|
|
105
|
-
|
106
|
-
|
163
|
+
context 'when unknown setting name' do
|
164
|
+
let(:clone_settings) { settings.class.clone.instance }
|
165
|
+
it 'raise undefined method error' do
|
166
|
+
expect { clone_settings.emial }.to raise_error(
|
167
|
+
NoMethodError,
|
168
|
+
/undefined method `emial' for SexySettings::Base:#{clone_settings.class}/
|
169
|
+
)
|
170
|
+
end
|
107
171
|
end
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
172
|
+
end
|
173
|
+
context 'when missing default settings' do
|
174
|
+
let(:klass) { SexySettings::Base.clone }
|
175
|
+
let(:default_path) { File.expand_path('missing_config.yaml', File.join(File.dirname(__FILE__), '..', '_config')) }
|
176
|
+
let(:custom_path) { File.expand_path('overwritten.yaml', File.join(File.dirname(__FILE__), '..', '_config')) }
|
177
|
+
before do
|
178
|
+
SexySettings.configure do |config|
|
179
|
+
config.path_to_default_settings = default_path
|
180
|
+
config.path_to_custom_settings = custom_path
|
181
|
+
config.path_to_project = File.dirname(__FILE__)
|
182
|
+
end
|
112
183
|
end
|
113
184
|
|
114
|
-
it '
|
115
|
-
expect
|
116
|
-
|
185
|
+
it 'raise error' do
|
186
|
+
expect { klass.instance }.to raise_error(
|
187
|
+
Errno::ENOENT,
|
188
|
+
"No such file or directory @ rb_sysopen - #{default_path}"
|
189
|
+
)
|
117
190
|
end
|
191
|
+
end
|
118
192
|
|
119
|
-
|
120
|
-
|
193
|
+
context 'when missing custom settings' do
|
194
|
+
let(:klass) { SexySettings::Base.clone }
|
195
|
+
let(:default_path) { File.expand_path('config.yaml', File.join(File.dirname(__FILE__), '..', '_config')) }
|
196
|
+
let(:custom_path) { File.expand_path('missing_custom.yaml', File.join(File.dirname(__FILE__), '..', '_config')) }
|
197
|
+
before do
|
198
|
+
SexySettings.configure do |config|
|
199
|
+
config.path_to_default_settings = default_path
|
200
|
+
config.path_to_custom_settings = custom_path
|
201
|
+
config.path_to_project = File.dirname(__FILE__)
|
202
|
+
end
|
121
203
|
end
|
122
204
|
|
123
|
-
it '
|
124
|
-
expect(
|
125
|
-
expect(clone_settings.boolean_false.class).to eq(FalseClass)
|
205
|
+
it 'returns blank custom settings' do
|
206
|
+
expect(klass.instance.custom).to eq({})
|
126
207
|
end
|
208
|
+
end
|
127
209
|
|
128
|
-
|
129
|
-
|
210
|
+
context 'when blank settings' do
|
211
|
+
let(:klass) { SexySettings::Base.clone }
|
212
|
+
let(:default_path) { File.expand_path('blank_default.yml', File.join(File.dirname(__FILE__), '..', '_config')) }
|
213
|
+
let(:custom_path) { File.expand_path('blank_custom.yml', File.join(File.dirname(__FILE__), '..', '_config')) }
|
214
|
+
before do
|
215
|
+
SexySettings.configure do |config|
|
216
|
+
config.path_to_default_settings = default_path
|
217
|
+
config.path_to_custom_settings = custom_path
|
218
|
+
config.path_to_project = File.dirname(__FILE__)
|
219
|
+
config.env_variable_with_options = 'OPTS'
|
220
|
+
end
|
130
221
|
end
|
131
222
|
|
132
|
-
it '
|
133
|
-
expect(
|
223
|
+
it 'returns blank default and custom settings' do
|
224
|
+
expect(klass.instance.default).to eq({})
|
225
|
+
expect(klass.instance.custom).to eq({})
|
134
226
|
end
|
135
227
|
end
|
136
228
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sexy_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Parashchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Library for flexible specifying of application settings different ways
|
56
70
|
email:
|
57
71
|
- romikoops1@gmail.com
|
@@ -72,10 +86,13 @@ files:
|
|
72
86
|
- lib/sexy_settings/base.rb
|
73
87
|
- lib/sexy_settings/configuration.rb
|
74
88
|
- lib/sexy_settings/core.rb
|
89
|
+
- lib/sexy_settings/exceptions.rb
|
75
90
|
- lib/sexy_settings/printable.rb
|
76
91
|
- lib/sexy_settings/sensitive_data_protector.rb
|
77
92
|
- lib/sexy_settings/version.rb
|
78
93
|
- sexy_settings.gemspec
|
94
|
+
- spec/_config/blank_custom.yml
|
95
|
+
- spec/_config/blank_default.yml
|
79
96
|
- spec/_config/config.yaml
|
80
97
|
- spec/_config/overwritten.yaml
|
81
98
|
- spec/sexy_settings/base_spec.rb
|
@@ -84,7 +101,8 @@ files:
|
|
84
101
|
- spec/sexy_settings/version_spec.rb
|
85
102
|
- spec/spec_helper.rb
|
86
103
|
homepage: https://github.com/romikoops/sexy_settings
|
87
|
-
licenses:
|
104
|
+
licenses:
|
105
|
+
- MIT
|
88
106
|
metadata: {}
|
89
107
|
post_install_message:
|
90
108
|
rdoc_options: []
|
@@ -94,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
112
|
requirements:
|
95
113
|
- - ">="
|
96
114
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
115
|
+
version: 2.2.2
|
98
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
117
|
requirements:
|
100
118
|
- - ">="
|
@@ -102,11 +120,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
120
|
version: '0'
|
103
121
|
requirements: []
|
104
122
|
rubyforge_project: sexy_settings
|
105
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.11
|
106
124
|
signing_key:
|
107
125
|
specification_version: 4
|
108
126
|
summary: Flexible specifying of application settings
|
109
127
|
test_files:
|
128
|
+
- spec/_config/blank_custom.yml
|
129
|
+
- spec/_config/blank_default.yml
|
110
130
|
- spec/_config/config.yaml
|
111
131
|
- spec/_config/overwritten.yaml
|
112
132
|
- spec/sexy_settings/base_spec.rb
|
@@ -114,3 +134,4 @@ test_files:
|
|
114
134
|
- spec/sexy_settings/core_spec.rb
|
115
135
|
- spec/sexy_settings/version_spec.rb
|
116
136
|
- spec/spec_helper.rb
|
137
|
+
has_rdoc:
|