tp_link 0.0.1 → 0.0.2

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: 1ecbd0295f05df003c78bbcc8cf1299dc1a7af18
4
- data.tar.gz: f34c62675f5fdd65b9607f06408d0c5a66f1c90a
3
+ metadata.gz: be4ee47d454bf5549642c0b14e47c52bb4c2d34a
4
+ data.tar.gz: 7cdec85ca46153c0b0be7d3b65d05de1af3ceee5
5
5
  SHA512:
6
- metadata.gz: 9aa8132ae642b60c8bd28623acb3dbd3c5ab1e76d0c712fba47e5026b34cb838eaae53b49cbd58b916c18a9014cb113c2a53cccd8ded999630db4d17e8b08afd
7
- data.tar.gz: 6b13493b9a882282f9fe0c9ec7015bd5204007813b1c3397289b0aa46f4a5805ab3d11d93fb710919ebe57ef3cb878bb9e097c9e8d06a098f6b9b066849e9643
6
+ metadata.gz: 9a48613be5c49bc3e8fce8c346106483e798fe786729c96962589abd263c022e24c93e7846d35ee00748ffdb466925674d1ab13ea653cfca651e4c828b62427f
7
+ data.tar.gz: d410502874577cc66eaf4df792481e17140f46d36e450e8de647b7849d98d052e44e05ff4946b26f21d4c755df9856e121991f1fe7afaa53659058b1a0acdaa9
@@ -43,9 +43,8 @@ module TPLink
43
43
  end
44
44
 
45
45
  # @!visibility private
46
- def initialize(opts = nil)
47
- options = opts || "#{ENV['HOME']}/.tp_link"
48
- @config = Config.new(options)
46
+ def initialize(opts = {})
47
+ @config = Config.new(opts)
49
48
  @token = nil
50
49
  @device_list = []
51
50
  end
@@ -5,9 +5,8 @@ module TPLink
5
5
  # It is used internally and should not need to be called.
6
6
  # @!visibility private
7
7
  class Config
8
- def initialize(config = "#{ENV['HOME']}/.tp_link")
9
- @config_file = nil
10
- @config = get_config(config)
8
+ def initialize(config = {})
9
+ @config = config
11
10
  raise 'User name not spcified in configuration.' \
12
11
  unless @config.key?('user')
13
12
  raise 'Password not specified in configuration.' \
@@ -16,12 +15,7 @@ module TPLink
16
15
  end
17
16
 
18
17
  def generate_uuid
19
- if @config_file && @config['uuid'].nil?
20
- @config['uuid'] ||= SecureRandom.uuid
21
- File.open(@config_file, 'w') do |f|
22
- f.write @config.to_yaml
23
- end
24
- end
18
+ @config['uuid'] ||= SecureRandom.uuid
25
19
  @config['uuid']
26
20
  end
27
21
 
@@ -30,7 +24,7 @@ module TPLink
30
24
  end
31
25
 
32
26
  def terminal_uuid
33
- @config['uuid']
27
+ @config['uuid'] ||= Securerandom.uuid
34
28
  end
35
29
 
36
30
  def cloud_user_name
@@ -53,19 +47,5 @@ module TPLink
53
47
  def to_json(_o)
54
48
  to_hash.to_json
55
49
  end
56
-
57
- private
58
-
59
- def get_config(config)
60
- if config.is_a? String
61
- raise "Config file missing: #{config}" \
62
- unless File.exist?(config)
63
- @config_file = config
64
- return YAML.load_file(config) || {}
65
- elsif !config.is_a?(Hash)
66
- raise "Invalid config type #{config.class}"
67
- end
68
- config
69
- end
70
50
  end
71
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Paterni
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-05 00:00:00.000000000 Z
12
+ date: 2018-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday