xlogin 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36970bb1e8aa8b5964f5f6816def6f9c7f022e29
4
- data.tar.gz: 43247a1af547984234d5a27e3cd5376545a6b609
3
+ metadata.gz: e7279f5af85472ff7036bae0371989769c7b59af
4
+ data.tar.gz: 7a462b1f5df61cb32dec19548cdc0cf205a183d3
5
5
  SHA512:
6
- metadata.gz: 93a538d2bb67c8602e042580f41c3593c3f2cd81b2b1ee57e94d4fbfb0a51326e5e25e5efb202eed8e9c593eb794081ebccc80a08098f05f28bfc4bf24ab18c8
7
- data.tar.gz: fd43f1cc39141d0707c056ed6f9d3e1d47d3bac58e7330114f5d3188201b0fbdd9853403101dee4b82f1c53bdb98b26448e55850da10687b5fa5dd3e4f8ea93c
6
+ metadata.gz: b3880819e38e42ff5213d36b020f86f84e991bc027bef87ae89d98c279101fba03a3586ba6de923b488c6cb243909f6ed6b9e528474a026a941a553fb0cd1c89
7
+ data.tar.gz: bb354168a5ba42ded1ba9ae6dffedf4fbf2f48df67e1def6dfae35d9b29111985faf65eaedab8e9e95b8357d3bcdd61765e80d320bc9bcd6d56912b2adcd036b
data/.gitignore CHANGED
@@ -56,5 +56,5 @@ build-iPhoneSimulator/
56
56
  # End of https://www.gitignore.io/api/ruby
57
57
  /lib/xlogin/.xloginrc
58
58
  /lib/xlogin/_xloginrc
59
- /lib/xlogin/firmwares/*
60
- !/lib/xlogin/firmwares/vyos.rb
59
+ /lib/xlogin/firmware_templates/*
60
+ !/lib/xlogin/firmware_templates/vyos.rb
@@ -9,7 +9,7 @@ module Xlogin
9
9
 
10
10
  if hostname = opts.delete(:delegate)
11
11
  target = Xlogin.factory.get(hostname)
12
- target_os = Xlogin.factory.template_for(target[:type])
12
+ target_os = Xlogin.factory.get_template(target[:type])
13
13
  target_uri = URI(target[:uri])
14
14
 
15
15
  login = @methods.delete(:login)
@@ -13,16 +13,20 @@ module Xlogin
13
13
  @templates = Hash.new
14
14
  end
15
15
 
16
- def register_template_file(file)
16
+ def load_template_file(file)
17
17
  require file if file =~ /.rb$/
18
18
  end
19
19
 
20
- def register_template(name, template)
20
+ def get_template(name)
21
+ @templates[name.to_s.downcase]
22
+ end
23
+
24
+ def set_template(name, template)
21
25
  @templates[name.to_s.downcase] = template
22
26
  end
23
27
 
24
- def template_for(name)
25
- @templates[name.to_s.downcase]
28
+ def list_templates
29
+ @templates.keys
26
30
  end
27
31
 
28
32
  def source(db_file)
@@ -51,7 +55,7 @@ module Xlogin
51
55
  opts = args.reduce({}) { |a, (k, v)| a.merge(k.to_s.downcase.to_sym => v) }
52
56
  raise Xlogin::GeneralError.new("Host not found: #{args}") unless uri && type
53
57
 
54
- session = template_for(type).dup.run(uri, opts)
58
+ session = get_template(type).dup.run(uri, opts)
55
59
  session.name = name if name
56
60
  session
57
61
  end
@@ -1,3 +1,3 @@
1
1
  module Xlogin
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
data/lib/xlogin.rb CHANGED
@@ -7,12 +7,12 @@ require 'xlogin/version'
7
7
  module Xlogin
8
8
 
9
9
  ## where firmware templates locate.
10
- TemplateDir = File.join(File.dirname(__FILE__), 'xlogin', 'firmwares')
10
+ template_dir = File.join(File.dirname(__FILE__), 'xlogin', 'firmware_templates')
11
11
 
12
12
  ## where instance parameter definitions locate.
13
- SourceDirs = [
14
- File.join(File.dirname(__FILE__), 'xlogin'),
15
- ENV['HOME'], ENV['XLOGIN_HOME'],
13
+ source_dirs = [
14
+ ENV['HOME'],
15
+ ENV['XLOGIN_HOME'],
16
16
  Dir.pwd
17
17
  ]
18
18
 
@@ -23,11 +23,11 @@ module Xlogin
23
23
  unless @factory
24
24
  @factory = Xlogin::FirmwareFactory.instance
25
25
 
26
- Dir.entries(TemplateDir).each do |file|
27
- @factory.register_template_file(File.join(TemplateDir, file))
26
+ Dir.entries(template_dir).each do |file|
27
+ @factory.load_template_file(File.join(TemplateDir, file))
28
28
  end
29
29
 
30
- SourceDirs.compact.uniq.each do |dir|
30
+ source_dirs.compact.uniq.each do |dir|
31
31
  @factory.source(File.join(dir, '.xloginrc'))
32
32
  @factory.source(File.join(dir, '_xloginrc'))
33
33
  end
@@ -37,17 +37,17 @@ module Xlogin
37
37
  end
38
38
 
39
39
  def configure(name)
40
- template = factory.template_for(name) || Xlogin::Firmware.new
40
+ template = factory.get_template(name) || Xlogin::Firmware.new
41
41
  yield template if block_given?
42
42
 
43
- factory.register_template(name, template)
43
+ factory.set_template(name, template)
44
44
  end
45
45
 
46
46
  def alias(new_name, original_name)
47
- template = factory.template_for(original_name)
47
+ template = factory.get_template(original_name)
48
48
  raise Xlogin::GeneralError.new("'#{original_name}' not found") unless template
49
49
 
50
- factory.register_template(new_name, template)
50
+ factory.set_template(new_name, template)
51
51
  end
52
52
 
53
53
  def get(hostname, args = {})
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.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - haccht
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,7 +73,7 @@ files:
73
73
  - lib/xlogin/delegator.rb
74
74
  - lib/xlogin/firmware.rb
75
75
  - lib/xlogin/firmware_factory.rb
76
- - lib/xlogin/firmwares/vyos.rb
76
+ - lib/xlogin/firmware_templates/vyos.rb
77
77
  - lib/xlogin/gateway.rb
78
78
  - lib/xlogin/rake_task.rb
79
79
  - lib/xlogin/rspec.rb