eac_tools 0.76.0 → 0.76.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +28 -48
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/eac_cli/Gemfile +2 -2
  5. data/sub/eac_cli/eac_cli.gemspec +5 -3
  6. data/sub/eac_cli/lib/eac_cli/config.rb +0 -4
  7. data/sub/eac_cli/lib/eac_cli/core_ext.rb +1 -1
  8. data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +24 -3
  9. data/sub/eac_cli/lib/eac_cli/definition.rb +1 -1
  10. data/sub/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +1 -1
  11. data/sub/eac_cli/lib/eac_cli/parser/alternative/any_options.rb +19 -0
  12. data/sub/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +1 -1
  13. data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +1 -3
  14. data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +0 -9
  15. data/sub/eac_cli/lib/eac_cli/parser.rb +1 -1
  16. data/sub/eac_cli/lib/eac_cli/patches/object.rb +1 -1
  17. data/sub/eac_cli/lib/eac_cli/patches.rb +1 -1
  18. data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +1 -1
  19. data/sub/eac_cli/lib/eac_cli/runner/context_responders/set.rb +2 -2
  20. data/sub/eac_cli/lib/eac_cli/runner/exit.rb +2 -1
  21. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +1 -1
  22. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +1 -1
  23. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +2 -2
  24. data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +1 -0
  25. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  26. data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +1 -1
  27. data/sub/eac_cli/lib/eac_cli/speaker/list.rb +4 -4
  28. data/sub/eac_cli/lib/eac_cli/speaker/options.rb +3 -3
  29. data/sub/eac_cli/lib/eac_cli/speaker.rb +2 -1
  30. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  31. data/sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +2 -2
  32. data/sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb +1 -1
  33. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +10 -10
  34. data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +13 -13
  35. data/sub/eac_cli/spec/lib/eac_cli/runner_spec.rb +10 -10
  36. data/sub/eac_cli/spec/lib/eac_cli/runner_with/confirmation_spec.rb +3 -3
  37. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +1 -1
  38. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +3 -2
  39. data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +6 -6
  40. data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +6 -6
  41. data/sub/eac_cli/spec/lib/eac_cli/speaker_spec.rb +1 -1
  42. data/sub/eac_cli/spec/rubocop_spec.rb +1 -1
  43. data/sub/eac_cli/spec/spec_helper.rb +1 -1
  44. metadata +3 -166
  45. data/sub/eac_envs-http/Gemfile +0 -8
  46. data/sub/eac_envs-http/eac_envs-http.gemspec +0 -25
  47. data/sub/eac_envs-http/lib/eac_envs/http/error.rb +0 -8
  48. data/sub/eac_envs-http/lib/eac_envs/http/request/body_field.rb +0 -51
  49. data/sub/eac_envs-http/lib/eac_envs/http/request/body_field_value.rb +0 -32
  50. data/sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb +0 -39
  51. data/sub/eac_envs-http/lib/eac_envs/http/request/faraday_connection.rb +0 -75
  52. data/sub/eac_envs-http/lib/eac_envs/http/request.rb +0 -58
  53. data/sub/eac_envs-http/lib/eac_envs/http/response/body.rb +0 -62
  54. data/sub/eac_envs-http/lib/eac_envs/http/response/headers.rb +0 -41
  55. data/sub/eac_envs-http/lib/eac_envs/http/response/links.rb +0 -28
  56. data/sub/eac_envs-http/lib/eac_envs/http/response/statuses.rb +0 -21
  57. data/sub/eac_envs-http/lib/eac_envs/http/response.rb +0 -30
  58. data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server/request_processor.rb +0 -42
  59. data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server/webrick_servlet.rb +0 -22
  60. data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server.rb +0 -63
  61. data/sub/eac_envs-http/lib/eac_envs/http/rspec.rb +0 -11
  62. data/sub/eac_envs-http/lib/eac_envs/http/version.rb +0 -7
  63. data/sub/eac_envs-http/lib/eac_envs/http.rb +0 -9
  64. data/sub/eac_envs-http/spec/lib/eac_envs/http/request/body_fields_spec.rb +0 -47
  65. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec.rb +0 -68
  66. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get.source.yaml +0 -5
  67. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get.target.yaml +0 -9
  68. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get_with_auth.source.yaml +0 -8
  69. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get_with_auth.target.yaml +0 -10
  70. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_array_body.source.yaml +0 -10
  71. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_array_body.target.yaml +0 -11
  72. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_string_body.source.yaml +0 -4
  73. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_string_body.target.yaml +0 -11
  74. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_hash_body.source.yaml +0 -6
  75. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_hash_body.target.yaml +0 -11
  76. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_with_file.source.yaml +0 -5
  77. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_with_file.target.yaml +0 -13
  78. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/root.source.yaml +0 -2
  79. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/root.target.yaml +0 -9
  80. data/sub/eac_envs-http/spec/rubocop_spec.rb +0 -3
  81. data/sub/eac_envs-http/spec/spec_helper/request_builder.rb +0 -62
  82. data/sub/eac_envs-http/spec/spec_helper.rb +0 -7
  83. data/sub/eac_fs/Gemfile +0 -8
  84. data/sub/eac_fs/eac_fs.gemspec +0 -20
  85. data/sub/eac_fs/lib/eac_fs/cached_download.rb +0 -40
  86. data/sub/eac_fs/lib/eac_fs/comparator/build.rb +0 -57
  87. data/sub/eac_fs/lib/eac_fs/comparator/rename_file.rb +0 -15
  88. data/sub/eac_fs/lib/eac_fs/comparator.rb +0 -18
  89. data/sub/eac_fs/lib/eac_fs/contexts.rb +0 -21
  90. data/sub/eac_fs/lib/eac_fs/core_ext.rb +0 -4
  91. data/sub/eac_fs/lib/eac_fs/file_info.rb +0 -29
  92. data/sub/eac_fs/lib/eac_fs/logs/file.rb +0 -56
  93. data/sub/eac_fs/lib/eac_fs/logs.rb +0 -64
  94. data/sub/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +0 -15
  95. data/sub/eac_fs/lib/eac_fs/patches/module.rb +0 -4
  96. data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +0 -32
  97. data/sub/eac_fs/lib/eac_fs/patches/object.rb +0 -4
  98. data/sub/eac_fs/lib/eac_fs/patches/pathname/info.rb +0 -12
  99. data/sub/eac_fs/lib/eac_fs/patches/pathname.rb +0 -4
  100. data/sub/eac_fs/lib/eac_fs/patches.rb +0 -4
  101. data/sub/eac_fs/lib/eac_fs/rspec/setup.rb +0 -25
  102. data/sub/eac_fs/lib/eac_fs/rspec.rb +0 -9
  103. data/sub/eac_fs/lib/eac_fs/storage_tree.rb +0 -81
  104. data/sub/eac_fs/lib/eac_fs/traversable.rb +0 -45
  105. data/sub/eac_fs/lib/eac_fs/traverser.rb +0 -76
  106. data/sub/eac_fs/lib/eac_fs/version.rb +0 -5
  107. data/sub/eac_fs/lib/eac_fs.rb +0 -7
  108. data/sub/eac_fs/spec/lib/eac_fs/storage_tree_spec.rb +0 -32
  109. data/sub/eac_fs/spec/rubocop_spec.rb +0 -3
  110. data/sub/eac_fs/spec/spec_helper.rb +0 -4
  111. data/sub/eac_rest/Gemfile +0 -8
  112. data/sub/eac_rest/eac_rest.gemspec +0 -21
  113. data/sub/eac_rest/lib/eac_rest/api.rb +0 -57
  114. data/sub/eac_rest/lib/eac_rest/entity/data.rb +0 -44
  115. data/sub/eac_rest/lib/eac_rest/entity/fetching.rb +0 -20
  116. data/sub/eac_rest/lib/eac_rest/entity.rb +0 -35
  117. data/sub/eac_rest/lib/eac_rest/error.rb +0 -6
  118. data/sub/eac_rest/lib/eac_rest/helper.rb +0 -34
  119. data/sub/eac_rest/lib/eac_rest/request.rb +0 -48
  120. data/sub/eac_rest/lib/eac_rest/response.rb +0 -27
  121. data/sub/eac_rest/lib/eac_rest/version.rb +0 -5
  122. data/sub/eac_rest/lib/eac_rest.rb +0 -7
  123. data/sub/eac_rest/spec/lib/eac_rest/api_spec.rb +0 -71
  124. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get.source.yaml +0 -5
  125. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get.target.yaml +0 -9
  126. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get_with_auth.source.yaml +0 -8
  127. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get_with_auth.target.yaml +0 -10
  128. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_array_body.source.yaml +0 -10
  129. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_array_body.target.yaml +0 -11
  130. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_string_body.source.yaml +0 -4
  131. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_string_body.target.yaml +0 -11
  132. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_hash_body.source.yaml +0 -6
  133. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_hash_body.target.yaml +0 -11
  134. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_with_file.source.yaml +0 -5
  135. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_with_file.target.yaml +0 -13
  136. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/root.source.yaml +0 -2
  137. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/root.target.yaml +0 -9
  138. data/sub/eac_rest/spec/rubocop_spec.rb +0 -3
  139. data/sub/eac_rest/spec/spec_helper/request_builder.rb +0 -51
  140. data/sub/eac_rest/spec/spec_helper.rb +0 -7
  141. data/sub/eac_templates/Gemfile +0 -8
  142. data/sub/eac_templates/eac_templates.gemspec +0 -19
  143. data/sub/eac_templates/lib/eac_templates/abstract/directory.rb +0 -42
  144. data/sub/eac_templates/lib/eac_templates/abstract/file.rb +0 -25
  145. data/sub/eac_templates/lib/eac_templates/abstract/fs_object.rb +0 -94
  146. data/sub/eac_templates/lib/eac_templates/abstract/fs_object_by_pathname.rb +0 -13
  147. data/sub/eac_templates/lib/eac_templates/abstract/not_found_error.rb +0 -8
  148. data/sub/eac_templates/lib/eac_templates/core_ext.rb +0 -4
  149. data/sub/eac_templates/lib/eac_templates/interface_methods.rb +0 -12
  150. data/sub/eac_templates/lib/eac_templates/modules/ancestor/directory.rb +0 -17
  151. data/sub/eac_templates/lib/eac_templates/modules/ancestor/file.rb +0 -16
  152. data/sub/eac_templates/lib/eac_templates/modules/ancestor/fs_object.rb +0 -25
  153. data/sub/eac_templates/lib/eac_templates/modules/ancestor.rb +0 -51
  154. data/sub/eac_templates/lib/eac_templates/modules/base.rb +0 -35
  155. data/sub/eac_templates/lib/eac_templates/modules.rb +0 -9
  156. data/sub/eac_templates/lib/eac_templates/patches/module/erb_template.rb +0 -9
  157. data/sub/eac_templates/lib/eac_templates/patches/module/template.rb +0 -9
  158. data/sub/eac_templates/lib/eac_templates/patches/module.rb +0 -4
  159. data/sub/eac_templates/lib/eac_templates/patches/object/erb_template.rb +0 -9
  160. data/sub/eac_templates/lib/eac_templates/patches/object/template.rb +0 -9
  161. data/sub/eac_templates/lib/eac_templates/patches/object.rb +0 -4
  162. data/sub/eac_templates/lib/eac_templates/patches.rb +0 -4
  163. data/sub/eac_templates/lib/eac_templates/sources/directory.rb +0 -37
  164. data/sub/eac_templates/lib/eac_templates/sources/file.rb +0 -13
  165. data/sub/eac_templates/lib/eac_templates/sources/from_all_gems.rb +0 -4
  166. data/sub/eac_templates/lib/eac_templates/sources/from_gem.rb +0 -37
  167. data/sub/eac_templates/lib/eac_templates/sources/fs_object.rb +0 -53
  168. data/sub/eac_templates/lib/eac_templates/sources/internal_set.rb +0 -22
  169. data/sub/eac_templates/lib/eac_templates/sources/set.rb +0 -55
  170. data/sub/eac_templates/lib/eac_templates/sources/single.rb +0 -29
  171. data/sub/eac_templates/lib/eac_templates/sources.rb +0 -9
  172. data/sub/eac_templates/lib/eac_templates/variables/content.rb +0 -52
  173. data/sub/eac_templates/lib/eac_templates/variables/directory.rb +0 -49
  174. data/sub/eac_templates/lib/eac_templates/variables/file.rb +0 -26
  175. data/sub/eac_templates/lib/eac_templates/variables/fs_object.rb +0 -65
  176. data/sub/eac_templates/lib/eac_templates/variables/not_found_error.rb +0 -7
  177. data/sub/eac_templates/lib/eac_templates/variables/providers/base.rb +0 -23
  178. data/sub/eac_templates/lib/eac_templates/variables/providers/config_reader.rb +0 -29
  179. data/sub/eac_templates/lib/eac_templates/variables/providers/entries_reader.rb +0 -25
  180. data/sub/eac_templates/lib/eac_templates/variables/providers/generic.rb +0 -25
  181. data/sub/eac_templates/lib/eac_templates/variables/providers/hash.rb +0 -29
  182. data/sub/eac_templates/lib/eac_templates/variables/providers.rb +0 -25
  183. data/sub/eac_templates/lib/eac_templates/variables.rb +0 -9
  184. data/sub/eac_templates/lib/eac_templates/version.rb +0 -5
  185. data/sub/eac_templates/lib/eac_templates.rb +0 -7
  186. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec.rb +0 -141
  187. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/a_module/a/a_a +0 -1
  188. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/a_module/b +0 -1
  189. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/super_class/a/a_b +0 -1
  190. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/super_class/b +0 -1
  191. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/a/a_b +0 -1
  192. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/b +0 -1
  193. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/c +0 -1
  194. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/prepended_module/c +0 -1
  195. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/sub_class/b +0 -1
  196. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/a/a_b +0 -1
  197. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/b +0 -1
  198. data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec.rb +0 -26
  199. data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec_files/path/my_stub_with_template +0 -1
  200. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec.rb +0 -42
  201. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file1.template +0 -1
  202. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file2 +0 -1
  203. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path2/subdir1/file3.template +0 -1
  204. data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec.rb +0 -35
  205. data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec_files/expected_content +0 -2
  206. data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec_files/source.template +0 -2
  207. data/sub/eac_templates/spec/rubocop_spec.rb +0 -3
  208. data/sub/eac_templates/spec/spec_helper.rb +0 -4
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_templates/abstract/directory'
5
- require 'eac_templates/sources/fs_object'
6
-
7
- module EacTemplates
8
- module Sources
9
- class Directory < ::EacTemplates::Abstract::Directory
10
- include ::EacTemplates::Sources::FsObject
11
-
12
- # @return [Hash<Pathname, Symbol>]
13
- def children_basenames
14
- r = {}
15
- real_paths.each do |real_path|
16
- real_path.children.each do |child|
17
- next if r.key?(child.basename)
18
-
19
- r[child.basename] = real_path_type(child)
20
- end
21
- end
22
- r
23
- end
24
-
25
- # @return [Pathname]
26
- def real_path_type(path)
27
- if path.file?
28
- :file
29
- elsif path.directory?
30
- :directory
31
- else
32
- raise "Path \"#{path}\" is not a file nor a directory"
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_templates/abstract/file'
5
- require 'eac_templates/sources/fs_object'
6
-
7
- module EacTemplates
8
- module Sources
9
- class File < ::EacTemplates::Abstract::File
10
- include ::EacTemplates::Sources::FsObject
11
- end
12
- end
13
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_templates/sources/from_gem'
4
- ::EacTemplates::Sources::FromGem.include_all
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_templates/sources/set'
4
-
5
- module EacTemplates
6
- module Sources
7
- class FromGem
8
- class << self
9
- def include_all(searcher = nil)
10
- ::Gem::Specification.each { |gemspec| new(gemspec, searcher).include }
11
- end
12
- end
13
-
14
- TEMPLATES_DIR_SUBPATH = 'template'
15
-
16
- common_constructor :gemspec, :searcher, default: [nil] do
17
- self.searcher ||= ::EacTemplates::Sources::Set.default
18
- end
19
-
20
- # @return [Boolean]
21
- delegate :exist?, to: :path
22
-
23
- # @return [Pathname]
24
- def include
25
- return nil unless exist?
26
-
27
- searcher.included_paths << path
28
- path
29
- end
30
-
31
- # @return [Pathname]
32
- def path
33
- gemspec.gem_dir.to_pathname.join(TEMPLATES_DIR_SUBPATH)
34
- end
35
- end
36
- end
37
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_templates/abstract/not_found_error'
5
-
6
- module EacTemplates
7
- module Sources
8
- module FsObject
9
- PATH_FOR_SEARCH_PREFIX = ::Pathname.new('')
10
-
11
- common_concern do
12
- enable_abstract_methods
13
- enable_simple_cache
14
- end
15
-
16
- # @return [Boolean]
17
- def found?
18
- real_paths.any?
19
- end
20
-
21
- # @return [Pathname]
22
- def path
23
- real_paths.first
24
- end
25
-
26
- # @return [Pathname]
27
- def path_for_search_prefix
28
- PATH_FOR_SEARCH_PREFIX
29
- end
30
-
31
- protected
32
-
33
- # @return [Array<Pathname>]
34
- def real_paths_uncached
35
- source_set.included_paths.lazy.map { |source_single| source_single_search(source_single) }
36
- .select(&:present?)
37
- end
38
-
39
- # @param path [Pathname]
40
- # @return [Boolean]
41
- def select_path?(path)
42
- path.present? && path.send("#{type}?")
43
- end
44
-
45
- # @param source_single [EacTemplates::Sources::Single]
46
- # @return [Pathname, nil]
47
- def source_single_search(source_single)
48
- r = source_single.search(path_for_search)
49
- select_path?(r) ? r : nil
50
- end
51
- end
52
- end
53
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_templates/sources/single'
5
-
6
- module EacTemplates
7
- module Sources
8
- class InternalSet < ::Set
9
- # @param single [EacTemplates::Sources::Single]
10
- # @return [self]
11
- def add(single)
12
- super(::EacTemplates::Sources::Single.assert(single))
13
- end
14
-
15
- # @param single [EacTemplates::Sources::Single]
16
- # @return [self]
17
- def <<(single)
18
- add(single)
19
- end
20
- end
21
- end
22
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/object/blank'
4
- require 'eac_templates/sources/directory'
5
- require 'eac_templates/sources/file'
6
- require 'eac_templates/sources/internal_set'
7
- require 'eac_templates/abstract/not_found_error'
8
-
9
- module EacTemplates
10
- module Sources
11
- class Set
12
- class << self
13
- def default
14
- @default ||= new
15
- end
16
- end
17
-
18
- # @param subpath [Pathname]
19
- # @return [EacTemplates::Sources::Directory]
20
- def directory(subpath)
21
- ::EacTemplates::Sources::Directory.by_subpath(self, nil, subpath, source_set: self)
22
- end
23
-
24
- # @param subpath [Pathname]
25
- # @return [EacTemplates::Sources::Directory]
26
- def file(subpath)
27
- ::EacTemplates::Sources::File.by_subpath(self, nil, subpath, source_set: self)
28
- end
29
-
30
- def template(subpath, required = true)
31
- found_file = file(subpath)
32
- return found_file if found_file.found?
33
-
34
- found_directory = directory(subpath)
35
- return found_directory if found_directory.found?
36
-
37
- return nil unless required
38
-
39
- raise_template_not_found(subpath)
40
- end
41
-
42
- # @return [EacTemplates::Sources::InternalSet]
43
- def included_paths
44
- @included_paths ||= ::EacTemplates::Sources::InternalSet.new
45
- end
46
-
47
- private
48
-
49
- def raise_template_not_found(subpath)
50
- raise ::EacTemplates::Abstract::NotFoundError, 'Template not found for subpath ' \
51
- "\"#{subpath}\" (Included paths: #{included_paths.to_a.join(::File::PATH_SEPARATOR)})"
52
- end
53
- end
54
- end
55
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacTemplates
6
- module Sources
7
- class Single
8
- class << self
9
- # @param object [EacTemplates::Sources::Single, Pathname]
10
- # @return [EacTemplates::Sources::Single]
11
- def assert(object)
12
- return object if object.is_a?(self)
13
-
14
- new(object.to_pathname)
15
- end
16
- end
17
-
18
- common_constructor :path do
19
- self.path = path.to_pathname.expand_path
20
- end
21
-
22
- # @return [Pathname, nil]
23
- def search(subpath)
24
- r = path.join(subpath)
25
- r.exist? ? r : nil
26
- end
27
- end
28
- end
29
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacTemplates
6
- module Sources
7
- require_sub __FILE__
8
- end
9
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_templates/variables/providers'
5
-
6
- module EacTemplates
7
- module Variables
8
- class Content
9
- VARIABLE_DELIMITER = ::Regexp.quote('%%')
10
- VARIABLE_PATTERN = /#{VARIABLE_DELIMITER}([a-z0-9\._]*)#{VARIABLE_DELIMITER}/i.freeze
11
-
12
- class << self
13
- # @param path [Pathname]
14
- # @return [EacTemplates::Variables::Content]
15
- def from_file(path)
16
- new(path.to_pathname.read)
17
- end
18
- end
19
-
20
- enable_simple_cache
21
- common_constructor :content
22
-
23
- # +variables_provider+ A [Hash] or object which responds to +read_entry(entry_name)+.
24
- def apply(variables_source)
25
- variables_provider = ::EacTemplates::Variables::Providers.build(variables_source)
26
- variables.inject(content) do |a, e|
27
- a.gsub(variable_pattern(e), variables_provider.variable_value(e).to_s)
28
- end
29
- end
30
-
31
- def apply_to_file(variables_source, output_file_path)
32
- output_file_path.to_pathname.write(apply(variables_source))
33
- end
34
-
35
- private
36
-
37
- def variables_uncached
38
- content.scan(VARIABLE_PATTERN).map(&:first).map do |name|
39
- sanitize_variable_name(name)
40
- end.to_set
41
- end
42
-
43
- def sanitize_variable_name(variable_name)
44
- variable_name.to_s.downcase
45
- end
46
-
47
- def variable_pattern(name)
48
- /#{VARIABLE_DELIMITER}#{::Regexp.quote(name)}#{VARIABLE_DELIMITER}/i
49
- end
50
- end
51
- end
52
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_templates/abstract/not_found_error'
4
- require 'eac_templates/abstract/directory'
5
- require 'eac_templates/variables/file'
6
- require 'eac_templates/variables/fs_object'
7
-
8
- module EacTemplates
9
- module Variables
10
- class Directory
11
- common_constructor :abstract_directory do
12
- self.abstract_directory = ::EacTemplates::Abstract::Directory.assert(abstract_directory)
13
- end
14
- delegate :path, to: :abstract_directory
15
-
16
- def apply(variables_source, directory)
17
- ::EacTemplates::Variables::FsObject.new(self, '.', directory, variables_source).apply
18
- end
19
-
20
- def child(subpath)
21
- child_path = ::File.join(path, subpath)
22
- return ::EacTemplates::Variables::File.new(child_path) if ::File.file?(child_path)
23
- return ::EacTemplates::Variables::Directory.new(child_path) if ::File.directory?(child_path)
24
-
25
- raise ::EacTemplates::Abstract::NotFoundError,
26
- "Child \"#{subpath}\" from \"#{path}\" not found"
27
- end
28
-
29
- def children
30
- path.children.map do |path_child|
31
- child(path_child.basename.to_path)
32
- end
33
- end
34
-
35
- private
36
-
37
- def apply_fs_object(source_relative, target)
38
- if ::File.directory?(source_absolute(source_relative))
39
- apply_directory(source_relative, target)
40
- elsif ::File.file?(source_absolute(source_relative))
41
- end
42
- end
43
-
44
- def source_absolute(source_relative)
45
- ::File.expand_path(source_relative, path)
46
- end
47
- end
48
- end
49
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_templates/abstract/file'
5
- require 'eac_templates/variables/content'
6
- require 'eac_templates/variables/providers'
7
-
8
- module EacTemplates
9
- module Variables
10
- class File
11
- enable_simple_cache
12
- common_constructor :abstract_file do
13
- self.abstract_file = ::EacTemplates::Abstract::File.assert(abstract_file)
14
- end
15
- delegate :path, to: :abstract_file
16
- delegate :apply, :apply_to_file, :content, :variables, to: :content_applier
17
-
18
- private
19
-
20
- # @return [EacTemplates::Variables::Content]
21
- def content_applier_uncached
22
- ::EacTemplates::Variables::Content.from_file(path)
23
- end
24
- end
25
- end
26
- end
@@ -1,65 +0,0 @@
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
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacTemplates
4
- module Variables
5
- class NotFoundError < StandardError; end
6
- end
7
- end
@@ -1,23 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,25 +0,0 @@
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
@@ -1,25 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,25 +0,0 @@
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
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacTemplates
6
- module Variables
7
- require_sub __FILE__
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacTemplates
4
- VERSION = '0.5.0'
5
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacTemplates
6
- require_sub __FILE__
7
- end