opencpu 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +114 -2
- data/circle.yml +3 -1
- data/lib/opencpu/version.rb +1 -1
- data/opencpu.gemspec +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7fa48f6ada8ed51e24bd637e2f5accb66f21236
|
4
|
+
data.tar.gz: 03bec11de590ae6e37cf14827db242e009aab50d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90622347a231242315ad05ab6626cd4e49242792c1d3606a201eee06417dfd09d8c46fbcf9e8659fceb205f0baaea6fcd32e09eacce47b1466b31012583bba5d
|
7
|
+
data.tar.gz: 1c25c6bb72e88d2bd340c54011a6a7cc6be1ee3f314e8ef57dd47ff4a969b9304975f00d0b2b00c2b239dd040a2f41ae531b2933d2b83a69912a149445b28960
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
![Build Status](https://circleci.com/gh/roqua/opencpu.png?circle-token=4689df66bef26cd4aff65a4893c25400795b408a)
|
4
4
|
|
5
|
+
[![Code Climate](https://codeclimate.com/github/roqua/opencpu.png)](https://codeclimate.com/github/roqua/opencpu)
|
6
|
+
[![Dependency Status](https://gemnasium.com/roqua/opencpu.svg)](https://gemnasium.com/roqua/opencpu)
|
7
|
+
|
5
8
|
Roqua wrapper for the OpenCPU REST API.
|
6
9
|
|
7
10
|
## Installation
|
@@ -18,10 +21,119 @@ Or install it yourself as:
|
|
18
21
|
|
19
22
|
$ gem install opencpu
|
20
23
|
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
```Ruby
|
27
|
+
OpenCPU.configure do |config|
|
28
|
+
config.endpoint_url = 'https://public.opencpu.org/ocpu'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
21
32
|
## Usage
|
22
33
|
|
23
|
-
|
24
|
-
|
34
|
+
```Ruby
|
35
|
+
client = OpenCPU.client
|
36
|
+
```
|
37
|
+
|
38
|
+
### One-step call
|
39
|
+
|
40
|
+
One-step call always returns a JSON result from OpenCPU. However this is a
|
41
|
+
preferred way to use this gem, not every R-package supports one-step responses.
|
42
|
+
|
43
|
+
To get a response just pass a package name, function and the payload to the
|
44
|
+
function. In the following example `:digest` is an R-package name, `:hmac` is a
|
45
|
+
function and `{ key: 'foo', object: 'bar' }` is the payload:
|
46
|
+
|
47
|
+
```Ruby
|
48
|
+
client.execute :digest, :hmac, { key: 'foo', object: 'bar' }
|
49
|
+
# => ['0c7a250281315ab863549f66cd8a3a53']
|
50
|
+
```
|
51
|
+
|
52
|
+
### Two-steps way
|
53
|
+
|
54
|
+
To prepare the calculations on OpenCPU execute the `#prepare` method. It accepts
|
55
|
+
the same arguments as `#execute`.
|
56
|
+
|
57
|
+
```Ruby
|
58
|
+
calculations = client.prepare :animation, 'flip.coin'
|
59
|
+
```
|
60
|
+
|
61
|
+
`calculations` variable now holds the reference URL's to the calculations made
|
62
|
+
by OpenCPU. These URL are available through one of the following methods. Which
|
63
|
+
of them are available depends on the package and possible response it can
|
64
|
+
generate.
|
65
|
+
|
66
|
+
**#graphics(obj, type)**
|
67
|
+
|
68
|
+
```Ruby
|
69
|
+
calculations.graphics
|
70
|
+
# => Returns the first SVG created by OpenCPU.
|
71
|
+
calculations.graphics(1)
|
72
|
+
# => Returns the second SVG created by OpenCPU.
|
73
|
+
calculations.graphics(1, :png)
|
74
|
+
# => Returns the second PNG created by OpenCPU.
|
75
|
+
```
|
76
|
+
|
77
|
+
**#value**
|
78
|
+
|
79
|
+
```Ruby
|
80
|
+
calculations.value
|
81
|
+
# => Returns the raw output of the R-function.
|
82
|
+
```
|
83
|
+
|
84
|
+
**#stdout**
|
85
|
+
|
86
|
+
```Ruby
|
87
|
+
calculations.stdout
|
88
|
+
# => Returns the raw output of stdout being written at the runtime.
|
89
|
+
```
|
90
|
+
|
91
|
+
**#warnings**
|
92
|
+
|
93
|
+
```Ruby
|
94
|
+
calculations.warnings
|
95
|
+
# => Returns the warnings returned by the script.
|
96
|
+
```
|
97
|
+
|
98
|
+
**#source**
|
99
|
+
|
100
|
+
```Ruby
|
101
|
+
calculations.source
|
102
|
+
# => Returns the source of the script.
|
103
|
+
```
|
104
|
+
|
105
|
+
**#console**
|
106
|
+
|
107
|
+
```Ruby
|
108
|
+
calculations.console
|
109
|
+
# => Returns the output from R-console.
|
110
|
+
```
|
111
|
+
|
112
|
+
**#info**
|
113
|
+
|
114
|
+
```Ruby
|
115
|
+
calculations.info
|
116
|
+
# => Returns information about R-environment of the script.
|
117
|
+
```
|
118
|
+
|
119
|
+
## Test mode
|
120
|
+
|
121
|
+
OpenCPU gem provides a test mode. It basically disables all HTTP interactions
|
122
|
+
with provided OpenCPU server. It is very handy when testing your software for
|
123
|
+
example. You can easily turn it on:
|
124
|
+
|
125
|
+
```Ruby
|
126
|
+
OpenCPU.enable_test_mode!
|
127
|
+
```
|
128
|
+
|
129
|
+
After that you can set fake responses per package/script combination:
|
130
|
+
|
131
|
+
```Ruby
|
132
|
+
OpenCPU.set_fake_response! :digest, :hmac, 'foo'
|
133
|
+
```
|
134
|
+
|
135
|
+
This will allways return `'foo'` when calling function `hmac` in package
|
136
|
+
`digest`.
|
25
137
|
|
26
138
|
## Contributing
|
27
139
|
|
data/circle.yml
CHANGED
data/lib/opencpu/version.rb
CHANGED
data/opencpu.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency 'yajl-ruby', '~> 1.2.0'
|
22
|
-
spec.add_dependency 'httparty', '~> 0.
|
22
|
+
spec.add_dependency 'httparty', '~> 0.13.1'
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
24
|
spec.add_development_dependency 'rake'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 2.14.1'
|
data/spec/spec_helper.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Malykh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.13.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.13.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|