tp_link 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tp_link/api.rb +2 -3
- data/lib/tp_link/config.rb +4 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be4ee47d454bf5549642c0b14e47c52bb4c2d34a
|
4
|
+
data.tar.gz: 7cdec85ca46153c0b0be7d3b65d05de1af3ceee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a48613be5c49bc3e8fce8c346106483e798fe786729c96962589abd263c022e24c93e7846d35ee00748ffdb466925674d1ab13ea653cfca651e4c828b62427f
|
7
|
+
data.tar.gz: d410502874577cc66eaf4df792481e17140f46d36e450e8de647b7849d98d052e44e05ff4946b26f21d4c755df9856e121991f1fe7afaa53659058b1a0acdaa9
|
data/lib/tp_link/api.rb
CHANGED
@@ -43,9 +43,8 @@ module TPLink
|
|
43
43
|
end
|
44
44
|
|
45
45
|
# @!visibility private
|
46
|
-
def initialize(opts =
|
47
|
-
|
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
|
data/lib/tp_link/config.rb
CHANGED
@@ -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 =
|
9
|
-
@
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|