avm-tools 0.87.0 → 0.87.1

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: df3208595cdaefa7e6f51a5a14518064df146b2081e32365e3ad746326e844bb
4
- data.tar.gz: 367b039c49b3ff3e9a8083bafe1c889656e924403014efbeec2f3032ccfe0247
3
+ metadata.gz: 39b5ee493e22bb4e2eb77a9e62067e0de6dd23b3d3d4dd62ba2eeadedf183d22
4
+ data.tar.gz: 0d528d18932807487721a84c32a6c4d1f2906a015840ac360921fcbca78b493c
5
5
  SHA512:
6
- metadata.gz: 1e1aa08cda713c6600a551681f4f2d986e939675ba41bd5f270497f9dba564213906ae71890ce9ea00285a289d8edc626d70bd91aa31e2a381524bc19404d58b
7
- data.tar.gz: 25c272f9097b2d48cf1d88ece314eef1361527644942c3b0e1e862709f60e155ac4db9a31b823432f72abd478eaec9f4218503932228a8bf0c44c30b3a3ee46b
6
+ metadata.gz: 4a7a88618b900c728d17a3ef9f492f1b0f42d74313190f8de7d532ebda8f89e27866eb9edbdee7043cfadfd075b71b44390d8c190191b11341120baef2489fea
7
+ data.tar.gz: e209c17b18ab7d34483054cb5545da9e946212ca857ae52ec18fa87b00704c3a589697ab1e0dfa1ec8b093afe55a8f8ea5a1e61487bda8ca717196d4e0e47679
@@ -20,12 +20,24 @@ module Avm
20
20
  end
21
21
 
22
22
  def auto_fs_url
23
+ auto_fs_url_with_ssh || auto_fs_url_without_ssh
24
+ end
25
+
26
+ def auto_fs_url_with_ssh
23
27
  read_entry_optional('ssh.url').if_present do |ssh_url|
24
28
  read_entry_optional('fs_path').if_present do |fs_path|
25
29
  "#{ssh_url}#{fs_path}"
26
30
  end
27
31
  end
28
32
  end
33
+
34
+ def auto_fs_url_without_ssh
35
+ return nil if read_entry_optional('ssh.url').present?
36
+
37
+ read_entry_optional('fs_path').if_present do |fs_path|
38
+ "file://#{fs_path}"
39
+ end
40
+ end
29
41
  end
30
42
  end
31
43
  end
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_cli/core_ext'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
4
 
6
5
  module Avm
7
6
  module Instances
8
- class Runner < ::EacRubyUtils::Console::DocoptRunner
7
+ class Runner
9
8
  class << self
10
9
  def instance_class
11
10
  ::Avm.const_get(stereotype_name).const_get('Instance')
@@ -20,9 +19,8 @@ module Avm
20
19
  end
21
20
  end
22
21
 
23
- runner_with
24
22
  description = "Utilities for #{stereotype_name} instances."
25
- runner_definition do
23
+ runner_with :help, :subcommands do
26
24
  desc description
27
25
  pos_arg 'instance-id'
28
26
  subcommands
@@ -15,7 +15,7 @@ module Avm
15
15
  arg_opt '-a', '--append-dirs', 'Append directories to deploy (List separated by ":").'
16
16
  arg_opt '-i', '--instance', 'Read entries from instance with id=<instance-id>.'
17
17
  arg_opt '-r', '--reference', "Reference (default: #{DEFAULT_REFERENCE})."
18
- pos_arg :target_url
18
+ pos_arg :target_url, optional: true
19
19
  end
20
20
 
21
21
  def run
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.87.0'
5
+ VERSION = '0.87.1'
6
6
  end
7
7
  end
@@ -47,53 +47,5 @@ module EacCli
47
47
  include ActiveSupport::Callbacks
48
48
  define_callbacks :run
49
49
  end
50
-
51
- module AfterClassMethods
52
- def create(*runner_context_args)
53
- r = new
54
- r.runner_context = ::EacCli::Runner::Context.new(r, *runner_context_args)
55
- r
56
- end
57
-
58
- def run(*runner_context_args)
59
- r = create(*runner_context_args)
60
- r.run_run
61
- r
62
- end
63
-
64
- def runner_definition(&block)
65
- @runner_definition ||= super_runner_definition
66
- @runner_definition.instance_eval(&block) if block
67
- @runner_definition
68
- end
69
-
70
- def super_runner_definition
71
- superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
72
- end
73
- end
74
-
75
- module InstanceMethods
76
- def run_run
77
- parsed
78
- run_callbacks(:run) { run }
79
- rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
80
- # Do nothing
81
- end
82
-
83
- def runner_context
84
- return @runner_context if @runner_context
85
-
86
- raise 'Context was required, but was not set yet'
87
- end
88
-
89
- def runner_context=(new_runner_context)
90
- @runner_context = new_runner_context
91
- @parsed = nil
92
- end
93
-
94
- def parsed
95
- @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
96
- end
97
- end
98
50
  end
99
51
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ module Runner
5
+ module AfterClassMethods
6
+ def create(*runner_context_args)
7
+ r = new
8
+ r.runner_context = ::EacCli::Runner::Context.new(r, *runner_context_args)
9
+ r
10
+ end
11
+
12
+ def run(*runner_context_args)
13
+ r = create(*runner_context_args)
14
+ r.run_run
15
+ r
16
+ end
17
+
18
+ def runner_definition(&block)
19
+ @runner_definition ||= super_runner_definition
20
+ @runner_definition.instance_eval(&block) if block
21
+ @runner_definition
22
+ end
23
+
24
+ def super_runner_definition
25
+ superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacCli
4
+ module Runner
5
+ module InstanceMethods
6
+ def run_run
7
+ parsed
8
+ run_callbacks(:run) { run }
9
+ rescue ::EacCli::Parser::Error => e
10
+ $stderr.write("#{e}\n")
11
+ rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
12
+ # Do nothing
13
+ end
14
+
15
+ def runner_context
16
+ return @runner_context if @runner_context
17
+
18
+ raise 'Context was required, but was not set yet'
19
+ end
20
+
21
+ def runner_context=(new_runner_context)
22
+ @runner_context = new_runner_context
23
+ @parsed = nil
24
+ end
25
+
26
+ def parsed
27
+ @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
28
+ end
29
+ end
30
+ end
31
+ end
@@ -40,7 +40,7 @@ module EacCli
40
40
  end
41
41
 
42
42
  def help_extra_text
43
- (['Subcommands:'] + available_subcommands.keys.map { |s| " #{s}" })
43
+ (['Subcommands:'] + available_subcommands.keys.sort.map { |s| " #{s}" })
44
44
  .map { |v| "#{v}\n" }.join
45
45
  end
46
46
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.12.5'
4
+ VERSION = '0.12.6'
5
5
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+ require 'active_support/values/time_zone'
5
+
6
+ module EacRubyUtils
7
+ module LocalTimeZone
8
+ DEBIAN_CONFIG_PATH = '/etc/timezone'
9
+
10
+ class << self
11
+ TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
12
+
13
+ def auto
14
+ %w[tz_env debian_config offset].lazy.map { |s| send("by_#{s}") }.find(&:present?)
15
+ end
16
+
17
+ def by_debian_config
18
+ path = ::Pathname.new(DEBIAN_CONFIG_PATH)
19
+ path.exist? ? path.read.strip.presence : nil
20
+ end
21
+
22
+ def by_offset
23
+ ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
24
+ end
25
+
26
+ def by_timedatectl
27
+ executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
28
+ return nil unless executable.exist?
29
+
30
+ TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
31
+ end
32
+
33
+ def by_tz_env
34
+ ENV['TZ'].presence
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kernel
4
+ # Raise exception with text "Not yet implemented".
5
+ def nyi
6
+ raise "Not yet implemented (Called in #{caller.first})"
7
+ end
8
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/patches/time/local_time_zone'
3
+ require 'active_support/core_ext/time/zones'
4
+ require 'eac_ruby_utils/local_time_zone'
4
5
 
5
- ::Time.zone = ::Time.local_time_zone
6
+ ::Time.zone = ::EacRubyUtils::LocalTimeZone.auto
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.57.1'
4
+ VERSION = '0.58.0'
5
5
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/local_time_zone'
4
+
5
+ RSpec.describe(::EacRubyUtils::LocalTimeZone) do
6
+ describe '#auto' do
7
+ context 'when TZ environment variable is set' do
8
+ let(:expected_time_zone) { 'America/Sao_Paulo' }
9
+
10
+ before do
11
+ ENV['TZ'] = expected_time_zone
12
+ end
13
+
14
+ it { expect(described_class.auto).to eq(expected_time_zone) }
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.87.0
4
+ version: 0.87.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-10 00:00:00.000000000 Z
11
+ date: 2021-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -639,8 +639,10 @@ files:
639
639
  - vendor/eac_cli/lib/eac_cli/patches/object.rb
640
640
  - vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb
641
641
  - vendor/eac_cli/lib/eac_cli/runner.rb
642
+ - vendor/eac_cli/lib/eac_cli/runner/after_class_methods.rb
642
643
  - vendor/eac_cli/lib/eac_cli/runner/context.rb
643
644
  - vendor/eac_cli/lib/eac_cli/runner/exit.rb
645
+ - vendor/eac_cli/lib/eac_cli/runner/instance_methods.rb
644
646
  - vendor/eac_cli/lib/eac_cli/runner_with.rb
645
647
  - vendor/eac_cli/lib/eac_cli/runner_with/help.rb
646
648
  - vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb
@@ -995,6 +997,7 @@ files:
995
997
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/string_list.rb
996
998
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb
997
999
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb
1000
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb
998
1001
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/on_clean_ruby_environment.rb
999
1002
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/options_consumer.rb
1000
1003
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patch.rb
@@ -1009,6 +1012,8 @@ files:
1009
1012
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash.rb
1010
1013
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/options_consumer.rb
1011
1014
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/hash/sym_keys_hash.rb
1015
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb
1016
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb
1012
1017
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module.rb
1013
1018
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/abstract_methods.rb
1014
1019
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb
@@ -1034,7 +1039,6 @@ files:
1034
1039
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb
1035
1040
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time.rb
1036
1041
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb
1037
- - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb
1038
1042
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb
1039
1043
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/entry_key_error.rb
1040
1044
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash/node.rb
@@ -1079,6 +1083,7 @@ files:
1079
1083
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp_spec.rb
1080
1084
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb
1081
1085
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb
1086
+ - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb
1082
1087
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
1083
1088
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerable/boolean_combinations_spec.rb
1084
1089
  - vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/enumerator/current_spec.rb
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support/core_ext/time/zones'
4
- require 'eac_ruby_utils/envs'
5
-
6
- class Time
7
- class << self
8
- TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
9
-
10
- def local_time_zone
11
- local_time_zone_by_timedatectl || local_time_zone_by_offset
12
- end
13
-
14
- def local_time_zone_by_timedatectl
15
- executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version')
16
- return nil unless executable.exist?
17
-
18
- TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] }
19
- end
20
-
21
- def local_time_zone_by_offset
22
- ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
23
- end
24
- end
25
- end