eac_tools 0.7.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +43 -31
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/avm.gemspec +1 -0
  5. data/sub/avm/lib/avm/application_stereotypes/base/by_gem.rb +17 -0
  6. data/sub/avm/lib/avm/application_stereotypes/base/detection.rb +34 -0
  7. data/sub/avm/lib/avm/application_stereotypes/base.rb +21 -0
  8. data/sub/avm/lib/avm/application_stereotypes.rb +9 -0
  9. data/sub/avm/lib/avm/{instances/application.rb → applications/base.rb} +5 -6
  10. data/sub/avm/lib/avm/applications.rb +9 -0
  11. data/sub/avm/lib/avm/docker/image.rb +12 -2
  12. data/sub/avm/lib/avm/instances/base.rb +7 -2
  13. data/sub/avm/lib/avm/instances.rb +1 -1
  14. data/sub/avm/lib/avm/registry/application_stereotypes/build_available.rb +46 -0
  15. data/sub/avm/lib/avm/registry/application_stereotypes/stereotype_builder.rb +30 -0
  16. data/sub/avm/lib/avm/registry/application_stereotypes.rb +36 -0
  17. data/sub/avm/lib/avm/registry/{base.rb → from_gems.rb} +13 -4
  18. data/sub/avm/lib/avm/registry/instances.rb +16 -0
  19. data/sub/avm/lib/avm/registry/runners.rb +10 -0
  20. data/sub/avm/lib/avm/registry/scms.rb +10 -0
  21. data/sub/avm/lib/avm/registry/sources.rb +10 -0
  22. data/sub/avm/lib/avm/registry/with_path/cache.rb +31 -0
  23. data/sub/avm/lib/avm/registry/with_path.rb +33 -7
  24. data/sub/avm/lib/avm/registry.rb +3 -7
  25. data/sub/avm/lib/avm/rspec/shared_examples/not_in_avm_registry.rb +1 -1
  26. data/sub/avm/lib/avm/sources/base/configuration.rb +23 -2
  27. data/sub/avm/lib/avm/sources/base/instance.rb +2 -2
  28. data/sub/avm/lib/avm/sources/base/locale.rb +1 -1
  29. data/sub/avm/lib/avm/sources/base/parent.rb +8 -11
  30. data/sub/avm/lib/avm/sources/base/subs_paths.rb +1 -1
  31. data/sub/avm/lib/avm/sources/base/testing.rb +4 -4
  32. data/sub/avm/lib/avm/sources/base.rb +4 -0
  33. data/sub/avm/lib/avm/sources/tests/builder.rb +5 -10
  34. data/sub/avm/lib/avm/version.rb +1 -1
  35. data/sub/avm/lib/avm/with_application_stereotype.rb +23 -0
  36. data/sub/avm/lib/avm/with_dynamic_runners.rb +42 -0
  37. data/sub/{avm-tools/spec/lib/avm/instances/application_spec.rb → avm/spec/lib/avm/applications/base_spec.rb} +3 -3
  38. data/sub/{avm-tools/spec/lib/avm/instances/application_spec_fixture.yml → avm/spec/lib/avm/applications/base_spec_fixture.yml} +0 -0
  39. data/sub/{avm-tools → avm}/spec/lib/avm/instances/base_spec.rb +0 -0
  40. data/sub/{avm-tools → avm}/spec/lib/avm/instances/base_spec_configs_storage.yml +0 -0
  41. data/sub/avm-eac_generic_base0/avm-eac_generic_base0.gemspec +2 -2
  42. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker/runner.rb +61 -0
  43. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/sources/docker.rb +13 -0
  44. data/sub/avm-eac_generic_base0/lib/avm/eac_generic_base0/version.rb +1 -1
  45. data/sub/avm-eac_rails_base0/Gemfile +3 -0
  46. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +1 -0
  47. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/sources/runners/docker.rb +19 -0
  48. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  49. data/sub/avm-eac_redmine_plugin_base0/avm-eac_redmine_plugin_base0.gemspec +1 -1
  50. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base.rb +15 -4
  51. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/version.rb +1 -1
  52. data/sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec +1 -1
  53. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/bundler.rb +1 -1
  54. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/sources/base/rake.rb +14 -0
  55. data/sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/version.rb +1 -1
  56. data/sub/avm-tools/Gemfile +3 -0
  57. data/sub/avm-tools/avm-tools.gemspec +1 -1
  58. data/sub/avm-tools/lib/avm/tools/runner/app_src/info.rb +19 -0
  59. data/sub/avm-tools/lib/avm/tools/runner/application_stereotypes/list.rb +31 -0
  60. data/sub/avm-tools/lib/avm/tools/runner/application_stereotypes.rb +16 -0
  61. data/sub/avm-tools/lib/avm/tools/version.rb +1 -1
  62. data/sub/eac_cli/Gemfile +3 -0
  63. data/sub/eac_cli/lib/eac_cli/version.rb +1 -1
  64. data/sub/eac_config/Gemfile +8 -0
  65. data/sub/{avm-tools/sub/eac_config → eac_config}/eac_config.gemspec +0 -0
  66. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/entry.rb +0 -0
  67. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/entry_path.rb +5 -0
  68. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/envvars_node/entry.rb +0 -0
  69. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/envvars_node.rb +0 -0
  70. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/load_nodes_search.rb +0 -0
  71. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/load_path.rb +0 -0
  72. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/node.rb +6 -0
  73. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/node_entry.rb +0 -0
  74. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/node_uri.rb +0 -0
  75. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/old_configs/base.rb +0 -0
  76. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/old_configs/file.rb +0 -0
  77. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/old_configs.rb +0 -0
  78. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash/entry_key_error.rb +0 -0
  79. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash/node.rb +0 -0
  80. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash/path_search.rb +0 -0
  81. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/paths_hash.rb +0 -0
  82. data/sub/eac_config/lib/eac_config/prefixed_path_node/entry.rb +25 -0
  83. data/sub/eac_config/lib/eac_config/prefixed_path_node.rb +19 -0
  84. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/rspec/setup.rb +0 -0
  85. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/rspec.rb +0 -0
  86. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/version.rb +1 -1
  87. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/yaml_file_node/entry.rb +0 -0
  88. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config/yaml_file_node.rb +0 -0
  89. data/sub/{avm-tools/sub/eac_config → eac_config}/lib/eac_config.rb +0 -0
  90. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/entry_path_spec.rb +0 -0
  91. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/envvars_node/entry_spec.rb +0 -0
  92. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/envvars_node_spec.rb +0 -0
  93. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/old_configs_spec.rb +0 -0
  94. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/paths_hash_spec.rb +0 -0
  95. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec.rb +0 -0
  96. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1.yaml +0 -0
  97. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1_1.yaml +0 -0
  98. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2/storage1_2_1.yaml +0 -0
  99. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/lib/eac_config/yaml_file_node_spec_files/storage1_2.yaml +0 -0
  100. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/rubocop_spec.rb +0 -0
  101. data/sub/{avm-tools/sub/eac_config → eac_config}/spec/spec_helper.rb +0 -0
  102. data/sub/eac_docker/Gemfile +8 -0
  103. data/sub/{avm-tools/sub/eac_docker → eac_docker}/eac_docker.gemspec +3 -3
  104. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/container.rb +4 -3
  105. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/debug.rb +0 -0
  106. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/executables.rb +0 -0
  107. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/base.rb +0 -0
  108. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/coded.rb +0 -0
  109. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/named.rb +0 -0
  110. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images/templatized.rb +0 -0
  111. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/images.rb +0 -0
  112. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/registry.rb +0 -0
  113. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/rspec/setup.rb +0 -0
  114. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/rspec.rb +0 -0
  115. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker/version.rb +1 -1
  116. data/sub/{avm-tools/sub/eac_docker → eac_docker}/lib/eac_docker.rb +0 -0
  117. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/executables_spec.rb +0 -0
  118. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/coded_spec.rb +0 -0
  119. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/coded_spec_files/image1/Dockerfile +0 -0
  120. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/templatized_spec.rb +0 -0
  121. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/lib/eac_docker/images/templatized_spec_files/stub_docker_image/Dockerfile +0 -0
  122. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/rubocop_spec.rb +0 -0
  123. data/sub/{avm-tools/sub/eac_docker → eac_docker}/spec/spec_helper.rb +0 -0
  124. data/sub/eac_fs/Gemfile +3 -0
  125. data/sub/eac_fs/lib/eac_fs/version.rb +1 -1
  126. data/sub/eac_ruby_base0/Gemfile +3 -0
  127. data/sub/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
  128. data/sub/eac_ruby_utils/Gemfile +2 -10
  129. data/sub/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +22 -5
  130. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  131. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/immutable_spec.rb +34 -0
  132. metadata +101 -87
  133. data/sub/avm/lib/avm/sources/base/runners.rb +0 -47
  134. data/sub/avm-tools/Gemfile.lock +0 -296
  135. data/sub/avm-tools/lib/avm/tools/runner/eac_redmine_base0/dev_docker.rb +0 -17
  136. data/sub/avm-tools/sub/eac_config/Gemfile +0 -5
  137. data/sub/avm-tools/sub/eac_docker/Gemfile +0 -5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.10.0'
5
+ VERSION = '0.11.0'
6
6
  end
7
7
  end
@@ -10,3 +10,6 @@ Dir["#{gems_subdir}/*"].each do |dir|
10
10
 
11
11
  gem ::File.basename(dir), path: dir
12
12
  end
13
+
14
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
15
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
16
 
17
17
  s.add_dependency 'aranha-parsers', '~> 0.4'
18
- s.add_dependency 'avm', '~> 0.22'
18
+ s.add_dependency 'avm', '~> 0.27'
19
19
  s.add_dependency 'avm-eac_asciidoctor_base0', '~> 0.3', '>= 0.3.4'
20
20
  s.add_dependency 'avm-eac_rails_base0', '~> 0.3'
21
21
  s.add_dependency 'avm-eac_redmine_base0', '~> 0.5', '>= 0.5.2'
@@ -9,11 +9,15 @@ module Avm
9
9
  class Info
10
10
  runner_with :help do
11
11
  desc 'Show information about local project instance.'
12
+ bool_opt '-p', '--parent', 'Show the parent source.'
13
+ bool_opt '-t', '--tests', 'Show test commands.'
12
14
  end
13
15
 
14
16
  def run
15
17
  show_instance
16
18
  show_source
19
+ show_parent
20
+ show_test_commands
17
21
  end
18
22
 
19
23
  private
@@ -23,11 +27,26 @@ module Avm
23
27
  infov 'Launcher stereotypes', instance.stereotypes.map(&:label).join(', ')
24
28
  end
25
29
 
30
+ def show_parent
31
+ return unless parsed.parent?
32
+
33
+ infov 'Parent', runner_context.call(:subject).parent
34
+ end
35
+
26
36
  def show_source
27
37
  infov 'Stereotype', runner_context.call(:subject).class
28
38
  infov 'SCM', runner_context.call(:subject).scm
29
39
  end
30
40
 
41
+ def show_test_commands
42
+ return unless parsed.tests?
43
+
44
+ infov 'Test commands', runner_context.call(:subject).test_commands.count
45
+ runner_context.call(:subject).test_commands.each do |name, command|
46
+ infov " * #{name}", command
47
+ end
48
+ end
49
+
31
50
  def instance
32
51
  runner_context.call(:instance)
33
52
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/tools/core_ext'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner
8
+ class ApplicationStereotypes
9
+ class List
10
+ runner_with :help, :output
11
+
12
+ def run
13
+ infov 'Found', stereotypes.count
14
+ run_output
15
+ end
16
+
17
+ def output_content
18
+ stereotypes.map { |s| "#{s}\n" }.join
19
+ end
20
+
21
+ private
22
+
23
+ def stereotypes
24
+ ::Avm::Registry.application_stereotypes.available
25
+ .sort_by { |s| [s.name, s.namespace_module] }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Avm
6
+ module Tools
7
+ class Runner
8
+ class ApplicationStereotypes
9
+ require_sub __FILE__
10
+ runner_with :help, :subcommands do
11
+ subcommands
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.121.2'
5
+ VERSION = '0.124.0'
6
6
  end
7
7
  end
data/sub/eac_cli/Gemfile CHANGED
@@ -3,3 +3,6 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.27.6'
4
+ VERSION = '0.27.7'
5
5
  end
@@ -0,0 +1,8 @@
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)
@@ -34,6 +34,11 @@ module EacConfig
34
34
  @parts = parts.to_a.freeze
35
35
  end
36
36
 
37
+ # @return [EacConfig::EntryPath]
38
+ def +(other)
39
+ self.class.new(parts + self.class.assert(other).parts)
40
+ end
41
+
37
42
  def to_s
38
43
  "#{self.class}[#{parts.join(PART_SEPARATOR)}]"
39
44
  end
@@ -58,6 +58,12 @@ module EacConfig
58
58
  ::EacConfig::LoadNodesSearch.new(self).result
59
59
  end
60
60
 
61
+ # @return [EacConfig::PrefixedPathNode]
62
+ def with_prefix(path_prefix)
63
+ require 'eac_config/prefixed_path_node'
64
+ ::EacConfig::PrefixedPathNode.new(self, path_prefix)
65
+ end
66
+
61
67
  private
62
68
 
63
69
  def load_node(node_path)
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/node_entry'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module EacConfig
7
+ class PrefixedPathNode
8
+ class Entry < ::EacConfig::NodeEntry
9
+ enable_simple_cache
10
+ delegate :found?, :found_node, :secret_value, :value, :value=, :writ_node, to: :full_entry
11
+
12
+ # @return [EacConfig::EntryPath]
13
+ def full_path
14
+ node.path_prefix + path
15
+ end
16
+
17
+ private
18
+
19
+ # @return [EacConfig::NodeEntry]
20
+ def full_entry_uncached
21
+ node.from_node.entry(full_path)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/entry_path'
4
+ require 'eac_config/paths_hash'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module EacConfig
8
+ class PrefixedPathNode
9
+ require_sub __FILE__
10
+ include ::EacConfig::Node
11
+ common_constructor :from_node, :path_prefix do
12
+ self.path_prefix = ::EacConfig::EntryPath.assert(path_prefix)
13
+ end
14
+
15
+ def entry(path)
16
+ ::EacConfig::Entry.new(self, path)
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacConfig
4
- VERSION = '0.8.1'
4
+ VERSION = '0.9.0'
5
5
  end
@@ -0,0 +1,8 @@
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)
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'eac_ruby_utils', '~> 0.74'
16
- s.add_dependency 'eac_templates', '~> 0.1'
15
+ s.add_dependency 'eac_ruby_utils', '~> 0.96'
16
+ s.add_dependency 'eac_templates', '~> 0.3', '>= 0.3.1'
17
17
 
18
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3', '>= 0.3.3'
18
+ s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
19
19
  end
@@ -34,7 +34,7 @@ module EacDocker
34
34
  end
35
35
  end
36
36
 
37
- def volume(left_part, right_part = null)
37
+ def volume(left_part, right_part = nil)
38
38
  immutable_volume(right_part.if_present(left_part) { |v| "#{left_part}:#{v}" })
39
39
  end
40
40
 
@@ -43,8 +43,9 @@ module EacDocker
43
43
  end
44
44
 
45
45
  def run_command_args
46
- run_command_boolean_args + run_command_capabilities_args + run_command_envs_args +
47
- run_command_volumes_args + [image.provide.id] + command_args
46
+ %w[boolean capabilities envs volumes]
47
+ .inject([]) { |a, e| a + send("run_command_#{e}_args") } +
48
+ [image.provide.id] + command_args
48
49
  end
49
50
 
50
51
  def stop
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacDocker
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
data/sub/eac_fs/Gemfile CHANGED
@@ -3,3 +3,6 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacFs
4
- VERSION = '0.12.2'
4
+ VERSION = '0.12.3'
5
5
  end
@@ -3,3 +3,6 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.16.5'
4
+ VERSION = '0.16.6'
5
5
  end
@@ -2,15 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Declare your gem's dependencies in users_support.gemspec.
6
- # Bundler will treat runtime dependencies like base dependencies, and
7
- # development dependencies will be added by default to the :development group.
8
5
  gemspec
9
6
 
10
- # Declare any dependencies that are still in development here instead of in
11
- # your gemspec. These might include edge Rails or gems from your path or
12
- # Git. Remember to move these dependencies to your gemspec before releasing
13
- # your gem to rubygems.org.
14
-
15
- # To use a debugger
16
- # gem 'byebug', group: [:development, :test]
7
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -8,13 +8,26 @@ module EacRubyUtils
8
8
  module Immutable
9
9
  class ArrayAccessor < ::EacRubyUtils::Immutable::BaseAccessor
10
10
  def apply(klass)
11
+ apply_singular(klass)
12
+ apply_plural(klass)
13
+ end
14
+
15
+ def apply_plural(klass)
11
16
  accessor = self
12
- klass.send(:define_method, name) do |value|
13
- accessor.immutable_value_set(self, value)
17
+ klass.send(:define_method, ::ActiveSupport::Inflector.pluralize(name)) do |*args|
18
+ case args.count
19
+ when 0 then next accessor.immutable_value_get(self)
20
+ when 1 then next accessor.immutable_value_set(self, args.first)
21
+ else
22
+ raise ::ArgumentError, "wrong number of arguments (given #{args.count}, expected 0..1)"
23
+ end
14
24
  end
25
+ end
15
26
 
16
- klass.send(:define_method, ::ActiveSupport::Inflector.pluralize(name)) do
17
- accessor.immutable_value_get(self)
27
+ def apply_singular(klass)
28
+ accessor = self
29
+ klass.send(:define_method, name) do |value|
30
+ accessor.immutable_value_push(self, value)
18
31
  end
19
32
  end
20
33
 
@@ -22,11 +35,15 @@ module EacRubyUtils
22
35
  super || []
23
36
  end
24
37
 
25
- def immutable_value_set(object, value)
38
+ def immutable_value_push(object, value)
26
39
  duplicate_object(object) do |old_value|
27
40
  (old_value || []) + [value]
28
41
  end
29
42
  end
43
+
44
+ def immutable_value_set(object, value)
45
+ duplicate_object(object) { |_old_value| value }
46
+ end
30
47
  end
31
48
  end
32
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.95.2'
4
+ VERSION = '0.96.0'
5
5
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::RSpec.describe ::EacRubyUtils::Immutable do
4
+ let(:stub_class) do
5
+ the_described_class = described_class
6
+ ::Class.new do
7
+ include the_described_class
8
+
9
+ immutable_accessor :array_attr, type: :array
10
+ end
11
+ end
12
+
13
+ let(:initial_instance) { stub_class.new }
14
+
15
+ it do
16
+ expect(initial_instance.array_attrs).to eq([])
17
+ end
18
+
19
+ context 'when array_attr pushs for' do
20
+ let(:change1_instance) { initial_instance.array_attr('A') }
21
+
22
+ it { expect(change1_instance).to be_a(initial_instance.class) }
23
+ it { expect(change1_instance.object_id).not_to eq(initial_instance.object_id) }
24
+ it { expect(change1_instance.array_attrs).to eq(%w[A]) }
25
+
26
+ context 'when array_attrs sets for' do
27
+ let(:change2_instance) { initial_instance.array_attrs(%w[B]) }
28
+
29
+ it { expect(change2_instance).to be_a(initial_instance.class) }
30
+ it { expect(change2_instance.object_id).not_to eq(change1_instance.object_id) }
31
+ it { expect(change2_instance.array_attrs).to eq(%w[B]) }
32
+ end
33
+ end
34
+ end