xlogin 0.10.4 → 0.10.5

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: 9d1d3a6d542d119f68907e730830c7a96c3cfe000651344aa55f8eecbfd9641e
4
- data.tar.gz: aeebf45583736b0c2d8754f1b3440b5970074e631dcb38493c0c3c213fdb39f6
3
+ metadata.gz: d7c0c48f0e43214927dbdba1f0033e6e06e563ffd4a781b391b072557ff26ade
4
+ data.tar.gz: c2a3b20ceef5323db59f71d0d4da2969c7de2ab7416c25df60243364ca2b2540
5
5
  SHA512:
6
- metadata.gz: af2864edb358c631ebf2dc1113d2168d024fbd2005549f6fcf415ff4898e2fe3708537a19d6ad085ff296a29b9007261cdf90a1ef0abdd038d65fe2f510afaf7
7
- data.tar.gz: 569159401aab9730cebd526136b7524b7cbb449c0d31bfd580d59b4eac03aabb1932d5ea71bfa51d5064edc10f4f529c5a206b949ecced0af5227bd5d080d350
6
+ metadata.gz: c9dad66a4dc1de1ccd2a60218b0ea0b35d0ebeb983d9ba3b3610e3c998823ed40d5902da5e7764aa3eb425ab8e0cb8a33892b698b513bd06f11747ce026e9e01
7
+ data.tar.gz: 5080938c72495cf7c87ca3e92ea2a7628ff0a67dd170fcfa3b44fcc7102b9cbefafc79a6578e308d0bccd1e7dafbee475255a177390ec6488cf112da38dcd73c
@@ -1,3 +1,4 @@
1
+ require 'time'
1
2
  require 'rake'
2
3
  require 'rake/tasklib'
3
4
  require 'ostruct'
@@ -92,7 +93,7 @@ module Xlogin
92
93
  @runner.call(session)
93
94
  session.close if session
94
95
 
95
- output($stdout, buffer.string) if !silent && Rake.application.options.always_multitask
96
+ printf($stdout, buffer.string) if !silent && Rake.application.options.always_multitask
96
97
  rescue => e
97
98
  output($stderr, buffer.string) if !silent && Rake.application.options.always_multitask
98
99
  output($stderr, "[ERROR] Xlogin - #{e}\n")
@@ -101,10 +102,13 @@ module Xlogin
101
102
  end
102
103
  end
103
104
 
104
- def output(fp, text)
105
- prefix = (Rake.application.options.always_multitask)? "#{name}\t|" : ""
106
- lines = text.lines.map { |line| "#{prefix}#{line.strip}\n" }
107
- lines.each { |line| $stdout.print line }
105
+ def printf(fp, text)
106
+ time = Time.now.iso8061
107
+ text.each_line do |line|
108
+ fp.print "#{time} "
109
+ fp.print "#{name}\t" if Rake.application.options.always_multitask
110
+ fp.print "|#{line.chomp.gsub(/^\s*\r/, '')}\n"
111
+ end
108
112
  end
109
113
 
110
114
  end
@@ -1,3 +1,3 @@
1
1
  module Xlogin
2
- VERSION = "0.10.4"
2
+ VERSION = "0.10.5"
3
3
  end
data/lib/xlogin.rb CHANGED
@@ -60,7 +60,12 @@ module Xlogin
60
60
  factory.set_inventory(**args)
61
61
  end
62
62
 
63
- def source(*source_files)
63
+ def source(*source_files, &block)
64
+ return source_file(*source_files) unless block
65
+ instance_eval(&block) unless source_files.empty?
66
+ end
67
+
68
+ def source_file(*source_files)
64
69
  source_files.compact.each do |file|
65
70
  raise SessionError.new("Inventory file not found: #{file}") unless File.exist?(file)
66
71
  instance_eval(IO.read(file), file) if File.exist?(file)
@@ -68,17 +73,12 @@ module Xlogin
68
73
  end
69
74
 
70
75
  def template(name, *args, &block)
71
- return template_dir(name, *args) unless block # for backward compatibility
76
+ return template_dir(name, *args) unless block
72
77
 
73
78
  raise ArgumentError.new('missing template name') unless name
74
79
  factory.set_template(name, &block)
75
80
  end
76
81
 
77
- def template_dir(*template_dirs)
78
- files = template_dirs.flat_map { |dir| Dir.glob(File.join(dir, '*.rb')) }
79
- template_file(*files)
80
- end
81
-
82
82
  def template_file(*template_files)
83
83
  template_files.compact.each do |file|
84
84
  raise TemplateError.new("Template file not found: #{file}") unless File.exist?(file)
@@ -87,6 +87,11 @@ module Xlogin
87
87
  end
88
88
  end
89
89
 
90
+ def template_dir(*template_dirs)
91
+ files = template_dirs.flat_map { |dir| Dir.glob(File.join(dir, '*.rb')) }
92
+ template_file(*files)
93
+ end
94
+
90
95
  def method_missing(method_name, *args, &block)
91
96
  type = method_name.to_s.downcase
92
97
  name = args[0]
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.10.4
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - haccht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-11 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-telnet