eigen.vision 0.5.0 → 0.6.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/lib/ev/cli.rb +81 -12
- data/lib/ev.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c33e73e01384088bcb9253995d4ceba69aa05afb6c33dadf243917a3548f09a
|
|
4
|
+
data.tar.gz: ca95cb89b402f1de06e288f9d16dc133637a9094bed4eaac025946060787cac7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67909e745f5630e6d388c950f5620f35b682c5afa4a1b5020a1b2351d4a156f02c585dffb63f31c6764bb1a70bf3f9cce2bdd7136530a82ac9487e874f134b3e
|
|
7
|
+
data.tar.gz: a3b48c2d27d417cf20c6f7a41eb51a586ca17c47094f74e28a39e9248ee501f37bc4d1d955b89bc3e83c436585820e61f225c34b53c9f7570e477e586cb3886a
|
data/lib/ev/cli.rb
CHANGED
|
@@ -18,33 +18,94 @@ module EV
|
|
|
18
18
|
def run
|
|
19
19
|
case @args[0]
|
|
20
20
|
when "push" then push
|
|
21
|
+
when "create" then create
|
|
22
|
+
when "projects" then projects
|
|
21
23
|
when "login" then login
|
|
22
24
|
when "logout" then logout
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def push
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
name = @args[1]
|
|
30
|
+
rest = @args[2..]
|
|
31
|
+
if rest.last&.start_with?("http")
|
|
32
|
+
url = rest.pop
|
|
33
|
+
else
|
|
34
|
+
url = "http://localhost:8080"
|
|
35
|
+
end
|
|
36
|
+
files = {}
|
|
37
|
+
rest.each do |f|
|
|
38
|
+
files[File.basename(f)] =
|
|
39
|
+
File.read(f)
|
|
40
|
+
end
|
|
41
|
+
uri = URI("#{url}/projects/push")
|
|
30
42
|
req = Net::HTTP::Post.new(uri)
|
|
31
43
|
req["Accept"] = "application/json"
|
|
32
|
-
req.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
req.content_type =
|
|
45
|
+
"application/json"
|
|
46
|
+
req.body = JSON.generate(
|
|
47
|
+
"project" => name,
|
|
48
|
+
"files" => files
|
|
49
|
+
)
|
|
50
|
+
add_auth(req, url)
|
|
51
|
+
res = request(uri, req)
|
|
52
|
+
return unless res
|
|
53
|
+
data = JSON.parse(res.body)
|
|
54
|
+
if res.code != "200"
|
|
55
|
+
@output =
|
|
56
|
+
"error: #{data["error"]}\n"
|
|
57
|
+
return
|
|
37
58
|
end
|
|
59
|
+
@output = "#{data["project"]}" \
|
|
60
|
+
" version #{data["version"]}\n"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def create
|
|
64
|
+
name = @args[1]
|
|
65
|
+
url = @args[2] ||
|
|
66
|
+
"http://localhost:8080"
|
|
67
|
+
uri = URI("#{url}/projects")
|
|
68
|
+
req = Net::HTTP::Post.new(uri)
|
|
69
|
+
req["Accept"] = "application/json"
|
|
70
|
+
req.content_type =
|
|
71
|
+
"application/json"
|
|
72
|
+
req.body = JSON.generate(
|
|
73
|
+
"name" => name
|
|
74
|
+
)
|
|
75
|
+
add_auth(req, url)
|
|
38
76
|
res = request(uri, req)
|
|
39
77
|
return unless res
|
|
40
78
|
data = JSON.parse(res.body)
|
|
41
79
|
if res.code != "200"
|
|
42
|
-
@output =
|
|
80
|
+
@output =
|
|
81
|
+
"error: #{data["error"]}\n"
|
|
43
82
|
return
|
|
44
83
|
end
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
84
|
+
@output =
|
|
85
|
+
"project created: #{data["name"]}\n"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def projects
|
|
89
|
+
url = @args[1] ||
|
|
90
|
+
"http://localhost:8080"
|
|
91
|
+
uri = URI("#{url}/projects")
|
|
92
|
+
req = Net::HTTP::Get.new(uri)
|
|
93
|
+
req["Accept"] = "application/json"
|
|
94
|
+
add_auth(req, url)
|
|
95
|
+
res = request(uri, req)
|
|
96
|
+
return unless res
|
|
97
|
+
data = JSON.parse(res.body)
|
|
98
|
+
if res.code != "200"
|
|
99
|
+
@output =
|
|
100
|
+
"error: #{data["error"]}\n"
|
|
101
|
+
return
|
|
102
|
+
end
|
|
103
|
+
if data.empty?
|
|
104
|
+
@output = "no projects\n"
|
|
105
|
+
return
|
|
106
|
+
end
|
|
107
|
+
data.each do |p|
|
|
108
|
+
@output += "#{p["name"]}\n"
|
|
48
109
|
end
|
|
49
110
|
end
|
|
50
111
|
|
|
@@ -84,6 +145,14 @@ module EV
|
|
|
84
145
|
@output = "logged out\n"
|
|
85
146
|
end
|
|
86
147
|
|
|
148
|
+
def add_auth(req, url)
|
|
149
|
+
creds = load_credentials
|
|
150
|
+
if creds && creds[:url] == url
|
|
151
|
+
req["Cookie"] =
|
|
152
|
+
"session=#{creds[:token]}"
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
87
156
|
def request(uri, req)
|
|
88
157
|
Net::HTTP.start(
|
|
89
158
|
uri.hostname, uri.port
|
data/lib/ev.rb
CHANGED