piston_api 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/piston_api.rb +2 -2
- data/lib/piston_api/client.rb +11 -4
- data/lib/piston_api/version.rb +3 -0
- metadata +37 -85
- data/.document +0 -5
- data/CHANGELOG.md +0 -8
- data/Gemfile +0 -10
- data/Gemfile.lock +0 -23
- data/LICENSE +0 -20
- data/README.rdoc +0 -17
- data/Rakefile +0 -48
- data/VERSION +0 -1
- data/examples/create_batch.rb +0 -30
- data/piston_api.gemspec +0 -81
- data/spec/fixtures/vcr_cassettes/create_batch/basic.yml +0 -63
- data/spec/fixtures/vcr_cassettes/create_batch/errors.yml +0 -46
- data/spec/fixtures/vcr_cassettes/create_batch/key_phrases.yml +0 -63
- data/spec/piston_api/client_spec.rb +0 -74
- data/spec/piston_api_spec.rb +0 -27
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -19
data/lib/piston_api.rb
CHANGED
@@ -3,8 +3,6 @@ require 'monster_mash'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module PistonApi
|
6
|
-
VERSION = File.read(File.dirname(__FILE__) + '/../VERSION').chomp
|
7
|
-
|
8
6
|
class << self
|
9
7
|
attr_accessor :api_key
|
10
8
|
attr_accessor :private_key
|
@@ -15,4 +13,6 @@ module PistonApi
|
|
15
13
|
end
|
16
14
|
|
17
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
16
|
+
|
17
|
+
require 'piston_api/version'
|
18
18
|
require 'piston_api/client'
|
data/lib/piston_api/client.rb
CHANGED
@@ -8,12 +8,12 @@ module PistonApi
|
|
8
8
|
|
9
9
|
post :create_batch do |json|
|
10
10
|
uri uri_for('/api/v1/batches')
|
11
|
-
params sign_params(
|
11
|
+
params escape_params(sign_params(
|
12
12
|
'/api/v1/batches',
|
13
13
|
PistonApi.private_key,
|
14
14
|
:order_data => json.to_json,
|
15
15
|
:api_key => PistonApi.api_key
|
16
|
-
)
|
16
|
+
))
|
17
17
|
|
18
18
|
handler do |response|
|
19
19
|
JSON.parse(response.body)
|
@@ -21,11 +21,18 @@ module PistonApi
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.uri_for(path)
|
24
|
-
(PistonApi.sandbox ?
|
24
|
+
(PistonApi.sandbox ?
|
25
|
+
'http://sandbox.mediapiston.com' :
|
26
|
+
'http://www.mediapiston.com') << path
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.sign_params(path, api_key, params)
|
28
|
-
params[:signature] =
|
30
|
+
params[:signature] = SignedRequest.sign(params, api_key, :path => path)
|
31
|
+
params
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.escape_params(params)
|
35
|
+
params.each { |k, v| params[k] = CGI.escape(v) }
|
29
36
|
params
|
30
37
|
end
|
31
38
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piston_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Balatero
|
@@ -15,9 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-22 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
+
name: signed_request
|
22
|
+
prerelease: false
|
21
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
22
24
|
none: false
|
23
25
|
requirements:
|
@@ -27,27 +29,27 @@ dependencies:
|
|
27
29
|
segments:
|
28
30
|
- 0
|
29
31
|
version: "0"
|
30
|
-
version_requirements: *id001
|
31
|
-
name: signed_request
|
32
|
-
prerelease: false
|
33
32
|
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
+
name: monster_mash
|
36
|
+
prerelease: false
|
35
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
36
38
|
none: false
|
37
39
|
requirements:
|
38
40
|
- - ">="
|
39
41
|
- !ruby/object:Gem::Version
|
40
|
-
hash:
|
42
|
+
hash: 19
|
41
43
|
segments:
|
42
44
|
- 0
|
43
|
-
-
|
45
|
+
- 3
|
44
46
|
- 0
|
45
|
-
version: 0.
|
46
|
-
version_requirements: *id002
|
47
|
-
name: monster_mash
|
48
|
-
prerelease: false
|
47
|
+
version: 0.3.0
|
49
48
|
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
+
name: json
|
52
|
+
prerelease: false
|
51
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
52
54
|
none: false
|
53
55
|
requirements:
|
@@ -57,100 +59,53 @@ dependencies:
|
|
57
59
|
segments:
|
58
60
|
- 0
|
59
61
|
version: "0"
|
60
|
-
version_requirements: *id003
|
61
|
-
name: json
|
62
|
-
prerelease: false
|
63
62
|
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
+
name: rspec
|
66
|
+
prerelease: false
|
65
67
|
requirement: &id004 !ruby/object:Gem::Requirement
|
66
68
|
none: false
|
67
69
|
requirements:
|
68
|
-
- -
|
70
|
+
- - ~>
|
69
71
|
- !ruby/object:Gem::Version
|
70
|
-
hash:
|
72
|
+
hash: 25
|
71
73
|
segments:
|
72
|
-
-
|
74
|
+
- 1
|
73
75
|
- 3
|
74
|
-
-
|
75
|
-
version:
|
76
|
+
- 1
|
77
|
+
version: 1.3.1
|
78
|
+
type: :development
|
76
79
|
version_requirements: *id004
|
77
|
-
name: monster_mash
|
78
|
-
prerelease: false
|
79
|
-
type: :runtime
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
|
82
|
-
none: false
|
83
|
-
requirements:
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
hash: 3
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
90
|
-
version_requirements: *id005
|
91
|
-
name: signed_request
|
81
|
+
name: vcr
|
92
82
|
prerelease: false
|
93
|
-
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
-
none: false
|
97
|
-
requirements:
|
98
|
-
- - ">="
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
hash: 3
|
101
|
-
segments:
|
102
|
-
- 0
|
103
|
-
version: "0"
|
104
|
-
version_requirements: *id006
|
105
|
-
name: json
|
106
|
-
prerelease: false
|
107
|
-
type: :runtime
|
108
|
-
- !ruby/object:Gem::Dependency
|
109
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
110
84
|
none: false
|
111
85
|
requirements:
|
112
86
|
- - ">="
|
113
87
|
- !ruby/object:Gem::Version
|
114
|
-
hash:
|
88
|
+
hash: 27
|
115
89
|
segments:
|
116
90
|
- 1
|
117
91
|
- 3
|
118
|
-
-
|
119
|
-
version: 1.3.
|
120
|
-
version_requirements: *id007
|
121
|
-
name: rspec
|
122
|
-
prerelease: false
|
92
|
+
- 0
|
93
|
+
version: 1.3.0
|
123
94
|
type: :development
|
95
|
+
version_requirements: *id005
|
124
96
|
description: Provides a Ruby interface to the MediaPiston API.
|
125
97
|
email: david@mediapiston.com
|
126
98
|
executables: []
|
127
99
|
|
128
100
|
extensions: []
|
129
101
|
|
130
|
-
extra_rdoc_files:
|
131
|
-
|
132
|
-
- README.rdoc
|
102
|
+
extra_rdoc_files: []
|
103
|
+
|
133
104
|
files:
|
134
|
-
- .document
|
135
|
-
- CHANGELOG.md
|
136
|
-
- Gemfile
|
137
|
-
- Gemfile.lock
|
138
|
-
- LICENSE
|
139
|
-
- README.rdoc
|
140
|
-
- Rakefile
|
141
|
-
- VERSION
|
142
|
-
- examples/create_batch.rb
|
143
105
|
- lib/piston_api.rb
|
144
106
|
- lib/piston_api/client.rb
|
145
|
-
- piston_api.
|
146
|
-
|
147
|
-
- spec/fixtures/vcr_cassettes/create_batch/errors.yml
|
148
|
-
- spec/fixtures/vcr_cassettes/create_batch/key_phrases.yml
|
149
|
-
- spec/piston_api/client_spec.rb
|
150
|
-
- spec/piston_api_spec.rb
|
151
|
-
- spec/spec.opts
|
152
|
-
- spec/spec_helper.rb
|
153
|
-
homepage: http://github.com/mediapiston/piston_api
|
107
|
+
- lib/piston_api/version.rb
|
108
|
+
homepage: https://github.com/mediapiston/piston_api
|
154
109
|
licenses: []
|
155
110
|
|
156
111
|
post_install_message:
|
@@ -178,13 +133,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
133
|
version: "0"
|
179
134
|
requirements: []
|
180
135
|
|
181
|
-
rubyforge_project:
|
136
|
+
rubyforge_project: "[none]"
|
182
137
|
rubygems_version: 1.8.10
|
183
138
|
signing_key:
|
184
139
|
specification_version: 3
|
185
140
|
summary: Provides a Ruby interface to the MediaPiston API.
|
186
|
-
test_files:
|
187
|
-
|
188
|
-
- spec/piston_api/client_spec.rb
|
189
|
-
- spec/piston_api_spec.rb
|
190
|
-
- spec/spec_helper.rb
|
141
|
+
test_files: []
|
142
|
+
|
data/.document
DELETED
data/CHANGELOG.md
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
json (1.6.1)
|
5
|
-
mime-types (1.17.2)
|
6
|
-
monster_mash (0.3.0)
|
7
|
-
typhoeus (>= 0.3.3)
|
8
|
-
typhoeus (>= 0.3.3)
|
9
|
-
rspec (1.3.1)
|
10
|
-
signed_request (1.0.4)
|
11
|
-
typhoeus (0.3.3)
|
12
|
-
mime-types
|
13
|
-
vcr (1.10.0)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
ruby
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
json
|
20
|
-
monster_mash (>= 0.2.0)
|
21
|
-
rspec (= 1.3.1)
|
22
|
-
signed_request
|
23
|
-
vcr (>= 1.3.0)
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 David Balatero
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
= piston_api
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Note on Patches/Pull Requests
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2010 David Balatero. See LICENSE for details.
|
data/Rakefile
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "piston_api"
|
8
|
-
gem.summary = %Q{Provides a Ruby interface to the MediaPiston API.}
|
9
|
-
gem.description = %Q{Provides a Ruby interface to the MediaPiston API.}
|
10
|
-
gem.email = "david@mediapiston.com"
|
11
|
-
gem.homepage = "http://github.com/mediapiston/piston_api"
|
12
|
-
gem.authors = ["David Balatero"]
|
13
|
-
gem.add_dependency "monster_mash", ">= 0.3.0"
|
14
|
-
gem.add_dependency "signed_request"
|
15
|
-
gem.add_dependency 'json'
|
16
|
-
gem.add_development_dependency "rspec", ">= 1.3.1"
|
17
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'spec/rake/spectask'
|
25
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
-
spec.libs << 'lib' << 'spec'
|
27
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
-
end
|
29
|
-
|
30
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
-
spec.libs << 'lib' << 'spec'
|
32
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
-
spec.rcov = true
|
34
|
-
end
|
35
|
-
|
36
|
-
task :spec => :check_dependencies
|
37
|
-
|
38
|
-
task :default => :spec
|
39
|
-
|
40
|
-
require 'rake/rdoctask'
|
41
|
-
Rake::RDocTask.new do |rdoc|
|
42
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
-
|
44
|
-
rdoc.rdoc_dir = 'rdoc'
|
45
|
-
rdoc.title = "piston_api #{version}"
|
46
|
-
rdoc.rdoc_files.include('README*')
|
47
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|
data/examples/create_batch.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require '../lib/piston_api'
|
2
|
-
|
3
|
-
PistonApi.sandbox = true
|
4
|
-
PistonApi.api_key = 'a688c8abd25fd37e50e8512e75aebbe2d869510368a58f66b6f9f00ed8de'
|
5
|
-
PistonApi.private_key = '65469e402f88852f338c79f8e8171ebaf2f6d5a28879799ea9a17c8a6b67'
|
6
|
-
|
7
|
-
|
8
|
-
result = PistonApi::Client.create_batch(
|
9
|
-
{
|
10
|
-
'batch' => {
|
11
|
-
'name' => "Character Guides for 'The Simpsons'",
|
12
|
-
'minimum_words' => 250,
|
13
|
-
'topic_overview_instructions' => "Write a short blurb of at least 250-words that describes the given character.",
|
14
|
-
'style_tone_instructions' => "Make it fun to read! Focus on the fictional character in the TV show.",
|
15
|
-
'structure_format_instructions' => "Describe the character's role and personality. Talk about the evolution of the character through the various seasons, or any highlights from the given seasons. As well, mention any important scenes, episodes, or other trivia of relevance about the character.",
|
16
|
-
'content_keywords_instructions' => "Include a quote from the character.",
|
17
|
-
'detail_research_instructions' => "For an example of good writing, please see http://goodwriting.com",
|
18
|
-
'articles' => [
|
19
|
-
{ :topic => 'Homer Simpson Character Guide', :metadata => "{ show_id: 1, character_id: 5432 }" },
|
20
|
-
{ :topic => 'Milhouse Character Guide', :metadata => "{ show_id: 1, character_id: 432165 }" },
|
21
|
-
{ :topic => 'Bart Simpson Character Guide', :metadata => "{ show_id: 1, character_id: 939921 }" },
|
22
|
-
{ :topic => 'Principal Skinner Character Guide', :metadata => "{ show_id: 1, character_id: 1432 }" }
|
23
|
-
]
|
24
|
-
}
|
25
|
-
}
|
26
|
-
)
|
27
|
-
|
28
|
-
puts "Got back result!"
|
29
|
-
puts "-----------------"
|
30
|
-
puts result.inspect
|
data/piston_api.gemspec
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "piston_api"
|
8
|
-
s.version = "0.1.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["David Balatero"]
|
12
|
-
s.date = "2011-11-21"
|
13
|
-
s.description = "Provides a Ruby interface to the MediaPiston API."
|
14
|
-
s.email = "david@mediapiston.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
"CHANGELOG.md",
|
22
|
-
"Gemfile",
|
23
|
-
"Gemfile.lock",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"examples/create_batch.rb",
|
29
|
-
"lib/piston_api.rb",
|
30
|
-
"lib/piston_api/client.rb",
|
31
|
-
"piston_api.gemspec",
|
32
|
-
"spec/fixtures/vcr_cassettes/create_batch/basic.yml",
|
33
|
-
"spec/fixtures/vcr_cassettes/create_batch/errors.yml",
|
34
|
-
"spec/fixtures/vcr_cassettes/create_batch/key_phrases.yml",
|
35
|
-
"spec/piston_api/client_spec.rb",
|
36
|
-
"spec/piston_api_spec.rb",
|
37
|
-
"spec/spec.opts",
|
38
|
-
"spec/spec_helper.rb"
|
39
|
-
]
|
40
|
-
s.homepage = "http://github.com/mediapiston/piston_api"
|
41
|
-
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = "1.8.10"
|
43
|
-
s.summary = "Provides a Ruby interface to the MediaPiston API."
|
44
|
-
s.test_files = [
|
45
|
-
"examples/create_batch.rb",
|
46
|
-
"spec/piston_api/client_spec.rb",
|
47
|
-
"spec/piston_api_spec.rb",
|
48
|
-
"spec/spec_helper.rb"
|
49
|
-
]
|
50
|
-
|
51
|
-
if s.respond_to? :specification_version then
|
52
|
-
s.specification_version = 3
|
53
|
-
|
54
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_runtime_dependency(%q<signed_request>, [">= 0"])
|
56
|
-
s.add_runtime_dependency(%q<monster_mash>, [">= 0.2.0"])
|
57
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
58
|
-
s.add_runtime_dependency(%q<monster_mash>, [">= 0.3.0"])
|
59
|
-
s.add_runtime_dependency(%q<signed_request>, [">= 0"])
|
60
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
61
|
-
s.add_development_dependency(%q<rspec>, [">= 1.3.1"])
|
62
|
-
else
|
63
|
-
s.add_dependency(%q<signed_request>, [">= 0"])
|
64
|
-
s.add_dependency(%q<monster_mash>, [">= 0.2.0"])
|
65
|
-
s.add_dependency(%q<json>, [">= 0"])
|
66
|
-
s.add_dependency(%q<monster_mash>, [">= 0.3.0"])
|
67
|
-
s.add_dependency(%q<signed_request>, [">= 0"])
|
68
|
-
s.add_dependency(%q<json>, [">= 0"])
|
69
|
-
s.add_dependency(%q<rspec>, [">= 1.3.1"])
|
70
|
-
end
|
71
|
-
else
|
72
|
-
s.add_dependency(%q<signed_request>, [">= 0"])
|
73
|
-
s.add_dependency(%q<monster_mash>, [">= 0.2.0"])
|
74
|
-
s.add_dependency(%q<json>, [">= 0"])
|
75
|
-
s.add_dependency(%q<monster_mash>, [">= 0.3.0"])
|
76
|
-
s.add_dependency(%q<signed_request>, [">= 0"])
|
77
|
-
s.add_dependency(%q<json>, [">= 0"])
|
78
|
-
s.add_dependency(%q<rspec>, [">= 1.3.1"])
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
@@ -1,63 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :post
|
5
|
-
uri: http://sandbox.mediapiston.com:80/api/v1/batches
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
user-agent:
|
9
|
-
- MediaPiston API Ruby Client
|
10
|
-
response: !ruby/struct:VCR::Response
|
11
|
-
status: !ruby/struct:VCR::ResponseStatus
|
12
|
-
code: 200
|
13
|
-
message: OK
|
14
|
-
headers:
|
15
|
-
etag:
|
16
|
-
- "\"6b5916d9534bf8744512cada5aa59145\""
|
17
|
-
connection:
|
18
|
-
- keep-alive
|
19
|
-
content-type:
|
20
|
-
- application/json; charset=utf-8
|
21
|
-
server:
|
22
|
-
- nginx/0.7.67
|
23
|
-
date:
|
24
|
-
- Tue, 30 Nov 2010 19:59:32 GMT
|
25
|
-
x-runtime:
|
26
|
-
- "9"
|
27
|
-
content-length:
|
28
|
-
- "44"
|
29
|
-
cache-control:
|
30
|
-
- private, max-age=0, must-revalidate
|
31
|
-
body: "{\"batch_id\":1234567890,\"articles_created\":3}"
|
32
|
-
http_version: "1.1"
|
33
|
-
- !ruby/struct:VCR::HTTPInteraction
|
34
|
-
request: !ruby/struct:VCR::Request
|
35
|
-
method: :post
|
36
|
-
uri: http://localhost:3000/api/v1/batches
|
37
|
-
body:
|
38
|
-
headers:
|
39
|
-
user-agent:
|
40
|
-
- MediaPiston API Ruby Client
|
41
|
-
response: !ruby/struct:VCR::Response
|
42
|
-
status: !ruby/struct:VCR::ResponseStatus
|
43
|
-
code: 200
|
44
|
-
message: OK
|
45
|
-
headers:
|
46
|
-
x-ua-compatible:
|
47
|
-
- IE=Edge
|
48
|
-
etag:
|
49
|
-
- "\"6b5916d9534bf8744512cada5aa59145\""
|
50
|
-
content-type:
|
51
|
-
- application/json; charset=utf-8
|
52
|
-
server:
|
53
|
-
- WEBrick/1.3.1 (Ruby/1.8.7/2011-02-18)
|
54
|
-
date:
|
55
|
-
- Mon, 21 Nov 2011 22:00:49 GMT
|
56
|
-
x-runtime:
|
57
|
-
- "0.258930"
|
58
|
-
content-length:
|
59
|
-
- "44"
|
60
|
-
cache-control:
|
61
|
-
- max-age=0, private, must-revalidate
|
62
|
-
body: "{\"batch_id\":1234567890,\"articles_created\":3}"
|
63
|
-
http_version: "1.1"
|
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :post
|
5
|
-
uri: http://sandbox.mediapiston.com:80/api/v1/batches
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
user-agent:
|
9
|
-
- MediaPiston API Ruby Client
|
10
|
-
response: !ruby/struct:VCR::Response
|
11
|
-
status: !ruby/struct:VCR::ResponseStatus
|
12
|
-
code: 400
|
13
|
-
message: Bad Request
|
14
|
-
headers:
|
15
|
-
content-type:
|
16
|
-
- application/json; charset=utf-8
|
17
|
-
connection:
|
18
|
-
- keep-alive
|
19
|
-
x-runtime:
|
20
|
-
- "4"
|
21
|
-
date:
|
22
|
-
- Tue, 30 Nov 2010 20:02:45 GMT
|
23
|
-
server:
|
24
|
-
- nginx/0.7.67
|
25
|
-
content-length:
|
26
|
-
- "128"
|
27
|
-
cache-control:
|
28
|
-
- no-cache
|
29
|
-
body: "{\"error\":{\"type\":\"InvalidRequest\",\"messages\":[{\"message\":\"Please enter some article titles.\",\"field\":\"order_data.batch.base\"}]}}"
|
30
|
-
http_version: "1.1"
|
31
|
-
- !ruby/struct:VCR::HTTPInteraction
|
32
|
-
request: !ruby/struct:VCR::Request
|
33
|
-
method: :post
|
34
|
-
uri: http://localhost:3000/api/v1/batches
|
35
|
-
body:
|
36
|
-
headers:
|
37
|
-
user-agent:
|
38
|
-
- MediaPiston API Ruby Client
|
39
|
-
response: !ruby/struct:VCR::Response
|
40
|
-
status: !ruby/struct:VCR::ResponseStatus
|
41
|
-
code: 0
|
42
|
-
message:
|
43
|
-
headers: {}
|
44
|
-
|
45
|
-
body: ""
|
46
|
-
http_version:
|
@@ -1,63 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :post
|
5
|
-
uri: http://sandbox.mediapiston.com:80/api/v1/batches
|
6
|
-
body:
|
7
|
-
headers:
|
8
|
-
user-agent:
|
9
|
-
- MediaPiston API Ruby Client
|
10
|
-
response: !ruby/struct:VCR::Response
|
11
|
-
status: !ruby/struct:VCR::ResponseStatus
|
12
|
-
code: 200
|
13
|
-
message: OK
|
14
|
-
headers:
|
15
|
-
etag:
|
16
|
-
- "\"0b37d0aaf9c5640a23ee27de320c67fd\""
|
17
|
-
content-type:
|
18
|
-
- application/json; charset=utf-8
|
19
|
-
connection:
|
20
|
-
- keep-alive
|
21
|
-
x-runtime:
|
22
|
-
- "34"
|
23
|
-
date:
|
24
|
-
- Tue, 14 Dec 2010 23:29:58 GMT
|
25
|
-
server:
|
26
|
-
- nginx/0.7.67
|
27
|
-
content-length:
|
28
|
-
- "44"
|
29
|
-
cache-control:
|
30
|
-
- private, max-age=0, must-revalidate
|
31
|
-
body: "{\"articles_created\":3,\"batch_id\":1234567890}"
|
32
|
-
http_version: "1.1"
|
33
|
-
- !ruby/struct:VCR::HTTPInteraction
|
34
|
-
request: !ruby/struct:VCR::Request
|
35
|
-
method: :post
|
36
|
-
uri: http://localhost:3000/api/v1/batches
|
37
|
-
body:
|
38
|
-
headers:
|
39
|
-
user-agent:
|
40
|
-
- MediaPiston API Ruby Client
|
41
|
-
response: !ruby/struct:VCR::Response
|
42
|
-
status: !ruby/struct:VCR::ResponseStatus
|
43
|
-
code: 200
|
44
|
-
message: OK
|
45
|
-
headers:
|
46
|
-
x-ua-compatible:
|
47
|
-
- IE=Edge
|
48
|
-
etag:
|
49
|
-
- "\"6b5916d9534bf8744512cada5aa59145\""
|
50
|
-
content-type:
|
51
|
-
- application/json; charset=utf-8
|
52
|
-
server:
|
53
|
-
- WEBrick/1.3.1 (Ruby/1.8.7/2011-02-18)
|
54
|
-
date:
|
55
|
-
- Mon, 21 Nov 2011 21:59:32 GMT
|
56
|
-
x-runtime:
|
57
|
-
- "0.185853"
|
58
|
-
content-length:
|
59
|
-
- "44"
|
60
|
-
cache-control:
|
61
|
-
- max-age=0, private, must-revalidate
|
62
|
-
body: "{\"batch_id\":1234567890,\"articles_created\":3}"
|
63
|
-
http_version: "1.1"
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
def mock_batch(articles)
|
4
|
-
{
|
5
|
-
'batch' => {
|
6
|
-
'name' => 'Mock Batch',
|
7
|
-
'minimum_words' => 250,
|
8
|
-
'topic_overview_instructions' => 'Basic instructions.',
|
9
|
-
'articles' => articles
|
10
|
-
}
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
def mock_article(topic, options = {})
|
15
|
-
article = {
|
16
|
-
'topic' => topic,
|
17
|
-
'metadata' => 'my metadata'
|
18
|
-
}
|
19
|
-
|
20
|
-
if options[:key_phrases]
|
21
|
-
article['key_phrases'] = [
|
22
|
-
{ 'text' => 'savings', 'minimum' => 1 },
|
23
|
-
{ 'text' => 'keyword', 'maximum' => 5 }
|
24
|
-
]
|
25
|
-
end
|
26
|
-
|
27
|
-
article
|
28
|
-
end
|
29
|
-
|
30
|
-
describe PistonApi::Client do
|
31
|
-
describe "#create_batch" do
|
32
|
-
describe "a basic batch" do
|
33
|
-
before(:all) do
|
34
|
-
@articles = []
|
35
|
-
3.times { |i| @articles << mock_article("Article #{i}") }
|
36
|
-
@batch = mock_batch(@articles)
|
37
|
-
end
|
38
|
-
|
39
|
-
use_vcr_cassette 'create_batch/basic', :record => :new_episodes
|
40
|
-
|
41
|
-
it "should post correctly" do
|
42
|
-
result = PistonApi::Client.create_batch(@batch)
|
43
|
-
result['articles_created'].should == 3
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "a batch with key phrases" do
|
48
|
-
use_vcr_cassette 'create_batch/key_phrases', :record => :new_episodes
|
49
|
-
|
50
|
-
before(:all) do
|
51
|
-
@articles = []
|
52
|
-
3.times { |i| @articles << mock_article("Article #{i}",
|
53
|
-
:key_phrases => true) }
|
54
|
-
@batch = mock_batch(@articles)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should create 3 articles" do
|
58
|
-
result = PistonApi::Client.create_batch(@batch)
|
59
|
-
result['articles_created'].should == 3
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "a batch with errors" do
|
64
|
-
use_vcr_cassette 'create_batch/errors', :record => :new_episodes
|
65
|
-
|
66
|
-
it "should raise an error with no articles" do
|
67
|
-
batch = mock_batch([])
|
68
|
-
lambda {
|
69
|
-
PistonApi::Client.create_batch(batch)
|
70
|
-
}.should raise_error
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
data/spec/piston_api_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PistonApi do
|
4
|
-
describe "VERSION" do
|
5
|
-
it "should not be blank" do
|
6
|
-
PistonApi::VERSION.should_not be_nil
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#api_key" do
|
11
|
-
it "should be settable" do
|
12
|
-
PistonApi.api_key = 'fdsafdsa'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should be gettable" do
|
16
|
-
PistonApi.api_key = 'fdsafdsa'
|
17
|
-
PistonApi.api_key.should == 'fdsafdsa'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#sandbox" do
|
22
|
-
it "should be settable" do
|
23
|
-
PistonApi.sandbox = true
|
24
|
-
PistonApi.sandbox?.should be_true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/spec/spec_helper.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
require 'piston_api'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
6
|
-
require 'vcr'
|
7
|
-
|
8
|
-
PistonApi.sandbox = true
|
9
|
-
PistonApi.api_key = 'a688c8abd25fd37e50e8512e75aebbe2d869510368a58f66b6f9f00ed8de'
|
10
|
-
PistonApi.private_key = '65469e402f88852f338c79f8e8171ebaf2f6d5a28879799ea9a17c8a6b67'
|
11
|
-
|
12
|
-
VCR.config do |c|
|
13
|
-
c.cassette_library_dir = File.dirname(__FILE__) + "/fixtures/vcr_cassettes"
|
14
|
-
c.stub_with :typhoeus
|
15
|
-
end
|
16
|
-
|
17
|
-
Spec::Runner.configure do |config|
|
18
|
-
config.extend VCR::RSpec::Macros
|
19
|
-
end
|