eac_tools 0.86.2 → 0.86.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 971a844d5fe39f713dc7a9b084aa58f9f3f906131004e0660f32990fc96a2bc3
4
- data.tar.gz: cc342a3c34371fc6a245150be49105580a53f2761f1b9272a16691864b3dfe78
3
+ metadata.gz: 011f97eae6daa1839bb3c2938d98554408f6e4a20668234656ef8edf79774e16
4
+ data.tar.gz: 06c5b0b6586b45f323b8db0d6c50f892c514f6f49893838898db9c0baa646e1f
5
5
  SHA512:
6
- metadata.gz: 48a6afe66fec33a33278c334b9471354350bc1f118ec4f7658e082c005a625f7c5587a5ef0063ba0d94477b38cd89ddc97e3509994ae00f329823b35a0065006
7
- data.tar.gz: 05011c8c364dfc4947403deb2664fe6b2c3feec9ce3e1495cf1e86bd54091dbbe12bcf6ee439709e1ea3ec191b72aba9f72a18f364a54d388af27b08af3c197e
6
+ metadata.gz: 9331c22d9f4f02fdad091ab6a46ce650b05301b2f11dd93d4590b3a21776aff08d25bfeebdb3370f3cfe5bedcf550e242bb4120fb439eeea1e37ce63cae621f8
7
+ data.tar.gz: 433b4e4280272b529171d525b050fbf4bc8573015c57387868815e904421cd472c1ca26e181a6588a200c4ff996c6d4de7ed51b0b58e57f63860752d77bb7292
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eac_tools (0.86.2)
5
- avm (~> 0.85)
4
+ eac_tools (0.86.4)
5
+ avm (~> 0.86)
6
6
  avm-eac_asciidoctor_base0 (~> 0.22)
7
7
  avm-eac_generic_base0 (~> 0.12, >= 0.12.2)
8
8
  avm-eac_github_base0 (~> 0.3)
9
9
  avm-eac_gitlab_base0 (~> 0.4)
10
10
  avm-eac_latex_base0 (~> 0.3, >= 0.3.2)
11
11
  avm-eac_php_base0 (~> 0.4, >= 0.4.3)
12
- avm-eac_postgresql_base0 (~> 0.5, >= 0.5.2)
12
+ avm-eac_postgresql_base0 (~> 0.5, >= 0.5.3)
13
13
  avm-eac_python_base0 (~> 0.2, >= 0.2.2)
14
14
  avm-eac_rails_base0 (~> 0.11)
15
15
  avm-eac_rails_base1 (~> 0.10)
@@ -18,17 +18,10 @@ PATH
18
18
  avm-eac_ruby_base1 (~> 0.33, >= 0.33.1)
19
19
  avm-eac_webapp_base0 (~> 0.18, >= 0.18.3)
20
20
  avm-eac_wordpress_base0 (~> 0.3, >= 0.3.1)
21
- avm-git (~> 0.15)
22
- avm-tools (~> 0.160, >= 0.160.1)
21
+ avm-git (~> 0.16)
22
+ avm-tools (~> 0.160, >= 0.160.2)
23
23
  eac_ruby_utils (~> 0.121)
24
24
 
25
- PATH
26
- remote: sub/avm-eac_postgresql_base0
27
- specs:
28
- avm-eac_postgresql_base0 (0.5.2)
29
- avm (~> 0.79)
30
- eac_ruby_utils (~> 0.119, >= 0.119.1)
31
-
32
25
  PATH
33
26
  remote: sub/avm-eac_redmine_plugin_base0
34
27
  specs:
@@ -55,8 +48,8 @@ PATH
55
48
  PATH
56
49
  remote: sub/avm-git
57
50
  specs:
58
- avm-git (0.15.0)
59
- avm (~> 0.85)
51
+ avm-git (0.16.0)
52
+ avm (~> 0.86)
60
53
  avm-files (~> 0.7)
61
54
  eac_git (~> 0.16)
62
55
  eac_ruby_utils (~> 0.121)
@@ -65,13 +58,13 @@ PATH
65
58
  PATH
66
59
  remote: sub/avm-tools
67
60
  specs:
68
- avm-tools (0.160.1)
61
+ avm-tools (0.160.2)
69
62
  aranha-parsers (~> 0.22)
70
- avm (~> 0.85)
63
+ avm (~> 0.86)
71
64
  avm-eac_ruby_base1 (~> 0.33, >= 0.33.1)
72
65
  avm-eac_ubuntu_base0 (~> 0.5)
73
66
  avm-files (~> 0.7)
74
- avm-git (~> 0.15)
67
+ avm-git (~> 0.16)
75
68
  clipboard (~> 1.3, >= 1.3.6)
76
69
  curb (~> 0.9, >= 0.9.11)
77
70
  eac_git (~> 0.16)
@@ -83,7 +76,7 @@ PATH
83
76
  PATH
84
77
  remote: sub/avm
85
78
  specs:
86
- avm (0.85.0)
79
+ avm (0.86.0)
87
80
  aranha-parsers (~> 0.22)
88
81
  eac_cli (~> 0.40, >= 0.40.1)
89
82
  eac_config (~> 0.14, >= 0.14.2)
@@ -147,6 +140,9 @@ GEM
147
140
  avm-eac_generic_base0 (~> 0.12, >= 0.12.2)
148
141
  avm-eac_webapp_base0 (~> 0.18, >= 0.18.3)
149
142
  eac_ruby_utils (~> 0.121)
143
+ avm-eac_postgresql_base0 (0.5.3)
144
+ avm (~> 0.85)
145
+ eac_ruby_utils (~> 0.121)
150
146
  avm-eac_python_base0 (0.2.2)
151
147
  avm-eac_generic_base0 (~> 0.12, >= 0.12.1)
152
148
  eac_ruby_utils (~> 0.119, >= 0.119.2)
@@ -355,7 +351,6 @@ PLATFORMS
355
351
 
356
352
  DEPENDENCIES
357
353
  avm!
358
- avm-eac_postgresql_base0!
359
354
  avm-eac_redmine_plugin_base0!
360
355
  avm-eac_ubuntu_base0!
361
356
  avm-eac_wordpress_base0!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacTools
4
- VERSION = '0.86.2'
4
+ VERSION = '0.86.4'
5
5
  end
@@ -20,6 +20,11 @@ module Avm
20
20
  raise_abstract_method __method__
21
21
  end
22
22
 
23
+ # @param options [Hash<Symbol, Object>]
24
+ def completer(options = {}) # rubocop:disable Lint/UnusedMethodArgument
25
+ raise_abstract_method __method__
26
+ end
27
+
23
28
  # @return [Avm::Scms::Interval]
24
29
  def interval(_from, _to)
25
30
  raise_abstract_method __method__
@@ -24,6 +24,11 @@ module Avm
24
24
 
25
25
  abstract_methods :valid?
26
26
 
27
+ # @param options [Hash<Symbol, Object>]
28
+ def completer(options = {})
29
+ scm.completer(options)
30
+ end
31
+
27
32
  # @return [EacRubyUtils::Envs::LocalEnv]
28
33
  def env
29
34
  ::EacRubyUtils::Envs::LocalEnv.new
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.85.0'
4
+ VERSION = '0.86.0'
5
5
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.files = Dir['{lib,locale}/**/*']
14
14
  s.required_ruby_version = '>= 2.7'
15
15
 
16
- s.add_dependency 'avm', '~> 0.85'
16
+ s.add_dependency 'avm', '~> 0.86'
17
17
  s.add_dependency 'avm-files', '~> 0.7'
18
18
  s.add_dependency 'eac_git', '~> 0.16'
19
19
  s.add_dependency 'eac_ruby_utils', '~> 0.121'
@@ -1,17 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'clipboard'
4
-
5
3
  module Avm
6
4
  module Git
7
5
  module Issue
8
6
  class Complete
9
7
  module Tracker
10
- def clipboard_copy_tracker_message
11
- ::Clipboard.copy(textile_tracker_message)
12
- infov 'Copied to clipboard', textile_tracker_message
13
- end
14
-
15
8
  private
16
9
 
17
10
  def textile_tracker_message_uncached
@@ -11,17 +11,21 @@ module Avm
11
11
  enable_simple_cache
12
12
  enable_speaker
13
13
 
14
- BRANCH_NAME_ISSUE_ID_PATTERN =
14
+ attr_reader :scm, :skip_validations
15
15
 
16
- attr_reader :dir, :skip_validations
17
-
18
- def initialize(options)
16
+ def initialize(scm, options)
17
+ @scm = scm
19
18
  consumer = ::EacRubyUtils::OptionsConsumer.new(options)
20
- @dir, @skip_validations = consumer.consume_all(:dir, :skip_validations)
19
+ @skip_validations = consumer.consume(:skip_validations)
21
20
  validate_skip_validations
22
21
  consumer.validate
23
22
  end
24
23
 
24
+ # @return [String]
25
+ def dir
26
+ scm.path.to_path
27
+ end
28
+
25
29
  def start_banner
26
30
  validations_banner
27
31
  end
@@ -32,7 +36,6 @@ module Avm
32
36
  assert_tag
33
37
  push
34
38
  remove_local_branch
35
- clipboard_copy_tracker_message
36
39
  true
37
40
  end
38
41
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/git/issue/complete'
3
4
  require 'avm/git/scms/git_subrepo'
4
5
  require 'avm/scms/base'
5
6
  require 'eac_ruby_utils/core_ext'
@@ -17,6 +18,12 @@ module Avm
17
18
  git_repo <=> other.git_repo
18
19
  end
19
20
 
21
+ # @param options [Hash<Symbol, Object>]
22
+ # @return [Avm::Git::Issues::Complete]
23
+ def completer(options = {})
24
+ ::Avm::Git::Issue::Complete.new(self, options)
25
+ end
26
+
20
27
  def git_repo
21
28
  @git_repo ||= ::EacGit::Local.new(path)
22
29
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Git
5
- VERSION = '0.15.0'
5
+ VERSION = '0.16.0'
6
6
  end
7
7
  end
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.required_ruby_version = '>= 2.7.0'
18
18
 
19
19
  s.add_dependency 'aranha-parsers', '~> 0.22'
20
- s.add_dependency 'avm', '~> 0.85'
20
+ s.add_dependency 'avm', '~> 0.86'
21
21
  s.add_dependency 'avm-eac_ruby_base1', '~> 0.33', '>= 0.33.1'
22
22
  s.add_dependency 'avm-eac_ubuntu_base0', '~> 0.5'
23
23
  s.add_dependency 'avm-files', '~> 0.7'
24
- s.add_dependency 'avm-git', '~> 0.15'
24
+ s.add_dependency 'avm-git', '~> 0.16'
25
25
  s.add_dependency 'clipboard', '~> 1.3', '>= 1.3.6'
26
26
  s.add_dependency 'curb', '~> 0.9', '>= 0.9.11'
27
27
  s.add_dependency 'eac_git', '~> 0.16'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/core_ext'
4
- require 'avm/git/issue/complete'
4
+ require 'clipboard'
5
5
 
6
6
  module Avm
7
7
  module Tools
@@ -10,7 +10,7 @@ module Avm
10
10
  class Issue
11
11
  class Complete
12
12
  runner_with :confirmation, :help do
13
- desc 'Closes a issue in a Git repository.'
13
+ desc 'Closes a issue in a remote repository.'
14
14
  bool_opt '-f', '--uncomplete-unfail', 'Do not exit with error if issue is not ' \
15
15
  'completed or is invalid.'
16
16
  arg_opt '-s', '--skip-validations', 'Does not validate conditions on <validations> ' \
@@ -21,6 +21,8 @@ module Avm
21
21
  return unless run_validate
22
22
  return unless run_complete
23
23
 
24
+ clipboard_copy_tracker_message
25
+
24
26
  success('Done!')
25
27
  end
26
28
 
@@ -43,21 +45,25 @@ module Avm
43
45
 
44
46
  private
45
47
 
48
+ def clipboard_copy_tracker_message
49
+ ::Clipboard.copy(complete.textile_tracker_message)
50
+ infov 'Copied to clipboard', complete.textile_tracker_message
51
+ end
52
+
46
53
  def complete_uncached
47
- ::Avm::Git::Issue::Complete.new(git_complete_issue_options)
54
+ runner_context.call(:subject).completer(complete_issue_options)
48
55
  end
49
56
 
50
57
  def skip_validations
51
58
  parsed.skip_validations.to_s.split(',').map(&:strip).compact_blank
52
59
  end
53
60
 
54
- def git_complete_issue_options
55
- { dir: runner_context.call(:subject).path.to_path,
56
- skip_validations: skip_validations }
61
+ def complete_issue_options
62
+ { skip_validations: skip_validations }
57
63
  end
58
64
 
59
65
  def doc_validations_list
60
- ::Avm::Git::Issue::Complete::VALIDATIONS.keys.map { |k| " * #{k}" }.join("\n")
66
+ complete.validation_keys.map { |k| " * #{k}" }.join("\n")
61
67
  end
62
68
 
63
69
  def uncomplete_unfail?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.160.1'
5
+ VERSION = '0.160.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.86.2
4
+ version: 0.86.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-18 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.85'
19
+ version: '0.86'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.85'
26
+ version: '0.86'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: avm-eac_asciidoctor_base0
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -135,7 +135,7 @@ dependencies:
135
135
  version: '0.5'
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 0.5.2
138
+ version: 0.5.3
139
139
  type: :runtime
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
@@ -145,7 +145,7 @@ dependencies:
145
145
  version: '0.5'
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- version: 0.5.2
148
+ version: 0.5.3
149
149
  - !ruby/object:Gem::Dependency
150
150
  name: avm-eac_python_base0
151
151
  requirement: !ruby/object:Gem::Requirement
@@ -288,14 +288,14 @@ dependencies:
288
288
  requirements:
289
289
  - - "~>"
290
290
  - !ruby/object:Gem::Version
291
- version: '0.15'
291
+ version: '0.16'
292
292
  type: :runtime
293
293
  prerelease: false
294
294
  version_requirements: !ruby/object:Gem::Requirement
295
295
  requirements:
296
296
  - - "~>"
297
297
  - !ruby/object:Gem::Version
298
- version: '0.15'
298
+ version: '0.16'
299
299
  - !ruby/object:Gem::Dependency
300
300
  name: avm-tools
301
301
  requirement: !ruby/object:Gem::Requirement
@@ -305,7 +305,7 @@ dependencies:
305
305
  version: '0.160'
306
306
  - - ">="
307
307
  - !ruby/object:Gem::Version
308
- version: 0.160.1
308
+ version: 0.160.2
309
309
  type: :runtime
310
310
  prerelease: false
311
311
  version_requirements: !ruby/object:Gem::Requirement
@@ -315,7 +315,7 @@ dependencies:
315
315
  version: '0.160'
316
316
  - - ">="
317
317
  - !ruby/object:Gem::Version
318
- version: 0.160.1
318
+ version: 0.160.2
319
319
  - !ruby/object:Gem::Dependency
320
320
  name: eac_ruby_utils
321
321
  requirement: !ruby/object:Gem::Requirement
@@ -354,17 +354,6 @@ files:
354
354
  - Gemfile.lock
355
355
  - lib/eac_tools.rb
356
356
  - lib/eac_tools/version.rb
357
- - sub/avm-eac_postgresql_base0/Gemfile
358
- - sub/avm-eac_postgresql_base0/avm-eac_postgresql_base0.gemspec
359
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0.rb
360
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance.rb
361
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/assert.rb
362
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/commands.rb
363
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance/data_unit.rb
364
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/instance_with.rb
365
- - sub/avm-eac_postgresql_base0/lib/avm/eac_postgresql_base0/version.rb
366
- - sub/avm-eac_postgresql_base0/spec/rubocop_spec.rb
367
- - sub/avm-eac_postgresql_base0/spec/spec_helper.rb
368
357
  - sub/avm-eac_redmine_plugin_base0/Gemfile
369
358
  - sub/avm-eac_redmine_plugin_base0/avm-eac_redmine_plugin_base0.gemspec
370
359
  - sub/avm-eac_redmine_plugin_base0/lib/avm/eac_redmine_plugin_base0.rb
@@ -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,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push File.expand_path('lib', __dir__)
4
-
5
- require 'avm/eac_postgresql_base0/version'
6
-
7
- Gem::Specification.new do |s|
8
- s.name = 'avm-eac_postgresql_base0'
9
- s.version = Avm::EacPostgresqlBase0::VERSION
10
- s.authors = ['Put here the authors']
11
- s.summary = 'Put here de description.'
12
-
13
- s.files = Dir['{lib}/**/*']
14
-
15
- s.add_dependency 'avm', '~> 0.79'
16
- s.add_dependency 'eac_ruby_utils', '~> 0.119', '>= 0.119.1'
17
-
18
- s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
19
- end
@@ -1,77 +0,0 @@
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
@@ -1,79 +0,0 @@
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
- module Commands
10
- DUMP_EXCLUDE_PATTERNS = ['(CREATE|COMMENT ON) EXTENSION',
11
- 'SET default_table_access_method'].freeze
12
-
13
- # @return [EacRubyUtils::Envs::Command]
14
- def dump_command
15
- DUMP_EXCLUDE_PATTERNS
16
- .inject(pg_dump_command) { |a, e| a.pipe(exclude_pattern_command(e)) }
17
- end
18
-
19
- # @return [EacRubyUtils::Envs::Command]
20
- def dump_gzip_command
21
- dump_command.pipe(gzip_compress_command)
22
- end
23
-
24
- # @return [EacRubyUtils::Envs::Command]
25
- def gzip_compress_command
26
- env.command('gzip', '-9', '-c')
27
- end
28
-
29
- # @return [EacRubyUtils::Envs::Command]
30
- def gzip_decompress_command
31
- env.command('gzip', '-d')
32
- end
33
-
34
- # @return [EacRubyUtils::Envs::Command]
35
- def load_gzip_command
36
- gzip_decompress_command.pipe(psql_command)
37
- end
38
-
39
- # @return [String]
40
- def password_command_argument
41
- "@ESC_PGPASSWORD=#{password}"
42
- end
43
-
44
- def psql_command(database = true)
45
- env.command(password_command_argument, 'psql', '--variable', 'ON_ERROR_STOP=t',
46
- *common_command_args(database))
47
- end
48
-
49
- def psql_command_command(sql, database = true)
50
- psql_command(database).append(['--quiet', '--tuples-only', '--command', sql])
51
- end
52
-
53
- def root_psql_command(sql = nil)
54
- args = ['sudo', '-u', 'postgres', 'psql']
55
- args += ['--quiet', '--tuples-only', '--command', sql] if sql.present?
56
- env.command(*args)
57
- end
58
-
59
- def common_command_args(database = true)
60
- ['--host', host, '--username', user, '--port', port,
61
- (database ? name : MAINTENANCE_DATABASE)]
62
- end
63
-
64
- private
65
-
66
- # @return [EacRubyUtils::Envs::Command]
67
- def exclude_pattern_command(pattern)
68
- env.command('sed', '--regexp-extended', "s/(^|\\n)#{pattern}[^;]*;//gm")
69
- end
70
-
71
- # @return [EacRubyUtils::Envs::Command]
72
- def pg_dump_command
73
- env.command('pg_dump', '--no-privileges', '--no-owner', *common_command_args)
74
- .envvar('PGPASSWORD', password)
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,65 +0,0 @@
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
- SCHEMA_VAR = '%%SCHEMA%%'
11
- TABLE_PARTS_SEPARATOR = '/'
12
- TABLES_SQL = "select schemaname || '#{TABLE_PARTS_SEPARATOR}' || tablename from " \
13
- "pg_tables where schemaname = '#{SCHEMA_VAR}'"
14
-
15
- def do_clear
16
- ts = tables
17
- if ts.empty?
18
- info 'Database has no tables'
19
- else
20
- info "Removing #{ts.count} table(s)..."
21
- run_sql(drop_tables_sql(ts))
22
- end
23
- end
24
-
25
- def dump_command
26
- instance.pg.dump_gzip_command
27
- end
28
-
29
- def load_command
30
- instance.pg.load_gzip_command
31
- end
32
-
33
- private
34
-
35
- # @param table_list [Array<String>]
36
- # @return [String]
37
- def drop_tables_sql(table_list)
38
- 'drop table ' + table_list.map(&:to_s).join(', ') + ' cascade'
39
- end
40
-
41
- # @param parts [Array<String>, Strings]
42
- # @return [String]
43
- def join_table_parts(parts)
44
- parts = parts.to_s.split(TABLE_PARTS_SEPARATOR) unless parts.is_a?(::Enumerable)
45
- parts.map { |p| "\"#{p}\"" }.join('.')
46
- end
47
-
48
- def run_sql(sql)
49
- instance.pg.psql_command_command(sql).execute!
50
- end
51
-
52
- # @return [Array<String>]
53
- def tables
54
- run_sql(tables_sql).each_line.map(&:strip).reject(&:blank?)
55
- .map { |line| join_table_parts(line) }
56
- end
57
-
58
- # @return [String]
59
- def tables_sql
60
- TABLES_SQL.gsub(SCHEMA_VAR, instance.pg.schema)
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,49 +0,0 @@
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__, include_modules: true
10
-
11
- DEFAULT_HOSTNAME = '127.0.0.1'
12
- DEFAULT_PORT = 5432
13
- DEFAULT_SCHEMA = 'public'
14
- MAINTENANCE_DATABASE = 'postgres'
15
-
16
- common_constructor :env, :connection_params do
17
- self.connection_params = connection_params.with_indifferent_access
18
- end
19
-
20
- def assert
21
- ::Avm::EacPostgresqlBase0::Instance::Assert.new(self).perform
22
- end
23
-
24
- def host
25
- connection_params[:host] || DEFAULT_HOSTNAME
26
- end
27
-
28
- def port
29
- connection_params[:port] || DEFAULT_PORT
30
- end
31
-
32
- def user
33
- connection_params.fetch(:user)
34
- end
35
-
36
- def password
37
- connection_params.fetch(:password)
38
- end
39
-
40
- def name
41
- connection_params.fetch(:name)
42
- end
43
-
44
- def schema
45
- connection_params[:schema] || DEFAULT_SCHEMA
46
- end
47
- end
48
- end
49
- end
@@ -1,25 +0,0 @@
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, host: database_hostname,
12
- port: database_port,
13
- user: database_username,
14
- password: database_password,
15
- name: database_name
16
- )
17
- end
18
-
19
- # @return [Avm::EacPostgresqlBase0::Instance::DataUnit]
20
- def pg_data_unit
21
- ::Avm::EacPostgresqlBase0::Instance::DataUnit.new(self)
22
- end
23
- end
24
- end
25
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module EacPostgresqlBase0
5
- VERSION = '0.5.2'
6
- end
7
- end
@@ -1,9 +0,0 @@
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
@@ -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__))