opencpu 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Guardfile +1 -1
- data/lib/opencpu/client.rb +6 -3
- data/lib/opencpu/version.rb +2 -2
- data/spec/fixtures/vcr_cassettes/github_animation_flip_coin.yml +64 -0
- data/spec/fixtures/vcr_cassettes/github_animation_flip_coin_error.yml +58 -0
- data/spec/lib/opencpu/client_spec.rb +27 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc821de62d9d3981b61ed2c4a501c9c67fd14335
|
4
|
+
data.tar.gz: 2257ce6bd32d940475aab7063b9c8f0812a38a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 326ddd1a403277239f0e9ba3ba8e860ecf50ef960b03efbd65dc596dccac401f68dfa5d878ea414f3a1477ea806b55f265abf25cf5f98c8a5e0406f81da09a14
|
7
|
+
data.tar.gz: b2f0770627b0663321cd710b1bff62148ba6c123c1ab76c0ec96473e4ce79d7d434d699cc97b781c64ca2c216c2e7a1258cd72750659fdb3cf3055974c063bd0
|
data/CHANGELOG.md
CHANGED
data/Guardfile
CHANGED
@@ -3,7 +3,7 @@ guard :bundler do
|
|
3
3
|
watch(/^.+\.gemspec/)
|
4
4
|
end
|
5
5
|
|
6
|
-
guard :rspec do
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec --color --format=documentation' do
|
7
7
|
watch(%r{^spec/.+_spec\.rb$})
|
8
8
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
9
9
|
watch('spec/spec_helper.rb') { "spec" }
|
data/lib/opencpu/client.rb
CHANGED
@@ -11,7 +11,8 @@ module OpenCPU
|
|
11
11
|
user = options.fetch :user, :system
|
12
12
|
data = options.fetch :data, {}
|
13
13
|
format = options.fetch :format, :json
|
14
|
-
|
14
|
+
github_remote = options.fetch :github_remote, false
|
15
|
+
process_query package_url(package, function, user, github_remote, :json), data, format do |response|
|
15
16
|
JSON.parse(response.body)
|
16
17
|
end
|
17
18
|
end
|
@@ -20,7 +21,8 @@ module OpenCPU
|
|
20
21
|
user = options.fetch :user, :system
|
21
22
|
data = options.fetch :data, {}
|
22
23
|
format = options.fetch :format, :json
|
23
|
-
|
24
|
+
github_remote = options.fetch :github_remote, false
|
25
|
+
process_query package_url(package, function, user, github_remote), data, format do |response|
|
24
26
|
location = response.headers['location']
|
25
27
|
resources = response.body.split(/\n/)
|
26
28
|
OpenCPU::DelayedCalculation.new(location, resources)
|
@@ -65,8 +67,9 @@ module OpenCPU
|
|
65
67
|
options
|
66
68
|
end
|
67
69
|
|
68
|
-
def package_url(package, function, user = :system, format = nil)
|
70
|
+
def package_url(package, function, user = :system, github_remote = false, format = nil)
|
69
71
|
return ['', 'library', package, 'R', function, format.to_s].join('/') if user == :system
|
72
|
+
return ['', 'github', user, package, 'R', function, format.to_s].join('/') if github_remote
|
70
73
|
return ['', 'user', user, 'library', package, 'R', function, format.to_s].join('/')
|
71
74
|
end
|
72
75
|
|
data/lib/opencpu/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://public.opencpu.org/ocpu/github/yihui/animation/R/flip.coin/json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "{}"
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: OK
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- nginx/1.4.6 (Ubuntu)
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jun 2015 13:15:43 GMT
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
Location:
|
24
|
+
- https://public.opencpu.org/ocpu/tmp/x028f930180/
|
25
|
+
Transfer-Encoding:
|
26
|
+
- chunked
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=300, public
|
31
|
+
X-Ocpu-Session:
|
32
|
+
- x028f930180
|
33
|
+
Access-Control-Allow-Origin:
|
34
|
+
- "*"
|
35
|
+
Access-Control-Expose-Headers:
|
36
|
+
- Location, X-ocpu-session, Content-Type, Cache-Control
|
37
|
+
Access-Control-Allow-Headers:
|
38
|
+
- Origin, Content-Type, Accept, Accept-Encoding, Cache-Control, Authorization
|
39
|
+
Access-Control-Allow-Credentials:
|
40
|
+
- 'true'
|
41
|
+
X-Ocpu-R:
|
42
|
+
- R version 3.2.0 Patched (2015-05-24 r68404)
|
43
|
+
X-Ocpu-Locale:
|
44
|
+
- en_US.UTF-8
|
45
|
+
X-Ocpu-Time:
|
46
|
+
- 2015-06-08 06:15:04 PDT
|
47
|
+
X-Ocpu-Version:
|
48
|
+
- 1.5.0
|
49
|
+
X-Ocpu-Server:
|
50
|
+
- rApache
|
51
|
+
Vary:
|
52
|
+
- Accept-Encoding
|
53
|
+
X-Ocpu-Cache:
|
54
|
+
- HIT
|
55
|
+
body:
|
56
|
+
encoding: UTF-8
|
57
|
+
string: |
|
58
|
+
{
|
59
|
+
"freq": [0.34, 0.66],
|
60
|
+
"nmax": [50]
|
61
|
+
}
|
62
|
+
http_version:
|
63
|
+
recorded_at: Mon, 08 Jun 2015 13:15:43 GMT
|
64
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,58 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://public.opencpu.org/ocpu/github/baz/foo/R/bar/json
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "{}"
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 400
|
15
|
+
message: Bad Request
|
16
|
+
headers:
|
17
|
+
Server:
|
18
|
+
- nginx/1.4.6 (Ubuntu)
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jun 2015 13:17:01 GMT
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
Access-Control-Expose-Headers:
|
28
|
+
- Location, X-ocpu-session, Content-Type, Cache-Control
|
29
|
+
Access-Control-Allow-Headers:
|
30
|
+
- Origin, Content-Type, Accept, Accept-Encoding, Cache-Control, Authorization
|
31
|
+
Access-Control-Allow-Credentials:
|
32
|
+
- 'true'
|
33
|
+
X-Ocpu-R:
|
34
|
+
- R version 3.2.0 Patched (2015-05-24 r68404)
|
35
|
+
X-Ocpu-Locale:
|
36
|
+
- en_US.UTF-8
|
37
|
+
X-Ocpu-Time:
|
38
|
+
- 2015-06-08 06:17:01 PDT
|
39
|
+
X-Ocpu-Version:
|
40
|
+
- 1.5.0
|
41
|
+
X-Ocpu-Server:
|
42
|
+
- rApache
|
43
|
+
Vary:
|
44
|
+
- Accept-Encoding
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: |
|
48
|
+
Package' foo ' did not successfully install.
|
49
|
+
Either installation failed or github repository name does not match package name.
|
50
|
+
|
51
|
+
|
52
|
+
Downloading github repo baz/foo@master
|
53
|
+
Error in download(dest, src, auth) : client error: (404) Not Found
|
54
|
+
Calls: do.call ... remote_download.github_remote -> download -> <Anonymous>
|
55
|
+
Execution halted
|
56
|
+
http_version:
|
57
|
+
recorded_at: Mon, 08 Jun 2015 13:17:01 GMT
|
58
|
+
recorded_with: VCR 2.9.3
|
@@ -139,6 +139,33 @@ describe OpenCPU::Client do
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
+
context 'GitHub package' do
|
143
|
+
before do
|
144
|
+
OpenCPU.configure do |config|
|
145
|
+
config.endpoint_url = 'https://public.opencpu.org/ocpu'
|
146
|
+
end
|
147
|
+
end
|
148
|
+
after { OpenCPU.reset_configuration! }
|
149
|
+
let(:client) { described_class.new }
|
150
|
+
|
151
|
+
it "can access github packages" do
|
152
|
+
VCR.use_cassette :github_animation_flip_coin do
|
153
|
+
response = client.execute(:animation, :'flip.coin', {user: "yihui", github_remote: true, data: {}})
|
154
|
+
expect(response['nmax']).to eq [50]
|
155
|
+
expect(response['freq'][0]).to satisfy { |result| result >= 0.0 && result <= 1.0 }
|
156
|
+
expect(response['freq'][1]).to satisfy { |result| result >= 0.0 && result <= 1.0 }
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it "what happens when package is not available on GitHub" do
|
161
|
+
VCR.use_cassette :github_animation_flip_coin_error do
|
162
|
+
expect {
|
163
|
+
client.execute(:foo, :bar, {user: "baz", github_remote: true})
|
164
|
+
}.to raise_error RuntimeError, /400: Bad Request/
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
142
169
|
context 'when in test mode' do
|
143
170
|
it 'has an empty fake response when just enabled' do
|
144
171
|
OpenCPU.enable_test_mode!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opencpu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Malykh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|
@@ -210,6 +210,8 @@ files:
|
|
210
210
|
- spec/fixtures/vcr_cassettes/animation_flip_coin.yml
|
211
211
|
- spec/fixtures/vcr_cassettes/digest_hmac.yml
|
212
212
|
- spec/fixtures/vcr_cassettes/digest_hmac_no_parameters.yml
|
213
|
+
- spec/fixtures/vcr_cassettes/github_animation_flip_coin.yml
|
214
|
+
- spec/fixtures/vcr_cassettes/github_animation_flip_coin_error.yml
|
213
215
|
- spec/fixtures/vcr_cassettes/prepare.yml
|
214
216
|
- spec/fixtures/vcr_cassettes/url_encoded_request.yml
|
215
217
|
- spec/fixtures/vcr_cassettes/user_digest_hmac.yml
|
@@ -247,6 +249,8 @@ test_files:
|
|
247
249
|
- spec/fixtures/vcr_cassettes/animation_flip_coin.yml
|
248
250
|
- spec/fixtures/vcr_cassettes/digest_hmac.yml
|
249
251
|
- spec/fixtures/vcr_cassettes/digest_hmac_no_parameters.yml
|
252
|
+
- spec/fixtures/vcr_cassettes/github_animation_flip_coin.yml
|
253
|
+
- spec/fixtures/vcr_cassettes/github_animation_flip_coin_error.yml
|
250
254
|
- spec/fixtures/vcr_cassettes/prepare.yml
|
251
255
|
- spec/fixtures/vcr_cassettes/url_encoded_request.yml
|
252
256
|
- spec/fixtures/vcr_cassettes/user_digest_hmac.yml
|