eac_templates 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_templates/abstract/fs_object.rb +4 -4
- data/lib/eac_templates/abstract/with_directory_file_methods.rb +46 -0
- data/lib/eac_templates/modules/ancestor/fs_object.rb +1 -3
- data/lib/eac_templates/modules/ancestor.rb +7 -21
- data/lib/eac_templates/modules/base/directory.rb +44 -0
- data/lib/eac_templates/modules/base/file.rb +27 -0
- data/lib/eac_templates/modules/base/fs_object.rb +18 -0
- data/lib/eac_templates/modules/base.rb +36 -5
- data/lib/eac_templates/version.rb +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc9aafcd773770ed687e7ba11baa553e5968e18c9f124f71a446430d387e18a5
|
4
|
+
data.tar.gz: '096625ceb82074fbf40278cb545602726e33848488b734fd4ff86ab199bc5637'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c42ec59495782f16ecba7f27a05a89fd096900baeb30745806bdb5262b8d5057d2100339cdf3f11ea7bd503a42567fef0bf489ba0a4e7dd25648b6da8d616512
|
7
|
+
data.tar.gz: 106e1e173c5adc5e448514009616f6760ae7053cc05e2c2aa44c35b3963dc14e28b1edbd3d2bf8cc124753337ab91808787b175fc89116fa852df967ee68e10e
|
@@ -23,12 +23,12 @@ module EacTemplates
|
|
23
23
|
# @param subpath [Pathname]
|
24
24
|
# @return [EacTemplates::Abstract::FsObject]
|
25
25
|
def by_subpath(owner, parent_object, subpath, options = {})
|
26
|
-
r = nil
|
27
|
-
subpath.to_pathname.each_filename do |basename|
|
28
|
-
r = new(owner, parent_object, basename, options)
|
26
|
+
r = new(owner, parent_object, nil, options)
|
27
|
+
subpath.if_present(::Pathname.new(''), &:to_pathname).each_filename do |basename|
|
29
28
|
parent_object = r
|
29
|
+
r = new(owner, parent_object, basename, options)
|
30
30
|
end
|
31
|
-
r
|
31
|
+
r
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_templates/abstract/not_found_error'
|
4
|
+
|
5
|
+
module EacTemplates
|
6
|
+
module Abstract
|
7
|
+
module WithDirectoryFileMethods
|
8
|
+
def build_fs_object(type)
|
9
|
+
fs_object_class(type).by_subpath(self, nil, subpath, source_set: source_set)
|
10
|
+
end
|
11
|
+
|
12
|
+
# @param child_basename [Pathname
|
13
|
+
# @return [Pathname]
|
14
|
+
def child_subpath(child_basename)
|
15
|
+
subpath.if_present(child_basename) { |v| v.join(child_basename) }.to_pathname
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [EacTemplates::Abstract::Directory]
|
19
|
+
def directory
|
20
|
+
build_fs_object(:directory)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [EacTemplates::Abstract::File]
|
24
|
+
def file
|
25
|
+
build_fs_object(:file)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param type [Symbol]
|
29
|
+
# @return [Class]
|
30
|
+
def fs_object_class(type)
|
31
|
+
self.class.const_get(type.to_s.camelize)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [EacTemplates::Abstract::Directory, EacTemplates::Abstract::File]
|
35
|
+
def sub_fs_object
|
36
|
+
file_search = file
|
37
|
+
return file_search if file_search.found?
|
38
|
+
|
39
|
+
directory_search = directory
|
40
|
+
return directory_search if directory_search.found?
|
41
|
+
|
42
|
+
raise ::EacTemplates::Abstract::NotFoundError, "No template found: #{self}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
4
|
require 'eac_templates/interface_methods'
|
5
|
-
require 'eac_templates/abstract/
|
5
|
+
require 'eac_templates/abstract/with_directory_file_methods'
|
6
6
|
|
7
7
|
module EacTemplates
|
8
8
|
module Modules
|
9
9
|
class Ancestor
|
10
|
+
include ::EacTemplates::Abstract::WithDirectoryFileMethods
|
11
|
+
|
10
12
|
class << self
|
11
13
|
# @param a_module [Module]
|
12
14
|
# @return [Pathname]
|
@@ -17,34 +19,18 @@ module EacTemplates
|
|
17
19
|
|
18
20
|
common_constructor :base, :ancestor
|
19
21
|
delegate :subpath, :source_set, to: :base
|
20
|
-
delegate(*::EacTemplates::InterfaceMethods::ALL, to: :
|
21
|
-
|
22
|
-
# @return [EacTemplates::Modules::Directory]
|
23
|
-
def directory
|
24
|
-
@directory ||= ::EacTemplates::Modules::Ancestor::Directory
|
25
|
-
.new(self, nil, nil, source_set: source_set)
|
26
|
-
end
|
22
|
+
delegate(*::EacTemplates::InterfaceMethods::ALL, to: :sub_fs_object)
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
@file ||= ::EacTemplates::Modules::Ancestor::File
|
31
|
-
.new(self, nil, nil, source_set: source_set)
|
24
|
+
def ancestor_path_for_search
|
25
|
+
self.class.path_for_search(ancestor)
|
32
26
|
end
|
33
27
|
|
34
28
|
# @return [Pathname]
|
35
29
|
def path_for_search
|
36
|
-
r =
|
30
|
+
r = ancestor_path_for_search
|
37
31
|
subpath.if_present(r) { |v| r.join(v) }
|
38
32
|
end
|
39
33
|
|
40
|
-
# @return [EacTemplates::Modules::Ancestor::FsObject]
|
41
|
-
def source_object
|
42
|
-
return file if file.found?
|
43
|
-
return directory if directory.found?
|
44
|
-
|
45
|
-
raise ::EacTemplates::Abstract::NotFoundError, "No template found: #{path_for_search}"
|
46
|
-
end
|
47
|
-
|
48
34
|
require_sub __FILE__
|
49
35
|
end
|
50
36
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_templates/abstract/directory'
|
5
|
+
require 'eac_templates/interface_methods'
|
6
|
+
require 'eac_templates/modules/base/fs_object'
|
7
|
+
|
8
|
+
module EacTemplates
|
9
|
+
module Modules
|
10
|
+
class Base
|
11
|
+
class Directory < ::EacTemplates::Abstract::Directory
|
12
|
+
include ::EacTemplates::Modules::Base::FsObject
|
13
|
+
delegate(*(EacTemplates::InterfaceMethods::DIRECTORY - %i[children]), to: :self_ancestor)
|
14
|
+
|
15
|
+
# @param basename [Pathname]
|
16
|
+
# @return [EacTemplates::Abstract::FsObject]
|
17
|
+
delegate :child, to: :owner
|
18
|
+
|
19
|
+
# @return [Hash<Pathname, Symbol>]
|
20
|
+
def children_basenames
|
21
|
+
owner.ancestors.each_with_object({}) do |e, a|
|
22
|
+
ancestor_children_names(e, a)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean]
|
27
|
+
def found?
|
28
|
+
children.any?
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
# @param ancestor []
|
34
|
+
# @param result [Hash<Pathname, Symbol>]
|
35
|
+
# @return [void]
|
36
|
+
def ancestor_children_names(ancestor, result)
|
37
|
+
ancestor.directory.source_object.children_basenames.each do |path, type|
|
38
|
+
result[path] = type
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_templates/abstract/file'
|
5
|
+
require 'eac_templates/interface_methods'
|
6
|
+
require 'eac_templates/modules/base/fs_object'
|
7
|
+
|
8
|
+
module EacTemplates
|
9
|
+
module Modules
|
10
|
+
class Base
|
11
|
+
class File < ::EacTemplates::Abstract::File
|
12
|
+
include ::EacTemplates::Modules::Base::FsObject
|
13
|
+
delegate(*EacTemplates::InterfaceMethods::FILE, to: :ancestor_found)
|
14
|
+
|
15
|
+
def found?
|
16
|
+
ancestor_found.present?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def ancestor_found_uncached
|
22
|
+
owner.ancestors.lazy.map(&:file).select(&:found?).first
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_templates/interface_methods'
|
5
|
+
|
6
|
+
module EacTemplates
|
7
|
+
module Modules
|
8
|
+
class Base
|
9
|
+
module FsObject
|
10
|
+
def self_ancestor
|
11
|
+
owner.self_ancestor.send(type)
|
12
|
+
end
|
13
|
+
|
14
|
+
delegate :found?, to: :self_ancestor
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -2,23 +2,40 @@
|
|
2
2
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
4
|
require 'eac_templates/interface_methods'
|
5
|
+
require 'eac_templates/abstract/with_directory_file_methods'
|
5
6
|
require 'eac_templates/modules/ancestor'
|
6
7
|
require 'eac_templates/sources/set'
|
7
8
|
|
8
9
|
module EacTemplates
|
9
10
|
module Modules
|
10
11
|
class Base
|
12
|
+
include ::EacTemplates::Abstract::WithDirectoryFileMethods
|
11
13
|
enable_listable
|
14
|
+
enable_simple_cache
|
12
15
|
lists.add_symbol :option, :source_set, :subpath
|
13
16
|
common_constructor :the_module, :options, default: [{}] do
|
14
17
|
self.options = self.class.lists.option.hash_keys_validate!(options)
|
15
18
|
end
|
16
|
-
delegate(*::EacTemplates::InterfaceMethods::
|
17
|
-
|
19
|
+
delegate(*::EacTemplates::InterfaceMethods::ONLY_DIRECTORY, to: :directory)
|
20
|
+
delegate(*::EacTemplates::InterfaceMethods::ONLY_FILE, to: :file)
|
21
|
+
delegate(*::EacTemplates::InterfaceMethods::COMMON, :path_for_search, :source_object,
|
22
|
+
to: :sub_fs_object)
|
18
23
|
|
19
|
-
# @
|
20
|
-
|
21
|
-
|
24
|
+
# @param basename [Pathname]
|
25
|
+
# @return [EacTemplates::Abstract::FsObject]
|
26
|
+
def child(basename)
|
27
|
+
r = ::EacTemplates::Modules::Base.new(
|
28
|
+
the_module, subpath: child_subpath(basename), source_set: source_set
|
29
|
+
)
|
30
|
+
return r if r.found?
|
31
|
+
|
32
|
+
raise ::EacTemplates::Abstract::NotFoundError,
|
33
|
+
"No child for #{self} found with basename \"#{basename}\""
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Boolean]
|
37
|
+
def found?
|
38
|
+
file.found? || directory.found?
|
22
39
|
end
|
23
40
|
|
24
41
|
# @return [EacTemplates::SourceSet]
|
@@ -30,6 +47,20 @@ module EacTemplates
|
|
30
47
|
def subpath
|
31
48
|
options[OPTION_SUBPATH].if_present(&:to_pathname)
|
32
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# @return [Enumerable<EacTemplates::Modules::Ancestor>]
|
54
|
+
def ancestors_uncached
|
55
|
+
the_module.ancestors.map { |a| ::EacTemplates::Modules::Ancestor.new(self, a) }
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [EacTemplates::Modules::Ancestor]
|
59
|
+
def self_ancestor_uncached
|
60
|
+
ancestors.find { |a| a.ancestor == the_module } || ibr
|
61
|
+
end
|
62
|
+
|
63
|
+
require_sub __FILE__
|
33
64
|
end
|
34
65
|
end
|
35
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_config
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.14'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.14.
|
22
|
+
version: 0.14.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,21 +29,21 @@ dependencies:
|
|
29
29
|
version: '0.14'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.14.
|
32
|
+
version: 0.14.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: eac_ruby_utils
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
39
|
+
version: '0.122'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.122'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: eac_ruby_gem_support
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/eac_templates/abstract/fs_object.rb
|
71
71
|
- lib/eac_templates/abstract/fs_object_by_pathname.rb
|
72
72
|
- lib/eac_templates/abstract/not_found_error.rb
|
73
|
+
- lib/eac_templates/abstract/with_directory_file_methods.rb
|
73
74
|
- lib/eac_templates/core_ext.rb
|
74
75
|
- lib/eac_templates/interface_methods.rb
|
75
76
|
- lib/eac_templates/modules.rb
|
@@ -78,6 +79,9 @@ files:
|
|
78
79
|
- lib/eac_templates/modules/ancestor/file.rb
|
79
80
|
- lib/eac_templates/modules/ancestor/fs_object.rb
|
80
81
|
- lib/eac_templates/modules/base.rb
|
82
|
+
- lib/eac_templates/modules/base/directory.rb
|
83
|
+
- lib/eac_templates/modules/base/file.rb
|
84
|
+
- lib/eac_templates/modules/base/fs_object.rb
|
81
85
|
- lib/eac_templates/patches.rb
|
82
86
|
- lib/eac_templates/patches/module.rb
|
83
87
|
- lib/eac_templates/patches/module/erb_template.rb
|