xlogin 0.12.2 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xlogin.rb +28 -28
- data/lib/xlogin/cli.rb +1 -1
- data/lib/xlogin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7bce41012494be0a8efad4624674f5677a0830b7d3ebff88df664a2cbe5131e
|
4
|
+
data.tar.gz: 4f08a126e596f227ae6ff97361995ef48e3a588f2cf13746979cddf379851f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 848c4161be59adabd9931374d26deec1e67efa9a0be44c50f58237c96c7c84857987213ea5c34ded3ca683e971dbdfa3e2bb68dd83e243286aac612c15833068
|
7
|
+
data.tar.gz: ab6627e2a78435ee709d19e8cb230ac9b3645da9fe991cbc879667e62355985efdbaf63a544afa9318ce12733b11c9ac5b58a372a113c1888386c0e9ddbb9ffa
|
data/lib/xlogin.rb
CHANGED
@@ -20,6 +20,10 @@ module Xlogin
|
|
20
20
|
factory.list_inventory(*patterns)
|
21
21
|
end
|
22
22
|
|
23
|
+
def find(*patterns)
|
24
|
+
list(*patterns).first
|
25
|
+
end
|
26
|
+
|
23
27
|
def get(args, **opts, &block)
|
24
28
|
session = case args
|
25
29
|
when Hash then factory.build(**args.merge(**opts))
|
@@ -57,32 +61,41 @@ module Xlogin
|
|
57
61
|
@authorized = boolean == true || (block && block.call == true)
|
58
62
|
end
|
59
63
|
|
60
|
-
def source(*
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
source_files.compact.each do |file|
|
67
|
-
raise SessionError.new("Inventory file not found: #{file}") unless File.exist?(file)
|
68
|
-
factory.instance_eval(IO.read(file), file) if File.exist?(file)
|
64
|
+
def source(*sources, &block)
|
65
|
+
unless block
|
66
|
+
return sources.each do |path|
|
67
|
+
raise SessionError.new("Inventory file not found: #{path}") unless File.exist?(path)
|
68
|
+
factory.instance_eval(IO.read(path), path)
|
69
|
+
end
|
69
70
|
end
|
71
|
+
|
72
|
+
factory.instance_eval(&block)
|
70
73
|
end
|
71
74
|
|
72
|
-
def template(
|
75
|
+
def template(*templates, **opts, &block)
|
73
76
|
unless block
|
74
|
-
|
75
|
-
|
77
|
+
templates.each do |template|
|
78
|
+
return template_url(template, **opts) if template =~ URI.regexp(['http', 'https'])
|
79
|
+
raise TemplateError.new("Template file or directory not found: #{template}") unless File.exist?(template)
|
80
|
+
|
81
|
+
files = [template] if File.file?(template)
|
82
|
+
files = Dir.glob(File.join(template, '*.rb')) if File.directory?(template)
|
83
|
+
files.each do |file|
|
84
|
+
name = opts[:type] || File.basename(file, '.rb').scan(/\w+/).join('_')
|
85
|
+
factory.set_template(name, IO.read(file))
|
86
|
+
end
|
87
|
+
end
|
76
88
|
end
|
77
89
|
|
78
|
-
|
90
|
+
name = opts[:type] || templates.first
|
91
|
+
raise ArgumentError.new('Missing template name') unless name
|
79
92
|
factory.set_template(name, &block)
|
80
93
|
end
|
81
94
|
|
82
|
-
def template_url(*template_urls)
|
95
|
+
def template_url(*template_urls, **opts)
|
83
96
|
template_urls.compact.each do |url|
|
84
97
|
uri = URI(url.to_s)
|
85
|
-
name = File.basename(uri.path, '.rb').scan(/\w+/).join('_')
|
98
|
+
name = opts[:type] || File.basename(uri.path, '.rb').scan(/\w+/).join('_')
|
86
99
|
text = Net::HTTP.get(uri)
|
87
100
|
if text =~ /\w+.rb$/
|
88
101
|
uri.path = File.join(File.dirname(uri.path), text.lines.first.chomp)
|
@@ -92,19 +105,6 @@ module Xlogin
|
|
92
105
|
end
|
93
106
|
end
|
94
107
|
|
95
|
-
def template_file(*template_files)
|
96
|
-
template_files.compact.each do |file|
|
97
|
-
raise TemplateError.new("Template file not found: #{file}") unless File.exist?(file)
|
98
|
-
name = File.basename(file, '.rb').scan(/\w+/).join('_')
|
99
|
-
factory.set_template(name, IO.read(file))
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def template_dir(*template_dirs)
|
104
|
-
files = template_dirs.flat_map { |dir| Dir.glob(File.join(dir, '*.rb')) }
|
105
|
-
template_file(*files)
|
106
|
-
end
|
107
|
-
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
data/lib/xlogin/cli.rb
CHANGED
@@ -47,7 +47,7 @@ module Xlogin
|
|
47
47
|
Xlogin.configure do
|
48
48
|
authorize(config.auth)
|
49
49
|
source(File.expand_path(config.inventory, ENV['PWD']))
|
50
|
-
|
50
|
+
template(File.expand_path(config.template_dir, ENV['PWD']))
|
51
51
|
end
|
52
52
|
|
53
53
|
config.hosts = Xlogin.list(*args)
|
data/lib/xlogin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xlogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- haccht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-telnet
|