eac_tools 0.75.2 → 0.76.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -5
  3. data/Gemfile.lock +69 -71
  4. data/lib/eac_tools/version.rb +1 -1
  5. data/sub/avm-eac_redmine_base0/Gemfile +2 -2
  6. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +8 -6
  7. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base/install.rb +9 -0
  8. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/docker_image.rb +1 -1
  9. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/rest_api/entity_base.rb +2 -2
  10. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/core_update.rb +1 -1
  11. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  12. data/sub/avm-eac_redmine_base0/spec/lib/avm/eac_redmine_base0/instances/apache_host_spec.rb +3 -3
  13. data/sub/avm-eac_redmine_base0/spec/lib/avm/eac_redmine_base0/instances/base/gitolite_spec.rb +1 -1
  14. data/sub/avm-eac_redmine_base0/spec/rubocop_spec.rb +1 -1
  15. data/sub/avm-eac_redmine_base0/spec/spec_helper.rb +2 -2
  16. data/sub/avm-eac_redmine_base0/template/avm/eac_redmine_base0/instances/deploy/config/install.sh.template +3 -0
  17. data/sub/eac_cli/Gemfile +2 -2
  18. data/sub/eac_cli/eac_cli.gemspec +5 -3
  19. data/sub/eac_cli/lib/eac_cli/config.rb +0 -4
  20. data/sub/eac_cli/lib/eac_cli/core_ext.rb +1 -1
  21. data/sub/eac_cli/lib/eac_cli/definition/alternative.rb +24 -3
  22. data/sub/eac_cli/lib/eac_cli/definition.rb +1 -1
  23. data/sub/eac_cli/lib/eac_cli/old_configs/store_passwords_entry_reader.rb +1 -1
  24. data/sub/eac_cli/lib/eac_cli/parser/alternative/any_options.rb +19 -0
  25. data/sub/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +1 -1
  26. data/sub/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +1 -3
  27. data/sub/eac_cli/lib/eac_cli/parser/alternative.rb +0 -9
  28. data/sub/eac_cli/lib/eac_cli/parser.rb +1 -1
  29. data/sub/eac_cli/lib/eac_cli/patches/object.rb +1 -1
  30. data/sub/eac_cli/lib/eac_cli/patches.rb +1 -1
  31. data/sub/eac_cli/lib/eac_cli/runner/class_runner.rb +1 -1
  32. data/sub/eac_cli/lib/eac_cli/runner/context_responders/set.rb +2 -2
  33. data/sub/eac_cli/lib/eac_cli/runner/exit.rb +2 -1
  34. data/sub/eac_cli/lib/eac_cli/runner/instance_methods.rb +1 -1
  35. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder/alternative.rb +1 -1
  36. data/sub/eac_cli/lib/eac_cli/runner_with/help/builder.rb +2 -2
  37. data/sub/eac_cli/lib/eac_cli/runner_with/help.rb +1 -0
  38. data/sub/eac_cli/lib/eac_cli/runner_with/subcommands.rb +1 -1
  39. data/sub/eac_cli/lib/eac_cli/runner_with_set.rb +1 -1
  40. data/sub/eac_cli/lib/eac_cli/speaker/list.rb +4 -4
  41. data/sub/eac_cli/lib/eac_cli/speaker/options.rb +3 -3
  42. data/sub/eac_cli/lib/eac_cli/speaker.rb +2 -1
  43. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  44. data/sub/eac_cli/spec/lib/eac_cli/definition/alternative_spec.rb +2 -2
  45. data/sub/eac_cli/spec/lib/eac_cli/old_configs_spec.rb +1 -1
  46. data/sub/eac_cli/spec/lib/eac_cli/parser/alternative_spec.rb +10 -10
  47. data/sub/eac_cli/spec/lib/eac_cli/runner/for_context_spec.rb +13 -13
  48. data/sub/eac_cli/spec/lib/eac_cli/runner_spec.rb +10 -10
  49. data/sub/eac_cli/spec/lib/eac_cli/runner_with/confirmation_spec.rb +3 -3
  50. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help/layout_spec.rb +1 -1
  51. data/sub/eac_cli/spec/lib/eac_cli/runner_with/help_spec.rb +3 -2
  52. data/sub/eac_cli/spec/lib/eac_cli/runner_with/output_spec.rb +6 -6
  53. data/sub/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +6 -6
  54. data/sub/eac_cli/spec/lib/eac_cli/speaker_spec.rb +1 -1
  55. data/sub/eac_cli/spec/rubocop_spec.rb +1 -1
  56. data/sub/eac_cli/spec/spec_helper.rb +1 -1
  57. data/sub/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  58. data/sub/eac_ruby_utils/lib/eac_ruby_utils/module_ancestors_variable.rb +1 -1
  59. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  60. metadata +10 -179
  61. data/sub/eac_envs-http/Gemfile +0 -8
  62. data/sub/eac_envs-http/eac_envs-http.gemspec +0 -25
  63. data/sub/eac_envs-http/lib/eac_envs/http/error.rb +0 -8
  64. data/sub/eac_envs-http/lib/eac_envs/http/request/body_field.rb +0 -51
  65. data/sub/eac_envs-http/lib/eac_envs/http/request/body_field_value.rb +0 -32
  66. data/sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb +0 -39
  67. data/sub/eac_envs-http/lib/eac_envs/http/request/faraday_connection.rb +0 -75
  68. data/sub/eac_envs-http/lib/eac_envs/http/request.rb +0 -58
  69. data/sub/eac_envs-http/lib/eac_envs/http/response/body.rb +0 -62
  70. data/sub/eac_envs-http/lib/eac_envs/http/response/headers.rb +0 -41
  71. data/sub/eac_envs-http/lib/eac_envs/http/response/links.rb +0 -28
  72. data/sub/eac_envs-http/lib/eac_envs/http/response/statuses.rb +0 -21
  73. data/sub/eac_envs-http/lib/eac_envs/http/response.rb +0 -30
  74. data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server/request_processor.rb +0 -42
  75. data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server/webrick_servlet.rb +0 -22
  76. data/sub/eac_envs-http/lib/eac_envs/http/rspec/echo_server.rb +0 -63
  77. data/sub/eac_envs-http/lib/eac_envs/http/rspec.rb +0 -11
  78. data/sub/eac_envs-http/lib/eac_envs/http/version.rb +0 -7
  79. data/sub/eac_envs-http/lib/eac_envs/http.rb +0 -9
  80. data/sub/eac_envs-http/spec/lib/eac_envs/http/request/body_fields_spec.rb +0 -47
  81. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec.rb +0 -68
  82. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get.source.yaml +0 -5
  83. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get.target.yaml +0 -9
  84. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get_with_auth.source.yaml +0 -8
  85. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/get_with_auth.target.yaml +0 -10
  86. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_array_body.source.yaml +0 -10
  87. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_array_body.target.yaml +0 -11
  88. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_string_body.source.yaml +0 -4
  89. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/post_string_body.target.yaml +0 -11
  90. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_hash_body.source.yaml +0 -6
  91. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_hash_body.target.yaml +0 -11
  92. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_with_file.source.yaml +0 -5
  93. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/put_with_file.target.yaml +0 -13
  94. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/root.source.yaml +0 -2
  95. data/sub/eac_envs-http/spec/lib/eac_envs/http/request_spec_files/root.target.yaml +0 -9
  96. data/sub/eac_envs-http/spec/rubocop_spec.rb +0 -3
  97. data/sub/eac_envs-http/spec/spec_helper/request_builder.rb +0 -62
  98. data/sub/eac_envs-http/spec/spec_helper.rb +0 -7
  99. data/sub/eac_fs/Gemfile +0 -8
  100. data/sub/eac_fs/eac_fs.gemspec +0 -20
  101. data/sub/eac_fs/lib/eac_fs/cached_download.rb +0 -40
  102. data/sub/eac_fs/lib/eac_fs/comparator/build.rb +0 -57
  103. data/sub/eac_fs/lib/eac_fs/comparator/rename_file.rb +0 -15
  104. data/sub/eac_fs/lib/eac_fs/comparator.rb +0 -18
  105. data/sub/eac_fs/lib/eac_fs/contexts.rb +0 -21
  106. data/sub/eac_fs/lib/eac_fs/core_ext.rb +0 -4
  107. data/sub/eac_fs/lib/eac_fs/file_info.rb +0 -29
  108. data/sub/eac_fs/lib/eac_fs/logs/file.rb +0 -56
  109. data/sub/eac_fs/lib/eac_fs/logs.rb +0 -64
  110. data/sub/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +0 -15
  111. data/sub/eac_fs/lib/eac_fs/patches/module.rb +0 -4
  112. data/sub/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +0 -32
  113. data/sub/eac_fs/lib/eac_fs/patches/object.rb +0 -4
  114. data/sub/eac_fs/lib/eac_fs/patches/pathname/info.rb +0 -12
  115. data/sub/eac_fs/lib/eac_fs/patches/pathname.rb +0 -4
  116. data/sub/eac_fs/lib/eac_fs/patches.rb +0 -4
  117. data/sub/eac_fs/lib/eac_fs/rspec/setup.rb +0 -25
  118. data/sub/eac_fs/lib/eac_fs/rspec.rb +0 -9
  119. data/sub/eac_fs/lib/eac_fs/storage_tree.rb +0 -81
  120. data/sub/eac_fs/lib/eac_fs/traversable.rb +0 -45
  121. data/sub/eac_fs/lib/eac_fs/traverser.rb +0 -76
  122. data/sub/eac_fs/lib/eac_fs/version.rb +0 -5
  123. data/sub/eac_fs/lib/eac_fs.rb +0 -7
  124. data/sub/eac_fs/spec/lib/eac_fs/storage_tree_spec.rb +0 -32
  125. data/sub/eac_fs/spec/rubocop_spec.rb +0 -3
  126. data/sub/eac_fs/spec/spec_helper.rb +0 -4
  127. data/sub/eac_rest/Gemfile +0 -8
  128. data/sub/eac_rest/eac_rest.gemspec +0 -21
  129. data/sub/eac_rest/lib/eac_rest/api.rb +0 -57
  130. data/sub/eac_rest/lib/eac_rest/entity/data.rb +0 -44
  131. data/sub/eac_rest/lib/eac_rest/entity/fetching.rb +0 -20
  132. data/sub/eac_rest/lib/eac_rest/entity.rb +0 -35
  133. data/sub/eac_rest/lib/eac_rest/error.rb +0 -6
  134. data/sub/eac_rest/lib/eac_rest/helper.rb +0 -34
  135. data/sub/eac_rest/lib/eac_rest/request.rb +0 -48
  136. data/sub/eac_rest/lib/eac_rest/response.rb +0 -27
  137. data/sub/eac_rest/lib/eac_rest/version.rb +0 -5
  138. data/sub/eac_rest/lib/eac_rest.rb +0 -7
  139. data/sub/eac_rest/spec/lib/eac_rest/api_spec.rb +0 -71
  140. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get.source.yaml +0 -5
  141. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get.target.yaml +0 -9
  142. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get_with_auth.source.yaml +0 -8
  143. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/get_with_auth.target.yaml +0 -10
  144. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_array_body.source.yaml +0 -10
  145. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_array_body.target.yaml +0 -11
  146. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_string_body.source.yaml +0 -4
  147. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/post_string_body.target.yaml +0 -11
  148. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_hash_body.source.yaml +0 -6
  149. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_hash_body.target.yaml +0 -11
  150. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_with_file.source.yaml +0 -5
  151. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/put_with_file.target.yaml +0 -13
  152. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/root.source.yaml +0 -2
  153. data/sub/eac_rest/spec/lib/eac_rest/api_spec_files/root.target.yaml +0 -9
  154. data/sub/eac_rest/spec/rubocop_spec.rb +0 -3
  155. data/sub/eac_rest/spec/spec_helper/request_builder.rb +0 -51
  156. data/sub/eac_rest/spec/spec_helper.rb +0 -7
  157. data/sub/eac_templates/Gemfile +0 -8
  158. data/sub/eac_templates/eac_templates.gemspec +0 -19
  159. data/sub/eac_templates/lib/eac_templates/abstract/directory.rb +0 -42
  160. data/sub/eac_templates/lib/eac_templates/abstract/file.rb +0 -25
  161. data/sub/eac_templates/lib/eac_templates/abstract/fs_object.rb +0 -94
  162. data/sub/eac_templates/lib/eac_templates/abstract/fs_object_by_pathname.rb +0 -13
  163. data/sub/eac_templates/lib/eac_templates/abstract/not_found_error.rb +0 -8
  164. data/sub/eac_templates/lib/eac_templates/core_ext.rb +0 -4
  165. data/sub/eac_templates/lib/eac_templates/interface_methods.rb +0 -12
  166. data/sub/eac_templates/lib/eac_templates/modules/ancestor/directory.rb +0 -17
  167. data/sub/eac_templates/lib/eac_templates/modules/ancestor/file.rb +0 -16
  168. data/sub/eac_templates/lib/eac_templates/modules/ancestor/fs_object.rb +0 -25
  169. data/sub/eac_templates/lib/eac_templates/modules/ancestor.rb +0 -51
  170. data/sub/eac_templates/lib/eac_templates/modules/base.rb +0 -35
  171. data/sub/eac_templates/lib/eac_templates/modules.rb +0 -9
  172. data/sub/eac_templates/lib/eac_templates/patches/module/erb_template.rb +0 -9
  173. data/sub/eac_templates/lib/eac_templates/patches/module/template.rb +0 -9
  174. data/sub/eac_templates/lib/eac_templates/patches/module.rb +0 -4
  175. data/sub/eac_templates/lib/eac_templates/patches/object/erb_template.rb +0 -9
  176. data/sub/eac_templates/lib/eac_templates/patches/object/template.rb +0 -9
  177. data/sub/eac_templates/lib/eac_templates/patches/object.rb +0 -4
  178. data/sub/eac_templates/lib/eac_templates/patches.rb +0 -4
  179. data/sub/eac_templates/lib/eac_templates/sources/directory.rb +0 -37
  180. data/sub/eac_templates/lib/eac_templates/sources/file.rb +0 -13
  181. data/sub/eac_templates/lib/eac_templates/sources/from_all_gems.rb +0 -4
  182. data/sub/eac_templates/lib/eac_templates/sources/from_gem.rb +0 -37
  183. data/sub/eac_templates/lib/eac_templates/sources/fs_object.rb +0 -53
  184. data/sub/eac_templates/lib/eac_templates/sources/internal_set.rb +0 -22
  185. data/sub/eac_templates/lib/eac_templates/sources/set.rb +0 -55
  186. data/sub/eac_templates/lib/eac_templates/sources/single.rb +0 -29
  187. data/sub/eac_templates/lib/eac_templates/sources.rb +0 -9
  188. data/sub/eac_templates/lib/eac_templates/variables/content.rb +0 -52
  189. data/sub/eac_templates/lib/eac_templates/variables/directory.rb +0 -49
  190. data/sub/eac_templates/lib/eac_templates/variables/file.rb +0 -26
  191. data/sub/eac_templates/lib/eac_templates/variables/fs_object.rb +0 -65
  192. data/sub/eac_templates/lib/eac_templates/variables/not_found_error.rb +0 -7
  193. data/sub/eac_templates/lib/eac_templates/variables/providers/base.rb +0 -23
  194. data/sub/eac_templates/lib/eac_templates/variables/providers/config_reader.rb +0 -29
  195. data/sub/eac_templates/lib/eac_templates/variables/providers/entries_reader.rb +0 -25
  196. data/sub/eac_templates/lib/eac_templates/variables/providers/generic.rb +0 -25
  197. data/sub/eac_templates/lib/eac_templates/variables/providers/hash.rb +0 -29
  198. data/sub/eac_templates/lib/eac_templates/variables/providers.rb +0 -25
  199. data/sub/eac_templates/lib/eac_templates/variables.rb +0 -9
  200. data/sub/eac_templates/lib/eac_templates/version.rb +0 -5
  201. data/sub/eac_templates/lib/eac_templates.rb +0 -7
  202. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec.rb +0 -141
  203. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/a_module/a/a_a +0 -1
  204. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/a_module/b +0 -1
  205. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/super_class/a/a_b +0 -1
  206. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path1/super_class/b +0 -1
  207. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/a/a_b +0 -1
  208. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/b +0 -1
  209. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/a_module/c +0 -1
  210. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/prepended_module/c +0 -1
  211. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/sub_class/b +0 -1
  212. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/a/a_b +0 -1
  213. data/sub/eac_templates/spec/lib/eac_templates/modules/base_spec_files/path2/super_class/b +0 -1
  214. data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec.rb +0 -26
  215. data/sub/eac_templates/spec/lib/eac_templates/patches/object/template_spec_files/path/my_stub_with_template +0 -1
  216. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec.rb +0 -42
  217. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file1.template +0 -1
  218. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path1/subdir1/file2 +0 -1
  219. data/sub/eac_templates/spec/lib/eac_templates/sources/set_spec_files/path2/subdir1/file3.template +0 -1
  220. data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec.rb +0 -35
  221. data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec_files/expected_content +0 -2
  222. data/sub/eac_templates/spec/lib/eac_templates/variables/content_spec_files/source.template +0 -2
  223. data/sub/eac_templates/spec/rubocop_spec.rb +0 -3
  224. data/sub/eac_templates/spec/spec_helper.rb +0 -4
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacFs
6
- class Comparator
7
- class Build
8
- TRUNCATE_FILE_CONTENT = "__TRUNCATED__\n"
9
-
10
- enable_method_class
11
- common_constructor :comparator, :root
12
- delegate :rename_files, :truncate_files, to: :comparator
13
-
14
- # @return [Hash]
15
- def result
16
- build(root)
17
- end
18
-
19
- private
20
-
21
- def build(obj)
22
- if obj.file?
23
- build_file(obj)
24
- elsif obj.directory?
25
- build_directory(obj)
26
- else
27
- raise "Unknown filesystem object \"#{obj}\""
28
- end
29
- end
30
-
31
- # @param dir [Pathname]
32
- # @return [Hash]
33
- def build_directory(dir)
34
- dir.children.map do |child|
35
- [fs_object_basename(child), build(child)]
36
- end.to_h
37
- end
38
-
39
- # @param file [Pathname]
40
- # @return [Hash]
41
- def build_file(file)
42
- truncate_file?(file) ? TRUNCATE_FILE_CONTENT : file.read
43
- end
44
-
45
- # @return [String]
46
- def fs_object_basename(obj)
47
- rename_files.inject(obj.basename.to_path) { |a, e| e.apply(a) }
48
- end
49
-
50
- def truncate_file?(file)
51
- truncate_files.any? do |pattern|
52
- file.basename.fnmatch?(pattern)
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacFs
6
- class Comparator
7
- class RenameFile
8
- common_constructor :from, :to
9
-
10
- def apply(basename)
11
- basename == from ? to : basename
12
- end
13
- end
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacFs
6
- class Comparator
7
- require_sub __FILE__, require_dependency: true
8
-
9
- enable_immutable
10
- immutable_accessor :rename_file, :truncate_file, type: :array
11
-
12
- alias rename_file_push rename_file
13
-
14
- def rename_file(from, to)
15
- rename_file_push(::EacFs::Comparator::RenameFile.new(from, to))
16
- end
17
- end
18
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/context'
5
-
6
- module EacFs
7
- class Contexts
8
- TYPES = %i[cache config data].freeze
9
-
10
- class << self
11
- TYPES.each do |type|
12
- class_eval <<~CODE, __FILE__, __LINE__ + 1
13
- # @return [EacRubyUtils::Context<EacFs::StorageTree>]
14
- def #{type}
15
- @#{type} ||= ::EacRubyUtils::Context.new
16
- end
17
- CODE
18
- end
19
- end
20
- end
21
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_fs/patches'
4
- require 'eac_ruby_utils/core_ext'
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'content-type'
5
- require 'filemagic'
6
-
7
- module EacFs
8
- class FileInfo
9
- UNKNOWN_CONTENT_TYPE_STRING = 'application/octet-stream'
10
- UNKNOWN_CONTENT_TYPE = ::ContentType.parse(UNKNOWN_CONTENT_TYPE_STRING)
11
-
12
- enable_simple_cache
13
- attr_reader :magic_string
14
-
15
- def initialize(path)
16
- @magic_string = ::FileMagic.new(FileMagic::MAGIC_MIME).file(path.to_pathname.to_path)
17
- end
18
-
19
- delegate :charset, :mime_type, :subtype, :type, to: :content_type
20
-
21
- private
22
-
23
- def content_type_uncached
24
- ::ContentType.parse(magic_string)
25
- rescue ::Parslet::ParseFailed
26
- UNKNOWN_CONTENT_TYPE
27
- end
28
- end
29
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacFs
6
- class Logs
7
- class File
8
- enable_simple_cache
9
- common_constructor :label
10
-
11
- TRUNCATE_DEFAULT_LENGTH = 1000
12
- TRUNCATE_APPEND_TEXT = '(...) '
13
-
14
- delegate :remove, to: :file
15
-
16
- def clean
17
- file.truncate(0) if file.exist?
18
- end
19
-
20
- def file_size
21
- file.file? ? file.size : 0
22
- end
23
-
24
- def pretty_file_size
25
- ::Filesize.from("#{file_size} B").pretty
26
- end
27
-
28
- # @param length [Integer]
29
- # @return [String]
30
- def truncate(length = TRUNCATE_DEFAULT_LENGTH)
31
- content = file.file? ? file.read.strip : ''
32
- return content if content.length <= TRUNCATE_DEFAULT_LENGTH
33
-
34
- TRUNCATE_APPEND_TEXT + content[content.length - length + TRUNCATE_APPEND_TEXT.length,
35
- length - TRUNCATE_APPEND_TEXT.length]
36
- end
37
-
38
- # @param length [Integer]
39
- # @return [String]
40
- def truncate_with_label(length = TRUNCATE_DEFAULT_LENGTH)
41
- header = [label, file, pretty_file_size].join(' / ')
42
- return ">>> #{header} (Not found) <<<" unless file.file?
43
-
44
- content = truncate(length)
45
- content.blank? ? ">>> #{header} (Blank) <<<" : ">>> #{header}\n#{content}\n<<< #{header}\n"
46
- end
47
-
48
- protected
49
-
50
- # @return [EacRubyUtils::Fs::Temp::File
51
- def file_uncached
52
- ::EacRubyUtils::Fs::Temp.file
53
- end
54
- end
55
- end
56
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/fs/temp'
5
- require 'filesize'
6
-
7
- module EacFs
8
- class Logs
9
- require_sub __FILE__
10
-
11
- # @param label [Symbol]
12
- # @return [EacRubyUtils::Fs::Temp::File]
13
- def [](label)
14
- log_set.fetch(sanitize_label(label)).file
15
- end
16
-
17
- # @param label [Symbol]
18
- # @return [EacFs::Logs]
19
- def add(label)
20
- file = ::EacFs::Logs::File.new(sanitize_label(label))
21
- log_set[file.label] = file
22
-
23
- self
24
- end
25
-
26
- # @return [EacFs::Logs]
27
- def clean_all
28
- log_set.values.each(&:clean)
29
- end
30
-
31
- # @return [EacFs::Logs]
32
- def remove_all
33
- log_set.each_key { |label| remove(label) }
34
-
35
- self
36
- end
37
-
38
- # @param label [Symbol]
39
- def remove(label)
40
- log_set.fetch(sanitize_label(label)).remove
41
- log_set.delete(sanitize_label(label))
42
- end
43
-
44
- # @param length [Integer]
45
- # @return [String]
46
- def truncate_all(length = ::EacFs::Logs::File::TRUNCATE_DEFAULT_LENGTH)
47
- "Files: #{log_set.length}\n" +
48
- log_set.values.map { |file| file.truncate_with_label(length) }.join
49
- end
50
-
51
- private
52
-
53
- # @param label [Object]
54
- # @return [Symbol]
55
- def sanitize_label(label)
56
- label.to_sym
57
- end
58
-
59
- # @return [Hash<Symbol, EacFs::Logs::File>]
60
- def log_set
61
- @log_set ||= {}
62
- end
63
- end
64
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_fs/contexts'
4
-
5
- class Module
6
- ::EacFs::Contexts::TYPES.each do |type|
7
- method_name = "fs_#{type}"
8
- class_eval <<~CODE, __FILE__, __LINE__ + 1
9
- # @return [EacFs::StorageTree]
10
- def #{method_name}
11
- ::EacFs::Contexts.#{type}.current.child('#{method_name}', *name.split('::'))
12
- end
13
- CODE
14
- end
15
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_fs/contexts'
4
- require 'eac_fs/patches/module/fs_cache'
5
-
6
- class Object
7
- ::EacFs::Contexts::TYPES.each do |type|
8
- class_eval <<~CODE, __FILE__, __LINE__ + 1
9
- # @return [EacFs::StorageTree]
10
- def fs_#{type}
11
- oid = fs_object_id_by_type(:'#{type}')
12
- oid = [oid.to_s] unless oid.is_a?(::Enumerable)
13
- oid.inject(fs_#{type}_parent) { |a, e| a.child(e.to_s) }
14
- end
15
-
16
- # @return [EacFs::StorageTree]
17
- def fs_#{type}_parent
18
- self.class.fs_#{type}
19
- end
20
- CODE
21
- end
22
-
23
- # @return [String, Array<String>]
24
- def fs_object_id
25
- raise 'Abstract method hit'
26
- end
27
-
28
- def fs_object_id_by_type(type)
29
- method = "fs_#{type}_object_id"
30
- respond_to?(method) ? send(method) : fs_object_id
31
- end
32
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_fs/file_info'
4
- require 'pathname'
5
-
6
- class Pathname
7
- # Shortcut for `EacFs::FileInfo.new(self)`.
8
- # @return [EacFs::FileInfo]
9
- def info
10
- ::EacFs::FileInfo.new(self)
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_fs/contexts'
5
- require 'eac_fs/storage_tree'
6
- require 'eac_ruby_utils/fs/temp'
7
-
8
- module EacFs
9
- module Rspec
10
- module Setup
11
- require_sub __FILE__
12
-
13
- # @return [self]
14
- def stub_eac_fs_contexts
15
- ::EacFs::Contexts::TYPES.each do |type|
16
- ::EacFs::Contexts.send(type).push(
17
- ::EacFs::StorageTree.new(::EacRubyUtils::Fs::Temp.directory)
18
- )
19
- end
20
-
21
- self
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 EacFs
6
- module Rspec
7
- require_sub __FILE__
8
- end
9
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/yaml'
5
- require 'fileutils'
6
-
7
- module EacFs
8
- class StorageTree
9
- CONTENT_FILE_NAME = '__content__'
10
-
11
- attr_reader :path
12
-
13
- def initialize(*path_parts)
14
- raise ArgumentError, "\"#{path_parts}\" is empty" if path_parts.empty?
15
-
16
- @path = ::File.expand_path(::File.join(*path_parts.map(&:to_s)))
17
- end
18
-
19
- def clear
20
- return unless stored?
21
-
22
- ::File.unlink(content_path)
23
- end
24
-
25
- def read
26
- return nil unless stored?
27
-
28
- ::File.read(content_path)
29
- end
30
-
31
- def read_or_store
32
- write(yield) unless stored?
33
-
34
- read
35
- end
36
-
37
- # @return [Object]
38
- def read_or_store_yaml(use_cache = true)
39
- write_yaml(yield) unless stored? && use_cache
40
-
41
- read_yaml
42
- end
43
-
44
- # @return [Object, nil]
45
- def read_yaml
46
- r = read
47
- r.nil? ? nil : ::EacRubyUtils::Yaml.load(r)
48
- end
49
-
50
- def write(value)
51
- assert_directory_on_path
52
- ::File.write(content_path, value)
53
- value
54
- end
55
-
56
- def write_yaml(object)
57
- write(::EacRubyUtils::Yaml.dump(object))
58
- object
59
- end
60
-
61
- def child(*child_path_parts)
62
- self.class.new(path, *child_path_parts)
63
- end
64
-
65
- def stored?
66
- ::File.exist?(content_path)
67
- end
68
-
69
- def content_path
70
- ::File.join(path, CONTENT_FILE_NAME)
71
- end
72
-
73
- private
74
-
75
- def assert_directory_on_path
76
- raise "#{path} is a file" if ::File.file?(path)
77
-
78
- ::FileUtils.mkdir_p(path)
79
- end
80
- end
81
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_fs/traverser'
4
-
5
- module EacFs
6
- module Traversable
7
- PROP_METHOD_PREFIX = 'traverser_'
8
- BOOLEAN_PROPS = %i[hidden_directories recursive sort].freeze
9
- PATH_PROPS = %i[check_directory check_file].freeze
10
-
11
- class << self
12
- def prop_method_name(prop)
13
- "#{PROP_METHOD_PREFIX}#{prop}"
14
- end
15
- end
16
-
17
- PATH_PROPS.each do |method|
18
- define_method(::EacFs::Traversable.prop_method_name(method)) do |_path|
19
- nil
20
- end
21
- end
22
-
23
- BOOLEAN_PROPS.each do |method|
24
- define_method(::EacFs::Traversable.prop_method_name(method)) do
25
- false
26
- end
27
-
28
- define_method("#{::EacFs::Traversable.prop_method_name(method)}?") do
29
- send(method_name)
30
- end
31
- end
32
-
33
- def traverser_check_path(path)
34
- traverser_new.check_path(path)
35
- end
36
-
37
- def traverser_new
38
- r = ::EacFs::Traverser.new
39
- (BOOLEAN_PROPS + PATH_PROPS).each do |prop|
40
- r.send("#{prop}=", method(::EacFs::Traversable.prop_method_name(prop)))
41
- end
42
- r
43
- end
44
- end
45
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacFs
4
- class Traverser
5
- attr_accessor :check_directory, :check_file, :recursive, :hidden_directories, :sort
6
-
7
- def initialize(options = {})
8
- options.each do |accessor, value|
9
- send("#{accessor}=", value)
10
- end
11
- end
12
-
13
- def check_path(path)
14
- path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
15
- internal_check_path(path, 0)
16
- end
17
-
18
- def hidden_directories?
19
- boolean_value(hidden_directories)
20
- end
21
-
22
- def recursive?
23
- boolean_value(recursive)
24
- end
25
-
26
- def sort?
27
- boolean_value(sort)
28
- end
29
-
30
- private
31
-
32
- def boolean_value(source_value)
33
- source_value = source_value.call if source_value.respond_to?(:call)
34
- source_value ? true : false
35
- end
36
-
37
- def each_child(dir, &block)
38
- if sort?
39
- dir.each_child.sort_by { |p| [p.to_s] }.each(&block)
40
- else
41
- dir.each_child(&block)
42
- end
43
- end
44
-
45
- def process_directory?(level)
46
- level.zero? || recursive?
47
- end
48
-
49
- def inner_check_directory(dir, level)
50
- return unless process_directory?(level)
51
-
52
- user_check_directory(dir)
53
- each_child(dir) do |e|
54
- next unless !e.basename.to_s.start_with?('.') || hidden_directories?
55
-
56
- internal_check_path(e, level + 1)
57
- end
58
- end
59
-
60
- def internal_check_path(path, level)
61
- if path.file?
62
- user_check_file(path)
63
- elsif path.directory?
64
- inner_check_directory(path, level)
65
- end
66
- end
67
-
68
- def user_check_file(path)
69
- check_file&.call(path)
70
- end
71
-
72
- def user_check_directory(path)
73
- check_directory&.call(path)
74
- end
75
- end
76
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacFs
4
- VERSION = '0.16.0'
5
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacFs
6
- require_sub __FILE__
7
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/object/blank'
4
- require 'eac_fs/storage_tree'
5
-
6
- RSpec.describe ::EacFs::StorageTree do
7
- let(:tmpdir) { ::Dir.mktmpdir }
8
- let(:instance) { described_class.new(tmpdir, 'instance') }
9
-
10
- it { expect(instance.read).to be_blank }
11
- it { expect(instance.stored?).to eq(false) }
12
-
13
- context 'when instance is writed' do
14
- before { instance.write('STUB') }
15
-
16
- it { expect(instance.read).to eq('STUB') }
17
- it { expect(instance.stored?).to eq(true) }
18
-
19
- context 'when instance is cleared' do
20
- before { instance.clear }
21
-
22
- it { expect(instance.read).to be_blank }
23
- it { expect(instance.stored?).to eq(false) }
24
- end
25
- end
26
-
27
- describe '#child' do
28
- let(:child) { instance.child('child') }
29
-
30
- it { expect(child.path).to match(/\A#{::Regexp.quote(instance.path)}/) }
31
- end
32
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/rspec/default_setup'
4
- ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
data/sub/eac_rest/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
- eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push File.expand_path('lib', __dir__)
4
-
5
- require 'eac_rest/version'
6
-
7
- Gem::Specification.new do |s|
8
- s.name = 'eac_rest'
9
- s.version = EacRest::VERSION
10
- s.authors = ['Eduardo H. Bogoni']
11
- s.summary = 'A REST helper for Ruby.'
12
-
13
- s.files = Dir['{lib}/**/*']
14
-
15
- s.add_dependency 'eac_envs-http', '~> 0.4', '>= 0.4.1'
16
- s.add_dependency 'eac_fs', '~> 0.16'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.119', '>= 0.119.1'
18
-
19
- s.add_development_dependency 'aranha-parsers', '~> 0.15'
20
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
21
- end