cloudwalk 0.0.2 → 0.1.0
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/exe/i386-apple-darwin14 +0 -0
- data/exe/i686-pc-linux-gnu +0 -0
- data/exe/i686-w64-mingw32.exe +0 -0
- data/exe/x86_64-apple-darwin14 +0 -0
- data/exe/x86_64-pc-linux-gnu +0 -0
- data/exe/x86_64-w64-mingw32.exe +0 -0
- data/lib/cloudwalk.rb +2 -0
- data/lib/cloudwalk/cw_file_json.rb +15 -16
- data/lib/cloudwalk/posxml_application.rb +3 -3
- data/lib/cloudwalk/posxml_version.rb +8 -7
- data/lib/cloudwalk/rake_task.rb +24 -9
- 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: a76eb0a4e3788de1be11141163b5f42589b64565
|
4
|
+
data.tar.gz: 492470763d237efd68559c1ffb025269d51ccba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ae5747d259dea477e657ece603a9de7be247e034aadb2caeca36246e306e86425c691b82c08d57ae1405436f43aa0355c0c4c4e1aac4e2dc597c35852a4bf2f
|
7
|
+
data.tar.gz: da09203da62f05e97b224b0c9cf7663125bffad6a31b5cf52ff6332403d6d4d6f2e22c34e080a2ae7cf8a0dbc2667dcda0fa8ea619b9f0ca0c78e248895e30b3
|
data/exe/i386-apple-darwin14
CHANGED
Binary file
|
data/exe/i686-pc-linux-gnu
CHANGED
Binary file
|
data/exe/i686-w64-mingw32.exe
CHANGED
Binary file
|
data/exe/x86_64-apple-darwin14
CHANGED
Binary file
|
data/exe/x86_64-pc-linux-gnu
CHANGED
Binary file
|
data/exe/x86_64-w64-mingw32.exe
CHANGED
Binary file
|
data/lib/cloudwalk.rb
CHANGED
@@ -3,6 +3,8 @@ require "net/http"
|
|
3
3
|
require "json"
|
4
4
|
require "fileutils"
|
5
5
|
|
6
|
+
require_relative "cloudwalk/config"
|
7
|
+
require_relative "cloudwalk/cw_file_json"
|
6
8
|
require_relative "cloudwalk/posxml_application"
|
7
9
|
require_relative "cloudwalk/posxml_version"
|
8
10
|
require_relative "cloudwalk/rake_task"
|
@@ -24,7 +24,9 @@ module Cloudwalk
|
|
24
24
|
CW_FILE_LOCK_PATH = "./Cwfile.json.lock"
|
25
25
|
CW_FILE_PATH = "./Cwfile.json"
|
26
26
|
|
27
|
-
|
27
|
+
class << self
|
28
|
+
attr_accessor :cwfile, :lock
|
29
|
+
end
|
28
30
|
|
29
31
|
def self.load_cwfile_lock
|
30
32
|
JSON.parse(File.read(CW_FILE_LOCK_PATH))
|
@@ -52,7 +54,7 @@ module Cloudwalk
|
|
52
54
|
# - json and lock are the same
|
53
55
|
# R: Just execute :)
|
54
56
|
#
|
55
|
-
# 2.
|
57
|
+
# 2.
|
56
58
|
# - Cwfile.json exists.
|
57
59
|
# - Cwfile.json.lock exists.
|
58
60
|
# - json and lock aren't the same
|
@@ -67,14 +69,14 @@ module Cloudwalk
|
|
67
69
|
# Scenarios:
|
68
70
|
# - The user could create a version on manager and just updated Cwfile.json, instead of delete Cwfile.json.lock
|
69
71
|
# - Maybe create an update action, rake cloudwalk:update
|
70
|
-
# - The user
|
72
|
+
# - The user
|
71
73
|
#
|
72
|
-
# 3.
|
74
|
+
# 3.
|
73
75
|
# - Cwfile.json exists.
|
74
76
|
# - Cwfile.json.lock not exists.
|
75
77
|
# R: Create Cwfile.json.lock
|
76
78
|
#
|
77
|
-
# 4.
|
79
|
+
# 4.
|
78
80
|
# - Cwfile.json not exists.
|
79
81
|
# - Cwfile.json.lock not exists.
|
80
82
|
# R: ASK: Cwfile.json not exists, should I create a skeleton or get the last versions available for the files we have here?
|
@@ -111,13 +113,13 @@ module Cloudwalk
|
|
111
113
|
all = Cloudwalk::PosxmlApplication.all
|
112
114
|
config = []
|
113
115
|
self.cwfile["apps"].each do |app_local|
|
114
|
-
app_remote = all.find { |app_json| app_json["posxml_app"]["name"] == xml2posxml(
|
116
|
+
app_remote = all.find { |app_json| app_json["posxml_app"]["name"] == xml2posxml(app_local["name"]) }
|
115
117
|
app_posxml = app_remote["posxml_app"]
|
116
118
|
versions = Cloudwalk::PosxmlVersion.all(app_posxml["id"])
|
117
|
-
version = versions.find { |json| json["app_version"]["number"] == version }
|
119
|
+
version = versions.find { |json| json["app_version"]["number"] == app_local["version"] }
|
118
120
|
|
119
121
|
if version && version = version["app_version"]
|
120
|
-
version_detail =
|
122
|
+
version_detail = Cloudwalk::PosxmlVersion.get(app_posxml["id"], version["id"])
|
121
123
|
config << build_application(app_posxml, version, version_detail["app_version"]["module_ids"])
|
122
124
|
else
|
123
125
|
# TODO Version not found, what to do?
|
@@ -127,10 +129,10 @@ module Cloudwalk
|
|
127
129
|
end
|
128
130
|
|
129
131
|
def self.build_module(mod)
|
130
|
-
response =
|
132
|
+
response = Cloudwalk::PosxmlVersion.get(mod["app_id"], mod["version_id"])
|
131
133
|
module_version = response["app_version"]
|
132
134
|
{
|
133
|
-
"name" => PosxmlApplication
|
135
|
+
"name" => Cloudwalk::PosxmlApplication.get_name(module_version["app_id"]),
|
134
136
|
"version" => module_version["number"],
|
135
137
|
"id" => module_version["app_id"],
|
136
138
|
"version_id" => module_version["id"]
|
@@ -159,10 +161,7 @@ module Cloudwalk
|
|
159
161
|
# TODO Check CRC
|
160
162
|
def self.deploy(outs)
|
161
163
|
outs.each do |path|
|
162
|
-
|
163
|
-
posxml = path.split("/").last
|
164
|
-
#app = posxml2xml(posxml)
|
165
|
-
|
164
|
+
posxml = path.split("/").last
|
166
165
|
app_lock = self.lock.find {|config| config["name"] == posxml }
|
167
166
|
|
168
167
|
unless app_lock
|
@@ -197,7 +196,7 @@ module Cloudwalk
|
|
197
196
|
# TODO future!
|
198
197
|
|
199
198
|
def self.compare
|
200
|
-
cwfile_list = self.cwfile.inject({}) do |hash, app|
|
199
|
+
cwfile_list = self.cwfile["apps"].inject({}) do |hash, app|
|
201
200
|
hash[app["name"]] = app["modules"].inject({}) do |hash_m, app_module|
|
202
201
|
hash_m[app_module[0]] = app_module[1]
|
203
202
|
hash_m
|
@@ -253,7 +252,7 @@ module Cloudwalk
|
|
253
252
|
remote_version_json = remote_versions.find { |json| json["app_version"]["number"] == version }
|
254
253
|
|
255
254
|
if remote_version_json && (remote_version = remote_version_json["app_version"])
|
256
|
-
remote_version_detail =
|
255
|
+
remote_version_detail = Cloudwalk::PosxmlVersion.get(remote_posxml_app["id"], remote_version["id"])
|
257
256
|
# TODO: Check if application exists locally
|
258
257
|
build_application(local_app, config, remote_posxml_app, remote_version, remote_version_detail["app_version"]["module_ids"])
|
259
258
|
else
|
@@ -12,13 +12,13 @@ module Cloudwalk
|
|
12
12
|
if @apps
|
13
13
|
@apps
|
14
14
|
else
|
15
|
-
response = JSON.parse(Net::HTTP.get(URI("
|
15
|
+
response = JSON.parse(Net::HTTP.get(URI("#{self.host}/v1/apps/posxml?access_token=#{self.token}&per_page=100")))
|
16
16
|
raise ManagerException.new(response["message"]) if response["message"]
|
17
17
|
|
18
18
|
total_pages = response["pagination"]["total_pages"].to_i
|
19
19
|
apps = response["posxmlapps"]
|
20
20
|
(total_pages - 1).times do |page|
|
21
|
-
url = "
|
21
|
+
url = "#{self.host}/v1/apps/posxml?access_token=#{self.token}&per_page=100&page=#{page+2}"
|
22
22
|
response = JSON.parse(Net::HTTP.get(URI(url)))
|
23
23
|
raise ManagerException.new(response["message"]) if response["message"]
|
24
24
|
|
@@ -29,7 +29,7 @@ module Cloudwalk
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.get(id)
|
32
|
-
url = "
|
32
|
+
url = "#{self.host}/v1/apps/posxml/#{id}?access_token=#{self.token}"
|
33
33
|
response = JSON.parse(Net::HTTP.get(URI(url)))
|
34
34
|
raise ManagerException.new(response["message"]) if response["message"]
|
35
35
|
|
@@ -9,7 +9,7 @@ module Cloudwalk
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.get_or_create(app, version)
|
12
|
-
response = JSON.parse(Net::HTTP.get(URI("
|
12
|
+
response = JSON.parse(Net::HTTP.get(URI("#{self.host}/v1/apps/posxml/#{app_id}/versions?access_token=#{self.token}&per_page=100")))
|
13
13
|
raise ManagerException.new(response["message"]) if response["message"]
|
14
14
|
|
15
15
|
#TODO
|
@@ -17,14 +17,14 @@ module Cloudwalk
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.all(app_id)
|
20
|
-
response = JSON.parse(Net::HTTP.get(URI("
|
20
|
+
response = JSON.parse(Net::HTTP.get(URI("#{self.host}/v1/apps/posxml/#{app_id}/versions?access_token=#{self.token}&per_page=100")))
|
21
21
|
raise ManagerException.new(response["message"]) if response["message"]
|
22
22
|
|
23
23
|
total_pages = response["pagination"]["total_pages"].to_i
|
24
24
|
versions = response["appversions"]
|
25
25
|
|
26
26
|
(total_pages - 1).times do |page|
|
27
|
-
url = "
|
27
|
+
url = "#{self.host}/v1/apps/posxml/#{app_id}/versions?access_token=#{self.token}&per_page=100&page=#{page+2}"
|
28
28
|
response = JSON.parse(Net::HTTP.get(URI(url)))
|
29
29
|
raise ManagerException.new(response["message"]) if response["message"]
|
30
30
|
|
@@ -34,7 +34,7 @@ module Cloudwalk
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.get(app_id, id)
|
37
|
-
url = "
|
37
|
+
url = "#{self.host}/v1/apps/posxml/#{app_id}/versions/#{id}?access_token=#{token}"
|
38
38
|
response = JSON.parse(Net::HTTP.get(URI(url)))
|
39
39
|
raise ManagerException.new(response["message"]) if response["message"]
|
40
40
|
|
@@ -44,13 +44,14 @@ module Cloudwalk
|
|
44
44
|
def self.update(app_id, version_id, bytecode)
|
45
45
|
url = "#{self.host}/v1/apps/posxml/#{app_id}/versions/#{version_id}?access_token=#{self.token}"
|
46
46
|
uri = URI(url)
|
47
|
-
|
47
|
+
response = nil
|
48
48
|
|
49
49
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
|
50
50
|
request = Net::HTTP::Put.new(uri)
|
51
|
-
|
51
|
+
request.set_form_data({"bytecode" => Base64.strict_encode64(bytecode)})
|
52
|
+
response = http.request(request)
|
52
53
|
end
|
53
|
-
|
54
|
+
response.code == 200
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
data/lib/cloudwalk/rake_task.rb
CHANGED
@@ -15,7 +15,7 @@ module Cloudwalk
|
|
15
15
|
class RakeTask < ::Rake::TaskLib
|
16
16
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
17
17
|
|
18
|
-
attr_accessor :libs, :root_path, :main_out, :out_path
|
18
|
+
attr_accessor :libs, :root_path, :main_out, :out_path, :outs
|
19
19
|
|
20
20
|
def initialize
|
21
21
|
yield self if block_given?
|
@@ -39,20 +39,35 @@ module Cloudwalk
|
|
39
39
|
def define
|
40
40
|
namespace :cloudwalk do
|
41
41
|
desc "Compile posxml"
|
42
|
-
task :build do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
posxml = CwFileJson.xml2posxml(out)
|
47
|
-
|
48
|
-
|
42
|
+
task :build do |t, args|
|
43
|
+
if path = ARGV[1..-1].first
|
44
|
+
xml, out = self.libs.zip(self.outs).find { |file, out| file == path }
|
45
|
+
|
46
|
+
posxml = Cloudwalk::CwFileJson.xml2posxml(out)
|
47
|
+
platform_call "cloudwalk compile -xml -o #{posxml} #{xml}"
|
48
|
+
else
|
49
|
+
FileUtils.rm_rf self.out_path
|
50
|
+
FileUtils.mkdir_p self.out_path
|
51
|
+
|
52
|
+
self.libs.zip(self.outs).each do |file, out|
|
53
|
+
posxml = Cloudwalk::CwFileJson.xml2posxml(out)
|
54
|
+
platform_call "cloudwalk compile -xml -o #{posxml} #{file}"
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
52
59
|
desc "Deploy all compiled applications based in Cwfile.json"
|
53
60
|
task :deploy => :build do
|
54
61
|
if Cloudwalk::CwFileJson.setup
|
55
|
-
|
62
|
+
if path = ARGV[1..-1].first
|
63
|
+
xml, out = self.libs.zip(self.outs).find { |file, out| file == path }
|
64
|
+
Cloudwalk::CwFileJson.deploy([Cloudwalk::CwFileJson.xml2posxml(out)])
|
65
|
+
else
|
66
|
+
posxmls = self.outs.collect do |xml|
|
67
|
+
Cloudwalk::CwFileJson.xml2posxml(out)
|
68
|
+
end
|
69
|
+
Cloudwalk::CwFileJson.deploy(posxmls)
|
70
|
+
end
|
56
71
|
end
|
57
72
|
end
|
58
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudwalk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Scalone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|