eac_tools 0.60.2 → 0.61.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 +34 -29
- data/lib/eac_tools/version.rb +1 -1
- data/sub/avm/avm.gemspec +1 -1
- data/sub/avm/lib/avm/version.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/header_lines.rb +1 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/pre_process_line.rb +16 -4
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document.rb +23 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/base.rb +21 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/breadcrumbs.rb +55 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/child_docs/document_builder.rb +63 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/child_docs.rb +35 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros/default_body.rb +21 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/macros.rb +13 -0
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/sources/base.rb +5 -1
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/version.rb +1 -1
- 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.rb +2 -2
- data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/sub/avm-eac_ubuntu_base0/Gemfile +3 -0
- data/sub/avm-eac_ubuntu_base0/avm-eac_ubuntu_base0.gemspec +1 -1
- data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/docker_image.rb +1 -1
- data/sub/avm-eac_ubuntu_base0/lib/avm/eac_ubuntu_base0/version.rb +1 -1
- data/sub/avm-files/avm-files.gemspec +5 -5
- data/sub/avm-files/lib/avm/files/appendable/templatized_directory.rb +2 -2
- data/sub/avm-files/lib/avm/files/version.rb +1 -1
- data/sub/eac_templates/Gemfile +8 -0
- data/sub/eac_templates/eac_templates.gemspec +19 -0
- data/sub/eac_templates/lib/eac_templates/core_ext.rb +4 -0
- data/sub/eac_templates/lib/eac_templates/interface_methods.rb +12 -0
- data/sub/eac_templates/lib/eac_templates/modules/ancestor/directory.rb +15 -0
- data/sub/eac_templates/lib/eac_templates/modules/ancestor/file.rb +15 -0
- data/sub/eac_templates/lib/eac_templates/modules/ancestor/fs_object.rb +32 -0
- data/sub/eac_templates/lib/eac_templates/modules/ancestor.rb +48 -0
- data/sub/eac_templates/lib/eac_templates/modules/base.rb +35 -0
- data/sub/eac_templates/lib/eac_templates/modules.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/patches/module/erb_template.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/patches/module/template.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/patches/module.rb +4 -0
- data/sub/eac_templates/lib/eac_templates/patches/object/erb_template.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/patches/object/template.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/patches/object.rb +4 -0
- data/sub/eac_templates/lib/eac_templates/patches.rb +4 -0
- data/sub/eac_templates/lib/eac_templates/sources/directory.rb +24 -0
- data/sub/eac_templates/lib/eac_templates/sources/file.rb +24 -0
- data/sub/eac_templates/lib/eac_templates/sources/from_all_gems.rb +4 -0
- data/sub/eac_templates/lib/eac_templates/sources/from_gem.rb +37 -0
- data/sub/eac_templates/lib/eac_templates/sources/fs_object.rb +53 -0
- data/sub/eac_templates/lib/eac_templates/sources/internal_set.rb +22 -0
- data/sub/eac_templates/lib/eac_templates/sources/set.rb +54 -0
- data/sub/eac_templates/lib/eac_templates/sources/single.rb +29 -0
- data/sub/eac_templates/lib/eac_templates/sources.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/variables/directory.rb +47 -0
- data/sub/eac_templates/lib/eac_templates/variables/file.rb +50 -0
- data/sub/eac_templates/lib/eac_templates/variables/fs_object.rb +65 -0
- data/sub/eac_templates/lib/eac_templates/variables/not_found_error.rb +7 -0
- data/sub/eac_templates/lib/eac_templates/variables/providers/base.rb +23 -0
- data/sub/eac_templates/lib/eac_templates/variables/providers/config_reader.rb +29 -0
- data/sub/eac_templates/lib/eac_templates/variables/providers/entries_reader.rb +25 -0
- data/sub/eac_templates/lib/eac_templates/variables/providers/generic.rb +25 -0
- data/sub/eac_templates/lib/eac_templates/variables/providers/hash.rb +29 -0
- data/sub/eac_templates/lib/eac_templates/variables/providers.rb +25 -0
- data/sub/eac_templates/lib/eac_templates/variables.rb +9 -0
- data/sub/eac_templates/lib/eac_templates/version.rb +5 -0
- data/sub/eac_templates/lib/eac_templates.rb +7 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec.rb +120 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path1/a_module/a/a_a +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path1/a_module/b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path1/super_class/a/a_b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path1/super_class/b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/a/a_b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/c +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/sub_class/b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/super_class/a/a_b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/super_class/b +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec.rb +26 -0
- data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec_files/path/my_stub_with_template +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec.rb +42 -0
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file1.template +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file2 +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path2/subdir1/file3.template +1 -0
- data/sub/eac_templates/spec/lib/eac_templates/variables/file_spec.rb +35 -0
- data/sub/eac_templates/spec/lib/eac_templates/variables/file_spec_files/expected_content +2 -0
- data/sub/eac_templates/spec/lib/eac_templates/variables/file_spec_files/source.template +2 -0
- data/sub/eac_templates/spec/rubocop_spec.rb +3 -0
- data/sub/eac_templates/spec/spec_helper.rb +4 -0
- metadata +79 -14
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/breadcrumbs_macro_value.rb +0 -59
- data/sub/avm-eac_asciidoctor_base0/lib/avm/eac_asciidoctor_base0/instances/build/document/child_docs_macro_value.rb +0 -49
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/variables/file'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Variables
|
7
|
+
class FsObject
|
8
|
+
TEMPLATE_EXTNAME = '.template'
|
9
|
+
|
10
|
+
common_constructor :source_directory, :source_relative, :target_root_directory,
|
11
|
+
:variables_source
|
12
|
+
|
13
|
+
def apply
|
14
|
+
if file?
|
15
|
+
apply_file
|
16
|
+
elsif directory?
|
17
|
+
apply_directory
|
18
|
+
else
|
19
|
+
raise "Unknown filesystem type: #{source_absolute}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def apply_directory
|
26
|
+
::FileUtils.mkdir_p(target_absolute)
|
27
|
+
Dir.entries(source_absolute).each do |entry|
|
28
|
+
child(entry).apply unless %w[. ..].include?(entry)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def apply_file
|
33
|
+
if ::File.extname(source_absolute) == TEMPLATE_EXTNAME
|
34
|
+
::EacTemplates::Variables::File.new(source_absolute).apply_to_file(
|
35
|
+
variables_source, target_absolute
|
36
|
+
)
|
37
|
+
else
|
38
|
+
::FileUtils.cp(source_absolute, target_absolute)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def child(entry)
|
43
|
+
self.class.new(source_directory, ::File.join(source_relative, entry),
|
44
|
+
target_root_directory, variables_source)
|
45
|
+
end
|
46
|
+
|
47
|
+
def file?
|
48
|
+
::File.file?(source_absolute)
|
49
|
+
end
|
50
|
+
|
51
|
+
def directory?
|
52
|
+
::File.directory?(source_absolute)
|
53
|
+
end
|
54
|
+
|
55
|
+
def source_absolute
|
56
|
+
::File.expand_path(source_relative, source_directory.path)
|
57
|
+
end
|
58
|
+
|
59
|
+
def target_absolute
|
60
|
+
::File.expand_path(source_relative, target_root_directory)
|
61
|
+
.gsub(/#{::Regexp.quote(TEMPLATE_EXTNAME)}\z/, '')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/variables/not_found_error'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Variables
|
7
|
+
module Providers
|
8
|
+
class Base
|
9
|
+
attr_reader :source
|
10
|
+
|
11
|
+
def initialize(source)
|
12
|
+
@source = source
|
13
|
+
end
|
14
|
+
|
15
|
+
def variable_value(name)
|
16
|
+
return variable_fetch(name) if variable_exist?(name)
|
17
|
+
|
18
|
+
raise VariableNotFoundError, "Variable \"#{name}\" not found in #{source}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_config/node'
|
4
|
+
require 'eac_templates/variables/providers/base'
|
5
|
+
|
6
|
+
module EacTemplates
|
7
|
+
module Variables
|
8
|
+
module Providers
|
9
|
+
class ConfigReader < ::EacTemplates::Variables::Providers::Base
|
10
|
+
class << self
|
11
|
+
def accept?(variables_source)
|
12
|
+
return false unless variables_source.respond_to?(:entry)
|
13
|
+
|
14
|
+
entry = variables_source.entry(:any_value)
|
15
|
+
entry.respond_to?(:value) && entry.respond_to?(:found?)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def variable_exist?(name)
|
20
|
+
source.entry(name).found?
|
21
|
+
end
|
22
|
+
|
23
|
+
def variable_fetch(name)
|
24
|
+
source.entry(name).value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/variables/providers/base'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Variables
|
7
|
+
module Providers
|
8
|
+
class EntriesReader < ::EacTemplates::Variables::Providers::Base
|
9
|
+
class << self
|
10
|
+
def accept?(variables_source)
|
11
|
+
variables_source.respond_to?(:read_entry)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def variable_exist?(_name)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def variable_fetch(name)
|
20
|
+
source.read_entry(name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/variables/providers/base'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Variables
|
7
|
+
module Providers
|
8
|
+
class Generic < ::EacTemplates::Variables::Providers::Base
|
9
|
+
class << self
|
10
|
+
def accept?(variables_source)
|
11
|
+
variables_source.is_a?(::Object)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def variable_exist?(name)
|
16
|
+
source.respond_to?(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def variable_fetch(name)
|
20
|
+
source.send(name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/variables/providers/base'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Variables
|
7
|
+
module Providers
|
8
|
+
class Hash < ::EacTemplates::Variables::Providers::Base
|
9
|
+
class << self
|
10
|
+
def accept?(variables_source)
|
11
|
+
variables_source.is_a?(::Hash)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(source)
|
16
|
+
super(source.with_indifferent_access)
|
17
|
+
end
|
18
|
+
|
19
|
+
def variable_exist?(name)
|
20
|
+
source.key?(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def variable_fetch(name)
|
24
|
+
source.fetch(name)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Variables
|
7
|
+
module Providers
|
8
|
+
require_sub __FILE__
|
9
|
+
|
10
|
+
PROVIDERS = %w[config_reader entries_reader hash generic].map do |name|
|
11
|
+
"eac_templates/variables/providers/#{name}".camelize.constantize
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def build(variables_source)
|
16
|
+
PROVIDERS.each do |provider|
|
17
|
+
return provider.new(variables_source) if provider.accept?(variables_source)
|
18
|
+
end
|
19
|
+
|
20
|
+
raise "Variables provider not found for #{variables_source}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/patches/module/template'
|
4
|
+
require 'eac_templates/sources/set'
|
5
|
+
|
6
|
+
RSpec.describe ::Module do
|
7
|
+
def self.on_node_specs(node_name, &block)
|
8
|
+
context "when object is \"#{node_name}\"" do # rubocop:disable RSpec/EmptyExampleGroup
|
9
|
+
let(:node) { send(node_name) }
|
10
|
+
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.dir_specs(node_name, expected_children)
|
16
|
+
on_node_specs(node_name) do
|
17
|
+
it do
|
18
|
+
expect(node.children.map { |child| child.path.basename.to_path }).to(
|
19
|
+
eq(expected_children)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.file_specs_ok(node_name, expected_content, expected_apply, # rubocop:disable Metrics/AbcSize
|
26
|
+
expected_variables)
|
27
|
+
on_node_specs(node_name) do
|
28
|
+
it { expect(node.content).to eq(expected_content) }
|
29
|
+
it { expect(node.variables).to eq(::Set.new(expected_variables)) }
|
30
|
+
it { expect(node.apply(variables_source)).to eq(expected_apply) }
|
31
|
+
|
32
|
+
it do
|
33
|
+
target_file = temp_file
|
34
|
+
node.apply_to_file(variables_source, target_file)
|
35
|
+
expect(target_file.read).to eq(expected_apply)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.file_specs_error(node_name)
|
41
|
+
on_node_specs(node_name) do
|
42
|
+
it do
|
43
|
+
expect { node }.to raise_error(::RuntimeError)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:a_module) do
|
49
|
+
described_class.new do
|
50
|
+
def self.name
|
51
|
+
'AModule'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
let(:super_class) do
|
56
|
+
r = ::Class.new do
|
57
|
+
def self.name
|
58
|
+
'SuperClass'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
r.include a_module
|
62
|
+
r
|
63
|
+
end
|
64
|
+
let(:sub_class) do
|
65
|
+
r = ::Class.new(super_class) do
|
66
|
+
def self.name
|
67
|
+
'SuperClass'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
r
|
71
|
+
end
|
72
|
+
let(:files_dir) { __dir__.to_pathname.join('template_spec_files') }
|
73
|
+
let(:variables_source) { { vx: '_X_', vy: '_Y_' } }
|
74
|
+
|
75
|
+
let(:a) { instance.template.child('a') }
|
76
|
+
let(:a_a) { a.child('a_a') }
|
77
|
+
let(:a_b) { a.child('a_b') }
|
78
|
+
let(:a_c) { a.child('a_c') }
|
79
|
+
let(:b) { instance.template.child('b') }
|
80
|
+
let(:c) { instance.template.child('c') }
|
81
|
+
|
82
|
+
before do
|
83
|
+
%w[path1 path2].each do |sub|
|
84
|
+
::EacTemplates::Sources::Set.default.included_paths << files_dir.join(sub)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when module is AModule' do # rubocop:disable RSpec/EmptyExampleGroup
|
89
|
+
let(:instance) { a_module }
|
90
|
+
|
91
|
+
dir_specs(:a, %w[a_a])
|
92
|
+
file_specs_ok(:a_a, "A_MODULE_A_A\n", "A_MODULE_A_A\n", [])
|
93
|
+
file_specs_error(:a_b)
|
94
|
+
file_specs_error(:a_c)
|
95
|
+
file_specs_ok(:b, "A_MODULE_B%%vy%%\n", "A_MODULE_B_Y_\n", %w[vy])
|
96
|
+
file_specs_error(:c)
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when module is SuperClass' do # rubocop:disable RSpec/EmptyExampleGroup
|
100
|
+
let(:instance) { super_class }
|
101
|
+
|
102
|
+
dir_specs(:a, %w[a_b])
|
103
|
+
file_specs_error(:a_a)
|
104
|
+
file_specs_ok(:a_b, "SUPER_CLASS_A_B\n", "SUPER_CLASS_A_B\n", [])
|
105
|
+
file_specs_error(:a_c)
|
106
|
+
file_specs_ok(:b, "SUPER_CLASS_B\n", "SUPER_CLASS_B\n", [])
|
107
|
+
file_specs_error(:c)
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when module is SubClass' do # rubocop:disable RSpec/EmptyExampleGroup
|
111
|
+
let(:instance) { sub_class }
|
112
|
+
|
113
|
+
dir_specs(:a, %w[a_b])
|
114
|
+
file_specs_error(:a_a)
|
115
|
+
file_specs_ok(:a_b, "SUPER_CLASS_A_B\n", "SUPER_CLASS_A_B\n", [])
|
116
|
+
file_specs_error(:a_c)
|
117
|
+
file_specs_ok(:b, "SUPER_CLASS_B\n", "SUPER_CLASS_B\n", [])
|
118
|
+
file_specs_error(:c)
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
A_MODULE_A_A
|
data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path1/a_module/b
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
A_MODULE_B%%vy%%
|
@@ -0,0 +1 @@
|
|
1
|
+
SUPER_CLASS_A_B
|
data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path1/super_class/b
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SUPER_CLASS_B
|
@@ -0,0 +1 @@
|
|
1
|
+
A_MODULE_A_A
|
data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/b
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
A_MODULE_B
|
data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/a_module/c
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
A_MODULE_%%vx%%
|
data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/sub_class/b
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SUB_CLASS_B
|
@@ -0,0 +1 @@
|
|
1
|
+
SUPER_CLASS_A_B
|
data/sub/eac_templates/spec/lib/eac_templates/patches/module/template_spec_files/path2/super_class/b
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SUB_CLASS_B
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/interface_methods'
|
4
|
+
require 'eac_templates/patches/object/template'
|
5
|
+
|
6
|
+
RSpec.describe ::Object do
|
7
|
+
class MyStubWithTemplate # rubocop:disable RSpec/LeakyConstantDeclaration
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:instance) { ::MyStubWithTemplate.new }
|
11
|
+
let(:templates_path) { ::File.join(__dir__, 'template_spec_files', 'path') }
|
12
|
+
|
13
|
+
before do
|
14
|
+
::EacTemplates::Sources::Set.default.included_paths.add(templates_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
::EacTemplates::Sources::Set.default.included_paths.delete(templates_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#template' do
|
22
|
+
::EacTemplates::InterfaceMethods::FILE.each do |method_name|
|
23
|
+
it { expect(instance.template).to respond_to(method_name) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/interface_methods'
|
4
|
+
require 'eac_templates/sources/set'
|
5
|
+
|
6
|
+
RSpec.describe ::EacTemplates::Sources::Set do
|
7
|
+
let(:files_dir) { ::File.join(__dir__, 'set_spec_files') }
|
8
|
+
let(:instance) do
|
9
|
+
r = described_class.new
|
10
|
+
r.included_paths << ::File.join(files_dir, 'path1')
|
11
|
+
r.included_paths << ::File.join(files_dir, 'path2')
|
12
|
+
r
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#template' do
|
16
|
+
{
|
17
|
+
'subdir1' => :directory,
|
18
|
+
'subdir1/file1.template' => :file,
|
19
|
+
'subdir1/file2' => :file,
|
20
|
+
'subdir1/file3.template' => :file,
|
21
|
+
'does_not_exist' => :nil
|
22
|
+
}.each do |subpath, type|
|
23
|
+
context "when subpath is \"#{subpath}\"" do
|
24
|
+
let(:result) { instance.template(subpath, false) }
|
25
|
+
|
26
|
+
case type
|
27
|
+
when :nil
|
28
|
+
it { expect(result).to be_nil }
|
29
|
+
when :directory
|
30
|
+
::EacTemplates::InterfaceMethods::DIRECTORY.each do |method_name|
|
31
|
+
it { expect(result).to respond_to(method_name) } # rubocop:disable RSpec/RepeatedExample
|
32
|
+
end
|
33
|
+
when :file
|
34
|
+
::EacTemplates::InterfaceMethods::FILE.each do |method_name|
|
35
|
+
it { expect(result).to respond_to(method_name) } # rubocop:disable RSpec/RepeatedExample
|
36
|
+
end
|
37
|
+
else ibr
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file1.template
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path2/subdir1/file3.template
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_config/old_configs'
|
4
|
+
require 'eac_templates/variables/file'
|
5
|
+
|
6
|
+
RSpec.describe ::EacTemplates::Variables::File do
|
7
|
+
let(:files_dir) { ::File.join(__dir__, 'file_spec_files') }
|
8
|
+
let(:source_path) { ::File.join(files_dir, 'source.template') }
|
9
|
+
let(:instance) { described_class.new(source_path) }
|
10
|
+
let(:expected_content) { ::File.read(::File.join(files_dir, 'expected_content')) }
|
11
|
+
|
12
|
+
describe '#apply' do
|
13
|
+
context 'when config is a hash' do
|
14
|
+
let(:config) { { name: 'Fulano de Tal', age: 33 } }
|
15
|
+
|
16
|
+
it { expect(instance.apply(config)).to eq(expected_content) }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when config responds to read_entry' do
|
20
|
+
let(:config) { ::EacConfig::OldConfigs.new('rspec_describe_eac_ruby_utils_templates_file') }
|
21
|
+
|
22
|
+
before do
|
23
|
+
config.clear
|
24
|
+
config['name'] = 'Fulano de Tal'
|
25
|
+
config['age'] = '33'
|
26
|
+
end
|
27
|
+
|
28
|
+
it { expect(instance.apply(config)).to eq(expected_content) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#variables' do
|
33
|
+
it { expect(instance.variables).to eq(::Set.new(%w[name age])) }
|
34
|
+
end
|
35
|
+
end
|