eac_ruby_utils 0.41.0 → 0.42.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_utils/boolean.rb +31 -0
- data/lib/eac_ruby_utils/envs/ssh_env.rb +10 -18
- data/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
- data/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +23 -0
- data/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +22 -0
- data/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +32 -0
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aae61dcf00f56fd19422516fdeddc796f6f18cb592bfda3d994ad91651f6ed9a
|
4
|
+
data.tar.gz: cec8de39973f51c39a7466249756105e3c37b80ffba2ab373f8a9a29f9eea8ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c8ec736251746dabf77d8d97b35c0768995cc83817830ec9af8c7261ce3d100d74ae87143ba7a3fbd82ca81e2618c8b0fbf13367820babb29341a1bfcf28efc
|
7
|
+
data.tar.gz: 98ce82f43d3f029d947e368dc1cd519d69249182e73fb13d0ee683050e0b93e4770d029eda3bc02f07b80909ab16788bec35b6086fb44f6daa82ec38255ebc37
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
class Boolean
|
5
|
+
class << self
|
6
|
+
def parse(value)
|
7
|
+
return parse_string(value) if value.is_a?(::String)
|
8
|
+
return parse_string(value.to_s) if value.is_a?(::Symbol)
|
9
|
+
return parse_number(value) if value.is_a?(::Number)
|
10
|
+
|
11
|
+
value ? true : false
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def parse_string(value)
|
17
|
+
['', 'n', 'no', 'f', 'false'].include?(value.strip.downcase) ? false : true
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse_number(value)
|
21
|
+
value.zero?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :value
|
26
|
+
|
27
|
+
def initialize(value)
|
28
|
+
@value = self.class.parse(value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,13 +3,15 @@
|
|
3
3
|
require 'addressable'
|
4
4
|
require 'eac_ruby_utils/envs/base_env'
|
5
5
|
require 'eac_ruby_utils/patches/object/if_present'
|
6
|
+
require 'eac_ruby_utils/patches/module/require_sub'
|
6
7
|
require 'net/ssh'
|
7
8
|
require 'shellwords'
|
8
9
|
|
9
10
|
module EacRubyUtils
|
10
11
|
module Envs
|
11
12
|
class SshEnv < ::EacRubyUtils::Envs::BaseEnv
|
12
|
-
|
13
|
+
require_sub __FILE__, include_modules: true
|
14
|
+
|
13
15
|
USER_PATTERN = /[a-z_][a-z0-9_-]*/.freeze
|
14
16
|
HOSTNAME_PATTERN = /[^@]+/.freeze
|
15
17
|
USER_HOSTNAME_PATTERN = /\A(?:(#{USER_PATTERN})@)?(#{HOSTNAME_PATTERN})\z/.freeze
|
@@ -51,20 +53,16 @@ module EacRubyUtils
|
|
51
53
|
private
|
52
54
|
|
53
55
|
def ssh_command_line
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
r << user_hostname_uri
|
59
|
-
r.map { |a| Shellwords.escape(a) }.join(' ')
|
56
|
+
(%w[ssh] +
|
57
|
+
%w[nodasho dasho port].flat_map { |m| send("ssh_command_line_#{m}_args") } +
|
58
|
+
[user_hostname_uri])
|
59
|
+
.map { |a| Shellwords.escape(a) }.join(' ')
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
r += ['-o', "#{k}=#{v}"] unless k == IDENTITITY_FILE_OPTION
|
62
|
+
def ssh_command_line_port_args
|
63
|
+
uri.port.if_present([]) do |v|
|
64
|
+
['-p', v]
|
66
65
|
end
|
67
|
-
r
|
68
66
|
end
|
69
67
|
|
70
68
|
def user_hostname_uri
|
@@ -72,12 +70,6 @@ module EacRubyUtils
|
|
72
70
|
r = "#{uri.user}@#{r}" if uri.user.present?
|
73
71
|
r
|
74
72
|
end
|
75
|
-
|
76
|
-
def ssh_identity_file
|
77
|
-
uri.query_values.if_present do |v|
|
78
|
-
v[IDENTITITY_FILE_OPTION]
|
79
|
-
end
|
80
|
-
end
|
81
73
|
end
|
82
74
|
end
|
83
75
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/patches/module/common_concern'
|
4
|
+
require 'eac_ruby_utils/patches/module/simple_cache'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Envs
|
8
|
+
class SshEnv < ::EacRubyUtils::Envs::BaseEnv
|
9
|
+
module DashoOptions
|
10
|
+
common_concern
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def add_nodasho_option(name)
|
14
|
+
return if nodasho_options.include?(name)
|
15
|
+
|
16
|
+
nodasho_options << name
|
17
|
+
const_set("#{name.underscore}_option".upcase, name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def nodasho_options
|
21
|
+
@nodasho_options ||= []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module InstanceMethods
|
26
|
+
def ssh_command_line_dasho_args
|
27
|
+
r = []
|
28
|
+
uri.query_values&.each do |k, v|
|
29
|
+
r += ['-o', "#{k}=#{v}"] unless nodasho_options.include?(k)
|
30
|
+
end
|
31
|
+
r
|
32
|
+
end
|
33
|
+
|
34
|
+
def ssh_command_line_nodasho_args
|
35
|
+
nodasho_options.flat_map do |option_name|
|
36
|
+
uri_query_value(option_name).if_present([]) do |option_value|
|
37
|
+
send("ssh_command_line_#{option_name.underscore}_args", option_value)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def nodasho_options
|
43
|
+
self.class.nodasho_options
|
44
|
+
end
|
45
|
+
|
46
|
+
def uri_query_value(name)
|
47
|
+
uri.query_values.if_present { |v| v[name] }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'eac_ruby_utils/listable'
|
5
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Envs
|
9
|
+
class SshEnv < ::EacRubyUtils::Envs::BaseEnv
|
10
|
+
module IdentityFile
|
11
|
+
extend ::ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
add_nodasho_option('IdentityFile')
|
15
|
+
end
|
16
|
+
|
17
|
+
def ssh_command_line_identity_file_args(value)
|
18
|
+
['-i', value]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'eac_ruby_utils/boolean'
|
5
|
+
|
6
|
+
module EacRubyUtils
|
7
|
+
module Envs
|
8
|
+
class SshEnv < ::EacRubyUtils::Envs::BaseEnv
|
9
|
+
module Quiet
|
10
|
+
extend ::ActiveSupport::Concern
|
11
|
+
|
12
|
+
included do
|
13
|
+
add_nodasho_option('Quiet')
|
14
|
+
end
|
15
|
+
|
16
|
+
def ssh_command_line_quiet_args(value)
|
17
|
+
::EacRubyUtils::Boolean.parse(value) ? ['-q'] : []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'eac_ruby_utils/listable'
|
5
|
+
require 'eac_ruby_utils/patches/object/if_present'
|
6
|
+
|
7
|
+
module EacRubyUtils
|
8
|
+
module Envs
|
9
|
+
class SshEnv < ::EacRubyUtils::Envs::BaseEnv
|
10
|
+
module Terminal
|
11
|
+
extend ::ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
add_nodasho_option('Terminal')
|
15
|
+
include ::EacRubyUtils::Listable
|
16
|
+
lists.add_string :terminal_option, :auto, :disable, :enable, :force
|
17
|
+
end
|
18
|
+
|
19
|
+
def ssh_command_line_terminal_args(value)
|
20
|
+
self.class.lists.terminal_option.value_validate!(value)
|
21
|
+
case value
|
22
|
+
when TERMINAL_OPTION_AUTO then ENV['TERM'].present? ? %w[-t] : []
|
23
|
+
when TERMINAL_OPTION_DISABLE then ['-T']
|
24
|
+
when TERMINAL_OPTION_ENABLE then ['-t']
|
25
|
+
when TERMINAL_OPTION_FORCE then ['-tt']
|
26
|
+
else raise "Invalid conditional branch: #{value}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.42.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- README.rdoc
|
110
110
|
- lib/eac_ruby_utils.rb
|
111
111
|
- lib/eac_ruby_utils/arguments_consumer.rb
|
112
|
+
- lib/eac_ruby_utils/boolean.rb
|
112
113
|
- lib/eac_ruby_utils/by_reference.rb
|
113
114
|
- lib/eac_ruby_utils/common_concern.rb
|
114
115
|
- lib/eac_ruby_utils/common_constructor.rb
|
@@ -139,6 +140,10 @@ files:
|
|
139
140
|
- lib/eac_ruby_utils/envs/process.rb
|
140
141
|
- lib/eac_ruby_utils/envs/spawn.rb
|
141
142
|
- lib/eac_ruby_utils/envs/ssh_env.rb
|
143
|
+
- lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb
|
144
|
+
- lib/eac_ruby_utils/envs/ssh_env/identity_file.rb
|
145
|
+
- lib/eac_ruby_utils/envs/ssh_env/quiet.rb
|
146
|
+
- lib/eac_ruby_utils/envs/ssh_env/terminal.rb
|
142
147
|
- lib/eac_ruby_utils/filesystem_cache.rb
|
143
148
|
- lib/eac_ruby_utils/fs.rb
|
144
149
|
- lib/eac_ruby_utils/fs/extname.rb
|
@@ -237,8 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
242
|
- !ruby/object:Gem::Version
|
238
243
|
version: '0'
|
239
244
|
requirements: []
|
240
|
-
|
241
|
-
rubygems_version: 2.7.7
|
245
|
+
rubygems_version: 3.0.6
|
242
246
|
signing_key:
|
243
247
|
specification_version: 4
|
244
248
|
summary: Utilities for E.A.C.'s Ruby projects.
|