zygote 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb685c710d11948c01a676b3a5e2fe7df5e78e98
4
- data.tar.gz: 54915838f5aa83edb7088efa978d2aca242a4c7f
3
+ metadata.gz: 3bd75d436fea9a8f78488c577965a3582cb9a08a
4
+ data.tar.gz: bd6f75e7c83ed3691f0dc8940209b34e1ad0c227
5
5
  SHA512:
6
- metadata.gz: 2976cb02ebe35a13e52b144c17873de7329be5e71ed1ec17ccde57dd52a9e7284250e7af07a72542ee1265ab4de3b3bf94377ec2540c8c3e67a174fe95052af9
7
- data.tar.gz: 9f254761b01073a42268dbe7d84646fe9dffe1d17a3152569f441e56e7c509b1363d03af7e03ee2e1a919ddc34d985596176bbe6cee611b32eec6f497c3560a5
6
+ metadata.gz: 69818393b6a753bf0a4e179332242aa81c6c49576ea5ff5a58e65f775170c6ef0b0b54860335d0f01e2a5c1c01c101a06dde0eceb2143337d74c6213acaa1608
7
+ data.tar.gz: 4523d4cc2876570e98f1adf3dbb2af410c790bedf885ee515fb32829e85ac9f68bbc0a2d43e3d019de665f39531245061bbfc3cfe0ecc28b08a76cbfa275c018
data/lib/zygote/http.rb CHANGED
@@ -73,18 +73,6 @@ class ZygoteWeb < Sinatra::Base
73
73
  body { JSON.pretty_generate(CellQueue.show(params['sku'])) }
74
74
  end
75
75
 
76
- apost %r{/queue/bulk$} do
77
- bulk_queue = JSON.parse(request.body.read)
78
- bulk_queue.each do |asset, queue|
79
- queue = [queue] unless queue.is_a?(Array)
80
- queue.each do |action|
81
- CellQueue.push(asset, action)
82
- end
83
- end
84
-
85
- 200
86
- end
87
-
88
76
  # Enable push cells (with optional data) to the cell queue for a SKU
89
77
  apost %r{/queue/(?<sku>\S*)/(?<selected_cell>\S*)$} do
90
78
  # Clean params into a simple hash
data/lib/zygote/test.rb CHANGED
@@ -70,7 +70,7 @@ module Zygote
70
70
 
71
71
  # Returns EventMachine::HttpClient
72
72
  def post(uri, params = {})
73
- EM::Synchrony.sync(EventMachine::HttpRequest.new("http://127.0.0.1:#{TestConfig.port}/#{uri}").apost(body: params))
73
+ EM::Synchrony.sync(EventMachine::HttpRequest.new("http://127.0.0.1:#{TestConfig.port}/#{uri}").apost(body: JSON.dump(params), head: {'Content-Type' => 'application/json'}))
74
74
  end
75
75
 
76
76
  def parameterize(params)
data/lib/zygote/util.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'socket'
2
+ require 'base64'
3
+ require 'json'
2
4
 
3
5
  def compute_sku(vendor, serial, board_serial)
4
6
  # Sanitize params
@@ -24,9 +26,14 @@ end
24
26
 
25
27
  def clean_params(params)
26
28
  params.delete_if { |x, _| x == 'splat' || x == 'captures' }
29
+ params = params.map { |k,v| [k, v.is_a?(Hash) ? encode64(v) : v] }.to_h
27
30
  params
28
31
  end
29
32
 
33
+ def encode64(content)
34
+ Base64.encode64(JSON.pretty_generate(content)).gsub(/\n|=/, '')
35
+ end
36
+
30
37
  def my_ip
31
38
  Socket.ip_address_list.find { |x| x.ipv4? && !x.ipv4_loopback? }.ip_address
32
39
  end
@@ -1,4 +1,4 @@
1
1
  # Namespace for our gem
2
2
  module Zygote
3
- VERSION = '0.2.4'.freeze
3
+ VERSION = '0.2.5'.freeze
4
4
  end
data/views/menu.erb CHANGED
@@ -75,7 +75,7 @@ goto ${selected}
75
75
  # Generate chains for each submenu entry
76
76
  <% data['menu']['submenu'].each do |entry, data| %>
77
77
  <% local_params = (data['params'] || {}).merge(params) %>
78
- <% parmstr = {entry: entry}.merge(local_params).map{ |k,v| "#{k}=#{v.is_a?(String) ? v : Base64.encode64(JSON.dump(v)).gsub(/\n|=/, '')}"}.join('&').gsub('?','').gsub(' ','') %>
78
+ <% parmstr = {entry: entry}.merge(local_params).to_query %>
79
79
  :<%= cell %>-<%= entry %>
80
80
  chain --replace --autofree http://${dhcp-server}/cell/<%= cell %>/<%= data['action'] || 'boot' %><%= parmstr.empty? ? "" : "?#{parmstr}" %>
81
81
  <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zygote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Hamel