fedux_org-stdlib 0.8.5 → 0.8.6
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/Gemfile.lock +1 -1
- data/lib/fedux_org_stdlib/directory_finder.rb +8 -5
- data/lib/fedux_org_stdlib/file_finder.rb +8 -5
- data/lib/fedux_org_stdlib/list.rb +2 -2
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/spec/file_finder_spec.rb +22 -0
- data/spec/list_spec.rb +1 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba82feafa5550f36fd7ba991c3fd85ba99331b9e
|
|
4
|
+
data.tar.gz: 3df271871db5706484768718d5f3c32d935b9b24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 653eb6a33b47bd9e1880a56957e8cde7e0b4e680a1da7e40f4edfef65c9b349f925411483267a8d3ea229845ddef10ee4083245801d91b6200ff39ab56e1ec2e
|
|
7
|
+
data.tar.gz: 833c25664b34a57fc52cc32f177e6928a995873de88b6ee3f71807e96747f706a3fb4d107cd51e75465083a4da5d9a9dd0c97547caa2a10d2ddbf43ba3c644ff
|
data/Gemfile.lock
CHANGED
|
@@ -60,14 +60,16 @@ module FeduxOrgStdlib
|
|
|
60
60
|
# config_engine does not respond to `:[]` an empty config object will be
|
|
61
61
|
# created.
|
|
62
62
|
|
|
63
|
-
attr_reader :directory, :logger
|
|
63
|
+
attr_reader :directory, :logger, :working_directory
|
|
64
64
|
|
|
65
65
|
def initialize(
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
directory: nil,
|
|
67
|
+
working_directory: Dir.getwd,
|
|
68
|
+
logger: FeduxOrgStdlib::Logging::Logger.new
|
|
68
69
|
)
|
|
69
|
-
@logger
|
|
70
|
-
@
|
|
70
|
+
@logger = logger
|
|
71
|
+
@working_directory = working_directory
|
|
72
|
+
@directory ||= (directory || _available_config_directory)
|
|
71
73
|
|
|
72
74
|
unless directory
|
|
73
75
|
logger.debug "No configuration directory found at #{_allowed_config_directory_paths.to_list}, therefor I'm going to use an empty config object instead."
|
|
@@ -130,6 +132,7 @@ module FeduxOrgStdlib
|
|
|
130
132
|
::File.expand_path(::File.join('~', format('.%s', _application_name), _config_directory)),
|
|
131
133
|
::File.expand_path(::File.join('~', format('.%s', _config_directory))),
|
|
132
134
|
::File.expand_path(::File.join('/etc', _application_name, _config_directory)),
|
|
135
|
+
::File.expand_path(::File.join(working_directory, _config_directory))
|
|
133
136
|
]
|
|
134
137
|
end
|
|
135
138
|
|
|
@@ -61,14 +61,16 @@ module FeduxOrgStdlib
|
|
|
61
61
|
# config_engine does not respond to `:[]` an empty config object will be
|
|
62
62
|
# created.
|
|
63
63
|
|
|
64
|
-
attr_reader :file, :logger
|
|
64
|
+
attr_reader :file, :logger, :working_directory
|
|
65
65
|
|
|
66
66
|
def initialize(
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
file: nil,
|
|
68
|
+
working_directory: Dir.getwd,
|
|
69
|
+
logger: FeduxOrgStdlib::Logging::Logger.new
|
|
69
70
|
)
|
|
70
|
-
@logger
|
|
71
|
-
@
|
|
71
|
+
@logger = logger
|
|
72
|
+
@working_directory = working_directory
|
|
73
|
+
@file ||= (file || _available_config_file)
|
|
72
74
|
|
|
73
75
|
unless file
|
|
74
76
|
logger.debug "No configuration file found at #{_allowed_config_file_paths.to_list}, therefor I'm going to use an empty config object instead."
|
|
@@ -150,6 +152,7 @@ module FeduxOrgStdlib
|
|
|
150
152
|
::File.expand_path(::File.join('~', format('.%s', _config_file))),
|
|
151
153
|
::File.expand_path(::File.join('~', format('.%src', _config_name))),
|
|
152
154
|
::File.expand_path(::File.join('/etc', _application_name, _config_file)),
|
|
155
|
+
::File.expand_path(::File.join(working_directory, _config_file))
|
|
153
156
|
]
|
|
154
157
|
end
|
|
155
158
|
|
|
@@ -36,8 +36,8 @@ module FeduxOrgStdlib
|
|
|
36
36
|
#
|
|
37
37
|
# @param [Hash] options
|
|
38
38
|
# Options which are supported by Hirb
|
|
39
|
-
def to_s(
|
|
40
|
-
Hirb::Helpers::Table.render data, header_filter: proc(&:humanize),
|
|
39
|
+
def to_s(**options)
|
|
40
|
+
Hirb::Helpers::Table.render data, header_filter: proc(&:humanize), **options
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Data as array
|
data/spec/file_finder_spec.rb
CHANGED
|
@@ -42,6 +42,28 @@ RSpec.describe FileFinder do
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
context 'config files' do
|
|
45
|
+
it 'looks at $PWD/test.yaml' do
|
|
46
|
+
touch_file 'test.yaml'
|
|
47
|
+
|
|
48
|
+
config = nil
|
|
49
|
+
|
|
50
|
+
in_current_dir do
|
|
51
|
+
config_klass = Class.new(FileFinder) do
|
|
52
|
+
def _class_name
|
|
53
|
+
'TestFile'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def _module_name
|
|
57
|
+
'MyApplication'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
config = config_klass.new
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
expect(config.file).to eq absolute_path('test.yaml')
|
|
65
|
+
end
|
|
66
|
+
|
|
45
67
|
it 'looks at ~/.test.yaml' do
|
|
46
68
|
with_env 'HOME' => absolute_path('.') do
|
|
47
69
|
touch_file '.test.yaml'
|
data/spec/list_spec.rb
CHANGED
|
@@ -31,10 +31,7 @@ RSpec.describe List do
|
|
|
31
31
|
it 'passes options to table helper' do
|
|
32
32
|
list = List.new(name: 'user1', age: 30)
|
|
33
33
|
expect_result = <<-EOS.strip_heredoc
|
|
34
|
-
|
|
35
|
-
Age: 30
|
|
36
|
-
Name: user1
|
|
37
|
-
1 row in set
|
|
34
|
+
****** 1. row ******
|
|
38
35
|
EOS
|
|
39
36
|
|
|
40
37
|
expect(list.to_s(style: :vertical)).to include expect_result
|