chimp_rewriter 1.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.travis.yml +21 -0
- data/COPYING-BSD +23 -0
- data/COPYING-ISC +13 -0
- data/COPYING-RUBY +57 -0
- data/Gemfile +4 -0
- data/Guardfile +7 -0
- data/README.adoc +63 -0
- data/Rakefile +2 -0
- data/chimp_rewriter.gemspec +32 -0
- data/lib/chimp_rewriter.rb +70 -0
- data/lib/chimp_rewriter/version.rb +3 -0
- data/spec/api_actions_spec.rb +77 -0
- data/spec/chimp_rewriter_spec.rb +74 -0
- data/spec/spec_helper.rb +93 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ff92b1ec2d65a7afb7061a7ab425fcfc572f1a74
|
4
|
+
data.tar.gz: 7efe578ba21ed281a38d03c0428736f463874f9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdfc7c85b4785778029e6da041a2efd068287c58f21b085613aae20ecaa4fd39c829b41810cce29d54a5888227c8d6622754e05c6cbe2caad9dd7c007f535502
|
7
|
+
data.tar.gz: bd6cbd2200967c78b9f6c1e2f614ee8a8864519d48029cc24e85cdc48ad83ea2126ca85bee47a15d33c95d08e10613328811c6877a0a8a010101ef844e3dcfca
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.gemrelease
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
script: bundle exec rspec --warnings
|
4
|
+
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- "2.0"
|
8
|
+
- ruby-head
|
9
|
+
- jruby
|
10
|
+
- jruby-head
|
11
|
+
- rbx-2
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
include:
|
15
|
+
# One build designated to check test coverage with Coveralls.
|
16
|
+
- rvm: "2.1"
|
17
|
+
env: RUN_COVERALLS=true
|
18
|
+
|
19
|
+
allow_failures:
|
20
|
+
- rvm: ruby-head
|
21
|
+
- rvm: jruby-head
|
data/COPYING-BSD
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2014 Sebastian Skałacki
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
15
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
16
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/COPYING-ISC
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2014 Sebastian Skałacki
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
4
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
5
|
+
and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
12
|
+
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
13
|
+
OR PERFORMANCE OF THIS SOFTWARE.
|
data/COPYING-RUBY
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Chimp Rewriter is copyrighted free software
|
2
|
+
by Sebastian Skałacki <skalee@gmail.com>.
|
3
|
+
|
4
|
+
You can redistribute it and/or modify it under conditions below:
|
5
|
+
|
6
|
+
1. You may make and give away verbatim copies of the source form of the
|
7
|
+
software without restriction, provided that you duplicate all of the
|
8
|
+
original copyright notices and associated disclaimers.
|
9
|
+
|
10
|
+
2. You may modify your copy of the software in any way, provided that
|
11
|
+
you do at least ONE of the following:
|
12
|
+
|
13
|
+
a) place your modifications in the Public Domain or otherwise
|
14
|
+
make them Freely Available, such as by posting said
|
15
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
16
|
+
the author to include your modifications in the software.
|
17
|
+
|
18
|
+
b) use the modified software only within your corporation or
|
19
|
+
organization.
|
20
|
+
|
21
|
+
c) give non-standard binaries non-standard names, with
|
22
|
+
instructions on where to get the original software distribution.
|
23
|
+
|
24
|
+
d) make other distribution arrangements with the author.
|
25
|
+
|
26
|
+
3. You may distribute the software in object code or binary form,
|
27
|
+
provided that you do at least ONE of the following:
|
28
|
+
|
29
|
+
a) distribute the binaries and library files of the software,
|
30
|
+
together with instructions (in the manual page or equivalent)
|
31
|
+
on where to get the original distribution.
|
32
|
+
|
33
|
+
b) accompany the distribution with the machine-readable source of
|
34
|
+
the software.
|
35
|
+
|
36
|
+
c) give non-standard binaries non-standard names, with
|
37
|
+
instructions on where to get the original software distribution.
|
38
|
+
|
39
|
+
d) make other distribution arrangements with the author.
|
40
|
+
|
41
|
+
4. You may modify and include the part of the software into any other
|
42
|
+
software (possibly commercial). But some files in the distribution
|
43
|
+
are not written by the author, so that they are not under these terms.
|
44
|
+
|
45
|
+
For the list of those files and their copying conditions, see the
|
46
|
+
file LEGAL.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.adoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
ChimpRewriter
|
2
|
+
=============
|
3
|
+
|
4
|
+
The project provides tools to make requests to the Chimp Rewriter API. The API
|
5
|
+
is used to automatically spin and rewrite articles using a host of intelligent
|
6
|
+
algorithms, phrases and synonyms.
|
7
|
+
|
8
|
+
The API clones features of the automatic rewriting available in the desktop
|
9
|
+
version of Chimp Rewriter. This is a content/article spinner and rewriter which
|
10
|
+
you can find out about here: http://chimprewriter.com
|
11
|
+
|
12
|
+
|
13
|
+
Usage
|
14
|
+
-----
|
15
|
+
|
16
|
+
Instantiate client with proper e-mail, application identifier and API key.
|
17
|
+
(Current API do not check application identifier at all and it can contain
|
18
|
+
arbitrary string, however it will change in future). Two methods:
|
19
|
+
+chimp_rewrite+ and +create_spin+ accept text as the first parameter and
|
20
|
+
return text as well. Additional options may be passed in optional hash.
|
21
|
+
+#statistics+ returns account usage statistics, limits etc.
|
22
|
+
|
23
|
+
More detailed description here: http://chimprewriter.com/api/documentation/
|
24
|
+
|
25
|
+
+ChimpRewriter::ChimpRewriterError+ with more details may be raised in case of
|
26
|
+
failure.
|
27
|
+
|
28
|
+
[source,Ruby]
|
29
|
+
-------------
|
30
|
+
client = ChimpRewriter.new(email, application_identifier, api_key) }
|
31
|
+
client.statistics
|
32
|
+
# => OpenStruct, contains statistics
|
33
|
+
client.chimp_rewrite "I wandered lonely as a cloud", quality: 4
|
34
|
+
# => String, spin results
|
35
|
+
client.create_spin "I wandered lonely as a cloud", reorderparagraphs: true
|
36
|
+
# => String, spin results
|
37
|
+
-------------
|
38
|
+
|
39
|
+
|
40
|
+
Installation
|
41
|
+
------------
|
42
|
+
|
43
|
+
Add this line to your application's Gemfile:
|
44
|
+
|
45
|
+
gem 'chimp_rewriter'
|
46
|
+
|
47
|
+
And then execute:
|
48
|
+
|
49
|
+
$ bundle
|
50
|
+
|
51
|
+
Or install it yourself as:
|
52
|
+
|
53
|
+
$ gem install chimp_rewriter
|
54
|
+
|
55
|
+
|
56
|
+
Contributing
|
57
|
+
------------
|
58
|
+
|
59
|
+
1. Fork it ( https://github.com/[my-github-username]/chimp_rewriter/fork )
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chimp_rewriter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chimp_rewriter"
|
8
|
+
spec.version = ChimpRewriter::VERSION
|
9
|
+
spec.authors = ["Sebastian Skałacki"]
|
10
|
+
spec.email = ["skalee@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby wrapper for Chimp Rewriter API}
|
12
|
+
spec.description = %q{The project provides tools to make requests to the } +
|
13
|
+
%q{Chimp Rewriter API. The API is used to } +
|
14
|
+
%q{automatically spin and rewrite articles us+ng } +
|
15
|
+
%q{a host of intelligent algorithms, phrases } +
|
16
|
+
%q{and synonyms.}
|
17
|
+
spec.homepage = "http://chimprewriter.com/api/documentation/"
|
18
|
+
spec.license = "Ruby, ISC, 2-clause BSD"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "httparty"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "guard-rspec"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "webmock"
|
32
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "chimp_rewriter/version"
|
2
|
+
require "httparty"
|
3
|
+
|
4
|
+
class ChimpRewriter
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
class ChimpRewriterError < StandardError ; end
|
8
|
+
|
9
|
+
base_uri "https://api.chimprewriter.com"
|
10
|
+
|
11
|
+
attr_reader :email, :app_id, :api_key
|
12
|
+
|
13
|
+
def initialize email, app_id, api_key
|
14
|
+
@email = email
|
15
|
+
@app_id = app_id
|
16
|
+
@api_key = api_key
|
17
|
+
end
|
18
|
+
|
19
|
+
def authentication_params
|
20
|
+
{email: email, aid: app_id, apikey: api_key}
|
21
|
+
end
|
22
|
+
|
23
|
+
def statistics
|
24
|
+
response_hash = make_request "Statistics"
|
25
|
+
response_hash.delete "error"
|
26
|
+
response_hash.each_pair do |key, value|
|
27
|
+
response_hash[key] = value.to_i if value.to_i.to_s == value
|
28
|
+
end
|
29
|
+
OpenStruct.new response_hash
|
30
|
+
end
|
31
|
+
|
32
|
+
def chimp_rewrite text, options = {}
|
33
|
+
response_hash = make_request "ChimpRewrite", options.merge(text: text)
|
34
|
+
response_hash["output"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_spin text, options = {}
|
38
|
+
response_hash = make_request "CreateSpin", options.merge(text: text)
|
39
|
+
response_hash["output"]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def make_request action, additional_params = {}
|
45
|
+
translated_params = translate_request_params_to_api additional_params
|
46
|
+
request_params = authentication_params.merge translated_params
|
47
|
+
raw_response = self.class.post("/#{action}", body: request_params)
|
48
|
+
response_hash = JSON.parse raw_response.body
|
49
|
+
|
50
|
+
if /\w/ =~ response_hash["error"]
|
51
|
+
raise ChimpRewriterError, response_hash["error"]
|
52
|
+
elsif response_hash["status"] == "failure"
|
53
|
+
raise ChimpRewriterError, response_hash["output"]
|
54
|
+
end
|
55
|
+
|
56
|
+
response_hash
|
57
|
+
end
|
58
|
+
|
59
|
+
def translate_request_params_to_api options
|
60
|
+
options.each_pair.inject({}) do |acc, (key, value)|
|
61
|
+
case value
|
62
|
+
when true, false then translated_value = value ? "1" : "0"
|
63
|
+
else translated_value = value
|
64
|
+
end
|
65
|
+
acc[key] = translated_value
|
66
|
+
acc
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Available API actions" do
|
4
|
+
|
5
|
+
let(:app_id){ "test.application.identifier" }
|
6
|
+
let(:email){ "myself@example.test" }
|
7
|
+
let(:api_key){ "12345" }
|
8
|
+
let(:client){ ChimpRewriter.new(email, app_id, api_key) }
|
9
|
+
let(:login_params){ { email: email, apikey: api_key, aid: app_id } }
|
10
|
+
|
11
|
+
example "Statistics call" do
|
12
|
+
stub_request(:post, "https://api.chimprewriter.com/Statistics")
|
13
|
+
.with(body: login_params)
|
14
|
+
.to_return(body: {
|
15
|
+
"error" => "",
|
16
|
+
"remainingthismonth" => "300",
|
17
|
+
"prolimit" => "1000",
|
18
|
+
"proexpiry" => "XXX",
|
19
|
+
"apilimit" => "0",
|
20
|
+
"apiexpiry" => "XXX",
|
21
|
+
"usedtoday" => "23",
|
22
|
+
"usedthismonth" => "700",
|
23
|
+
"usedever" => "6980",
|
24
|
+
}.to_json)
|
25
|
+
|
26
|
+
retval = client.statistics
|
27
|
+
|
28
|
+
expect(retval).to be_an(OpenStruct)
|
29
|
+
expect(retval.to_h).to eq({
|
30
|
+
remainingthismonth: 300,
|
31
|
+
prolimit: 1000,
|
32
|
+
proexpiry: "XXX",
|
33
|
+
apilimit: 0,
|
34
|
+
apiexpiry: "XXX",
|
35
|
+
usedtoday: 23,
|
36
|
+
usedthismonth: 700,
|
37
|
+
usedever: 6980,
|
38
|
+
})
|
39
|
+
end
|
40
|
+
|
41
|
+
example "CreateSpin call" do
|
42
|
+
req = stub_request(:post, "https://api.chimprewriter.com/CreateSpin")
|
43
|
+
.with(body: login_params.merge({
|
44
|
+
text: "I wandered lonely as a cloud",
|
45
|
+
dontuseoriginal: "1",
|
46
|
+
reorderparagraphs: "0",
|
47
|
+
}))
|
48
|
+
.to_return(body: {
|
49
|
+
status: "success",
|
50
|
+
output: "That floats on high o'er vales and hills",
|
51
|
+
}.to_json)
|
52
|
+
|
53
|
+
retval = client.create_spin "I wandered lonely as a cloud", dontuseoriginal: true, reorderparagraphs: false
|
54
|
+
|
55
|
+
expect(retval).to eq("That floats on high o'er vales and hills")
|
56
|
+
expect(req).to have_been_requested
|
57
|
+
end
|
58
|
+
|
59
|
+
example "ChimpRewrite call" do
|
60
|
+
req = stub_request(:post, "https://api.chimprewriter.com/ChimpRewrite")
|
61
|
+
.with(body: login_params.merge({
|
62
|
+
text: "I wandered lonely as a cloud",
|
63
|
+
quality: "4",
|
64
|
+
grammarcheck: "0",
|
65
|
+
}))
|
66
|
+
.to_return(body: {
|
67
|
+
status: "success",
|
68
|
+
output: "That floats on high o'er vales and hills",
|
69
|
+
}.to_json)
|
70
|
+
|
71
|
+
retval = client.chimp_rewrite "I wandered lonely as a cloud", quality: 4, grammarcheck: false
|
72
|
+
|
73
|
+
expect(retval).to eq("That floats on high o'er vales and hills")
|
74
|
+
expect(req).to have_been_requested
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ChimpRewriter do
|
4
|
+
|
5
|
+
let(:app_id){ "test.application.identifier" }
|
6
|
+
let(:email){ "myself@example.test" }
|
7
|
+
let(:api_key){ "12345" }
|
8
|
+
let(:client){ described_class.new(email, app_id, api_key) }
|
9
|
+
let(:login_params){ { email: email, apikey: api_key, aid: app_id } }
|
10
|
+
|
11
|
+
describe "::new" do
|
12
|
+
subject{ described_class.method :new }
|
13
|
+
|
14
|
+
it "instantiates API client and sets up e-mail, api key and application ID" do
|
15
|
+
instance = subject.(email, app_id, api_key)
|
16
|
+
expect(instance.email).to eq(email)
|
17
|
+
expect(instance.app_id).to eq(app_id)
|
18
|
+
expect(instance.api_key).to eq(api_key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
describe "#authentication_params" do
|
24
|
+
subject{ client.method :authentication_params }
|
25
|
+
|
26
|
+
it "returns all login credentials" do
|
27
|
+
expect(subject.()).to eq(login_params)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
describe "#make_request" do
|
33
|
+
subject{ client.method :make_request }
|
34
|
+
let(:action_url){ "https://api.chimprewriter.com/Action" }
|
35
|
+
|
36
|
+
it "makes POST request on API with path equal to passed action " \
|
37
|
+
"and setting login credentials and any additional params" do
|
38
|
+
rs = stub_request(:post, action_url)
|
39
|
+
.with(body: login_params.merge(also: "this one"))
|
40
|
+
.to_return(status: 200, body: "{}")
|
41
|
+
subject.("Action", also: "this one")
|
42
|
+
expect(rs).to have_been_requested
|
43
|
+
end
|
44
|
+
|
45
|
+
it "raises ChimpRewriterError when response JSON has error field set" do
|
46
|
+
stub_request(:post, action_url).to_return(body: %q[{"error":"Problem desc"}])
|
47
|
+
expect{
|
48
|
+
subject.("Action")
|
49
|
+
}.to raise_error(ChimpRewriter::ChimpRewriterError)
|
50
|
+
.with_message("Problem desc")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "raises ChimpRewriterError when response JSON has status field set to failure" do
|
54
|
+
stub_request(:post, action_url).to_return(body: %q[{"status": "failure", "output": "Problem desc"}])
|
55
|
+
expect{
|
56
|
+
subject.("Action")
|
57
|
+
}.to raise_error(ChimpRewriter::ChimpRewriterError)
|
58
|
+
.with_message("Problem desc")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns OpenStruct which reflects response JSON when neither status nor error fields indicate problems" do
|
62
|
+
stub_request(:post, action_url).to_return(
|
63
|
+
{body: %q[{"error": "", "param": "value"}]},
|
64
|
+
{body: %q[{"status": "success", "param": "value"}]}
|
65
|
+
)
|
66
|
+
2.times do
|
67
|
+
retval = subject.("Action")
|
68
|
+
expect(retval).to be_a(Hash)
|
69
|
+
expect(retval["param"]).to eq("value")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require "chimp_rewriter"
|
2
|
+
|
3
|
+
require "webmock/rspec"
|
4
|
+
|
5
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
7
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
8
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
9
|
+
#
|
10
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
11
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
12
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
13
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
14
|
+
# a separate helper file that requires the additional dependencies and performs
|
15
|
+
# the additional setup, and require it from the spec files that actually need it.
|
16
|
+
#
|
17
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
18
|
+
# users commonly want.
|
19
|
+
#
|
20
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
24
|
+
# assertions if you prefer.
|
25
|
+
config.expect_with :rspec do |expectations|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
28
|
+
# defined using `chain`, e.g.:
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
31
|
+
# ...rather than:
|
32
|
+
# # => "be bigger than 2"
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
38
|
+
config.mock_with :rspec do |mocks|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
40
|
+
# a real object. This is generally recommended, and will default to
|
41
|
+
# `true` in RSpec 4.
|
42
|
+
mocks.verify_partial_doubles = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# The settings below are suggested to provide a good initial experience
|
46
|
+
# with RSpec, but feel free to customize to your heart's content.
|
47
|
+
=begin
|
48
|
+
# These two settings work together to allow you to limit a spec run
|
49
|
+
# to individual examples or groups you care about by tagging them with
|
50
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
51
|
+
# get run.
|
52
|
+
config.filter_run :focus
|
53
|
+
config.run_all_when_everything_filtered = true
|
54
|
+
|
55
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
56
|
+
# For more details, see:
|
57
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
58
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
59
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
60
|
+
config.disable_monkey_patching!
|
61
|
+
|
62
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
63
|
+
# be too noisy due to issues in dependencies.
|
64
|
+
config.warnings = true
|
65
|
+
|
66
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
67
|
+
# file, and it's useful to allow more verbose output when running an
|
68
|
+
# individual spec file.
|
69
|
+
if config.files_to_run.one?
|
70
|
+
# Use the documentation formatter for detailed output,
|
71
|
+
# unless a formatter has already been configured
|
72
|
+
# (e.g. via a command-line flag).
|
73
|
+
config.default_formatter = 'doc'
|
74
|
+
end
|
75
|
+
|
76
|
+
# Print the 10 slowest examples and example groups at the
|
77
|
+
# end of the spec run, to help surface which specs are running
|
78
|
+
# particularly slow.
|
79
|
+
config.profile_examples = 10
|
80
|
+
|
81
|
+
# Run specs in random order to surface order dependencies. If you find an
|
82
|
+
# order dependency and want to debug it, you can fix the order by providing
|
83
|
+
# the seed, which is printed after each run.
|
84
|
+
# --seed 1234
|
85
|
+
config.order = :random
|
86
|
+
|
87
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
88
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
89
|
+
# test failures related to randomization by passing the same `--seed` value
|
90
|
+
# as the one that triggered the failure.
|
91
|
+
Kernel.srand config.seed
|
92
|
+
=end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chimp_rewriter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastian Skałacki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: The project provides tools to make requests to the Chimp Rewriter API. The
|
98
|
+
API is used to automatically spin and rewrite articles us+ng a host of intelligent
|
99
|
+
algorithms, phrases and synonyms.
|
100
|
+
email:
|
101
|
+
- skalee@gmail.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
109
|
+
- COPYING-BSD
|
110
|
+
- COPYING-ISC
|
111
|
+
- COPYING-RUBY
|
112
|
+
- Gemfile
|
113
|
+
- Guardfile
|
114
|
+
- README.adoc
|
115
|
+
- Rakefile
|
116
|
+
- chimp_rewriter.gemspec
|
117
|
+
- lib/chimp_rewriter.rb
|
118
|
+
- lib/chimp_rewriter/version.rb
|
119
|
+
- spec/api_actions_spec.rb
|
120
|
+
- spec/chimp_rewriter_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
homepage: http://chimprewriter.com/api/documentation/
|
123
|
+
licenses:
|
124
|
+
- Ruby, ISC, 2-clause BSD
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 1.3.1
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.2.2
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Ruby wrapper for Chimp Rewriter API
|
146
|
+
test_files:
|
147
|
+
- spec/api_actions_spec.rb
|
148
|
+
- spec/chimp_rewriter_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
has_rdoc:
|