xlogin 0.12.3 → 0.12.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: f7bce41012494be0a8efad4624674f5677a0830b7d3ebff88df664a2cbe5131e
4
- data.tar.gz: 4f08a126e596f227ae6ff97361995ef48e3a588f2cf13746979cddf379851f32
3
+ metadata.gz: 40a19a8c4be89c5b57af233605e059b2cb835c293e8ad6db1a52ed568b1968c7
4
+ data.tar.gz: 96d9bda304dd69d4a1c2962336af11c68862924987b7661af417ebc566be39ab
5
5
  SHA512:
6
- metadata.gz: 848c4161be59adabd9931374d26deec1e67efa9a0be44c50f58237c96c7c84857987213ea5c34ded3ca683e971dbdfa3e2bb68dd83e243286aac612c15833068
7
- data.tar.gz: ab6627e2a78435ee709d19e8cb230ac9b3645da9fe991cbc879667e62355985efdbaf63a544afa9318ce12733b11c9ac5b58a372a113c1888386c0e9ddbb9ffa
6
+ metadata.gz: 0f0720e0bb78e942f01d360e9a9e0cfb9fcaddcf4b324bac18052ef44d59a95e41e5925814b257be4604154cebed065b57589546d34a66c74f7aa1ab5e0a4b91
7
+ data.tar.gz: 89c7788c08960f365eacfdfc1c74b0e52a136faa84f60045da97939af8206b0d9739e7b19d51dfffb7de7bf771843c59156831f0c408f2d750047195ae451343
data/README.md CHANGED
@@ -34,7 +34,8 @@ login do |username, password|
34
34
  end
35
35
  ```
36
36
 
37
- Some other example are in [lib/xlogin/templates](https://github.com/haccht/xlogin/tree/master/lib/xlogin/templates).
37
+ Some other examples are in [lib/xlogin/templates](https://github.com/haccht/xlogin/tree/master/lib/xlogin/templates).
38
+ You can just load these built-in templates by adding `require "xlogin/template"` in your script.
38
39
 
39
40
  Beside template files, you need to prepare an inventory file `~/.xloginrc`.
40
41
  In this file, you need to write all information required to login each device.
@@ -31,13 +31,6 @@ module Xlogin
31
31
 
32
32
  def with
33
33
  session = deq
34
- begin
35
- raise IOError if session.sock.closed?
36
- rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET
37
- destroy(session)
38
- session = deq
39
- end
40
-
41
34
  Thread.handle_interrupt(Exception => :immediate) { yield session }
42
35
  ensure
43
36
  enq session
@@ -50,7 +43,6 @@ module Xlogin
50
43
  end
51
44
  end
52
45
 
53
- private
54
46
  def deq
55
47
  @mutex.synchronize do
56
48
  if @queue.empty? && @created < @size
@@ -65,6 +57,13 @@ module Xlogin
65
57
  return deq
66
58
  end
67
59
 
60
+ begin
61
+ raise IOError if session.sock.closed?
62
+ rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET
63
+ destroy(session)
64
+ session = deq
65
+ end
66
+
68
67
  session
69
68
  end
70
69
 
@@ -1,7 +1,4 @@
1
1
  prompt(/[>$#]/)
2
- prompt(/yes \/ no: /) do
3
- puts (Xlogin.authorized?)? 'y' : 'n'
4
- end
5
2
 
6
3
  login do |password|
7
4
  waitfor(/Password: /) && puts(password)
@@ -1,7 +1,4 @@
1
1
  prompt(/[>$#] /)
2
- prompt(/y\/n:/) do
3
- puts (Xlogin.authorized?)? 'y' : 'n'
4
- end
5
2
 
6
3
  login do |*args|
7
4
  username, password = *args
@@ -0,0 +1,4 @@
1
+ # load built-in templates
2
+ Xlogin.configure do
3
+ template File.join(__dir__, 'templates')
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Xlogin
2
- VERSION = "0.12.3"
2
+ VERSION = "0.12.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlogin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - haccht
@@ -166,6 +166,7 @@ files:
166
166
  - lib/xlogin/ssh.rb
167
167
  - lib/xlogin/telnet.rb
168
168
  - lib/xlogin/template.rb
169
+ - lib/xlogin/templates.rb
169
170
  - lib/xlogin/templates/ios.rb
170
171
  - lib/xlogin/templates/iosxr.rb
171
172
  - lib/xlogin/templates/junos.rb