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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34c952212689a1551ecfcb120620c509f11e8524
4
- data.tar.gz: e7962d79b6ffca4407d2fb677ca8703e5ff8ed57
3
+ metadata.gz: c7fa48f6ada8ed51e24bd637e2f5accb66f21236
4
+ data.tar.gz: 03bec11de590ae6e37cf14827db242e009aab50d
5
5
  SHA512:
6
- metadata.gz: 813129283d4c47ef0da68327772940d2a715eeac3111e11ce97766a590cad61beb5f9e9f33b4217c5291e3155ef2952771a05fe9e266eb175746e54c5d844616
7
- data.tar.gz: 5f1ee6a0a9948020c5d058cf688988cec3d4d5f71f99ca25940b063cabb5bc279332a2bc56bfbbaef7d32d003a4096102c29379af40a4940db6d17b27a66393b
6
+ metadata.gz: 90622347a231242315ad05ab6626cd4e49242792c1d3606a201eee06417dfd09d8c46fbcf9e8659fceb205f0baaea6fcd32e09eacce47b1466b31012583bba5d
7
+ data.tar.gz: 1c25c6bb72e88d2bd340c54011a6a7cc6be1ee3f314e8ef57dd47ff4a969b9304975f00d0b2b00c2b239dd040a2f41ae531b2933d2b83a69912a149445b28960
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ group :test do
4
+ gem "codeclimate-test-reporter", require: nil
5
+ end
3
6
  # Specify your gem's dependencies in opencpu.gemspec
4
7
  gemspec
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
- data = { '.someFunction': [{ x: [1,2,3,4,5], y: [7,3,9,4,1] }]}
24
- response = OpenCPU.execute 'PackageName', 'ScriptName', data
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
@@ -1,3 +1,5 @@
1
1
  machine:
2
+ environment:
3
+ CODECLIMATE_REPO_TOKEN: ecaec3d271bf32a8e203cafb71cc565d57a86dc0571b5529b491935e786001ff
2
4
  ruby:
3
- version: 2.1.0
5
+ version: 2.1.0
@@ -1,6 +1,6 @@
1
1
  module OpenCPU
2
2
  MAJOR = 0
3
3
  MINOR = 6
4
- TINY = 0
4
+ TINY = 1
5
5
  VERSION = [MAJOR, MINOR, TINY].join('.')
6
6
  end
@@ -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.12.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'
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'vcr'
2
5
 
3
6
  require File.expand_path('../lib/opencpu.rb', __dir__)
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.0
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-07 00:00:00.000000000 Z
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.12.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.12.0
40
+ version: 0.13.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement