eac_tools 0.45.2 → 0.47.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +42 -36
  3. data/lib/eac_tools/version.rb +1 -1
  4. data/sub/avm/lib/avm/data/callbacks.rb +37 -0
  5. data/sub/avm/lib/avm/data/package.rb +15 -7
  6. data/sub/avm/lib/avm/data/unit.rb +2 -23
  7. data/sub/avm/lib/avm/instances/base/auto_values/data.rb +1 -1
  8. data/sub/avm/lib/avm/instances/data/files_unit.rb +55 -0
  9. data/sub/avm/lib/avm/{data/instance → instances/data}/package.rb +2 -2
  10. data/sub/avm/lib/avm/instances/data/unit.rb +14 -0
  11. data/sub/avm/lib/avm/instances/data.rb +11 -0
  12. data/sub/avm/lib/avm/version.rb +1 -1
  13. data/sub/avm-eac_php_base0/avm-eac_php_base0.gemspec +3 -2
  14. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/instances/base.rb +14 -0
  15. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/instances.rb +11 -0
  16. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/source_generators/base.rb +28 -0
  17. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/source_generators.rb +11 -0
  18. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/sources/base.rb +17 -0
  19. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/sources.rb +11 -0
  20. data/sub/avm-eac_php_base0/lib/avm/eac_php_base0/version.rb +1 -1
  21. data/sub/avm-eac_php_base0/spec/lib/avm/eac_php_base0/source_generators/base_spec.rb +8 -0
  22. data/sub/avm-eac_php_base0/spec/lib/avm/eac_php_base0/source_generators/base_spec_files/no_options/index.php +0 -0
  23. data/sub/avm-eac_php_base0/spec/lib/avm/eac_php_base0/sources/base_spec.rb +7 -0
  24. data/sub/avm-eac_php_base0/template/avm/eac_php_base0/source_generators/base/index.php +0 -0
  25. data/sub/avm-eac_postgresql_base0/Gemfile +5 -0
  26. data/sub/avm-eac_postgresql_base0/avm-eac_postgresql_base0.gemspec +19 -0
  27. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/assert.rb +77 -0
  28. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb +39 -0
  29. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb +74 -0
  30. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance_with.rb +18 -0
  31. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb +7 -0
  32. data/sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0.rb +9 -0
  33. data/sub/avm-eac_postgresql_base0/spec/rubocop_spec.rb +3 -0
  34. data/sub/avm-eac_postgresql_base0/spec/spec_helper.rb +4 -0
  35. data/sub/avm-eac_rails_base1/avm-eac_rails_base1.gemspec +4 -4
  36. data/sub/avm-eac_rails_base1/lib/avm/eac_rails_base1/version.rb +1 -1
  37. data/sub/avm-eac_redmine_base0/avm-eac_redmine_base0.gemspec +2 -2
  38. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base/files.rb +22 -0
  39. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base/gitolite.rb +11 -0
  40. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base/install.rb +37 -0
  41. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/base.rb +3 -9
  42. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/data_package.rb +23 -0
  43. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/deploy.rb +1 -19
  44. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/version.rb +1 -1
  45. data/sub/avm-eac_redmine_plugin_base0/avm-eac_redmine_plugin_base0.gemspec +2 -2
  46. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base/init.rb +27 -0
  47. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base/parent.rb +31 -0
  48. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base/rubocop.rb +29 -0
  49. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base/version.rb +31 -0
  50. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/base.rb +2 -36
  51. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/sources/init_file.rb +43 -0
  52. data/sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0/version.rb +1 -1
  53. data/sub/avm-eac_redmine_plugin_base0/spec/lib/avm/eac_redmine_plugin_base0/sources/init_file_spec.rb +14 -0
  54. data/sub/avm-eac_redmine_plugin_base0/spec/lib/avm/eac_redmine_plugin_base0/sources/init_file_spec_files/a_init_file.rb +12 -0
  55. data/sub/avm-eac_webapp_base0/avm-eac_webapp_base0.gemspec +3 -3
  56. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/base.rb +4 -4
  57. data/sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/version.rb +1 -1
  58. data/sub/avm-git/avm-git.gemspec +3 -3
  59. data/sub/avm-git/lib/avm/git/launcher/base/underlying.rb +1 -1
  60. data/sub/avm-git/lib/avm/git/version.rb +1 -1
  61. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/append_command_options.rb +38 -0
  62. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/concat.rb +17 -2
  63. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/debugging.rb +19 -0
  64. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/envvars.rb +3 -0
  65. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/execution.rb +52 -0
  66. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +28 -84
  67. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/{command/exec_error.rb → execution_error.rb} +1 -3
  68. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/execution_result.rb +45 -0
  69. data/sub/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  70. data/sub/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/command_spec.rb +93 -0
  71. metadata +61 -39
  72. data/sub/avm/lib/avm/data/instance/files_unit.rb +0 -41
  73. data/sub/avm/lib/avm/data/instance/unit.rb +0 -17
  74. data/sub/avm/lib/avm/data/instance.rb +0 -11
  75. data/sub/avm-eac_redmine_base0/lib/avm/eac_redmine_base0/instances/data_unit.rb +0 -53
  76. data/sub/eac_ruby_utils/lib/eac_ruby_utils/envs/command/execute_result.rb +0 -47
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacPostgresqlBase0
7
+ class Instance
8
+ class Assert
9
+ common_constructor :instance
10
+ delegate :name, :password, :user, to: :instance
11
+
12
+ def perform
13
+ create_user unless user_exist?
14
+ change_password unless password_ok?
15
+ create_database unless database_exist?
16
+ change_owner unless user_owner?
17
+ end
18
+
19
+ def change_owner
20
+ root_execute("ALTER DaTABASE \"#{name}\" OWNER TO \"#{user}\"")
21
+ end
22
+
23
+ def change_password
24
+ root_execute("ALTER USER \"#{user}\" WITH PASSWORD '#{password}'")
25
+ end
26
+
27
+ def create_user
28
+ root_execute("CREATE USER \"#{user}\" WITH PASSWORD '#{password}'")
29
+ end
30
+
31
+ def current_owner
32
+ root_query(<<~SQL
33
+ SELECT pg_catalog.pg_get_userbyid(datdba)
34
+ FROM pg_catalog.pg_database
35
+ WHERE datname = '#{name}'
36
+ SQL
37
+ )
38
+ end
39
+
40
+ def database_exist?
41
+ root_boolean_query("FROM pg_database WHERE datname='#{name}'")
42
+ end
43
+
44
+ def password_ok?
45
+ instance.psql_command_command('SELECT 1', false)
46
+ .execute!(exit_outputs: { 512 => 'login_failed' }).strip == '1'
47
+ end
48
+
49
+ def user_exist?
50
+ root_boolean_query("FROM pg_roles WHERE rolname='#{user}'")
51
+ end
52
+
53
+ def user_owner?
54
+ user == current_owner
55
+ end
56
+
57
+ def create_database
58
+ root_execute("CREATE DATABASE \"#{name}\" WITH OWNER \"#{user}\"")
59
+ end
60
+
61
+ private
62
+
63
+ def root_boolean_query(sql_after_projection)
64
+ root_query("SELECT 1 #{sql_after_projection}") == '1'
65
+ end
66
+
67
+ def root_execute(sql)
68
+ instance.root_psql_command(sql).execute!
69
+ end
70
+
71
+ def root_query(sql)
72
+ root_execute(sql).strip
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/data/unit'
4
+
5
+ module Avm
6
+ module EacPostgresqlBase0
7
+ class Instance
8
+ class DataUnit < ::Avm::Instances::Data::Unit
9
+ EXTENSION = '.pgdump.gz'
10
+
11
+ before_load :clear_database
12
+
13
+ def dump_command
14
+ instance.dump_gzip_command
15
+ end
16
+
17
+ def load_command
18
+ instance.psql_command.prepend(['gzip', '-d', '@ESC_|'])
19
+ end
20
+
21
+ private
22
+
23
+ def clear_database
24
+ info 'Clearing database (Dropping all tables)...'
25
+ run_sql(drop_all_tables_sql).if_present { |v| run_sql(v) }
26
+ end
27
+
28
+ def drop_all_tables_sql
29
+ "select 'drop table \"' || tablename || '\" cascade;' from pg_tables " \
30
+ "where schemaname = 'public';"
31
+ end
32
+
33
+ def run_sql(sql)
34
+ instance.psql_command_command(sql).execute!
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_postgresql_base0/instance/data_unit'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacPostgresqlBase0
8
+ class Instance
9
+ require_sub __FILE__
10
+
11
+ MAINTENANCE_DATABASE = 'postgres'
12
+
13
+ common_constructor :env, :connection_params do
14
+ self.connection_params = connection_params.with_indifferent_access
15
+ end
16
+
17
+ def assert
18
+ ::Avm::EacPostgresqlBase0::Instance::Assert.new(self).perform
19
+ end
20
+
21
+ def data_unit
22
+ ::Avm::EacPostgresqlBase0::Instance::DataUnit.new(self)
23
+ end
24
+
25
+ def dump_command
26
+ env.command('pg_dump', '--no-privileges', '--clean', '--no-owner', *common_command_args)
27
+ .envvar('PGPASSWORD', password)
28
+ end
29
+
30
+ def dump_gzip_command
31
+ dump_command.append(['@ESC_|', 'gzip', '-9', '-c'])
32
+ end
33
+
34
+ def psql_command(database = true)
35
+ env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args(database))
36
+ end
37
+
38
+ def psql_command_command(sql, database = true)
39
+ psql_command(database).append(['--quiet', '--tuples-only', '--command', sql])
40
+ end
41
+
42
+ def root_psql_command(sql = nil)
43
+ args = ['sudo', '-u', 'postgres', 'psql']
44
+ args += ['--quiet', '--tuples-only', '--command', sql] if sql.present?
45
+ env.command(*args)
46
+ end
47
+
48
+ def common_command_args(database = true)
49
+ ['--host', host, '--username', user, '--port', port,
50
+ (database ? name : MAINTENANCE_DATABASE)]
51
+ end
52
+
53
+ def host
54
+ connection_params[:host] || '127.0.0.1'
55
+ end
56
+
57
+ def port
58
+ connection_params[:port] || '5432'
59
+ end
60
+
61
+ def user
62
+ connection_params.fetch(:user)
63
+ end
64
+
65
+ def password
66
+ connection_params.fetch(:password)
67
+ end
68
+
69
+ def name
70
+ connection_params.fetch(:name)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/entry_keys'
4
+ require 'avm/eac_postgresql_base0/instance'
5
+
6
+ module Avm
7
+ module EacPostgresqlBase0
8
+ module InstanceWith
9
+ def pg
10
+ @pg ||= ::Avm::EacPostgresqlBase0::Instance.new(
11
+ host_env, user: read_entry(::Avm::Instances::EntryKeys::DATABASE_USERNAME),
12
+ password: read_entry(::Avm::Instances::EntryKeys::DATABASE_PASSWORD),
13
+ name: read_entry(::Avm::Instances::EntryKeys::DATABASE_NAME)
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module EacPostgresqlBase0
5
+ VERSION = '0.2.1'
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacPostgresqlBase0
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/rspec/default_setup'
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
@@ -12,10 +12,10 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,template}/**/*']
14
14
 
15
- s.add_dependency 'avm', '~> 0.45'
16
- s.add_dependency 'avm-eac_ruby_base1', '~> 0.21'
17
- s.add_dependency 'avm-eac_webapp_base0', '~> 0.9'
18
- s.add_dependency 'eac_ruby_utils', '~> 0.104'
15
+ s.add_dependency 'avm', '~> 0.57'
16
+ s.add_dependency 'avm-eac_ruby_base1', '~> 0.27', '>= 0.27.1'
17
+ s.add_dependency 'avm-eac_webapp_base0', '~> 0.12', '>= 0.12.3'
18
+ s.add_dependency 'eac_ruby_utils', '~> 0.107', '>= 0.107.1'
19
19
 
20
20
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
21
21
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRailsBase1
5
- VERSION = '0.7.0'
5
+ VERSION = '0.7.1'
6
6
  end
7
7
  end
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib,locale,template}/**/*']
14
14
 
15
- s.add_dependency 'avm', '~> 0.56', '>= 0.56.1'
15
+ s.add_dependency 'avm', '~> 0.57'
16
16
  s.add_dependency 'avm-eac_generic_base0', '~> 0.8'
17
- s.add_dependency 'avm-eac_rails_base1', '~> 0.7'
17
+ s.add_dependency 'avm-eac_rails_base1', '~> 0.7', '>= 0.7.1'
18
18
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.3'
19
19
  s.add_dependency 'curb', '~> 0.9', '>= 0.9.11'
20
20
  s.add_dependency 'eac_fs', '~> 0.15'
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/instances/base'
4
+ require 'avm/instances/data/files_unit'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacRedmineBase0
9
+ module Instances
10
+ class Base < ::Avm::EacRailsBase1::Instances::Base
11
+ module Files
12
+ FILES_SUBPATH = 'files'
13
+
14
+ # @return [Avm::Instances::Data::FilesUnit]
15
+ def files_data_unit
16
+ ::Avm::Instances::Data::FilesUnit.new(self, FILES_SUBPATH)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -18,6 +18,12 @@ module Avm
18
18
  uri_components_entries_values GITOLITE_ENTRY_KEYS_PREFIX
19
19
  end
20
20
 
21
+ # @return [Avm::Instances::Data::FilesUnit]
22
+ def gitolite_data_unit
23
+ ::Avm::Instances::Data::FilesUnit.new(self, gitolite_repositories_path,
24
+ sudo_user: entry('gitolite.username').value!)
25
+ end
26
+
21
27
  def gitolite_hostname_default_value
22
28
  DEFAULT_HOSTNAME
23
29
  end
@@ -28,6 +34,11 @@ module Avm
28
34
  end
29
35
  end
30
36
 
37
+ # @return [Pathname]
38
+ def gitolite_repositories_path
39
+ entry('gitolite.path').value!.to_pathname.join('repositories')
40
+ end
41
+
31
42
  def gitolite_scheme_default_value
32
43
  DEFAULT_SCHEME
33
44
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_rails_base1/instances/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRedmineBase0
8
+ module Instances
9
+ class Base < ::Avm::EacRailsBase1::Instances::Base
10
+ module Install
11
+ def run_installer
12
+ ::EacRubyUtils::Ruby.on_clean_environment do
13
+ installer_command.system!
14
+ end
15
+ end
16
+
17
+ def installer_command
18
+ host_env.command(installer_path, install_task)
19
+ end
20
+
21
+ def installer_path
22
+ ::File.join(install_path, 'plugins', 'redmine_installer', 'installer',
23
+ 'run.sh')
24
+ end
25
+
26
+ def install_task
27
+ if web_path_optional.present?
28
+ 'redmine_as_apache_path'
29
+ else
30
+ 'redmine_as_apache_base'
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'addressable/uri'
4
- require 'avm/eac_redmine_base0/instances/data_unit'
4
+ require 'avm/eac_redmine_base0/instances/data_package'
5
5
  require 'avm/eac_redmine_base0/instances/docker_image'
6
6
  require 'avm/eac_redmine_base0/instances/runners'
7
7
  require 'avm/eac_redmine_base0/instances/rest_api'
@@ -14,8 +14,6 @@ module Avm
14
14
  require_sub __FILE__, include_modules: true
15
15
  enable_simple_cache
16
16
 
17
- FILES_UNITS = { files: 'files' }.freeze
18
-
19
17
  def docker_image_class
20
18
  ::Avm::EacRedmineBase0::Instances::DockerImage
21
19
  end
@@ -30,13 +28,9 @@ module Avm
30
28
  ]
31
29
  end
32
30
 
31
+ # @return [Avm::EacRedmineBase0::Instances::DataPackage]
33
32
  def data_package
34
- @data_package ||= ::Avm::Data::Instance::Package.new(
35
- self,
36
- units: {
37
- all: ::Avm::EacRedmineBase0::Instances::DataUnit.new(self)
38
- }
39
- )
33
+ @data_package ||= ::Avm::EacRedmineBase0::Instances::DataPackage.new(self)
40
34
  end
41
35
 
42
36
  # @return [Addressable::URI]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/instances/data/package'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRedmineBase0
8
+ module Instances
9
+ class DataPackage < ::Avm::Instances::Data::Package
10
+ after_load :run_installer
11
+
12
+ def initialize(instance, options = {})
13
+ super(instance, options.merge(units: options[:units].if_present({}).merge(
14
+ database: instance.database_unit, files: instance.files_data_unit,
15
+ gitolite: instance.gitolite_data_unit
16
+ )))
17
+ end
18
+
19
+ delegate :run_installer, to: :instance
20
+ end
21
+ end
22
+ end
23
+ end
@@ -11,25 +11,7 @@ module Avm
11
11
 
12
12
  def run_installer
13
13
  infom 'Running installer'
14
- ::EacRubyUtils::Ruby.on_clean_environment do
15
- installer_command.system!
16
- end
17
- end
18
-
19
- def installer_command
20
- instance.host_env.command(installer_path, install_task)
21
- end
22
-
23
- def installer_path
24
- ::File.join(instance.install_path, 'plugins', 'redmine_installer', 'installer', 'run.sh')
25
- end
26
-
27
- def install_task
28
- if instance.web_path_optional.present?
29
- 'redmine_as_apache_path'
30
- else
31
- 'redmine_as_apache_base'
32
- end
14
+ instance.run_installer
33
15
  end
34
16
  end
35
17
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRedmineBase0
5
- VERSION = '0.16.1'
5
+ VERSION = '0.17.0'
6
6
  end
7
7
  end
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'avm-eac_ruby_base1', '~> 0.11'
16
- s.add_dependency 'eac_ruby_utils', '~> 0.95', '>= 0.95.1'
15
+ s.add_dependency 'avm-eac_ruby_base1', '~> 0.27', '>= 0.27.1'
16
+ s.add_dependency 'eac_ruby_utils', '~> 0.107', '>= 0.107.1'
17
17
 
18
18
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5', '>= 0.5.1'
19
19
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_redmine_plugin_base0/sources/init_file'
4
+ require 'avm/eac_ruby_base1/sources/base'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacRedminePluginBase0
9
+ module Sources
10
+ class Base < ::Avm::EacRubyBase1::Sources::Base
11
+ module Init
12
+ INIT_SUBPATH = 'init.rb'
13
+
14
+ # @return [Avm::EacRedminePluginBase0::Sources::InitFile]
15
+ def init_file
16
+ ::Avm::EacRedminePluginBase0::Sources::InitFile.new(init_path)
17
+ end
18
+
19
+ # @return [String]
20
+ def init_path
21
+ path.join(INIT_SUBPATH)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/sources/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRedminePluginBase0
8
+ module Sources
9
+ class Base < ::Avm::EacRubyBase1::Sources::Base
10
+ module Parent
11
+ PARENT_RAKE_TASK_TEST_NAME = 'parent_rake_task'
12
+
13
+ # @return [String]
14
+ def parent_rake_test_task_name
15
+ [gem_name, 'test'].map(&:variableize).join(':')
16
+ end
17
+
18
+ # @return [Boolean]
19
+ def parent_rake_test_command?
20
+ ruby_parent.rake_task?(parent_rake_test_task_name)
21
+ end
22
+
23
+ # @return [EacRubyUtils::Envs::Command]
24
+ def parent_rake_test_command
25
+ ruby_parent.rake(parent_rake_test_task_name).chdir_root.envvar('RAILS_ENV', 'test')
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/sources/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRedminePluginBase0
8
+ module Sources
9
+ class Base < ::Avm::EacRubyBase1::Sources::Base
10
+ module Rubocop
11
+ RUBOCOP_GEM_NAME = 'rubocop'
12
+ RUBOCOP_TEST_NAME = 'rubocop'
13
+
14
+ # @return [EacRubyUtils::Envs::Command]
15
+ def rubocop_test_command
16
+ bundle('exec', 'rubocop', '--ignore-parent-exclusion')
17
+ .envvar('RAILS_ENV', 'test')
18
+ .chdir_root
19
+ end
20
+
21
+ # @return [Boolean]
22
+ def rubocop_test_command?
23
+ gemfile_path.exist? && gemfile_lock_gem_version(RUBOCOP_GEM_NAME).present?
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/sources/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRedminePluginBase0
8
+ module Sources
9
+ class Base < ::Avm::EacRubyBase1::Sources::Base
10
+ module Version
11
+ # @return [Avm::VersionNumber]
12
+ def version
13
+ if version_file_path.exist?
14
+ super
15
+ else
16
+ init_file.version
17
+ end
18
+ end
19
+
20
+ def version=(value)
21
+ if version_file_path.exist?
22
+ super
23
+ else
24
+ init_file.version = value
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -7,11 +7,9 @@ module Avm
7
7
  module EacRedminePluginBase0
8
8
  module Sources
9
9
  class Base < ::Avm::EacRubyBase1::Sources::Base
10
+ require_sub __FILE__, include_modules: true
11
+
10
12
  DEFAULT_GEMFILE_PATH = 'SelfGemfile'
11
- RUBOCOP_GEM_NAME = 'rubocop'
12
- RUBOCOP_TEST_NAME = 'rubocop'
13
- PARENT_RAKE_TASK_TEST_NAME = 'parent_rake_task'
14
- INIT_SUBPATH = 'init.rb'
15
13
 
16
14
  # @return [String]
17
15
  def default_gemfile_path
@@ -26,38 +24,6 @@ module Avm
26
24
  r
27
25
  end
28
26
 
29
- # @return [String]
30
- def init_path
31
- path.join(INIT_SUBPATH)
32
- end
33
-
34
- # @return [String]
35
- def parent_rake_test_task_name
36
- [gem_name, 'test'].map(&:variableize).join(':')
37
- end
38
-
39
- # @return [Boolean]
40
- def parent_rake_test_command?
41
- ruby_parent.rake_task?(parent_rake_test_task_name)
42
- end
43
-
44
- # @return [EacRubyUtils::Envs::Command]
45
- def parent_rake_test_command
46
- ruby_parent.rake(parent_rake_test_task_name).chdir_root.envvar('RAILS_ENV', 'test')
47
- end
48
-
49
- # @return [EacRubyUtils::Envs::Command]
50
- def rubocop_test_command
51
- bundle('exec', 'rubocop', '--ignore-parent-exclusion')
52
- .envvar('RAILS_ENV', 'test')
53
- .chdir_root
54
- end
55
-
56
- # @return [Boolean]
57
- def rubocop_test_command?
58
- gemfile_path.exist? && gemfile_lock_gem_version(RUBOCOP_GEM_NAME).present?
59
- end
60
-
61
27
  # @return [Boolean]
62
28
  def valid?
63
29
  init_path.exist?