reclame_aqui 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f7bad183f5b8d5def5f093ca2cd1b2bb49f6f41a
4
+ data.tar.gz: bc6c591e31a7054dc8fdb3fb20fcc82ece60c867
5
+ SHA512:
6
+ metadata.gz: 21d1a33d742a50409c6e86ee3bfb29ed90bd753f95236cd5bf48db28cf9f74d57047d41965f528b96fd8c77944814c465bb73755221333fe77d5803a00a54e08
7
+ data.tar.gz: 66d17e0558d07c4bc47dfe86ebb9a1eec63e6c2cd035d13382304287b87e63edc45d65df2112df407190dc31d11dd825bd0fb76e42c9eb46bbc788646a813584
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-2.1.5@reclame_aqui
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Gabriel Givigier
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # ReclameAqui
2
+
3
+ A gem that verify the reputation of a company in ReclameAqui.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'reclame_aqui'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install reclame_aqui
20
+
21
+ ## Usage
22
+
23
+ ReclameAqui.reputation("http://company.com")
24
+
25
+ ## Contributors
26
+ Pedro Dias( https://github.com/pdf13 )
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/givigier/reclame_aqui/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,9 @@
1
+ require "net/http"
2
+ require "reclame_aqui/version"
3
+ require "reclame_aqui/reputation_by_website"
4
+
5
+ module ReclameAqui
6
+ def self.reputation(term)
7
+ ReputationByWebsite.new(term).get_reputation
8
+ end
9
+ end
@@ -0,0 +1,47 @@
1
+ require "json"
2
+
3
+ class ReclameAqui::ReputationByWebsite
4
+ def initialize(website)
5
+ @website = website
6
+ end
7
+
8
+ def get_reputation
9
+ begin
10
+ response = do_request
11
+ format_response JSON.parse(response.body)
12
+ rescue
13
+ { error: true, reputation: {} }
14
+ end
15
+ end
16
+
17
+ private
18
+ def do_request
19
+ uri = URI.parse "http://app02.reclameaqui.com.br/reputacao"
20
+ http = Net::HTTP.new uri.host, uri.port
21
+ response = http.post uri.path, "url=#{@website}", {}
22
+ end
23
+
24
+ def format_response data
25
+ reputation = data["reputacao"]
26
+ status = reputation["status"] || []
27
+ { error: false,
28
+ reputation: {
29
+ id: reputation["empresa_id"].to_i,
30
+ name: reputation["nome_empresa"],
31
+ period: reputation["periodo"].to_i,
32
+ status: status["status_id"].to_i,
33
+ complaints: reputation["reclamacoes"].to_i,
34
+ answered: reputation["respondidas"].to_i,
35
+ not_answered: reputation["nao_respondidas"].to_i,
36
+ measured: reputation["avaliadas"].to_i,
37
+ solution_index: reputation["indice_solucao"].to_i,
38
+ would_return: reputation["voltaria_fazer_negocio"].to_i,
39
+ grade: reputation["nota_consumidor"].to_i,
40
+ time_to_response: reputation["tempo_resposta"],
41
+ chat: reputation["chat"].to_i,
42
+ fone: reputation["fone"].to_i,
43
+ show_selo: reputation["show_selo"].to_i
44
+ }
45
+ }
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module ReclameAqui
2
+ VERSION = "0.0.2"
3
+ end
Binary file
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'reclame_aqui/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "reclame_aqui"
8
+ spec.version = ReclameAqui::VERSION
9
+ spec.authors = ["Gabriel Givigier", "Pedro Dias"]
10
+ spec.email = ["gabriel@agrid.com.br", "pedro@agrid.com.br"]
11
+ spec.summary = %q{Company verification in ReclameAqui.}
12
+ spec.description = %q{A gem that verify the reputation of a company in ReclameAqui.}
13
+ spec.homepage = "https://github.com/givigier/reclame_aqui"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.1.0"
24
+ spec.add_development_dependency "json", "~> 1.8.2"
25
+ end
@@ -0,0 +1,87 @@
1
+ require "spec_helper"
2
+
3
+ describe ReclameAqui::ReputationByWebsite do
4
+ context "when passing an invalid website" do
5
+ let!(:reclame_aqui){ ReclameAqui::ReputationByWebsite.new("http://").get_reputation }
6
+ let!(:error){ reclame_aqui[:error] }
7
+ let!(:reputation){ reclame_aqui[:reputation] }
8
+
9
+ it "should return a hash with error equal true" do
10
+ expect(error).to eq true
11
+ end
12
+
13
+ it "should return an empty reputation" do
14
+ expect(reputation).to eq Hash.new({})
15
+ end
16
+ end
17
+
18
+ context "when passing a valid website" do
19
+ let!(:reclame_aqui){ ReclameAqui::ReputationByWebsite.new("http://ricardoeletro.com.br").get_reputation }
20
+ let!(:error){ reclame_aqui[:error] }
21
+ let!(:reputation){ reclame_aqui[:reputation] }
22
+
23
+ it "should return a hash with error equal false" do
24
+ expect(error).to eq false
25
+ end
26
+
27
+ it "should return the reputation with id" do
28
+ expect(reputation[:id]).to eq 10708
29
+ end
30
+
31
+ it "should return the reputation with name" do
32
+ expect(reputation[:name]).to eq "Ricardo Eletro ( Internet )"
33
+ end
34
+
35
+ it "should return the reputation with period" do
36
+ expect(reputation[:period]).to_not eq nil
37
+ end
38
+
39
+ it "should return the reputation with status" do
40
+ expect(reputation[:status]).to_not eq nil
41
+ end
42
+
43
+ it "should return the reputation with complaints" do
44
+ expect(reputation[:complaints]).to_not eq nil
45
+ end
46
+
47
+ it "should return the reputation with answered" do
48
+ expect(reputation[:answered]).to_not eq nil
49
+ end
50
+
51
+ it "should return the reputation with not_answered" do
52
+ expect(reputation[:not_answered]).to_not eq nil
53
+ end
54
+
55
+ it "should return the reputation with measured" do
56
+ expect(reputation[:measured]).to_not eq nil
57
+ end
58
+
59
+ it "should return the reputation with solution_index" do
60
+ expect(reputation[:solution_index]).to_not eq nil
61
+ end
62
+
63
+ it "should return the reputation with would_return" do
64
+ expect(reputation[:would_return]).to_not eq nil
65
+ end
66
+
67
+ it "should return the reputation with grade" do
68
+ expect(reputation[:grade]).to_not eq nil
69
+ end
70
+
71
+ it "should return the reputation with time_to_response" do
72
+ expect(reputation[:time_to_response]).to_not eq nil
73
+ end
74
+
75
+ it "should return the reputation with chat" do
76
+ expect(reputation[:chat]).to_not eq nil
77
+ end
78
+
79
+ it "should return the reputation with fone" do
80
+ expect(reputation[:fone]).to_not eq nil
81
+ end
82
+
83
+ it "should return the reputation with show_selo" do
84
+ expect(reputation[:show_selo]).to_not eq nil
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe ReclameAqui do
4
+ let(:reclame_aqui){ ReclameAqui }
5
+ let(:by_website){ double }
6
+
7
+ it "should call get_reputation of ReputationByWebsite" do
8
+ expect(ReclameAqui::ReputationByWebsite).to receive(:new).and_return(by_website)
9
+ expect(by_website).to receive(:get_reputation)
10
+ reclame_aqui.reputation("")
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require "reclame_aqui"
2
+
3
+ RSpec.configure do |config|
4
+
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reclame_aqui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Gabriel Givigier
8
+ - Pedro Dias
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-02-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.7'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 3.1.0
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 3.1.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: json
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 1.8.2
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.2
70
+ description: A gem that verify the reputation of a company in ReclameAqui.
71
+ email:
72
+ - gabriel@agrid.com.br
73
+ - pedro@agrid.com.br
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".rvmrc"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - lib/reclame_aqui.rb
86
+ - lib/reclame_aqui/reputation_by_website.rb
87
+ - lib/reclame_aqui/version.rb
88
+ - reclame_aqui-0.0.1.gem
89
+ - reclame_aqui.gemspec
90
+ - spec/reclame_aqui/reputation_by_website_spec.rb
91
+ - spec/reclame_aqui_spec.rb
92
+ - spec/spec_helper.rb
93
+ homepage: https://github.com/givigier/reclame_aqui
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.1.11
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Company verification in ReclameAqui.
117
+ test_files:
118
+ - spec/reclame_aqui/reputation_by_website_spec.rb
119
+ - spec/reclame_aqui_spec.rb
120
+ - spec/spec_helper.rb