fedux_org-stdlib 0.7.21 → 0.7.22
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/.rubocop.yml +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -19
- data/Rakefile +16 -0
- data/config/rubocop/exclude.yml +44 -0
- data/config/rubocop/include.yml +0 -0
- data/fedux_org-stdlib.gemspec +9 -9
- data/fixtures/plugin-load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-load.gemspec +11 -11
- data/fixtures/plugin-no_load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-no_load.gemspec +11 -11
- data/lib/fedux_org_stdlib.rb +2 -1
- data/lib/fedux_org_stdlib/app_config.rb +22 -21
- data/lib/fedux_org_stdlib/colors/html_color.rb +8 -2
- data/lib/fedux_org_stdlib/command.rb +1 -0
- data/lib/fedux_org_stdlib/command/command_result.rb +1 -0
- data/lib/fedux_org_stdlib/command/run_command.rb +6 -5
- data/lib/fedux_org_stdlib/command/which.rb +17 -17
- data/lib/fedux_org_stdlib/core_ext/array/list.rb +6 -1
- data/lib/fedux_org_stdlib/core_ext/hash/list.rb +6 -1
- data/lib/fedux_org_stdlib/core_ext/hash/options.rb +1 -0
- data/lib/fedux_org_stdlib/core_ext/shellwords/clean.rb +8 -0
- data/lib/fedux_org_stdlib/core_ext/string/underline.rb +9 -1
- data/lib/fedux_org_stdlib/environment.rb +6 -4
- data/lib/fedux_org_stdlib/file_template.rb +8 -10
- data/lib/fedux_org_stdlib/filesystem.rb +30 -29
- data/lib/fedux_org_stdlib/filesystem/exceptions.rb +1 -1
- data/lib/fedux_org_stdlib/gem_plugins/exceptions.rb +1 -0
- data/lib/fedux_org_stdlib/gem_plugins/no_plugin.rb +1 -2
- data/lib/fedux_org_stdlib/gem_plugins/plugin.rb +6 -6
- data/lib/fedux_org_stdlib/gem_plugins/plugin_manager.rb +6 -7
- data/lib/fedux_org_stdlib/list.rb +24 -2
- data/lib/fedux_org_stdlib/logging.rb +3 -2
- data/lib/fedux_org_stdlib/logging/logger.rb +7 -7
- data/lib/fedux_org_stdlib/logging/severity.rb +3 -0
- data/lib/fedux_org_stdlib/logic_converters.rb +1 -0
- data/lib/fedux_org_stdlib/logic_converters/exceptions.rb +2 -2
- data/lib/fedux_org_stdlib/logic_converters/logic_converter.rb +9 -8
- data/lib/fedux_org_stdlib/logic_converters/on_off_converter.rb +5 -4
- data/lib/fedux_org_stdlib/logic_converters/true_false_converter.rb +3 -3
- data/lib/fedux_org_stdlib/logic_converters/y_n_converter.rb +3 -3
- data/lib/fedux_org_stdlib/logic_converters/yes_no_converter.rb +4 -3
- data/lib/fedux_org_stdlib/models/base_model.rb +24 -25
- data/lib/fedux_org_stdlib/models/class_based_model.rb +15 -14
- data/lib/fedux_org_stdlib/models/exceptions.rb +14 -15
- data/lib/fedux_org_stdlib/models/filesystem_based_model.rb +12 -15
- data/lib/fedux_org_stdlib/process_environment.rb +11 -1
- data/lib/fedux_org_stdlib/project.rb +0 -1
- data/lib/fedux_org_stdlib/project/generators/taskjuggler.rb +11 -10
- data/lib/fedux_org_stdlib/project/logger.rb +1 -0
- data/lib/fedux_org_stdlib/project/plan.rb +1 -1
- data/lib/fedux_org_stdlib/project/report.rb +8 -9
- data/lib/fedux_org_stdlib/rake/project.rb +4 -4
- data/lib/fedux_org_stdlib/rake/project_task.rb +2 -3
- data/lib/fedux_org_stdlib/rake/shell_task.rb +7 -7
- data/lib/fedux_org_stdlib/rake/sub_task.rb +2 -2
- data/lib/fedux_org_stdlib/rake/task.rb +7 -6
- data/lib/fedux_org_stdlib/rake/version_bump_task.rb +6 -7
- data/lib/fedux_org_stdlib/rake_tasks/console.rb +0 -1
- data/lib/fedux_org_stdlib/rake_tasks/documentation/yard.rb +2 -2
- data/lib/fedux_org_stdlib/rake_tasks/gems/bundler.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/gems/package.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/project/report/generate.rb +1 -2
- data/lib/fedux_org_stdlib/rake_tasks/project/report/open.rb +1 -2
- data/lib/fedux_org_stdlib/rake_tasks/project/report/open_shortcut.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/qa/rubocop.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/qa/travis.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/software_version/bump.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/software_version/restore.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/software_version/show.rb +2 -3
- data/lib/fedux_org_stdlib/rake_tasks/software_version/show_shortcut.rb +1 -1
- data/lib/fedux_org_stdlib/rake_tasks/tests/cucumber.rb +0 -1
- data/lib/fedux_org_stdlib/rake_tasks/tests/travis.rb +1 -1
- data/lib/fedux_org_stdlib/require_files.rb +5 -4
- data/lib/fedux_org_stdlib/roles/typable.rb +2 -3
- data/lib/fedux_org_stdlib/roles/versionable.rb +3 -2
- data/lib/fedux_org_stdlib/shell_language_detector.rb +21 -2
- data/lib/fedux_org_stdlib/shell_language_detector/language.rb +9 -1
- data/lib/fedux_org_stdlib/support_information.rb +60 -55
- data/lib/fedux_org_stdlib/template_directory.rb +8 -11
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/lib/fedux_org_stdlib/version_management/library_builder.rb +3 -2
- data/lib/fedux_org_stdlib/version_management/ruby_library.rb +2 -2
- data/lib/fedux_org_stdlib/version_management/rubygem_version_file.rb +3 -3
- data/lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb +5 -5
- data/lib/fedux_org_stdlib/version_management/software_version.rb +4 -3
- data/lib/fedux_org_stdlib/version_management/version_builder.rb +1 -0
- data/rakefiles/default.rake +16 -0
- data/script/terminal +5 -5
- data/spec/app_config_spec.rb +6 -6
- data/spec/colors/html_color_spec.rb +1 -1
- data/spec/core_ext/array/list_spec.rb +8 -8
- data/spec/core_ext/hash/options_spec.rb +17 -17
- data/spec/core_ext/shellwords/clean_spec.rb +1 -1
- data/spec/environment_spec.rb +7 -5
- data/spec/examples/models/class_based/invalid_2.rb +1 -1
- data/spec/examples/models/class_based/valid_2.rb +1 -0
- data/spec/gem_plugins/plugin_manager_spec.rb +1 -1
- data/spec/logger/logger_spec.rb +1 -1
- data/spec/models/base_model_spec.rb +22 -22
- data/spec/models/class_based_model_spec.rb +66 -66
- data/spec/models/filesystem_based_model_spec.rb +28 -28
- data/spec/project/plan_spec.rb +1 -1
- data/spec/project/report_spec.rb +2 -2
- data/spec/project/taskjuggler_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -3
- data/spec/support/rspec.rb +1 -1
- data/spec/version_management/library_builder_spec.rb +2 -2
- data/spec/version_management/ruby_library_spec.rb +2 -2
- data/spec/version_management/rubygem_version_file_parser_spec.rb +8 -8
- data/spec/version_management/rubygem_version_file_spec.rb +8 -8
- data/spec/version_management/software_version_spec.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0e131c91284b360c65ea622094b771f1dd4ffef
|
|
4
|
+
data.tar.gz: 60c302269d7ac280cb6be8369e5408aa78b3caf6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 440e5a6eb063a5348a4f4f60fdb5854abb1a0e27c52bfe6e409c428c910e702706b8ea30ed0cd33dfdff8b4f483856068190556b9fe9aeeb2b2a301dfef65bcf
|
|
7
|
+
data.tar.gz: ba554cb16232d30f1f0c42d93a643267342089b67ee084470062b31076a4f84095ec2a5c5e179a78438e05e1400f6c33fdccb930accef6637cb79cde83f9d4fa
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fedux_org-stdlib (0.7.
|
|
4
|
+
fedux_org-stdlib (0.7.21)
|
|
5
5
|
activesupport
|
|
6
6
|
|
|
7
7
|
PATH
|
|
@@ -30,12 +30,15 @@ GEM
|
|
|
30
30
|
cucumber (>= 1.1.1)
|
|
31
31
|
rspec-expectations (>= 2.7.0)
|
|
32
32
|
ast (2.0.0)
|
|
33
|
+
astrolabe (1.3.0)
|
|
34
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
|
33
35
|
awesome_print (1.2.0)
|
|
34
36
|
blockenspiel (0.4.5)
|
|
35
37
|
builder (3.2.2)
|
|
36
|
-
byebug (
|
|
37
|
-
columnize (~> 0.
|
|
38
|
+
byebug (3.4.0)
|
|
39
|
+
columnize (~> 0.8)
|
|
38
40
|
debugger-linecache (~> 1.2)
|
|
41
|
+
slop (~> 3.6)
|
|
39
42
|
childprocess (0.5.3)
|
|
40
43
|
ffi (~> 1.0, >= 1.0.11)
|
|
41
44
|
coderay (1.1.0)
|
|
@@ -60,7 +63,7 @@ GEM
|
|
|
60
63
|
diff-lcs (1.2.5)
|
|
61
64
|
docile (1.1.5)
|
|
62
65
|
erubis (2.7.0)
|
|
63
|
-
facter (2.
|
|
66
|
+
facter (2.2.0)
|
|
64
67
|
CFPropertyList (~> 2.2.6)
|
|
65
68
|
ffi (1.9.3)
|
|
66
69
|
filegen (0.4.3)
|
|
@@ -81,7 +84,7 @@ GEM
|
|
|
81
84
|
mime-types (>= 1.16, < 3)
|
|
82
85
|
method_source (0.8.2)
|
|
83
86
|
mime-types (2.3)
|
|
84
|
-
minitest (5.4.
|
|
87
|
+
minitest (5.4.1)
|
|
85
88
|
multi_json (1.10.1)
|
|
86
89
|
multi_test (0.1.1)
|
|
87
90
|
netrc (0.7.7)
|
|
@@ -94,8 +97,8 @@ GEM
|
|
|
94
97
|
coderay (~> 1.1.0)
|
|
95
98
|
method_source (~> 0.8.1)
|
|
96
99
|
slop (~> 3.4)
|
|
97
|
-
pry-byebug (
|
|
98
|
-
byebug (~>
|
|
100
|
+
pry-byebug (2.0.0)
|
|
101
|
+
byebug (~> 3.4)
|
|
99
102
|
pry (~> 0.10)
|
|
100
103
|
pry-doc (0.6.0)
|
|
101
104
|
pry (~> 0.9)
|
|
@@ -106,22 +109,23 @@ GEM
|
|
|
106
109
|
rest-client (1.7.2)
|
|
107
110
|
mime-types (>= 1.16, < 3.0)
|
|
108
111
|
netrc (~> 0.7)
|
|
109
|
-
rspec (3.
|
|
110
|
-
rspec-core (~> 3.
|
|
111
|
-
rspec-expectations (~> 3.
|
|
112
|
-
rspec-mocks (~> 3.
|
|
113
|
-
rspec-core (3.
|
|
114
|
-
rspec-support (~> 3.
|
|
115
|
-
rspec-expectations (3.0
|
|
112
|
+
rspec (3.1.0)
|
|
113
|
+
rspec-core (~> 3.1.0)
|
|
114
|
+
rspec-expectations (~> 3.1.0)
|
|
115
|
+
rspec-mocks (~> 3.1.0)
|
|
116
|
+
rspec-core (3.1.2)
|
|
117
|
+
rspec-support (~> 3.1.0)
|
|
118
|
+
rspec-expectations (3.1.0)
|
|
116
119
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
117
|
-
rspec-support (~> 3.
|
|
120
|
+
rspec-support (~> 3.1.0)
|
|
118
121
|
rspec-legacy_formatters (1.0.0)
|
|
119
122
|
rspec-core (>= 3.0.0.beta2)
|
|
120
123
|
rspec-support (>= 3.0.0.beta2)
|
|
121
|
-
rspec-mocks (3.0
|
|
122
|
-
rspec-support (~> 3.
|
|
123
|
-
rspec-support (3.0
|
|
124
|
-
rubocop (0.
|
|
124
|
+
rspec-mocks (3.1.0)
|
|
125
|
+
rspec-support (~> 3.1.0)
|
|
126
|
+
rspec-support (3.1.0)
|
|
127
|
+
rubocop (0.26.0)
|
|
128
|
+
astrolabe (~> 1.3)
|
|
125
129
|
parser (>= 2.2.0.pre.4, < 3.0)
|
|
126
130
|
powerpack (~> 0.0.6)
|
|
127
131
|
rainbow (>= 1.99.1, < 3.0)
|
data/Rakefile
CHANGED
|
@@ -8,3 +8,19 @@ desc 'Show help for rake'
|
|
|
8
8
|
task :default do
|
|
9
9
|
sh 'bundle exec rake -T'
|
|
10
10
|
end
|
|
11
|
+
|
|
12
|
+
desc 'Run test suite'
|
|
13
|
+
task test: ['test:rubocop', 'test:rspec']
|
|
14
|
+
|
|
15
|
+
namespace :test do
|
|
16
|
+
desc 'Test with coveralls'
|
|
17
|
+
task coveralls: ['test', 'coveralls:push']
|
|
18
|
+
|
|
19
|
+
require 'rubocop/rake_task'
|
|
20
|
+
RuboCop::RakeTask.new
|
|
21
|
+
|
|
22
|
+
desc 'Run rspec'
|
|
23
|
+
task :rspec do
|
|
24
|
+
sh 'bundle exec rspec'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- spec/examples/**/*.rb
|
|
4
|
+
|
|
5
|
+
# Offense count: 230
|
|
6
|
+
# Configuration parameters: AllowURI.
|
|
7
|
+
Metrics/LineLength:
|
|
8
|
+
Max: 331
|
|
9
|
+
Enabled: false
|
|
10
|
+
|
|
11
|
+
## Offense count: 55
|
|
12
|
+
Style/Documentation:
|
|
13
|
+
Exclude:
|
|
14
|
+
- spec/**/*.rb
|
|
15
|
+
- fixtures/**/*.rb
|
|
16
|
+
|
|
17
|
+
# Offense count: 1
|
|
18
|
+
# Configuration parameters: CountComments.
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 136
|
|
21
|
+
|
|
22
|
+
# Offense count: 5
|
|
23
|
+
Metrics/CyclomaticComplexity:
|
|
24
|
+
Max: 14
|
|
25
|
+
|
|
26
|
+
# Offense count: 19
|
|
27
|
+
# Configuration parameters: CountComments.
|
|
28
|
+
Metrics/MethodLength:
|
|
29
|
+
Max: 38
|
|
30
|
+
|
|
31
|
+
# Offense count: 1
|
|
32
|
+
# Configuration parameters: CountKeywordArgs.
|
|
33
|
+
Metrics/ParameterLists:
|
|
34
|
+
Max: 7
|
|
35
|
+
|
|
36
|
+
# Offense count: 3
|
|
37
|
+
Metrics/PerceivedComplexity:
|
|
38
|
+
Max: 14
|
|
39
|
+
|
|
40
|
+
## Offense count: 1
|
|
41
|
+
## Cop supports --auto-correct.
|
|
42
|
+
## Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
|
|
43
|
+
#Style/TrivialAccessors:
|
|
44
|
+
# Enabled: false
|
|
File without changes
|
data/fedux_org-stdlib.gemspec
CHANGED
|
@@ -4,17 +4,17 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'fedux_org_stdlib/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
7
|
+
spec.name = 'fedux_org-stdlib'
|
|
8
8
|
spec.version = FeduxOrgStdlib::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
11
|
-
spec.summary =
|
|
12
|
-
spec.homepage =
|
|
13
|
-
spec.license =
|
|
9
|
+
spec.authors = ['Max Meyer']
|
|
10
|
+
spec.email = ['dev@fedux.org']
|
|
11
|
+
spec.summary = 'Collection of useful libraries. It maybe depend on external libraries.'
|
|
12
|
+
spec.homepage = ''
|
|
13
|
+
spec.license = 'MIT'
|
|
14
14
|
|
|
15
|
-
spec.files = `git ls-files`.split(
|
|
16
|
-
spec.executables = spec.files.grep(
|
|
17
|
-
spec.test_files = spec.files.grep(
|
|
15
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
16
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
|
17
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
|
18
18
|
spec.require_paths = ['lib']
|
|
19
19
|
|
|
20
20
|
spec.required_ruby_version = '>= 2.1.0'
|
|
@@ -3,19 +3,19 @@ lib = File.expand_path('../lib', __FILE__)
|
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
6
|
+
spec.name = 'fedux_org_stdlib-fixtures-plugin_manager-plugin-load'
|
|
7
7
|
spec.version = '0.0.1'
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
10
|
-
spec.summary =
|
|
11
|
-
spec.homepage =
|
|
12
|
-
spec.license =
|
|
8
|
+
spec.authors = ['Blub']
|
|
9
|
+
spec.email = ['email@example.com']
|
|
10
|
+
spec.summary = 'Summary'
|
|
11
|
+
spec.homepage = ''
|
|
12
|
+
spec.license = 'MIT'
|
|
13
13
|
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0")
|
|
15
|
-
spec.executables = spec.files.grep(
|
|
16
|
-
spec.test_files = spec.files.grep(
|
|
17
|
-
spec.require_paths = [
|
|
15
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
|
16
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
|
17
|
+
spec.require_paths = ['lib']
|
|
18
18
|
|
|
19
|
-
spec.add_development_dependency
|
|
20
|
-
spec.add_development_dependency
|
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
21
21
|
end
|
data/fixtures/plugin-no_load-app/fedux_org_stdlib-fixtures-plugin_manager-plugin-no_load.gemspec
CHANGED
|
@@ -3,19 +3,19 @@ lib = File.expand_path('../lib', __FILE__)
|
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
6
|
+
spec.name = 'fedux_org_stdlib-fixtures-plugin_manager-plugin-no_load'
|
|
7
7
|
spec.version = '0.0.1'
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
10
|
-
spec.summary =
|
|
11
|
-
spec.homepage =
|
|
12
|
-
spec.license =
|
|
8
|
+
spec.authors = ['blub']
|
|
9
|
+
spec.email = ['example@email.com']
|
|
10
|
+
spec.summary = 'Summary'
|
|
11
|
+
spec.homepage = ''
|
|
12
|
+
spec.license = 'MIT'
|
|
13
13
|
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0")
|
|
15
|
-
spec.executables = spec.files.grep(
|
|
16
|
-
spec.test_files = spec.files.grep(
|
|
17
|
-
spec.require_paths = [
|
|
15
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
|
16
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
|
17
|
+
spec.require_paths = ['lib']
|
|
18
18
|
|
|
19
|
-
spec.add_development_dependency
|
|
20
|
-
spec.add_development_dependency
|
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
21
21
|
end
|
data/lib/fedux_org_stdlib.rb
CHANGED
|
@@ -6,8 +6,9 @@ require 'fedux_org_stdlib/logic_converters'
|
|
|
6
6
|
require 'fedux_org_stdlib/models'
|
|
7
7
|
require 'fedux_org_stdlib/version'
|
|
8
8
|
|
|
9
|
+
# Main
|
|
9
10
|
module FeduxOrgStdlib
|
|
10
11
|
def self.root_directory
|
|
11
|
-
File.expand_path(
|
|
12
|
+
File.expand_path('../../..', __FILE__)
|
|
12
13
|
end
|
|
13
14
|
end
|
|
@@ -5,7 +5,7 @@ require 'fedux_org_stdlib/process_environment'
|
|
|
5
5
|
require 'fedux_org_stdlib/core_ext/array/list'
|
|
6
6
|
require 'fedux_org_stdlib/core_ext/hash/list'
|
|
7
7
|
require 'fedux_org_stdlib/logging/logger'
|
|
8
|
-
require_library %w
|
|
8
|
+
require_library %w(json psych active_support/core_ext/string/inflections set active_support/core_ext/hash/slice active_support/core_ext/object/blank active_support/core_ext/hash/keys)
|
|
9
9
|
|
|
10
10
|
module FeduxOrgStdlib
|
|
11
11
|
# This class makes a config file available as an object. The config file
|
|
@@ -31,7 +31,7 @@ module FeduxOrgStdlib
|
|
|
31
31
|
# off, e.g "ClientConfig" becomes "clients.yaml" (mind the pluralized name)
|
|
32
32
|
#
|
|
33
33
|
# Most conventions defined by me are implemented as separate methods. If one convention
|
|
34
|
-
# is not suitable for your use case, just overwrite the method.
|
|
34
|
+
# is not suitable for your use case, just overwrite the method.
|
|
35
35
|
#
|
|
36
36
|
# If you prefer to use a different path to the config file or name of the
|
|
37
37
|
# config file one of the following methods needs to be overwritten:
|
|
@@ -70,7 +70,6 @@ module FeduxOrgStdlib
|
|
|
70
70
|
# option1: 'data2'
|
|
71
71
|
class AppConfig
|
|
72
72
|
class << self
|
|
73
|
-
|
|
74
73
|
# @api private
|
|
75
74
|
def known_options
|
|
76
75
|
@options ||= Set.new
|
|
@@ -104,7 +103,7 @@ module FeduxOrgStdlib
|
|
|
104
103
|
_config.fetch(option, default_value)
|
|
105
104
|
end
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
known_options << option
|
|
108
107
|
end
|
|
109
108
|
|
|
110
109
|
# Define a writer for option
|
|
@@ -131,7 +130,7 @@ module FeduxOrgStdlib
|
|
|
131
130
|
end
|
|
132
131
|
end
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
known_options << option
|
|
135
134
|
end
|
|
136
135
|
|
|
137
136
|
# Define a writer and a reader for option
|
|
@@ -150,9 +149,11 @@ module FeduxOrgStdlib
|
|
|
150
149
|
private
|
|
151
150
|
|
|
152
151
|
# Holds the config
|
|
152
|
+
# rubocop:disable Style/TrivialAccessors
|
|
153
153
|
def _config
|
|
154
154
|
@__config
|
|
155
155
|
end
|
|
156
|
+
# rubocop:enable Style/TrivialAccessors
|
|
156
157
|
|
|
157
158
|
public
|
|
158
159
|
|
|
@@ -178,9 +179,9 @@ module FeduxOrgStdlib
|
|
|
178
179
|
# @return [AppConfig]
|
|
179
180
|
# The config instance. If the resulting data structure created by the
|
|
180
181
|
# config_engine does not respond to `:[]` an empty config object will be
|
|
181
|
-
# created.
|
|
182
|
+
# created.
|
|
182
183
|
def initialize(
|
|
183
|
-
file: _available_config_file,
|
|
184
|
+
file: _available_config_file,
|
|
184
185
|
config_engine: Psych,
|
|
185
186
|
logger: FeduxOrgStdlib::Logging::Logger.new,
|
|
186
187
|
check_unknown_options: true
|
|
@@ -188,24 +189,24 @@ module FeduxOrgStdlib
|
|
|
188
189
|
@logger = logger
|
|
189
190
|
|
|
190
191
|
unless file
|
|
191
|
-
logger.debug "No configuration file found at #{_allowed_config_file_paths.to_list}, therefor I'm going to use an empty config object instead."
|
|
192
|
+
logger.debug "No configuration file found at #{_allowed_config_file_paths.to_list}, therefor I'm going to use an empty config object instead."
|
|
192
193
|
@__config = {}
|
|
193
194
|
|
|
194
|
-
return
|
|
195
|
+
return
|
|
195
196
|
end
|
|
196
197
|
|
|
197
198
|
begin
|
|
198
|
-
yaml =
|
|
199
|
+
yaml = config_engine.safe_load(File.read(file), [Symbol])
|
|
199
200
|
rescue StandardError => e
|
|
200
|
-
|
|
201
|
+
raise Exceptions::ConfigFileNotReadable, JSON.dump(message: e.message, file: file)
|
|
201
202
|
end
|
|
202
203
|
|
|
203
204
|
if yaml.blank?
|
|
204
205
|
@__config = {}
|
|
205
|
-
elsif yaml.
|
|
206
|
+
elsif yaml.is_a? Hash
|
|
206
207
|
yaml = yaml.deep_symbolize_keys
|
|
207
208
|
|
|
208
|
-
yaml_withknown_options = yaml.deep_symbolize_keys.slice(*
|
|
209
|
+
yaml_withknown_options = yaml.deep_symbolize_keys.slice(*known_options)
|
|
209
210
|
unknown_options = yaml.keys - yaml_withknown_options.keys
|
|
210
211
|
|
|
211
212
|
logger.warn "Unknown config options #{(unknown_options).to_list} in config file #{file} detected. Please define them in your config class or remove the entries in your config file or disable check via `check_unknown_options: false` to get rid of this warning." unless unknown_options.blank? && check_unknown_options == true
|
|
@@ -233,11 +234,11 @@ module FeduxOrgStdlib
|
|
|
233
234
|
# An formatted version of the configuration
|
|
234
235
|
def to_s
|
|
235
236
|
# header 'length' = 6 letters
|
|
236
|
-
length = self.class.known_options.
|
|
237
|
+
length = self.class.known_options.reduce(6) { |a, e| e.size > a ? e.size : a }
|
|
237
238
|
|
|
238
239
|
result = []
|
|
239
|
-
result <<
|
|
240
|
-
result <<
|
|
240
|
+
result << format("%#{length}s | %s", 'option', 'value')
|
|
241
|
+
result << format('%s + %s', '-' * length, '-' * 80)
|
|
241
242
|
|
|
242
243
|
self.class.known_options.each do |o|
|
|
243
244
|
value = public_send(o)
|
|
@@ -252,7 +253,7 @@ module FeduxOrgStdlib
|
|
|
252
253
|
Array(value)
|
|
253
254
|
end
|
|
254
255
|
|
|
255
|
-
result <<
|
|
256
|
+
result << format("%#{length}s | %s", o, value.to_list)
|
|
256
257
|
end
|
|
257
258
|
|
|
258
259
|
result.join("\n")
|
|
@@ -300,7 +301,7 @@ module FeduxOrgStdlib
|
|
|
300
301
|
unless (name = _class_name.sub(/Config/, '').underscore.pluralize).blank?
|
|
301
302
|
return name
|
|
302
303
|
end
|
|
303
|
-
|
|
304
|
+
|
|
304
305
|
fail Exceptions::ClassNameIsMissing, JSON.dump(klass: _class_name)
|
|
305
306
|
end
|
|
306
307
|
|
|
@@ -346,13 +347,13 @@ module FeduxOrgStdlib
|
|
|
346
347
|
end
|
|
347
348
|
|
|
348
349
|
def _available_config_file
|
|
349
|
-
_allowed_config_file_paths.find { |f| ::File.
|
|
350
|
+
_allowed_config_file_paths.find { |f| ::File.exist? f }
|
|
350
351
|
end
|
|
351
352
|
|
|
352
353
|
def self._reserved_key_words
|
|
353
|
-
(methods | instance_methods | private_methods | private_instance_methods
|
|
354
|
+
(methods | instance_methods | private_methods | private_instance_methods) - (Class.methods | Class.private_methods) | [:to_s]
|
|
354
355
|
end
|
|
355
|
-
|
|
356
|
+
|
|
356
357
|
def method_missing(*args, &block)
|
|
357
358
|
$stderr.puts "Please check if you have defined an option for #{args.first}."
|
|
358
359
|
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
module FeduxOrgStdlib
|
|
3
3
|
module Colors
|
|
4
|
+
# HTML color
|
|
5
|
+
#
|
|
6
|
+
# Helps you to check if given string is a valid html color
|
|
4
7
|
class HtmlColor
|
|
5
8
|
# @param [String] color
|
|
6
9
|
# string in the html color format
|
|
7
|
-
def initialize(
|
|
8
|
-
@color
|
|
10
|
+
def initialize(color)
|
|
11
|
+
@color = color
|
|
9
12
|
@validator_regex = /^#[a-f0-9]{6}$/
|
|
10
13
|
end
|
|
11
14
|
|
|
15
|
+
# Is color valid?
|
|
12
16
|
# @return [true,false] color string is valid
|
|
13
17
|
def valid?
|
|
18
|
+
# rubocop:disable Style/CaseEquality
|
|
14
19
|
@validator_regex === @color
|
|
20
|
+
# rubocop:enable Style/CaseEquality
|
|
15
21
|
end
|
|
16
22
|
end
|
|
17
23
|
end
|