apiotics 0.1.70 → 0.1.71
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apiotics/configuration.rb +18 -1
- data/lib/apiotics/portal.rb +24 -0
- data/lib/apiotics/version.rb +1 -1
- 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: 4a3809901de2d9425bdbd21c799880024397c41a
|
4
|
+
data.tar.gz: 694739e2c592cf9873a95caf0ddaac8421efd5cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62c29e51f2ede14bb1b8a24a62022bb5c4766eabdda23124ac8ed6f0ee4668be13fb55061a360df6825b01a58ec0db05b30269c3c31cb107e7531c921511b3e4
|
7
|
+
data.tar.gz: 692258530d8551fe88af0670bec28370a5836026078d738d0de779907be438f5d8e7862af3cababc8ee97d9abd537a703c4a9fd51fa73809ca99fc467591d79a
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Apiotics
|
2
2
|
class Configuration
|
3
3
|
|
4
|
-
attr_accessor :public_key, :private_key, :local_logging, :targets, :local_port, :server, :server_port, :portal, :push, :tls, :verify_peer, :handshake, :parents
|
4
|
+
attr_accessor :public_key, :private_key, :local_logging, :targets, :local_port, :server, :server_port, :portal, :push, :tls, :verify_peer, :handshake, :parents, :interface_kinds
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@public_key = nil
|
@@ -17,6 +17,23 @@ module Apiotics
|
|
17
17
|
@verify_peer = true
|
18
18
|
@handshake = true
|
19
19
|
@parents = {}
|
20
|
+
@interface_kinds = {
|
21
|
+
"string" => "string",
|
22
|
+
"text" => "string",
|
23
|
+
"smallint" => "integer",
|
24
|
+
"integer" => "integer",
|
25
|
+
"bigint" => "integer",
|
26
|
+
"float" => "float",
|
27
|
+
"boolean" => "boolean",
|
28
|
+
"enum" => "string",
|
29
|
+
"json" => "json",
|
30
|
+
"uint8_t" => "integer",
|
31
|
+
"uint16_t" => "integer",
|
32
|
+
"uint32_t" => "integer",
|
33
|
+
"int16_t" => "integer",
|
34
|
+
"int32_t" => "integer",
|
35
|
+
"int64_t" => "integer"
|
36
|
+
}
|
20
37
|
end
|
21
38
|
|
22
39
|
end
|
data/lib/apiotics/portal.rb
CHANGED
@@ -140,6 +140,7 @@ module Apiotics
|
|
140
140
|
|
141
141
|
def self.sync_device_instances(worker_name, sync_data)
|
142
142
|
instance_hash = JSON.parse(HTTParty.post("#{Apiotics.configuration.portal}api/workers", :query => {:public_key => Apiotics.configuration.public_key, :private_key => Apiotics.configuration.private_key}).body)
|
143
|
+
configuration = Portal.retrieve_configuration
|
143
144
|
klass = (worker_name.to_s + "::" + worker_name.to_s).constantize rescue nil
|
144
145
|
unless klass == nil
|
145
146
|
instance_ids = Hash.new
|
@@ -165,6 +166,29 @@ module Apiotics
|
|
165
166
|
s = subklass.new
|
166
167
|
k = worker_name.underscore.gsub(" ","_").to_s + "_id="
|
167
168
|
s.send((k).to_sym, i.id)
|
169
|
+
configuration["workers"][worker_name]["drivers"][key]["interfaces"].each do |interface_name,interface_spec|
|
170
|
+
if interface_spec["default_value"] == ""
|
171
|
+
value = nil
|
172
|
+
else
|
173
|
+
value = interface_spec["default_value"]
|
174
|
+
end
|
175
|
+
if Apiotics.configuration.interface_kinds[interface_spec["type"]] == "integer"
|
176
|
+
value = value.to_i
|
177
|
+
elsif Apiotics.configuration.interface_kinds[interface_spec["type"]] == "float"
|
178
|
+
value = value.to_f
|
179
|
+
elsif Apiotics.configuration.interface_kinds[interface_spec["type"]] == "boolean"
|
180
|
+
if value == "nil"
|
181
|
+
value = nil
|
182
|
+
elsif value == "true"
|
183
|
+
value = true
|
184
|
+
elsif value == "false"
|
185
|
+
value = false
|
186
|
+
end
|
187
|
+
elsif Apiotics.configuration.interface_kinds[interface_spec["type"]] == "json"
|
188
|
+
value = value.to_json
|
189
|
+
end
|
190
|
+
s.send(interface_name + "=", value)
|
191
|
+
end
|
168
192
|
s.skip_extract = true
|
169
193
|
if sync_data == true
|
170
194
|
s.sync
|
data/lib/apiotics/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apiotics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.71
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MicroArx Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|