eac_tools 0.41.0 → 0.42.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/Gemfile.lock +23 -23
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +4 -4
- data/sub/avm/lib/avm/applications/base.rb +24 -3
- data/sub/avm/lib/avm/entries/entry.rb +5 -0
- data/sub/avm/lib/avm/instances/base.rb +5 -12
- data/sub/avm/lib/avm/instances/ids.rb +30 -0
- data/sub/avm/lib/avm/rspec/setup.rb +8 -0
- data/sub/avm/lib/avm/sources/base/instance.rb +2 -14
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm/spec/spec_helper.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/avm-eac_asciidoctor_base0.gemspec +1 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/base.rb +18 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_macro_value.rb +59 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/pre_process_line.rb +50 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/{sources → instances}/build/document.rb +11 -11
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/{sources → instances}/build.rb +8 -3
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/deploy.rb +3 -3
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/runners/build.rb +5 -3
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec.rb +32 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build/document_spec_files/pre_processed_root_body.adoc +15 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/instances/build_spec.rb +44 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/doc1.html +0 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/doc2/doc2_1.html +0 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/doc2.html +0 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/{sources → instances}/build_spec_files/index.html +0 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/source_generators/base_spec_files/no_options/content/body.adoc +1 -0
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/base_spec.rb +14 -0
- data/sub/avm-eac_asciidoctor_base0/spec/spec_helper.rb +1 -4
- data/sub/avm-eac_asciidoctor_base0/template/avm/eac_asciidoctor_base0/source_generators/base/content/body.adoc +1 -0
- data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/dependencies.rb +27 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/gemfile_lock.rb +27 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/options.rb +30 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb +52 -0
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base.rb +1 -66
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/sub/avm-eac_ruby_base1/spec/lib/avm/eac_ruby_base1/source_generators/base_spec.rb +2 -1
- data/sub/eac_cli/eac_cli.gemspec +2 -2
- data/sub/eac_cli/lib/eac_cli/config/entry.rb +4 -0
- data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
- data/sub/eac_config/eac_config.gemspec +2 -2
- data/sub/eac_config/lib/eac_config/entry/not_found_error.rb +13 -0
- data/sub/eac_config/lib/eac_config/entry.rb +7 -0
- data/sub/eac_config/lib/eac_config/version.rb +1 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/rspec/setup.rb +9 -0
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider/setting_value.rb +15 -6
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/settings_provider.rb +5 -1
- data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/settings_provider_spec.rb +9 -2
- metadata +27 -29
- data/sub/avm-eac_asciidoctor_base0/spec/lib/avm/eac_asciidoctor_base0/sources/build_spec.rb +0 -32
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/eac_asciidoctor_base0/sources/base'
|
|
4
|
+
require 'avm/eac_asciidoctor_base0/instances/build'
|
|
5
|
+
require 'eac_fs/comparator'
|
|
6
|
+
|
|
7
|
+
::RSpec.describe ::Avm::EacAsciidoctorBase0::Instances::Build do # rubocop:disable Metrics/BlockLength
|
|
8
|
+
let(:application) { ::Avm::Applications::Base.new('myapp') }
|
|
9
|
+
let(:application_instance) do
|
|
10
|
+
::Avm::EacAsciidoctorBase0::Instances::Base
|
|
11
|
+
.new(application, 'stub')
|
|
12
|
+
end
|
|
13
|
+
let(:fixtures_dir) { __dir__.to_pathname.join('build_spec_files') }
|
|
14
|
+
let(:fs_comparator) { ::EacFs::Comparator.new.truncate_file('*.html') }
|
|
15
|
+
let(:instance) { described_class.new(application_instance) }
|
|
16
|
+
let(:source) { avm_source('EacAsciidoctorBase0', target_basename: application.id) }
|
|
17
|
+
let(:target_dir) { fixtures_dir }
|
|
18
|
+
let(:main_document) do
|
|
19
|
+
source.path.join(::Avm::EacAsciidoctorBase0::Sources::Base::MAIN_FILE_SUBPATH)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
before do
|
|
23
|
+
application.entry('stereotype').write('EacAsciidoctorBase0')
|
|
24
|
+
::EacConfig::Node.context.current.entry("#{application.id}_dev.install.path")
|
|
25
|
+
.value = source.path.to_path
|
|
26
|
+
application_instance.entry('install.name').write('The Author')
|
|
27
|
+
application_instance.entry('install.name_initials').write('T.A.')
|
|
28
|
+
application_instance.entry('install.email').write('theauthor@example.net')
|
|
29
|
+
application_instance.entry('web.url').write('https://www.example.net')
|
|
30
|
+
%w[doc1 doc2 doc2/doc2_1].each do |subpath|
|
|
31
|
+
target_dir = source.content_directory.join(subpath)
|
|
32
|
+
target_dir.mkpath
|
|
33
|
+
::FileUtils.cp(
|
|
34
|
+
main_document,
|
|
35
|
+
target_dir.join(::Avm::EacAsciidoctorBase0::Sources::Base::CONTENT_DOCUMENT_BASENAME)
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
instance.perform
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it do
|
|
42
|
+
expect(fs_comparator.build(instance.target_directory)).to eq(fs_comparator.build(target_dir))
|
|
43
|
+
end
|
|
44
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'avm/eac_asciidoctor_base0/instances/base'
|
|
3
4
|
require 'avm/eac_asciidoctor_base0/sources/base'
|
|
4
5
|
|
|
5
6
|
::RSpec.describe ::Avm::EacAsciidoctorBase0::Sources::Base do
|
|
6
7
|
include_examples 'in_avm_registry', 'sources'
|
|
8
|
+
|
|
9
|
+
describe '#instance' do
|
|
10
|
+
let(:application) { ::Avm::Applications::Base.new('myapp') }
|
|
11
|
+
let(:source) { avm_source('EacAsciidoctorBase0', target_basename: application.id) }
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
application.local_source_path_entry.value = source.path
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it do
|
|
18
|
+
expect(source.instance).to be_a(::Avm::EacAsciidoctorBase0::Instances::Base)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
7
21
|
end
|
|
@@ -2,7 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
require 'eac_ruby_utils/rspec/default_setup'
|
|
4
4
|
::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
|
|
5
|
-
|
|
6
|
-
require 'eac_ruby_utils/speaker'
|
|
7
|
-
require 'eac_ruby_utils/rspec/stub_speaker'
|
|
8
|
-
::EacRubyUtils::Speaker.context.push(::EacRubyUtils::Rspec::StubSpeaker.new)
|
|
5
|
+
.stub_avm_contexts
|
|
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
|
|
13
13
|
s.files = Dir['{lib,locale,template}/**/*']
|
|
14
14
|
|
|
15
|
-
s.add_dependency 'avm', '~> 0.
|
|
15
|
+
s.add_dependency 'avm', '~> 0.55'
|
|
16
16
|
s.add_dependency 'avm-eac_generic_base0', '~> 0.8'
|
|
17
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
|
17
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.107'
|
|
18
18
|
|
|
19
19
|
s.add_development_dependency 'aranha-parsers', '~> 0.14', '>= 0.14.1'
|
|
20
20
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/eac_ruby_base1/source_generators/base/version_builder'
|
|
4
|
+
require 'avm/source_generators/base'
|
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
|
6
|
+
|
|
7
|
+
module Avm
|
|
8
|
+
module EacRubyBase1
|
|
9
|
+
module SourceGenerators
|
|
10
|
+
class Base < ::Avm::SourceGenerators::Base
|
|
11
|
+
module Dependencies
|
|
12
|
+
def eac_ruby_gem_support_version
|
|
13
|
+
dependency_version('eac_ruby_gem_support')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def eac_ruby_utils_version
|
|
17
|
+
dependency_version('eac_ruby_utils')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def dependency_version(gem_name)
|
|
21
|
+
::Avm::EacRubyBase1::SourceGenerators::Base::VersionBuilder.new(gem_name, options).to_s
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/eac_ruby_base1/source_generators/base/options'
|
|
4
|
+
require 'avm/source_generators/base'
|
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
|
6
|
+
|
|
7
|
+
module Avm
|
|
8
|
+
module EacRubyBase1
|
|
9
|
+
module SourceGenerators
|
|
10
|
+
class Base < ::Avm::SourceGenerators::Base
|
|
11
|
+
module GemfileLock
|
|
12
|
+
def generate_gemfile_lock
|
|
13
|
+
return unless generate_gemfile_lock?
|
|
14
|
+
|
|
15
|
+
self_gem.bundle('install').chdir_root.execute!
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# @return [Boolean]
|
|
19
|
+
def generate_gemfile_lock?
|
|
20
|
+
options[::Avm::EacRubyBase1::SourceGenerators::Base::Options::GEMFILE_LOCK_OPTION]
|
|
21
|
+
.to_bool
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/source_generators/base'
|
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module EacRubyBase1
|
|
8
|
+
module SourceGenerators
|
|
9
|
+
class Base < ::Avm::SourceGenerators::Base
|
|
10
|
+
module Options
|
|
11
|
+
common_concern
|
|
12
|
+
|
|
13
|
+
GEMFILE_LOCK_OPTION = 'gemfile-lock'.to_sym
|
|
14
|
+
|
|
15
|
+
OPTIONS = {
|
|
16
|
+
'eac-ruby-utils-version'.to_sym => 'Version for "eac_ruby_utils" gem.',
|
|
17
|
+
'eac-ruby-gem-support-version'.to_sym => 'Version for "eac_ruby_gem_support" gem.',
|
|
18
|
+
GEMFILE_LOCK_OPTION => 'Run "bundle install" at the end'
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
module ClassMethods
|
|
22
|
+
def option_list
|
|
23
|
+
OPTIONS.inject(super) { |a, e| a.option(*e) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'avm/source_generators/base'
|
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
|
5
|
+
|
|
6
|
+
module Avm
|
|
7
|
+
module EacRubyBase1
|
|
8
|
+
module SourceGenerators
|
|
9
|
+
class Base < ::Avm::SourceGenerators::Base
|
|
10
|
+
class VersionBuilder
|
|
11
|
+
enable_simple_cache
|
|
12
|
+
common_constructor :gem_name, :options
|
|
13
|
+
|
|
14
|
+
def to_s
|
|
15
|
+
r = "'~> #{two_segments}'"
|
|
16
|
+
r += ", '>= #{three_segments}'" if segments.count >= 3 && segments[2].positive?
|
|
17
|
+
r
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [Gem::Version]
|
|
21
|
+
def version
|
|
22
|
+
(options_version || default_version)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def two_segments
|
|
26
|
+
segments.first(2).join('.')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def three_segments
|
|
30
|
+
segments.first(3).join('.')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def segments_uncached
|
|
36
|
+
version.release.to_s.split('.').map(&:to_i)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def default_version
|
|
40
|
+
::Gem.loaded_specs[gem_name].version
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def options_version
|
|
44
|
+
options["#{gem_name}_version".dasherize.to_sym].if_present do |v|
|
|
45
|
+
::Gem::Version.new(v)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -12,32 +12,15 @@ module Avm
|
|
|
12
12
|
IDENT = ' '
|
|
13
13
|
JOBS = %w[root_directory gemspec root_lib version_lib static gemfile_lock].freeze
|
|
14
14
|
TEMPLATE_VARIABLES = %w[lib_path name root_module].freeze
|
|
15
|
-
OPTIONS = {
|
|
16
|
-
'eac-ruby-utils-version'.to_sym => 'Version for "eac_ruby_utils" gem.',
|
|
17
|
-
'eac-ruby-gem-support-version'.to_sym => 'Version for "eac_ruby_gem_support" gem.'
|
|
18
|
-
}.freeze
|
|
19
15
|
|
|
20
16
|
enable_speaker
|
|
21
17
|
enable_simple_cache
|
|
22
|
-
|
|
23
|
-
class << self
|
|
24
|
-
def option_list
|
|
25
|
-
OPTIONS.inject(super) { |a, e| a.option(*e) }
|
|
26
|
-
end
|
|
27
|
-
end
|
|
18
|
+
require_sub __FILE__, include_modules: true
|
|
28
19
|
|
|
29
20
|
def root_directory
|
|
30
21
|
target_path
|
|
31
22
|
end
|
|
32
23
|
|
|
33
|
-
def eac_ruby_gem_support_version
|
|
34
|
-
dependency_version('eac_ruby_gem_support')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def eac_ruby_utils_version
|
|
38
|
-
dependency_version('eac_ruby_utils')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
24
|
def name
|
|
42
25
|
root_directory.basename.to_s
|
|
43
26
|
end
|
|
@@ -93,18 +76,10 @@ module Avm
|
|
|
93
76
|
end
|
|
94
77
|
end
|
|
95
78
|
|
|
96
|
-
def dependency_version(gem_name)
|
|
97
|
-
VersionBuilder.new(gem_name, options).to_s
|
|
98
|
-
end
|
|
99
|
-
|
|
100
79
|
def generate_gemspec
|
|
101
80
|
template_apply('gemspec', "#{name}.gemspec")
|
|
102
81
|
end
|
|
103
82
|
|
|
104
|
-
def generate_gemfile_lock
|
|
105
|
-
self_gem.bundle('install').chdir_root.execute!
|
|
106
|
-
end
|
|
107
|
-
|
|
108
83
|
def generate_root_directory
|
|
109
84
|
root_directory.mkpath
|
|
110
85
|
end
|
|
@@ -130,46 +105,6 @@ module Avm
|
|
|
130
105
|
target.dirname.mkpath
|
|
131
106
|
template.child("#{from}.template").apply_to_file(self, target.to_path)
|
|
132
107
|
end
|
|
133
|
-
|
|
134
|
-
class VersionBuilder
|
|
135
|
-
enable_simple_cache
|
|
136
|
-
common_constructor :gem_name, :options
|
|
137
|
-
|
|
138
|
-
def to_s
|
|
139
|
-
r = "'~> #{two_segments}'"
|
|
140
|
-
r += ", '>= #{three_segments}'" if segments.count >= 3 && segments[2].positive?
|
|
141
|
-
r
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# @return [Gem::Version]
|
|
145
|
-
def version
|
|
146
|
-
(options_version || default_version)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def two_segments
|
|
150
|
-
segments.first(2).join('.')
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def three_segments
|
|
154
|
-
segments.first(3).join('.')
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
private
|
|
158
|
-
|
|
159
|
-
def segments_uncached
|
|
160
|
-
version.release.to_s.split('.').map(&:to_i)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def default_version
|
|
164
|
-
::Gem.loaded_specs[gem_name].version
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def options_version
|
|
168
|
-
options["#{gem_name}_version".dasherize.to_sym].if_present do |v|
|
|
169
|
-
::Gem::Version.new(v)
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
108
|
end
|
|
174
109
|
end
|
|
175
110
|
end
|
|
@@ -7,7 +7,8 @@ RSpec.describe ::Avm::EacRubyBase1::SourceGenerators::Base do
|
|
|
7
7
|
include_examples 'avm_source_generated', __FILE__, 'EacRubyBase1',
|
|
8
8
|
{
|
|
9
9
|
'eac-ruby-utils-version' => '0.35.0',
|
|
10
|
-
'eac-ruby-gem-support-version' => '0.2.0'
|
|
10
|
+
'eac-ruby-gem-support-version' => '0.2.0',
|
|
11
|
+
'gemfile-lock' => true
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
alias_method :fs_comparator_super, :fs_comparator
|
data/sub/eac_cli/eac_cli.gemspec
CHANGED
|
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.files = Dir['{lib}/**/*', 'Gemfile']
|
|
14
14
|
|
|
15
15
|
s.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
|
|
16
|
-
s.add_dependency 'eac_config', '~> 0.
|
|
17
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
|
16
|
+
s.add_dependency 'eac_config', '~> 0.12'
|
|
17
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.107'
|
|
18
18
|
|
|
19
19
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
|
20
20
|
end
|
|
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
|
|
13
13
|
s.files = Dir['{lib}/**/*']
|
|
14
14
|
|
|
15
|
-
s.add_dependency 'addressable', '~> 2.8'
|
|
16
|
-
s.add_dependency 'eac_ruby_utils', '~> 0.
|
|
15
|
+
s.add_dependency 'addressable', '~> 2.8', '>= 2.8.1'
|
|
16
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.107'
|
|
17
17
|
|
|
18
18
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
|
|
19
19
|
end
|
|
@@ -5,6 +5,7 @@ require 'eac_ruby_utils/core_ext'
|
|
|
5
5
|
|
|
6
6
|
module EacConfig
|
|
7
7
|
class Entry
|
|
8
|
+
require_sub __FILE__
|
|
8
9
|
enable_simple_cache
|
|
9
10
|
common_constructor :root_node, :path do
|
|
10
11
|
self.path = ::EacConfig::EntryPath.assert(path)
|
|
@@ -30,6 +31,12 @@ module EacConfig
|
|
|
30
31
|
node_entry.if_present(&:value)
|
|
31
32
|
end
|
|
32
33
|
|
|
34
|
+
def value!
|
|
35
|
+
return value if found?
|
|
36
|
+
|
|
37
|
+
raise ::EacConfig::Entry::NotFoundError, self
|
|
38
|
+
end
|
|
39
|
+
|
|
33
40
|
def value=(a_value)
|
|
34
41
|
write_node.self_entry(path).value = a_value
|
|
35
42
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
|
4
|
+
require 'eac_ruby_utils/rspec/stub_speaker'
|
|
5
|
+
require 'eac_ruby_utils/speaker'
|
|
4
6
|
|
|
5
7
|
module EacRubyUtils
|
|
6
8
|
module Rspec
|
|
@@ -13,6 +15,13 @@ module EacRubyUtils
|
|
|
13
15
|
obj.rspec_config.setup_manager = obj
|
|
14
16
|
obj.rspec_config.include(::EacRubyUtils::Rspec::Setup::SetupManager)
|
|
15
17
|
end
|
|
18
|
+
|
|
19
|
+
# @return [self]
|
|
20
|
+
def stub_eac_speaker
|
|
21
|
+
::EacRubyUtils::Speaker.context.push(::EacRubyUtils::Rspec::StubSpeaker.new)
|
|
22
|
+
|
|
23
|
+
self
|
|
24
|
+
end
|
|
16
25
|
end
|
|
17
26
|
end
|
|
18
27
|
end
|
|
@@ -28,8 +28,7 @@ module EacRubyUtils
|
|
|
28
28
|
|
|
29
29
|
def value
|
|
30
30
|
parsed_options.order.each do |method|
|
|
31
|
-
|
|
32
|
-
return value if value
|
|
31
|
+
return send("value_by_#{method}") if send("value_by_#{method}?")
|
|
33
32
|
end
|
|
34
33
|
return parsed_options.default if parsed_options.respond_to?(OPTION_DEFAULT)
|
|
35
34
|
return nil unless parsed_options.required
|
|
@@ -39,16 +38,26 @@ module EacRubyUtils
|
|
|
39
38
|
|
|
40
39
|
def value_by_constant
|
|
41
40
|
source.class.const_get(constant_name)
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def value_by_constant?
|
|
44
|
+
source.class.const_defined?(constant_name)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
def value_by_method
|
|
47
|
-
source.
|
|
48
|
+
source.send(key)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def value_by_method?
|
|
52
|
+
source.respond_to?(key, true)
|
|
48
53
|
end
|
|
49
54
|
|
|
50
55
|
def value_by_settings_object
|
|
51
|
-
source.settings_object
|
|
56
|
+
source.settings_object.fetch(key)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def value_by_settings_object?
|
|
60
|
+
source.settings_object.key?(key)
|
|
52
61
|
end
|
|
53
62
|
|
|
54
63
|
private
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
|
3
4
|
require 'eac_ruby_utils/require_sub'
|
|
4
5
|
|
|
5
6
|
module EacRubyUtils
|
|
@@ -15,8 +16,11 @@ module EacRubyUtils
|
|
|
15
16
|
%w[settings_object method constant]
|
|
16
17
|
end
|
|
17
18
|
|
|
19
|
+
# return [ActiveSupport::HashWithIndifferentAccess]
|
|
18
20
|
def settings_object
|
|
19
|
-
|
|
21
|
+
ActiveSupport::HashWithIndifferentAccess.new(
|
|
22
|
+
respond_to?(settings_object_name) ? send(settings_object_name) : {}
|
|
23
|
+
)
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
def settings_object_name
|
|
@@ -16,6 +16,10 @@ RSpec.describe ::EacRubyUtils::SettingsProvider do
|
|
|
16
16
|
'method_b'
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def key_f
|
|
20
|
+
nil
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def settings
|
|
20
24
|
{ 'key_b' => 'setting_b', key_c: 'setting_c' }
|
|
21
25
|
end
|
|
@@ -33,9 +37,12 @@ RSpec.describe ::EacRubyUtils::SettingsProvider do
|
|
|
33
37
|
[:key_b] => 'setting_b',
|
|
34
38
|
['key_b', { order: %w[constant method settings_object] }] => 'method_b',
|
|
35
39
|
['key_c'] => 'setting_c',
|
|
36
|
-
['key_d'] => 'constant_d'
|
|
40
|
+
['key_d'] => 'constant_d',
|
|
41
|
+
['key_f'] => nil
|
|
37
42
|
}.each do |args, expected_value|
|
|
38
|
-
|
|
43
|
+
context "when args are \"#{args}\"" do
|
|
44
|
+
it { expect(stub.setting_value(*args)).to eq(expected_value) }
|
|
45
|
+
end
|
|
39
46
|
end
|
|
40
47
|
|
|
41
48
|
it do
|