fedux_org-stdlib 0.7.33 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fedux_org_stdlib/config_directory/exceptions.rb +15 -0
- data/lib/fedux_org_stdlib/config_directory.rb +148 -0
- data/lib/fedux_org_stdlib/config_file/exceptions.rb +15 -0
- data/lib/fedux_org_stdlib/config_file.rb +168 -0
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/spec/config_directory_spec.rb +126 -0
- data/spec/config_file_spec.rb +126 -0
- data/spec/gem_plugins/plugin_manager_spec.rb +9 -14
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba0a7408d790446d802807ca52a3f5ef8e3f81a
|
4
|
+
data.tar.gz: 870ffc809e5ea3e9ff10c5950d2825b0a0245ee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a82ec771eaf3053241133c98b5a186096888b0b94d0e4f470800d310d2444faa6863db872d8f4112ec78e74c93c966b0b5b1074e4f536f6e20d68871bdfd01d
|
7
|
+
data.tar.gz: 3f6e181070c4e31b9bf8953b44ddeebe91e3fbaa0057af16c04c71bd14383c590b92a90a6c911c7e62eef687e06c09d1b70865d053c2846758bcd8a67f19aa3d
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module FeduxOrgStdlib
|
3
|
+
class ExternalConfigDirectory
|
4
|
+
module Exceptions
|
5
|
+
# No allowed config file could be found
|
6
|
+
class NoConfigDirectoryFound < StandardError; end
|
7
|
+
|
8
|
+
# If no module is given on class
|
9
|
+
class NamespaceIsMissing < StandardError; end
|
10
|
+
|
11
|
+
# If no class name is present
|
12
|
+
class ClassNameIsMissing < StandardError; end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'fedux_org_stdlib/require_files'
|
3
|
+
require 'fedux_org_stdlib/config_directory/exceptions'
|
4
|
+
require 'fedux_org_stdlib/logging/logger'
|
5
|
+
require_library %w(json 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)
|
6
|
+
|
7
|
+
module FeduxOrgStdlib
|
8
|
+
# This class detects the file name for an config file. By default it will
|
9
|
+
# look for a suitable config file in the given order:
|
10
|
+
#
|
11
|
+
# 1. $HOME/.config/<application_name>/<config_directory>
|
12
|
+
# 2. $HOME/.<application_name>/<config_directory>
|
13
|
+
# 2. $HOME/.<config_directory>
|
14
|
+
# 3. /etc/.<application_name>/<config_directory>
|
15
|
+
#
|
16
|
+
# Please keep in mind
|
17
|
+
#
|
18
|
+
# * application_name: Module of your class, e.g. "MyApplication" becomes
|
19
|
+
# "my_application"
|
20
|
+
# * config_directory: Pluarized name of your class and "Config" strip
|
21
|
+
# off, e.g "ClientConfig" becomes "clients.yaml" (mind the pluralized name)
|
22
|
+
#
|
23
|
+
# Most conventions defined by me are implemented as separate methods. If one convention
|
24
|
+
# is not suitable for your use case, just overwrite the method.
|
25
|
+
#
|
26
|
+
# If you prefer to use a different path to the config file or name of the
|
27
|
+
# config file one of the following methods needs to be overwritten:
|
28
|
+
#
|
29
|
+
# * config_directory
|
30
|
+
# * config_name
|
31
|
+
# * application_name
|
32
|
+
#
|
33
|
+
# If you want the class to look for your config file at a different place
|
34
|
+
# overwrite the following method
|
35
|
+
#
|
36
|
+
# * allowed_config_directory_paths
|
37
|
+
#
|
38
|
+
# Below you find some examples for the usage of the class:
|
39
|
+
#
|
40
|
+
# @example Create config with one writer and reader
|
41
|
+
# module MyApplication
|
42
|
+
# class ClientConfig < ConfigDirectory
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
class ConfigDirectory
|
46
|
+
# Create a new instance of config
|
47
|
+
#
|
48
|
+
# It tries to find a suitable configuration file. If it doesn't find one
|
49
|
+
# the config is empty and uses the defaults defined within a config class
|
50
|
+
#
|
51
|
+
# @param [String] file
|
52
|
+
# Path where config file is stored. The file will be read by the
|
53
|
+
# `config_engine`.
|
54
|
+
#
|
55
|
+
# @raise [Exceptions::ConfigFileNotReadable]
|
56
|
+
# If an avaiable config file could not be read by the config engine
|
57
|
+
#
|
58
|
+
# @return [ConfigDirectory]
|
59
|
+
# The config instance. If the resulting data structure created by the
|
60
|
+
# config_engine does not respond to `:[]` an empty config object will be
|
61
|
+
# created.
|
62
|
+
|
63
|
+
attr_reader :directory, :logger
|
64
|
+
|
65
|
+
def initialize(
|
66
|
+
logger: FeduxOrgStdlib::Logging::Logger.new,
|
67
|
+
directory: _available_config_directory
|
68
|
+
)
|
69
|
+
@logger = logger
|
70
|
+
@directory = directory
|
71
|
+
|
72
|
+
unless directory
|
73
|
+
logger.debug "No configuration directory found at #{_allowed_config_directory_paths.to_list}, therefor I'm going to use an empty config object instead."
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Return the path to the preferred configuration file
|
78
|
+
# @return [String]
|
79
|
+
# The path to the preferred configuration file
|
80
|
+
def preferred_configuration_directory
|
81
|
+
_allowed_config_directory_paths.first
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
# The base name of the config
|
87
|
+
#
|
88
|
+
# @return [String]
|
89
|
+
# This one returns the base name of the config file (without the file
|
90
|
+
# extension). It uses the class name of the config class
|
91
|
+
#
|
92
|
+
# @example Determine the base name of the config
|
93
|
+
#
|
94
|
+
# class ClientConfig; end
|
95
|
+
#
|
96
|
+
# This will result in `client` as base name for the config file.
|
97
|
+
def _config_directory
|
98
|
+
unless (name = _class_name.sub(/Config/, '').underscore.pluralize).blank?
|
99
|
+
return name
|
100
|
+
end
|
101
|
+
|
102
|
+
fail Exceptions::ClassNameIsMissing, JSON.dump(klass: _class_name)
|
103
|
+
end
|
104
|
+
|
105
|
+
# The name of your application
|
106
|
+
#
|
107
|
+
# @return [String]
|
108
|
+
# This will strip of the class part of fully qualified class name and
|
109
|
+
# converted it to a path.
|
110
|
+
#
|
111
|
+
# @example Determine application name
|
112
|
+
#
|
113
|
+
# class MyApplication::MyConfig; end
|
114
|
+
#
|
115
|
+
# This will be converted to
|
116
|
+
#
|
117
|
+
# my_application
|
118
|
+
def _application_name
|
119
|
+
_module_name.underscore
|
120
|
+
end
|
121
|
+
|
122
|
+
# The paths where to look for the config file
|
123
|
+
#
|
124
|
+
# @return [Array]
|
125
|
+
# A list of paths where the config object should look for its config
|
126
|
+
# file.
|
127
|
+
def _allowed_config_directory_paths
|
128
|
+
[
|
129
|
+
::File.expand_path(::File.join('~', '.config', _application_name, _config_directory)),
|
130
|
+
::File.expand_path(::File.join('~', format('.%s', _application_name), _config_directory)),
|
131
|
+
::File.expand_path(::File.join('~', format('.%s', _config_directory))),
|
132
|
+
::File.expand_path(::File.join('/etc', _application_name, _config_directory)),
|
133
|
+
]
|
134
|
+
end
|
135
|
+
|
136
|
+
def _class_name
|
137
|
+
self.class.name.to_s.demodulize
|
138
|
+
end
|
139
|
+
|
140
|
+
def _module_name
|
141
|
+
self.class.to_s.deconstantize
|
142
|
+
end
|
143
|
+
|
144
|
+
def _available_config_directory
|
145
|
+
_allowed_config_directory_paths.find { |f| ::File.directory? f }
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module FeduxOrgStdlib
|
3
|
+
class ConfigFile
|
4
|
+
module Exceptions
|
5
|
+
# No allowed config file could be found
|
6
|
+
class NoConfigFileFound < StandardError; end
|
7
|
+
|
8
|
+
# If no module is given on class
|
9
|
+
class NamespaceIsMissing < StandardError; end
|
10
|
+
|
11
|
+
# If no class name is present
|
12
|
+
class ClassNameIsMissing < StandardError; end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'fedux_org_stdlib/require_files'
|
3
|
+
require 'fedux_org_stdlib/config_file/exceptions'
|
4
|
+
require 'fedux_org_stdlib/logging/logger'
|
5
|
+
require_library %w(json 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)
|
6
|
+
|
7
|
+
module FeduxOrgStdlib
|
8
|
+
# This class detects the file name for an config file. By default it will
|
9
|
+
# look for a suitable config file in the given order:
|
10
|
+
#
|
11
|
+
# 1. $HOME/.config/<application_name>/<config_file>.yaml
|
12
|
+
# 2. $HOME/.<application_name>/<config_file>.yaml
|
13
|
+
# 2. $HOME/.<config_file>.yaml
|
14
|
+
# 2. $HOME/.<config_file>rc
|
15
|
+
# 3. /etc/.<application_name>/<config_file>.yaml
|
16
|
+
#
|
17
|
+
# Please keep in mind
|
18
|
+
#
|
19
|
+
# * application_name: Module of your class, e.g. "MyApplication" becomes
|
20
|
+
# "my_application"
|
21
|
+
# * config_file: Pluarized name of your class and "Config" strip
|
22
|
+
# off, e.g "ClientConfig" becomes "clients.yaml" (mind the pluralized name)
|
23
|
+
#
|
24
|
+
# Most conventions defined by me are implemented as separate methods. If one convention
|
25
|
+
# is not suitable for your use case, just overwrite the method.
|
26
|
+
#
|
27
|
+
# If you prefer to use a different path to the config file or name of the
|
28
|
+
# config file one of the following methods needs to be overwritten:
|
29
|
+
#
|
30
|
+
# * config_file
|
31
|
+
# * config_name
|
32
|
+
# * application_name
|
33
|
+
#
|
34
|
+
# If you want the class to look for your config file at a different place
|
35
|
+
# overwrite the following method
|
36
|
+
#
|
37
|
+
# * allowed_config_file_paths
|
38
|
+
#
|
39
|
+
# Below you find some examples for the usage of the class:
|
40
|
+
#
|
41
|
+
# @example Create config with one writer and reader
|
42
|
+
# module MyApplication
|
43
|
+
# class ClientConfig < ConfigFile
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
class ConfigFile
|
47
|
+
# Create a new instance of config
|
48
|
+
#
|
49
|
+
# It tries to find a suitable configuration file. If it doesn't find one
|
50
|
+
# the config is empty and uses the defaults defined within a config class
|
51
|
+
#
|
52
|
+
# @param [String] file
|
53
|
+
# Path where config file is stored. The file will be read by the
|
54
|
+
# `config_engine`.
|
55
|
+
#
|
56
|
+
# @raise [Exceptions::ConfigFileNotReadable]
|
57
|
+
# If an avaiable config file could not be read by the config engine
|
58
|
+
#
|
59
|
+
# @return [ConfigFile]
|
60
|
+
# The config instance. If the resulting data structure created by the
|
61
|
+
# config_engine does not respond to `:[]` an empty config object will be
|
62
|
+
# created.
|
63
|
+
|
64
|
+
attr_reader :file, :logger
|
65
|
+
|
66
|
+
def initialize(
|
67
|
+
logger: FeduxOrgStdlib::Logging::Logger.new,
|
68
|
+
file: _available_config_file
|
69
|
+
)
|
70
|
+
@logger = logger
|
71
|
+
@file = file
|
72
|
+
|
73
|
+
unless file
|
74
|
+
logger.debug "No configuration file found at #{_allowed_config_file_paths.to_list}, therefor I'm going to use an empty config object instead."
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Return the path to the preferred configuration file
|
79
|
+
# @return [String]
|
80
|
+
# The path to the preferred configuration file
|
81
|
+
def preferred_configuration_file
|
82
|
+
_allowed_config_file_paths.first
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
# The name of the config file
|
88
|
+
#
|
89
|
+
# @return [String]
|
90
|
+
# The name of the config file. It defaults to `<config_name>.yaml`. If
|
91
|
+
# you want to use a different file name you need to overwrite this
|
92
|
+
# method.
|
93
|
+
def _config_file
|
94
|
+
"#{_config_name}#{_config_file_suffix}"
|
95
|
+
end
|
96
|
+
|
97
|
+
# The suffix of the config file
|
98
|
+
#
|
99
|
+
# @return [String]
|
100
|
+
# The suffix of the config file
|
101
|
+
def _config_file_suffix
|
102
|
+
'.yaml'
|
103
|
+
end
|
104
|
+
|
105
|
+
# The base name of the config
|
106
|
+
#
|
107
|
+
# @return [String]
|
108
|
+
# This one returns the base name of the config file (without the file
|
109
|
+
# extension). It uses the class name of the config class
|
110
|
+
#
|
111
|
+
# @example Determine the base name of the config
|
112
|
+
#
|
113
|
+
# class ClientConfig; end
|
114
|
+
#
|
115
|
+
# This will result in `client` as base name for the config file.
|
116
|
+
def _config_name
|
117
|
+
unless (name = _class_name.sub(/Config/, '').underscore.pluralize).blank?
|
118
|
+
return name
|
119
|
+
end
|
120
|
+
|
121
|
+
fail Exceptions::ClassNameIsMissing, JSON.dump(klass: _class_name)
|
122
|
+
end
|
123
|
+
|
124
|
+
# The name of your application
|
125
|
+
#
|
126
|
+
# @return [String]
|
127
|
+
# This will strip of the class part of fully qualified class name and
|
128
|
+
# converted it to a path.
|
129
|
+
#
|
130
|
+
# @example Determine application name
|
131
|
+
#
|
132
|
+
# class MyApplication::MyConfig; end
|
133
|
+
#
|
134
|
+
# This will be converted to
|
135
|
+
#
|
136
|
+
# my_application
|
137
|
+
def _application_name
|
138
|
+
_module_name.underscore
|
139
|
+
end
|
140
|
+
|
141
|
+
# The paths where to look for the config file
|
142
|
+
#
|
143
|
+
# @return [Array]
|
144
|
+
# A list of paths where the config object should look for its config
|
145
|
+
# file.
|
146
|
+
def _allowed_config_file_paths
|
147
|
+
[
|
148
|
+
::File.expand_path(::File.join('~', '.config', _application_name, _config_file)),
|
149
|
+
::File.expand_path(::File.join('~', format('.%s', _application_name), _config_file)),
|
150
|
+
::File.expand_path(::File.join('~', format('.%s', _config_file))),
|
151
|
+
::File.expand_path(::File.join('~', format('.%src', _config_name))),
|
152
|
+
::File.expand_path(::File.join('/etc', _application_name, _config_file)),
|
153
|
+
]
|
154
|
+
end
|
155
|
+
|
156
|
+
def _class_name
|
157
|
+
self.class.name.to_s.demodulize
|
158
|
+
end
|
159
|
+
|
160
|
+
def _module_name
|
161
|
+
self.class.to_s.deconstantize
|
162
|
+
end
|
163
|
+
|
164
|
+
def _available_config_file
|
165
|
+
_allowed_config_file_paths.find { |f| ::File.exist? f }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'fedux_org_stdlib/config_directory'
|
4
|
+
|
5
|
+
RSpec.describe ConfigDirectory do
|
6
|
+
|
7
|
+
context '#preferred_configuration_file' do
|
8
|
+
it 'has a default configuration file which is the preferred place to store the configuration' do
|
9
|
+
with_env 'HOME' => absolute_path('.') do
|
10
|
+
config_klass = Class.new(ConfigDirectory) do
|
11
|
+
|
12
|
+
def _class_name
|
13
|
+
'TestConfig'
|
14
|
+
end
|
15
|
+
|
16
|
+
def _module_name
|
17
|
+
'MyApplication'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
config = config_klass.new
|
22
|
+
expect(config.preferred_configuration_directory).to eq File.expand_path('~/.config/my_application/tests')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works with nested module names' do
|
27
|
+
with_env 'HOME' => absolute_path('.') do
|
28
|
+
config_klass = Class.new(ConfigDirectory) do
|
29
|
+
|
30
|
+
def _class_name
|
31
|
+
'TestConfig'
|
32
|
+
end
|
33
|
+
|
34
|
+
def _module_name
|
35
|
+
'MyApplication::MySub'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
config = config_klass.new
|
40
|
+
expect(config.preferred_configuration_directory).to eq File.expand_path('~/.config/my_application/my_sub/tests')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'config files' do
|
46
|
+
it 'looks at ~/.test.yaml' do
|
47
|
+
with_env 'HOME' => absolute_path('.') do
|
48
|
+
create_dir '.tests'
|
49
|
+
|
50
|
+
config_klass = Class.new(ConfigDirectory) do
|
51
|
+
|
52
|
+
def _class_name
|
53
|
+
'TestConfig'
|
54
|
+
end
|
55
|
+
|
56
|
+
def _module_name
|
57
|
+
'MyApplication'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
config = config_klass.new
|
62
|
+
expect(config.directory).to eq absolute_path('.tests')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'looks at ~/.config/my_application/tests.yaml' do
|
67
|
+
with_env 'HOME' => absolute_path('.') do
|
68
|
+
create_dir '.config/my_application/tests'
|
69
|
+
|
70
|
+
config_klass = Class.new(ConfigDirectory) do
|
71
|
+
|
72
|
+
def _class_name
|
73
|
+
'TestConfig'
|
74
|
+
end
|
75
|
+
|
76
|
+
def _module_name
|
77
|
+
'MyApplication'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
config = config_klass.new
|
82
|
+
expect(config.directory).to eq absolute_path('.config/my_application/tests')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'looks at ~/.my_application/tests.yaml' do
|
87
|
+
with_env 'HOME' => absolute_path('.') do
|
88
|
+
create_dir '.my_application/tests'
|
89
|
+
|
90
|
+
config_klass = Class.new(ConfigDirectory) do
|
91
|
+
|
92
|
+
def _class_name
|
93
|
+
'TestConfig'
|
94
|
+
end
|
95
|
+
|
96
|
+
def _module_name
|
97
|
+
'MyApplication'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
config = config_klass.new
|
102
|
+
expect(config.directory).to eq absolute_path('.my_application/tests')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'looks at ~/.tests' do
|
107
|
+
with_env 'HOME' => absolute_path('.') do
|
108
|
+
create_dir '.tests'
|
109
|
+
|
110
|
+
config_klass = Class.new(ConfigDirectory) do
|
111
|
+
|
112
|
+
def _class_name
|
113
|
+
'TestConfig'
|
114
|
+
end
|
115
|
+
|
116
|
+
def _module_name
|
117
|
+
'MyApplication'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
config = config_klass.new
|
122
|
+
expect(config.directory).to eq absolute_path('.tests')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'fedux_org_stdlib/config_file'
|
4
|
+
|
5
|
+
RSpec.describe ConfigFile do
|
6
|
+
|
7
|
+
context '#preferred_configuration_file' do
|
8
|
+
it 'has a default configuration file which is the preferred place to store the configuration' do
|
9
|
+
with_env 'HOME' => absolute_path('.') do
|
10
|
+
config_klass = Class.new(ConfigFile) do
|
11
|
+
|
12
|
+
def _class_name
|
13
|
+
'TestConfig'
|
14
|
+
end
|
15
|
+
|
16
|
+
def _module_name
|
17
|
+
'MyApplication'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
config = config_klass.new
|
22
|
+
expect(config.preferred_configuration_file).to eq File.expand_path('~/.config/my_application/tests.yaml')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works with nested module names' do
|
27
|
+
with_env 'HOME' => absolute_path('.') do
|
28
|
+
config_klass = Class.new(ConfigFile) do
|
29
|
+
|
30
|
+
def _class_name
|
31
|
+
'TestConfig'
|
32
|
+
end
|
33
|
+
|
34
|
+
def _module_name
|
35
|
+
'MyApplication::MySub'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
config = config_klass.new
|
40
|
+
expect(config.preferred_configuration_file).to eq File.expand_path('~/.config/my_application/my_sub/tests.yaml')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'config files' do
|
46
|
+
it 'looks at ~/.test.yaml' do
|
47
|
+
with_env 'HOME' => absolute_path('.') do
|
48
|
+
touch_file '.tests.yaml'
|
49
|
+
|
50
|
+
config_klass = Class.new(ConfigFile) do
|
51
|
+
|
52
|
+
def _class_name
|
53
|
+
'TestConfig'
|
54
|
+
end
|
55
|
+
|
56
|
+
def _module_name
|
57
|
+
'MyApplication'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
config = config_klass.new
|
62
|
+
expect(config.file).to eq absolute_path('.tests.yaml')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'looks at ~/.config/my_application/tests.yaml' do
|
67
|
+
with_env 'HOME' => absolute_path('.') do
|
68
|
+
touch_file '.config/my_application/tests.yaml'
|
69
|
+
|
70
|
+
config_klass = Class.new(ConfigFile) do
|
71
|
+
|
72
|
+
def _class_name
|
73
|
+
'TestConfig'
|
74
|
+
end
|
75
|
+
|
76
|
+
def _module_name
|
77
|
+
'MyApplication'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
config = config_klass.new
|
82
|
+
expect(config.file).to eq absolute_path('.config/my_application/tests.yaml')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'looks at ~/.my_application/tests.yaml' do
|
87
|
+
with_env 'HOME' => absolute_path('.') do
|
88
|
+
touch_file '.my_application/tests.yaml'
|
89
|
+
|
90
|
+
config_klass = Class.new(ConfigFile) do
|
91
|
+
|
92
|
+
def _class_name
|
93
|
+
'TestConfig'
|
94
|
+
end
|
95
|
+
|
96
|
+
def _module_name
|
97
|
+
'MyApplication'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
config = config_klass.new
|
102
|
+
expect(config.file).to eq absolute_path('.my_application/tests.yaml')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'looks at ~/.testsrc' do
|
107
|
+
with_env 'HOME' => absolute_path('.') do
|
108
|
+
touch_file '.testsrc'
|
109
|
+
|
110
|
+
config_klass = Class.new(ConfigFile) do
|
111
|
+
|
112
|
+
def _class_name
|
113
|
+
'TestConfig'
|
114
|
+
end
|
115
|
+
|
116
|
+
def _module_name
|
117
|
+
'MyApplication'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
config = config_klass.new
|
122
|
+
expect(config.file).to eq absolute_path('.testsrc')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -15,16 +15,11 @@ RSpec.describe GemPlugins::PluginManager do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context '#activate_plugin' do
|
18
|
-
it 'loads available plugins by its name' do
|
19
|
-
FeduxOrgStdlib::Fixtures::PluginManager::Load::PluginManager.new
|
20
|
-
|
21
|
-
expect('FeduxOrgStdlib::Fixtures::PluginManager::Plugin::Load').not_to be_defined
|
22
|
-
end
|
23
|
-
|
24
18
|
it 'loads available plugins only on request' do
|
25
19
|
manager = FeduxOrgStdlib::Fixtures::PluginManager::Load::PluginManager.new
|
26
|
-
|
20
|
+
expect('FeduxOrgStdlib::Fixtures::PluginManager::Plugin::Load').not_to be_defined
|
27
21
|
|
22
|
+
manager.activate_plugin 'fedux_org_stdlib-fixtures-plugin_manager-load'
|
28
23
|
expect('FeduxOrgStdlib::Fixtures::PluginManager::Plugin::Load').to be_defined
|
29
24
|
end
|
30
25
|
end
|
@@ -39,12 +34,12 @@ RSpec.describe GemPlugins::PluginManager do
|
|
39
34
|
expect(result).to include 'plugin-blub'
|
40
35
|
end
|
41
36
|
|
42
|
-
context '#to_s' do
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
#context '#to_s' do
|
38
|
+
# it 'has a string representation' do
|
39
|
+
# manager = FeduxOrgStdlib::Fixtures::PluginManager::Load::PluginManager.new
|
40
|
+
# manager.activate_plugin 'fedux_org_stdlib-fixtures-plugin_manager-load'
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
42
|
+
# expect(manager.to_s).to include '1 row in set'
|
43
|
+
# end
|
44
|
+
#end
|
50
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedux_org-stdlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -62,6 +62,10 @@ files:
|
|
62
62
|
- lib/fedux_org_stdlib/command/command_result.rb
|
63
63
|
- lib/fedux_org_stdlib/command/run_command.rb
|
64
64
|
- lib/fedux_org_stdlib/command/which.rb
|
65
|
+
- lib/fedux_org_stdlib/config_directory.rb
|
66
|
+
- lib/fedux_org_stdlib/config_directory/exceptions.rb
|
67
|
+
- lib/fedux_org_stdlib/config_file.rb
|
68
|
+
- lib/fedux_org_stdlib/config_file/exceptions.rb
|
65
69
|
- lib/fedux_org_stdlib/core_ext/array.rb
|
66
70
|
- lib/fedux_org_stdlib/core_ext/array/list.rb
|
67
71
|
- lib/fedux_org_stdlib/core_ext/hash.rb
|
@@ -166,6 +170,8 @@ files:
|
|
166
170
|
- spec/colors/html_color_spec.rb
|
167
171
|
- spec/command/run_command_spec.rb
|
168
172
|
- spec/command/which_spec.rb
|
173
|
+
- spec/config_directory_spec.rb
|
174
|
+
- spec/config_file_spec.rb
|
169
175
|
- spec/core_ext/array/list_spec.rb
|
170
176
|
- spec/core_ext/hash/list_spec.rb
|
171
177
|
- spec/core_ext/hash/options_spec.rb
|
@@ -245,6 +251,8 @@ test_files:
|
|
245
251
|
- spec/colors/html_color_spec.rb
|
246
252
|
- spec/command/run_command_spec.rb
|
247
253
|
- spec/command/which_spec.rb
|
254
|
+
- spec/config_directory_spec.rb
|
255
|
+
- spec/config_file_spec.rb
|
248
256
|
- spec/core_ext/array/list_spec.rb
|
249
257
|
- spec/core_ext/hash/list_spec.rb
|
250
258
|
- spec/core_ext/hash/options_spec.rb
|