scirocco 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8204a2f0b87b4c5088b53ea216c722c61124c17
4
- data.tar.gz: 9bb49975ea027dfd85ec72da29b21f1671ae5570
3
+ metadata.gz: f9cc98e4a3aeb938c3d8452b8bac3c4f89a22446
4
+ data.tar.gz: abae65d087d094393a21d710abf5f8e724c301bc
5
5
  SHA512:
6
- metadata.gz: ed3510543b6ab286c9132106593df31f8a2229ca9cd06c0f5f48dfb429d5472a6a80398765c34b908c130995b46e963c618e167c215619ed9b70ff132c79a041
7
- data.tar.gz: bc32506071220d86eb498dcf5f65b7d7b1268102f044b40ecc550b698c844539eb30cdb32ff17001c717e471df227c1566e53e5fc2cc64f80f7938151112b091
6
+ metadata.gz: 0a799920fd15a9be2dc2353fb463f763850850fe2f1f4efd343805f22f3543e93492edfd686999d1b7af820ac6661d3e6a533306fc4907efe9e902c235568a44
7
+ data.tar.gz: 4b788bd345aae6d6c8be85b13f4e182038ad610caf8ee274710a7b530c290d3b2d34e140c001f4737bdf056c7feeb7a1ca76cbcef505298f1366dafde0b37f5c
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # SciroccoCloud Client
2
2
 
3
- The official Ruby client for the SciroccoCloud API.
3
+ The official Ruby client for the [SciroccoCloud](http://www.scirocco-cloud.com/) API.
4
+
5
+ ## Document
6
+
7
+ [Scirocco Cloud API Docs](https://www.scirocco-cloud.com/swagger)
4
8
 
5
9
  ## Installation
6
10
 
data/lib/scirocco/cli.rb CHANGED
@@ -24,7 +24,7 @@ module Scirocco
24
24
  desc "run_test <TEST_CLASS_ID> <DEVICE_ID>", "Runs the test on the device"
25
25
  def run_test(test_class_id, device_id)
26
26
  client = Scirocco::Client.new(options[:api_key], options)
27
- test_job = client.run_test(test_class_id, device_id)
27
+ test_job = client.run_test(test_class_id, device_id)["test_job"]
28
28
  puts "* test_job:"
29
29
  pp test_job
30
30
  if options[:poll]
@@ -51,5 +51,18 @@ module Scirocco
51
51
  client = Scirocco::Client.new(options[:api_key], options)
52
52
  pp client.devices(project_id)
53
53
  end
54
+
55
+ desc "apps <PROJECT_ID>", "Print list of apps"
56
+ def apps(project_id)
57
+ client = Scirocco::Client.new(options[:api_key], options)
58
+ pp client.apps(project_id)
59
+ end
60
+
61
+ desc "upload_app <PROJECT_ID> <APP_PATH>", "Upload app"
62
+ def upload_app(project_id, app_path)
63
+ client = Scirocco::Client.new(options[:api_key], options)
64
+ pp client.upload_app(project_id, app_path)
65
+ end
66
+
54
67
  end
55
68
  end
@@ -21,7 +21,7 @@ module Scirocco
21
21
 
22
22
  def projects
23
23
  url = build_url("projects")
24
- get(url)["projects"]
24
+ get(url)
25
25
  end
26
26
 
27
27
  ##############
@@ -40,7 +40,7 @@ module Scirocco
40
40
 
41
41
  def tests(project_id)
42
42
  url = build_url("tests")
43
- get(url, {:project_id => project_id})["tests"]
43
+ get(url, {:project_id => project_id})
44
44
  end
45
45
 
46
46
  def run_test(test_class_id, device_id)
@@ -51,7 +51,7 @@ module Scirocco
51
51
  :device_id => device_id
52
52
  }
53
53
 
54
- post(url, data)["test_job"]
54
+ post(url, data)
55
55
  end
56
56
 
57
57
  # Checks for when test completes
@@ -77,6 +77,26 @@ module Scirocco
77
77
  get(url, params)
78
78
  end
79
79
 
80
+ ############
81
+ ## App API
82
+ ############
83
+
84
+ def apps(project_id)
85
+ url = build_url("apps")
86
+ get(url, {:project_id => project_id})
87
+ end
88
+
89
+ def upload_app(project_id, app_path)
90
+ url = build_url("apps", "upload")
91
+ data = {
92
+ :multipart => true,
93
+ :api_key => @api_key,
94
+ :project_id => project_id,
95
+ :file => File.new(app_path)
96
+ }
97
+ post(url, data)
98
+ end
99
+
80
100
  private
81
101
 
82
102
  def build_url(type, resource=nil)
@@ -92,18 +112,18 @@ module Scirocco
92
112
  query_string_params = params.collect{ |p| "&#{p[0].to_s}=#{p[1].to_s}" }.join
93
113
  #p "#{url}?api_key=#{@api_key}#{query_string_params}"
94
114
 
95
- #begin
115
+ begin
96
116
  response = RestClient::Request.execute(:method => :get, :url => "#{url}?api_key=#{@api_key}#{query_string_params}", :timeout => @request_timeout, :open_timeout => @open_timeout)
97
117
  @last_request[:response] = response
98
- JSON.parse(response)
99
- #rescue => err
100
- # pp err
101
- # if err.response
102
- # raise JSON.parse(err.response)["error"]
103
- # else
104
- # raise err
105
- # end
106
- #end
118
+ return JSON.parse(response)
119
+ rescue => err
120
+ if err.response
121
+ pp JSON.parse(err.response)
122
+ raise err.message
123
+ else
124
+ raise err
125
+ end
126
+ end
107
127
  end
108
128
 
109
129
  def post(url, data, capture_request=true)
@@ -114,10 +134,18 @@ module Scirocco
114
134
  }
115
135
  end
116
136
 
117
- result = RestClient::Request.execute(:method => :post, :url => url, :payload => data, :timeout => @request_timeout, :open_timeout => @open_timeout)
118
- @last_request[:response] = result if capture_request
119
-
120
- JSON.parse(result)
137
+ begin
138
+ result = RestClient::Request.execute(:method => :post, :url => url, :payload => data, :timeout => @request_timeout, :open_timeout => @open_timeout)
139
+ @last_request[:response] = result if capture_request
140
+ JSON.parse(result)
141
+ rescue => err
142
+ if err.response
143
+ pp JSON.parse(err.response)
144
+ raise err.message
145
+ else
146
+ raise err
147
+ end
148
+ end
121
149
  end
122
150
  end
123
151
  end
@@ -1,3 +1,3 @@
1
1
  module Scirocco
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scirocco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - k-yamada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client