sparoid 1.0.3 → 1.0.4

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
  SHA256:
3
- metadata.gz: 594f1917e9cea3e563dcb027f0fb0ddc9fc41e4a0240a405b7fbba8445de61d9
4
- data.tar.gz: 7d39ad302157dfce633b339338e6564d407074556614422efc71b3e645272ac2
3
+ metadata.gz: 6bceab7682e1a59d1da6f51276f580f11c50456625ea57b1633dd8862f9045df
4
+ data.tar.gz: 97f3594df9310bd90472d6909e3a2f7ba719c43638d53cc12e5464cd2634bd8f
5
5
  SHA512:
6
- metadata.gz: 7c037f995e1fd41822c9b726e7d79e2fc065a75dff5697df4182b6e6294889c305f2d224bf6436bd4f26e4e790316d507cffd2dc58d7f6041cf6e4a6484e3098
7
- data.tar.gz: 2478cbdb04f16035a93c37711a1bb7eaab1cd7482a6c80418ba71f60c276d356513d1210b51615ea984167ba9b654cc1bf51c4d4899e37894a348abdfaa7e76a
6
+ metadata.gz: 668b9744c1f4e4c77cf91f5f351b23444f0e7a325fb6af0c834fe7d255273afa70b21455318c0979933dca994151ea17cb63f9db4ee5cc74d9e2b146f3e745b0
7
+ data.tar.gz: 040e356d56e371eb487079d6beb286b9dec64287f57301aa235e5cdadd8b6116839b564ffca7d894b93d151f2520a3af589b46962c0592974ca796363885242d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.4] - 2021-03-25
2
+
3
+ - Only warn if config is missing when connecting with CLI
4
+
1
5
  ## [1.0.3] - 2021-03-17
2
6
 
3
7
  - Nicer error handling in CLI, remove --fdpass option
data/lib/sparoid/cli.rb CHANGED
@@ -7,20 +7,23 @@ module Sparoid
7
7
  # CLI
8
8
  class CLI < Thor
9
9
  desc "auth HOST [PORT]", "Send a authorization packet"
10
- method_option :config, desc: "Path to a config file, INI format, with key and hmac-key"
10
+ method_option :config, desc: "Path to a config file, INI format, with key and hmac-key", default: "~/.sparoid.ini"
11
11
  def auth(host, port = 8484)
12
- config = File.expand_path(options[:config] || "~/.sparoid.ini")
13
- abort "Config '#{config}' not found" unless File.exist? config
14
-
15
- key, hmac_key = get_keys(parse_ini(config))
16
- Sparoid.auth(key, hmac_key, host, port.to_i)
12
+ send_auth(host, port, options[:config])
13
+ rescue Errno::ENOENT
14
+ abort "Config not found"
17
15
  rescue StandardError => e
18
16
  abort e.message
19
17
  end
20
18
 
21
19
  desc "connect HOST PORT [SPA-PORT]", "Send a SPA, TCP connect, and then pass the FD back to the parent"
20
+ method_option :config, desc: "Path to a config file, INI format, with key and hmac-key", default: "~/.sparoid.ini"
22
21
  def connect(host, port, spa_port = 8484)
23
- auth(host, spa_port)
22
+ begin
23
+ send_auth(host, spa_port, options[:config])
24
+ rescue Errno::ENOENT
25
+ warn "Config not found"
26
+ end
24
27
  Sparoid.fdpass(host, port)
25
28
  rescue StandardError => e
26
29
  abort e.message
@@ -37,8 +40,13 @@ module Sparoid
37
40
 
38
41
  private
39
42
 
43
+ def send_auth(host, port, config)
44
+ key, hmac_key = get_keys(parse_ini(config))
45
+ Sparoid.auth(key, hmac_key, host, port.to_i)
46
+ end
47
+
40
48
  def parse_ini(path)
41
- File.readlines(path).map! { |l| l.split("=", 2).map!(&:strip) }.to_h
49
+ File.readlines(File.expand_path(path)).map! { |line| line.split("=", 2).map!(&:strip) }.to_h
42
50
  end
43
51
 
44
52
  def get_keys(config)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sparoid
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Hörberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-17 00:00:00.000000000 Z
11
+ date: 2021-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor