apiotics 0.1.48 → 0.1.50
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 +4 -4
- data/lib/apiotics/configuration.rb +3 -2
- data/lib/apiotics/extract.rb +20 -0
- data/lib/apiotics/hardware.rb +1 -1
- data/lib/apiotics/portal.rb +41 -0
- data/lib/apiotics/version.rb +1 -1
- data/lib/generators/apiotics/create_table/create_table_generator.rb +10 -0
- data/lib/generators/apiotics/create_table/templates/create_logs_table.rb.erb +1 -1
- data/lib/generators/apiotics/create_table/templates/create_table.rb.erb +1 -1
- data/lib/generators/apiotics/initializer/initializer_generator.rb +2 -0
- data/lib/generators/apiotics/initializer/templates/apiotics_parents.rb.erb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 006c5f0304bd785db021131aebef23b266e742eb
|
4
|
+
data.tar.gz: d045f6082b865340d3e216cecaaa4f1a50c2841f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a3bbb4961e0805e1e7a164f2653527856ae252e7635e218eeeb59e5fc5b9e0023e29d9f72eb50110c33efd5566102637aef76167a167a1f2fc20a78aac32566
|
7
|
+
data.tar.gz: a40597c023ad2be4b442618e5a1c1c29d91002f2da067cda00c2f104e58347cad8b5b7eaed092de0abdbdea82ea1e6154234a3ba735ac1a382f5466c50981c16
|
@@ -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
|
4
|
+
attr_accessor :public_key, :private_key, :local_logging, :targets, :local_port, :server, :server_port, :portal, :push, :tls, :verify_peer, :handshake, :parents
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@public_key = nil
|
@@ -11,11 +11,12 @@ module Apiotics
|
|
11
11
|
@local_port = 8001
|
12
12
|
@server = "rgs.microarx.com"
|
13
13
|
@server_port = 8000
|
14
|
-
@portal = "https://
|
14
|
+
@portal = "https://test.apiotics.com/"
|
15
15
|
@push = false
|
16
16
|
@tls = true
|
17
17
|
@verify_peer = true
|
18
18
|
@handshake = true
|
19
|
+
@parents = {}
|
19
20
|
end
|
20
21
|
|
21
22
|
end
|
data/lib/apiotics/extract.rb
CHANGED
@@ -14,6 +14,26 @@ module Apiotics
|
|
14
14
|
end
|
15
15
|
if interfaces != {}
|
16
16
|
Extract.fire(object, interfaces, "set-request")
|
17
|
+
if Apiotics.configuration.parents != {}
|
18
|
+
interfaces.each do |k,v|
|
19
|
+
if Apiotics.configuration.parents[object.class.parent.demodulize][object.class.demodulize][k] != nil
|
20
|
+
m = "#{object.class.parent}".demodulize.underscore.gsub(" ","_").downcase
|
21
|
+
target_class = Apiotics.configuration.parents[object.class.parent.demodulize][object.class.demodulize][k]["driver"].downcase.constantize
|
22
|
+
target = object.m.target_class
|
23
|
+
i = Apiotics.configuration.parents[object.class.parent.demodulize][object.class.demodulize][k]["interface"].downcase.constantize
|
24
|
+
if Apiotics.configuration.parents[object.class.parent.demodulize][object.class.demodulize][k].keys < 3
|
25
|
+
target.i = v
|
26
|
+
target.skip_extract = true
|
27
|
+
target.save
|
28
|
+
target.skip_extract = false
|
29
|
+
else
|
30
|
+
target.i = Apiotics.configuration.parents[object.class.parent.demodulize][object.class.demodulize][k][v]
|
31
|
+
target.skip_extract = true
|
32
|
+
target.save
|
33
|
+
target.skip_extract = false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
17
37
|
end
|
18
38
|
end
|
19
39
|
|
data/lib/apiotics/hardware.rb
CHANGED
@@ -70,7 +70,7 @@ module Apiotics
|
|
70
70
|
config = Apiotics::Portal.openocd_worker_config(worker_name)
|
71
71
|
config = JSON.parse(config)
|
72
72
|
unless config["openocd_config_file_name"] == nil || config["openocd_config_file_name"] == ""
|
73
|
-
path = Rails.root.join('lib', 'openocd', 'downloads', config["
|
73
|
+
path = Rails.root.join('lib', 'openocd', 'downloads', config["openocd_config_file_name"])
|
74
74
|
if File.exist?(path)
|
75
75
|
else
|
76
76
|
firmware_data = Apiotics::Portal.download_firmware(worker_name)
|
data/lib/apiotics/portal.rb
CHANGED
@@ -86,6 +86,47 @@ module Apiotics
|
|
86
86
|
end
|
87
87
|
hash
|
88
88
|
end
|
89
|
+
|
90
|
+
def self.parse_parents
|
91
|
+
configuration = Portal.retrieve_configuration
|
92
|
+
hash = Hash.new
|
93
|
+
configuration["workers"].each do |key, value|
|
94
|
+
if hash[key] == nil
|
95
|
+
hash[key] = Hash.new
|
96
|
+
end
|
97
|
+
value["drivers"].each do |k, v|
|
98
|
+
if hash[key][k] == nil
|
99
|
+
hash[key][k] = Hash.new
|
100
|
+
end
|
101
|
+
if v["parents"] != {}
|
102
|
+
v["parents"].each do |parent_driver, parent_hash|
|
103
|
+
parent_hash.each do |parent_interface, parent_value|
|
104
|
+
if parent_value.is_a? Hash
|
105
|
+
hash[key][k][parent_value["interface"]] = Hash.new
|
106
|
+
hash[key][k][parent_value["interface"]]["interface"] = parent_interface
|
107
|
+
hash[key][k][parent_value["interface"]]["driver"] = parent_driver
|
108
|
+
if hash[key][parent_driver] == nil
|
109
|
+
hash[key][parent_driver] = Hash.new
|
110
|
+
hash[key][parent_driver][parent_interface] = Hash.new
|
111
|
+
end
|
112
|
+
hash[key][parent_driver][parent_interface]["interface"] = parent_value["interface"]
|
113
|
+
hash[key][parent_driver][parent_interface]["driver"] = k
|
114
|
+
if parent_value.keys.count > 2
|
115
|
+
parent_value.each do |pv_key, pv_value|
|
116
|
+
unless pv_key == "interface"
|
117
|
+
hash[key][parent_driver][parent_interface][pv_key] = pv_value
|
118
|
+
hash[key][k][parent_value["interface"]][pv_value] = pv_key
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
hash
|
129
|
+
end
|
89
130
|
|
90
131
|
def self.sync_device_instances(worker_name, sync_data)
|
91
132
|
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)
|
data/lib/apiotics/version.rb
CHANGED
@@ -6,6 +6,16 @@ module Apiotics
|
|
6
6
|
argument :attributes, :type => :hash, :required => false
|
7
7
|
|
8
8
|
def copy_create_table_files
|
9
|
+
@attribute_map = {
|
10
|
+
"smallint" => {"kind" => "integer", "limit" => 2},
|
11
|
+
"bigint" => {"kind" => "integer", "limit" => 8},
|
12
|
+
"uint8_t" => {"kind" => "integer", "limit" => 2},
|
13
|
+
"uint16_t" => {"kind" => "integer", "limit" => 4},
|
14
|
+
"uint32_t" => {"kind" => "integer", "limit" => 8},
|
15
|
+
"int16_t" => {"kind" => "integer", "limit" => 2},
|
16
|
+
"int32_t" => {"kind" => "integer", "limit" => 4},
|
17
|
+
"int_64t" => {"kind" => "integer", "limit" => 8}
|
18
|
+
}
|
9
19
|
template "create_table.rb.erb", "db/migrate/#{date_string}_create_#{plural_name}.rb"
|
10
20
|
unless Apiotics.configuration.local_logging == false
|
11
21
|
sleep 1
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Create<%= logs_class_name(@k) %> < ActiveRecord::Migration[5.1]
|
2
2
|
def change
|
3
3
|
create_table :<%= logs_table_name(@k) %> do |t|
|
4
|
-
t.<%= @v %> :<%= @k %>
|
4
|
+
<% if @attribute_map[@v] != nil %>t.<%= @attribute_map[@v]["kind"] %> :<%= @k %>, limit: <%= @attribute_map[@v]["limit"] %><% else %>t.<%= @v %> :<%= @k %><% end %>
|
5
5
|
t.boolean :<%= @k %>_ack
|
6
6
|
t.boolean :<%= @k %>_complete
|
7
7
|
t.string :<%= @k %>_timestamp
|
@@ -2,7 +2,7 @@ class Create<%= plural_class_name %> < ActiveRecord::Migration[5.1]
|
|
2
2
|
def change
|
3
3
|
create_table :<%= plural_name %> do |t|
|
4
4
|
<% attributes.each do |k,v| %>
|
5
|
-
t.<%= v %> :<%= k %>
|
5
|
+
<% if @attribute_map[v] != nil %>t.<%= @attribute_map[v]["kind"] %> :<%= k %>, limit: <%= @attribute_map[v]["limit"] %><% else %>t.<%= v %> :<%= k %><% end %>
|
6
6
|
t.boolean :<%= k %>_ack
|
7
7
|
t.boolean :<%= k %>_complete
|
8
8
|
t.string :<%= k %>_timestamp
|
@@ -7,6 +7,8 @@ module Apiotics
|
|
7
7
|
if portal == "true"
|
8
8
|
@c = Apiotics::Portal.parse_all_interfaces
|
9
9
|
template "apiotics_targets.rb.erb", "config/initializers/apiotics_targets.rb"
|
10
|
+
@p = Apiotics::Portal.parse_parents
|
11
|
+
template "apiotics_parents.rb.erb", "config/initializers/apiotics_parents.rb"
|
10
12
|
else
|
11
13
|
template "apiotics.rb.erb", "config/initializers/apiotics.rb"
|
12
14
|
template "apiotics_settings.rb.erb", "db/migrate/#{date_string}_create_apiotics_settings.rb"
|
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.50
|
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
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/generators/apiotics/initializer/initializer_generator.rb
|
194
194
|
- lib/generators/apiotics/initializer/templates/apiotics.rb.erb
|
195
195
|
- lib/generators/apiotics/initializer/templates/apiotics_module.rb.erb
|
196
|
+
- lib/generators/apiotics/initializer/templates/apiotics_parents.rb.erb
|
196
197
|
- lib/generators/apiotics/initializer/templates/apiotics_settings.rb.erb
|
197
198
|
- lib/generators/apiotics/initializer/templates/apiotics_targets.rb.erb
|
198
199
|
- lib/generators/apiotics/initializer/templates/setting.rb.erb
|