algorithmia 0.2.0 → 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/.gitignore +12 -1
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +3 -3
- data/LICENSE +21 -0
- data/README.md +196 -0
- data/Rakefile +6 -63
- data/algorithmia.gemspec +22 -24
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/algorithmia.rb +28 -15
- data/lib/algorithmia/algorithm.rb +49 -0
- data/lib/algorithmia/client.rb +21 -0
- data/lib/algorithmia/data_directory.rb +91 -0
- data/lib/algorithmia/data_file.rb +55 -0
- data/lib/algorithmia/data_object.rb +26 -0
- data/lib/algorithmia/errors.rb +19 -5
- data/lib/algorithmia/requester.rb +104 -0
- data/lib/algorithmia/response.rb +39 -0
- data/lib/algorithmia/unauthenticated_client.rb +7 -0
- data/lib/algorithmia/version.rb +3 -7
- metadata +56 -36
- data/.ruby-version +0 -1
- data/LICENSE.txt +0 -8
- data/algorithmia.png +0 -0
- data/lib/algorithmia/authentication.rb +0 -24
- data/lib/algorithmia/base.rb +0 -14
- data/lib/algorithmia/http.rb +0 -33
- data/lib/algorithmia/result.rb +0 -25
- data/readme.markdown +0 -37
- data/spec/algorithmia_spec.rb +0 -17
data/lib/algorithmia/version.rb
CHANGED
metadata
CHANGED
@@ -1,95 +1,116 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algorithmia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Algorithmia
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
33
|
+
version: '11.1'
|
34
|
+
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '11.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '3.4'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: json
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: '1.8'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: '1.8'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: httparty
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
62
|
-
type: :
|
75
|
+
version: '0.13'
|
76
|
+
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
69
|
-
description:
|
70
|
-
|
71
|
-
email:
|
82
|
+
version: '0.13'
|
83
|
+
description: This gem provides a friendly client interface to the Algorithmia API,
|
84
|
+
allowing you to call any of the algorithms on the Algorithmia Marketplace.
|
85
|
+
email:
|
86
|
+
- developer@algorithmia.com
|
72
87
|
executables: []
|
73
88
|
extensions: []
|
74
89
|
extra_rdoc_files: []
|
75
90
|
files:
|
76
91
|
- ".gitignore"
|
77
|
-
- ".
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- CODE_OF_CONDUCT.md
|
78
95
|
- Gemfile
|
79
|
-
- LICENSE
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
80
98
|
- Rakefile
|
81
99
|
- algorithmia.gemspec
|
82
|
-
-
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
83
102
|
- lib/algorithmia.rb
|
84
|
-
- lib/algorithmia/
|
85
|
-
- lib/algorithmia/
|
103
|
+
- lib/algorithmia/algorithm.rb
|
104
|
+
- lib/algorithmia/client.rb
|
105
|
+
- lib/algorithmia/data_directory.rb
|
106
|
+
- lib/algorithmia/data_file.rb
|
107
|
+
- lib/algorithmia/data_object.rb
|
86
108
|
- lib/algorithmia/errors.rb
|
87
|
-
- lib/algorithmia/
|
88
|
-
- lib/algorithmia/
|
109
|
+
- lib/algorithmia/requester.rb
|
110
|
+
- lib/algorithmia/response.rb
|
111
|
+
- lib/algorithmia/unauthenticated_client.rb
|
89
112
|
- lib/algorithmia/version.rb
|
90
|
-
|
91
|
-
- spec/algorithmia_spec.rb
|
92
|
-
homepage: http://github.com/bih/algorithmia
|
113
|
+
homepage: https://algorithmia.com/
|
93
114
|
licenses:
|
94
115
|
- MIT
|
95
116
|
metadata: {}
|
@@ -101,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
122
|
requirements:
|
102
123
|
- - ">="
|
103
124
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
125
|
+
version: '0'
|
105
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
127
|
requirements:
|
107
128
|
- - ">="
|
@@ -109,9 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
130
|
version: '0'
|
110
131
|
requirements: []
|
111
132
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.5.1
|
113
134
|
signing_key:
|
114
135
|
specification_version: 4
|
115
|
-
summary: Ruby
|
116
|
-
test_files:
|
117
|
-
- spec/algorithmia_spec.rb
|
136
|
+
summary: A Ruby client for making API calls to Algorithmia
|
137
|
+
test_files: []
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.2
|
data/LICENSE.txt
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
Copyright © 2014 Bilawal Hameed <me@bilaw.al>
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
-
|
6
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
-
|
8
|
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/algorithmia.png
DELETED
Binary file
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# Algorithmia Ruby wrapper.
|
2
|
-
# Released under the MIT License
|
3
|
-
# http://github.com/bih/algorithmia
|
4
|
-
|
5
|
-
class Algorithmia
|
6
|
-
attr_writer :api_key
|
7
|
-
|
8
|
-
# Authentication stuffs.
|
9
|
-
def self.api_key
|
10
|
-
@api_key
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.api_key?
|
14
|
-
not @api_key.nil?
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.api_key=(api_key)
|
18
|
-
if not api_key.is_a?(String) or api_key.to_s.empty?
|
19
|
-
raise AlgorithmiaApiKeyTooShort.new("Invalid Algorithmia API key")
|
20
|
-
end
|
21
|
-
|
22
|
-
@api_key = api_key
|
23
|
-
end
|
24
|
-
end
|
data/lib/algorithmia/base.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# Algorithmia Ruby wrapper.
|
2
|
-
# Released under the MIT License
|
3
|
-
# http://github.com/bih/algorithmia
|
4
|
-
|
5
|
-
require 'singleton'
|
6
|
-
require 'httparty'
|
7
|
-
|
8
|
-
class Algorithmia
|
9
|
-
include Singleton
|
10
|
-
include HTTParty
|
11
|
-
|
12
|
-
base_uri "https://api.algorithmia.com/v1/algo"
|
13
|
-
format :json
|
14
|
-
end
|
data/lib/algorithmia/http.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Algorithmia Ruby wrapper.
|
2
|
-
# Released under the MIT License
|
3
|
-
# http://github.com/bih/algorithmia
|
4
|
-
|
5
|
-
class Algorithmia
|
6
|
-
private
|
7
|
-
|
8
|
-
def self.post_http(endpoint, params = {})
|
9
|
-
params = params.to_s unless params.is_a?(Hash)
|
10
|
-
parse_output post(endpoint, body: params, headers: { "Authorization" => @api_key, "Content-Type" => "application/json" })
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.get_http(endpoint, params = {})
|
14
|
-
params = params.to_s unless params.is_a?(Hash)
|
15
|
-
parse_output get(endpoint, query: params, headers: { "Authorization" => @api_key, "Content-Type" => "application/json" })
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.parse_output(res)
|
19
|
-
result = res.parsed_response
|
20
|
-
|
21
|
-
# Error!
|
22
|
-
raise AlgorithmiaException.new(result[:error]) if result.include?(:error)
|
23
|
-
|
24
|
-
# Result!
|
25
|
-
Algorithmia::Result.new(result)
|
26
|
-
rescue NoMethodError => e
|
27
|
-
raise AlgorithmiaException.new(res.parsed_response)
|
28
|
-
rescue JSON::ParserError => e
|
29
|
-
raise AlgorithmiaException.new(e)
|
30
|
-
rescue Exception => e
|
31
|
-
raise AlgorithmiaException.new(e)
|
32
|
-
end
|
33
|
-
end
|
data/lib/algorithmia/result.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Algorithmia Ruby wrapper.
|
2
|
-
# Released under the MIT License
|
3
|
-
# http://github.com/bih/algorithmia
|
4
|
-
|
5
|
-
class Algorithmia::Result
|
6
|
-
def initialize(hash)
|
7
|
-
@json = clean_output(hash) rescue {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def duration
|
11
|
-
@json[:duration] rescue -1
|
12
|
-
end
|
13
|
-
|
14
|
-
def result
|
15
|
-
@json[:result] rescue nil
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def clean_output(hash_without_symbols)
|
21
|
-
hash_with_symbols = Hash.new
|
22
|
-
hash_without_symbols.each { |k, v| hash_with_symbols[k.to_sym] = v } if hash_without_symbols.is_a?(Hash)
|
23
|
-
hash_with_symbols
|
24
|
-
end
|
25
|
-
end
|
data/readme.markdown
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
![Algorithmia for Ruby](algorithmia.png)
|
2
|
-
|
3
|
-
# Ruby Wrapper for Algorithmia
|
4
|
-
|
5
|
-
Looks very interesting, so I quickly threw together an awesome Ruby wrapper to interact with [Algorithmia.com](http://algorithmia.com).
|
6
|
-
|
7
|
-
### Installation
|
8
|
-
|
9
|
-
```
|
10
|
-
# By your command line.
|
11
|
-
$ gem install algorithmia
|
12
|
-
|
13
|
-
# Alternatively, through your Gemfile.
|
14
|
-
gem 'algorithmia'
|
15
|
-
```
|
16
|
-
|
17
|
-
### Documentation
|
18
|
-
Keeping it simple for now. But it's super easy to make a request to Algorithmia:
|
19
|
-
|
20
|
-
```ruby
|
21
|
-
require "algorithmia"
|
22
|
-
|
23
|
-
# Your API key. Get it from your dashboard on Algorithmia.com
|
24
|
-
Algorithmia.api_key = "[INSERT API KEY]"
|
25
|
-
|
26
|
-
query = Algorithmia.call("kenny/Factor", 29)
|
27
|
-
# Example for algorithm: https://algorithmia.com/algorithms/kenny/Factor
|
28
|
-
# => #<Algorithmia::Result:0x007fad12c4fc68 @json={:duration=>0.035231213000000004, :result=>[29]}>
|
29
|
-
|
30
|
-
query.result # => [29]
|
31
|
-
query.duration # => 0.035231213000000004
|
32
|
-
```
|
33
|
-
|
34
|
-
See full [Algorithmia.com API docs by clicking here](https://algorithmia.com/docs/api#curl).
|
35
|
-
|
36
|
-
### Who made this?
|
37
|
-
[Bilawal Hameed](http://github.com/bih). Released freely under the [MIT License](http://bih.mit-license.org/).
|
data/spec/algorithmia_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# Algorithmia Ruby wrapper.
|
2
|
-
# Released under the MIT License
|
3
|
-
# http://github.com/bih/algorithmia
|
4
|
-
|
5
|
-
# Required according to the command-line tool.
|
6
|
-
gem 'minitest'
|
7
|
-
|
8
|
-
# Load in the test.
|
9
|
-
require 'minitest/autorun'
|
10
|
-
require 'minitest/spec'
|
11
|
-
|
12
|
-
# And the source of Algorithmia, of course.
|
13
|
-
FileList['lib/**/*.rb'].each{ |source| load(source) }
|
14
|
-
|
15
|
-
class AlgorithmiaRubyTest < Minitest::Test
|
16
|
-
# TODO: Some tests.
|
17
|
-
end
|