appurify 0.5.1 → 0.5.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: 6d59e7be284d07a80888cfbf0ee8560e0a633fd4
4
- data.tar.gz: 3d0d311f3a747f28a094efdd227d2bca6469b929
3
+ metadata.gz: f79f19a90a597542b2dbf33a28d9074952bb494e
4
+ data.tar.gz: e087d57fbd53f3925d0d7b27e0975166a92fcece
5
5
  SHA512:
6
- metadata.gz: d9d7575592de776d185b365d2184af8cb067d14dcf3218769c25faea01e351d25187a82087bd05a528b07357805ef378b71d098e4aa523c5b04227cccff91abe
7
- data.tar.gz: f61777f85d7448a3a76996216cbff789c1aebe2ff05bc1548574c6dc0f0d53bfb2264befd42f9f8c3e9cbaea68781d6d630c18cc4e4cc79cf0a44fba75ef4b4a
6
+ metadata.gz: 8a7aeea77a1723e5cad9fc4eef2c78c1b761a25bb8326dddec3d16c92ae5959d9ff1273ea3702deb798aff8f43967fca810cf32a68d2b1197136db44401f43c1
7
+ data.tar.gz: 0cd6c45c719d26571afc8230f6c1bc476e69c0b14e01ef3e2b36569904ae4a32c926a252b6eaee082bc0b92547038ad421bf2d256fc648407c0774a6e2e21bd9
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  The official Ruby client for the [Appurify](http://www.appurify.com) API.
4
4
 
5
+ ### Version History
6
+
7
+ 0.5.2 - Added support for uploading local application and test files.
8
+
5
9
  ### Installation
6
10
 
7
11
  ```
@@ -1,11 +1,11 @@
1
1
  module Appurify
2
2
  class Client
3
3
  attr_accessor :scheme, :host, :port, :key, :secret, :request_timeout, :open_timeout, :last_request
4
-
4
+
5
5
  def initialize(key, secret, options={})
6
6
  @key = key
7
7
  @secret = secret
8
-
8
+
9
9
  @scheme, @host, @port, @request_timeout, @open_timeout = {
10
10
  scheme: "https",
11
11
  host: HOSTNAME,
@@ -14,7 +14,7 @@ module Appurify
14
14
  open_timeout: 10
15
15
  }.merge(options).values
16
16
  end
17
-
17
+
18
18
  def access_token
19
19
  unless access_token_active?
20
20
  url = build_url("access_token", "generate")
@@ -32,66 +32,96 @@ module Appurify
32
32
 
33
33
  @access_token
34
34
  end
35
-
35
+
36
36
  def device_types
37
37
  url = build_url("devices", "list")
38
38
  get(url)
39
39
  end
40
-
40
+
41
41
  def network_conditions
42
42
  url = build_url("devices", "config/networks/list")
43
43
  get(url)
44
44
  end
45
-
45
+
46
46
  def apps
47
47
  url = build_url("apps", "list")
48
48
  get(url)
49
49
  end
50
-
50
+
51
51
  def tests
52
52
  url = build_url("tests", "list")
53
53
  get(url)
54
54
  end
55
-
55
+
56
+ def upload_app_from_file(app_path)
57
+ abort "App not found" unless File.exists? app_path
58
+ upload_app("raw", File.new(app_path, 'rb'))
59
+ end
60
+
56
61
  def upload_app_from_url(app_url)
62
+ upload_app("url", app_url)
63
+ end
64
+
65
+ def upload_app(source_type, source)
57
66
  url = build_url("apps", "upload")
58
67
  data = {
59
68
  :access_token => access_token,
60
- :source_type => "url",
61
- :source => app_url
69
+ :source_type => source_type,
70
+ :source => source
62
71
  }
63
72
 
64
73
  post(url, data)
65
74
  end
66
75
 
76
+ def upload_test_from_file(test_path, test_type)
77
+ abort "Tests not found" unless File.exists? test_path
78
+ upload_test("raw", File.new(test_path, 'rb'), test_type)
79
+ end
80
+
67
81
  def upload_test_from_url(test_url, test_type)
82
+ upload_test("url", test_url, test_type)
83
+ end
84
+
85
+ def upload_test(source_type, source, test_type)
68
86
  url = build_url("tests", "upload")
69
87
  data = {
70
88
  :access_token => access_token,
71
- :source_type => "url",
89
+ :source_type => source_type,
72
90
  :test_type => test_type,
73
- :source => test_url
91
+ :source => source
92
+ }
93
+
94
+ post(url, data)
95
+ end
96
+
97
+ def upload_config(test_id, config_src)
98
+ abort "Config not found" unless File.exists? config_src
99
+ url = build_url("config", "upload")
100
+ data = {
101
+ :access_token => access_token,
102
+ :test_id => test_id,
103
+ :source => File.new(config_src, 'rb')
74
104
  }
75
105
 
76
106
  post(url, data)
77
107
  end
78
-
108
+
79
109
  def upload_device_conditions(test_id, conditions)
80
110
  url = build_url("config", "upload")
81
111
  file_data = "[appurify]\n" + conditions.keys.collect{ |k| k.to_s + "=" + conditions[k].to_s }.join("\n")
82
-
112
+
83
113
  file = StringIO.new(file_data)
84
114
  file.class.class_eval { attr_accessor :name }
85
115
  file.class.class_eval { attr_accessor :path }
86
116
  file.name = "config.cnf"
87
117
  file.path = "config.cnf"
88
-
118
+
89
119
  data = {
90
120
  :access_token => access_token,
91
121
  :test_id => test_id,
92
122
  :source => file
93
123
  }
94
-
124
+
95
125
  post(url, data)
96
126
  end
97
127
 
@@ -107,36 +137,36 @@ module Appurify
107
137
 
108
138
  post(url, data)
109
139
  end
110
-
140
+
111
141
  def monitor_test(test_run_id)
112
142
  url = build_url("tests", "check")
113
143
  params = { test_run_id: test_run_id }
114
144
  get(url, params)
115
145
  end
116
-
146
+
117
147
  private
118
-
148
+
119
149
  def access_token_active?
120
150
  @access_token && Time.now < @access_token_created + @access_token_ttl
121
151
  end
122
-
152
+
123
153
  def build_url(type, resource)
124
154
  @scheme + "://" + [@host, "resource", type, resource].join("/") + "/"
125
155
  end
126
-
156
+
127
157
  def get(url, params={})
128
158
  @last_request = {
129
159
  url: url,
130
160
  request: params
131
161
  }
132
-
162
+
133
163
  query_string_params = params.collect{ |p| "&#{p[0].to_s}=#{p[1].to_s}" }.join
134
164
  result = RestClient::Request.execute(:method => :get, :url => "#{url}?access_token=#{access_token}#{query_string_params}", :timeout => @request_timeout, :open_timeout => @open_timeout)
135
165
  @last_request[:response] = result
136
-
166
+
137
167
  JSON.parse(result)["response"]
138
168
  end
139
-
169
+
140
170
  def post(url, data, capture_request=true)
141
171
  if capture_request
142
172
  @last_request = {
@@ -144,12 +174,12 @@ module Appurify
144
174
  request: data
145
175
  }
146
176
  end
147
-
177
+
148
178
  result = RestClient::Request.execute(:method => :post, :url => url, :payload => data, :timeout => @request_timeout, :open_timeout => @open_timeout)
149
179
  @last_request[:response] = result if capture_request
150
-
180
+
151
181
  JSON.parse(result)["response"]
152
182
  end
153
-
183
+
154
184
  end
155
185
  end
@@ -1,3 +1,3 @@
1
1
  module Appurify
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appurify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rohling
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-29 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 2.0.6
102
+ rubygems_version: 2.2.1
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: Run tests using Appurify's mobile devices.