quinoa 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/Gemfile.lock +4 -9
- data/README.md +1 -1
- data/Rakefile +1 -4
- data/changelog +4 -1
- data/lib/quinoa/service.rb +15 -7
- data/lib/quinoa/version.rb +1 -1
- data/quinoa.gemspec +1 -1
- data/spec/service_object_spec.rb +37 -0
- data/spec/spec_helper.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09a422a353b5c8594abff8e280cb247b2784b992
|
4
|
+
data.tar.gz: a373bf8ea1021939e4f20c208d7832a4f6d494f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9e0a10fc74665aa9f428e8291c52d2113320d7e900756763fffddff1aad475a1ced2cfd170432f42206c87f73cbff0093c0cdd95e99cc476092a944a77963d4
|
7
|
+
data.tar.gz: f6708b08501f673acd3ff244dbfe460aa64ab3b13b6c251f4347904c37241e65a324e529cbab0a4c5125633c17ede23d8c7ef7c0bb57278e0b6253cdc85e9bd2
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
quinoa (0.0.
|
4
|
+
quinoa (0.0.6)
|
5
5
|
rest-client (~> 1.8.0)
|
6
6
|
rspec (~> 3.3.0)
|
7
7
|
|
@@ -10,13 +10,9 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
addressable (2.3.8)
|
12
12
|
builder (3.2.2)
|
13
|
+
codeclimate-test-reporter (0.4.8)
|
14
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
13
15
|
coderay (1.1.0)
|
14
|
-
coveralls (0.8.2)
|
15
|
-
json (~> 1.8)
|
16
|
-
rest-client (>= 1.6.8, < 2)
|
17
|
-
simplecov (~> 0.10.0)
|
18
|
-
term-ansicolor (~> 1.3)
|
19
|
-
thor (~> 0.19.1)
|
20
16
|
crack (0.4.2)
|
21
17
|
safe_yaml (~> 1.0.0)
|
22
18
|
cucumber (0.10.7)
|
@@ -70,7 +66,6 @@ GEM
|
|
70
66
|
slop (3.6.0)
|
71
67
|
term-ansicolor (1.3.2)
|
72
68
|
tins (~> 1.0)
|
73
|
-
thor (0.19.1)
|
74
69
|
tins (1.6.0)
|
75
70
|
unf (0.1.4)
|
76
71
|
unf_ext
|
@@ -83,7 +78,7 @@ PLATFORMS
|
|
83
78
|
ruby
|
84
79
|
|
85
80
|
DEPENDENCIES
|
86
|
-
|
81
|
+
codeclimate-test-reporter (~> 0)
|
87
82
|
cucumber (~> 0)
|
88
83
|
nyan-cat-formatter (~> 0)
|
89
84
|
pry (~> 0)
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ quinoa
|
|
5
5
|
[![Build Status](https://travis-ci.org/camiloribeiro/quinoa.png?branch=master)](https://travis-ci.org/camiloribeiro/quinoa)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/camiloribeiro/quinoa.png)](https://codeclimate.com/github/camiloribeiro/quinoa)
|
7
7
|
[![Dependency Status](https://gemnasium.com/camiloribeiro/quinoa.png)](https://gemnasium.com/camiloribeiro/quinoa)
|
8
|
-
[![Coverage
|
8
|
+
[![Test Coverage](https://codeclimate.com/github/camiloribeiro/quinoa/badges/coverage.svg)](https://codeclimate.com/github/camiloribeiro/quinoa/coverage)
|
9
9
|
[![endorse](https://api.coderwall.com/camiloribeiro/endorsecount.png)](https://coderwall.com/camiloribeiro)
|
10
10
|
|
11
11
|
![alt tag](http://i.huffpost.com/gen/1821327/images/n-QUINOA-large570.jpg)
|
data/Rakefile
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
require "cucumber/rake/task"
|
2
2
|
require 'rspec/core/rake_task'
|
3
|
-
require 'coveralls/rake/task'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
task :default => [:spec,:run, 'coveralls:push']
|
4
|
+
task :default => [:spec]
|
8
5
|
|
9
6
|
RSpec::Core::RakeTask .new(:spec) do |task|
|
10
7
|
task.rspec_opts = ["--format documentation"]
|
data/changelog
CHANGED
data/lib/quinoa/service.rb
CHANGED
@@ -2,26 +2,34 @@ require "rest-client"
|
|
2
2
|
|
3
3
|
module Quinoa
|
4
4
|
class Service
|
5
|
-
|
5
|
+
|
6
6
|
attr_accessor :url, :content_type, :accept, :body, :response, :path, :authorization
|
7
|
-
|
7
|
+
|
8
8
|
def initialize url
|
9
9
|
self.path = ""
|
10
10
|
self.authorization = ""
|
11
11
|
self.url = url
|
12
12
|
end
|
13
|
-
|
14
|
-
def post!
|
13
|
+
|
14
|
+
def post! url=nil
|
15
15
|
begin
|
16
|
-
|
16
|
+
if url == nil
|
17
|
+
self.response = RestClient.post self.url + self.path, self.body, :accept => self.accept, :content_type => self.content_type, :authorization => self.authorization
|
18
|
+
else
|
19
|
+
self.response = RestClient.post url, self.body, :accept => self.accept, :content_type => self.content_type, :authorization => self.authorization
|
20
|
+
end
|
17
21
|
rescue => e
|
18
22
|
self.response = e.response
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
22
|
-
def get!
|
26
|
+
def get! url=nil
|
23
27
|
begin
|
24
|
-
|
28
|
+
if url == nil
|
29
|
+
self.response = RestClient.get self.url + self.path, :accept => self.accept, :authorization => self.authorization
|
30
|
+
else
|
31
|
+
self.response = RestClient.get url, :accept => self.accept, :authorization => self.authorization
|
32
|
+
end
|
25
33
|
rescue => e
|
26
34
|
self.response = e.response
|
27
35
|
end
|
data/lib/quinoa/version.rb
CHANGED
data/quinoa.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
24
|
s.add_development_dependency 'simplecov', '~> 0'
|
25
|
-
s.add_development_dependency '
|
25
|
+
s.add_development_dependency 'codeclimate-test-reporter', '~> 0'
|
26
26
|
s.add_development_dependency 'pry', '~> 0'
|
27
27
|
s.add_development_dependency 'rake', '~> 0'
|
28
28
|
s.add_development_dependency 'nyan-cat-formatter', '~> 0'
|
data/spec/service_object_spec.rb
CHANGED
@@ -42,6 +42,43 @@ describe Quinoa do
|
|
42
42
|
|
43
43
|
end
|
44
44
|
|
45
|
+
describe "overwiting the entire url to post and get" do
|
46
|
+
|
47
|
+
before(:each) do
|
48
|
+
stub_request(:any, "http://www.bugbang.com.br/foo").
|
49
|
+
to_return(:status => 200, :body => "simple response", :headers => {:accept=>"application/xml", :content_type => "application/json"})
|
50
|
+
|
51
|
+
@service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
52
|
+
@service.path = "/something"
|
53
|
+
@service.content_type = "application/json"
|
54
|
+
@service.authorization = "token !#€%&/()="
|
55
|
+
@service.body = "simple body"
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should overwite for get" do
|
60
|
+
@service.get! "http://www.bugbang.com.br/foo"
|
61
|
+
|
62
|
+
# explicity
|
63
|
+
expect(@service.response.headers[:accept]).to eq("application/xml")
|
64
|
+
expect(@service.response.headers[:content_type]).to eq("application/json")
|
65
|
+
expect(@service.response.body).to eq("simple response")
|
66
|
+
expect(@service.authorization).to eq "token !#€%&/()="
|
67
|
+
expect(@service.response.code).to eq(200)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should overwite for post" do
|
71
|
+
@service.post! "http://www.bugbang.com.br/foo"
|
72
|
+
|
73
|
+
# explicity
|
74
|
+
expect(@service.response.headers[:accept]).to eq("application/xml")
|
75
|
+
expect(@service.response.headers[:content_type]).to eq("application/json")
|
76
|
+
expect(@service.response.body).to eq("simple response")
|
77
|
+
expect(@service.authorization).to eq "token !#€%&/()="
|
78
|
+
expect(@service.response.code).to eq(200)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
45
82
|
|
46
83
|
describe "defining a different paths" do
|
47
84
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'webmock/rspec'
|
3
|
-
require
|
4
|
-
|
5
|
-
Coveralls.wear_merged!
|
3
|
+
require "codeclimate-test-reporter"
|
4
|
+
CodeClimate::TestReporter.start
|
6
5
|
|
7
6
|
|
8
7
|
RSpec.configure do |config|
|
9
8
|
config.color = true
|
10
9
|
config.formatter = 'documentation'
|
10
|
+
WebMock.disable_net_connect!(allow: %w{codeclimate.com})
|
11
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quinoa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: codeclimate-test-reporter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|