reclame_aqui 0.0.2 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7bad183f5b8d5def5f093ca2cd1b2bb49f6f41a
4
- data.tar.gz: bc6c591e31a7054dc8fdb3fb20fcc82ece60c867
3
+ metadata.gz: 747f2238e433feda52fb1a1d2a33c37b7abe6c7d
4
+ data.tar.gz: 6277f3053b4dfd0a81a461d99a183939f81b99c5
5
5
  SHA512:
6
- metadata.gz: 21d1a33d742a50409c6e86ee3bfb29ed90bd753f95236cd5bf48db28cf9f74d57047d41965f528b96fd8c77944814c465bb73755221333fe77d5803a00a54e08
7
- data.tar.gz: 66d17e0558d07c4bc47dfe86ebb9a1eec63e6c2cd035d13382304287b87e63edc45d65df2112df407190dc31d11dd825bd0fb76e42c9eb46bbc788646a813584
6
+ metadata.gz: 8d9bbb656416cd8aa8535d76000222421301d06a469f8cbc56bdc92b06f8d55b217e4b9daf38229a3a0c1f83d636d1a09ef16edfd51756a11e71f8d818031f58
7
+ data.tar.gz: 1c625ba83036fe472e15929b9b1419053a519f3ac26de6c7b2447a7431680c143719fa73f59942a92e3ad1e8d2118b4552f08ddc60f501ec1bb08876270ffa46
data/.gitignore CHANGED
@@ -11,4 +11,5 @@
11
11
  *.so
12
12
  *.o
13
13
  *.a
14
+ *.gem
14
15
  mkmf.log
data/Dockerfile ADDED
@@ -0,0 +1,12 @@
1
+ FROM ruby:2.3.0-alpine
2
+
3
+ RUN apk add --update git make g++ bash
4
+
5
+ RUN mkdir -p /reclame_aqui
6
+
7
+ WORKDIR /reclame_aqui
8
+
9
+ COPY . .
10
+
11
+ RUN gem install bundler -v 1.16.3
12
+ RUN bundle install
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ReclameAqui
2
2
 
3
- A gem that verify the reputation of a company in ReclameAqui.
3
+ A gem that verify the reputation of a company on ReclameAqui(http://reclameaqui.com.br/).
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ReclameAqui.reputation("http://company.com")
23
+ ReclameAqui.reputation("http://ricardoeletro.com.br")
24
24
 
25
25
  ## Contributors
26
26
  Pedro Dias( https://github.com/pdf13 )
@@ -0,0 +1,9 @@
1
+ version: "3.2"
2
+ services:
3
+ gem:
4
+ build: .
5
+ command: gem build reclame_aqui.gemspec
6
+ volumes:
7
+ - .:/reclame_aqui
8
+ volumes:
9
+ reclame_aqui:
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ReclameAqui
4
+ class InvalidWebsiteException < StandardError; end
5
+ end
@@ -1,47 +1,51 @@
1
- require "json"
1
+ # frozen_string_literal: true
2
2
 
3
- class ReclameAqui::ReputationByWebsite
4
- def initialize(website)
5
- @website = website
6
- end
3
+ require 'json'
4
+ require_relative 'invalid_website_exception'
7
5
 
8
- def get_reputation
9
- begin
10
- response = do_request
11
- format_response JSON.parse(response.body)
12
- rescue
13
- { error: true, reputation: {} }
6
+ module ReclameAqui
7
+ class ReputationByWebsite
8
+ def initialize(website)
9
+ @website = website
14
10
  end
15
- end
16
11
 
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
12
+ def reputation
13
+ begin
14
+ response = do_request
15
+ format_response JSON.parse(response.body)
16
+ rescue
17
+ raise ReclameAqui::InvalidWebsiteException
18
+ end
19
+ end
23
20
 
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
21
+ private
22
+
23
+ def do_request
24
+ uri = URI.parse 'http://app02.reclameaqui.com.br/reputacao'
25
+ http = Net::HTTP.new uri.host, uri.port
26
+ http.post uri.path, "url=#{@website}", {}
27
+ end
28
+
29
+ def format_response data
30
+ reputation = data['reputacao']
31
+ status = reputation['status'] || []
32
+ {
33
+ id: reputation['empresa_id'].to_i,
34
+ name: reputation['nome_empresa'],
35
+ period: reputation['periodo'].to_i,
36
+ status: status['status_id'].to_i,
37
+ complaints: reputation['reclamacoes'].to_i,
38
+ answered: reputation['respondidas'].to_i,
39
+ not_answered: reputation['nao_respondidas'].to_i,
40
+ measured: reputation['avaliadas'].to_i,
41
+ solution_index: reputation['indice_solucao'].to_i,
42
+ would_return: reputation['voltaria_fazer_negocio'].to_i,
43
+ grade: reputation['nota_consumidor'].to_i,
44
+ time_to_response: reputation['tempo_resposta'],
45
+ chat: reputation['chat'].to_i,
46
+ fone: reputation['fone'].to_i,
47
+ show_selo: reputation['show_selo'].to_i
44
48
  }
45
- }
49
+ end
46
50
  end
47
- end
51
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ReclameAqui
2
- VERSION = "0.0.2"
4
+ VERSION = '1.0.0'
3
5
  end
data/reclame_aqui.gemspec CHANGED
@@ -1,25 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'reclame_aqui/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "reclame_aqui"
8
+ spec.name = 'reclame_aqui'
8
9
  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"
10
+ spec.authors = ['Gabriel Givigier']
11
+ spec.email = ['gabriel@givigier.com.br']
12
+ spec.summary = 'Company verification on ReclameAqui.'
13
+ spec.description = 'A gem that verify the reputation of a company on ReclameAqui.'
14
+ spec.homepage = 'https://github.com/givigier/reclame_aqui'
15
+ spec.license = 'MIT'
16
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3')
15
17
 
16
18
  spec.files = `git ls-files -z`.split("\x0")
17
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'json', '~> 2.1.0'
20
24
 
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
+ spec.add_development_dependency 'bundler', '~> 1.16.3'
26
+ spec.add_development_dependency 'rspec', '~> 3.8.0'
25
27
  end
@@ -1,87 +1,84 @@
1
- require "spec_helper"
1
+ # frozen_string_literal: true
2
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] }
3
+ require 'spec_helper'
8
4
 
9
- it "should return a hash with error equal true" do
10
- expect(error).to eq true
5
+ describe ReclameAqui::ReputationByWebsite do
6
+ context 'when passing an invalid website' do
7
+ let(:reclame_aqui) do
8
+ ReclameAqui::ReputationByWebsite.new('http://')
11
9
  end
12
10
 
13
- it "should return an empty reputation" do
14
- expect(reputation).to eq Hash.new({})
11
+ it 'should raise an InvalidWebsiteException' do
12
+ expect { reclame_aqui.reputation }
13
+ .to raise_exception(ReclameAqui::InvalidWebsiteException)
15
14
  end
16
15
  end
17
16
 
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
17
+ context 'when passing a valid website' do
18
+ let(:reclame_aqui) do
19
+ ReclameAqui::ReputationByWebsite
20
+ .new('http://ricardoeletro.com.br')
25
21
  end
22
+ let!(:reputation) { reclame_aqui.reputation }
26
23
 
27
- it "should return the reputation with id" do
24
+ it 'should return the reputation with id' do
28
25
  expect(reputation[:id]).to eq 10708
29
26
  end
30
27
 
31
- it "should return the reputation with name" do
32
- expect(reputation[:name]).to eq "Ricardo Eletro ( Internet )"
28
+ it 'should return the reputation with name' do
29
+ expect(reputation[:name]).to eq 'Ricardo Eletro - Loja Online'
33
30
  end
34
31
 
35
- it "should return the reputation with period" do
32
+ it 'should return the reputation with period' do
36
33
  expect(reputation[:period]).to_not eq nil
37
34
  end
38
35
 
39
- it "should return the reputation with status" do
36
+ it 'should return the reputation with status' do
40
37
  expect(reputation[:status]).to_not eq nil
41
38
  end
42
39
 
43
- it "should return the reputation with complaints" do
40
+ it 'should return the reputation with complaints' do
44
41
  expect(reputation[:complaints]).to_not eq nil
45
42
  end
46
43
 
47
- it "should return the reputation with answered" do
44
+ it 'should return the reputation with answered' do
48
45
  expect(reputation[:answered]).to_not eq nil
49
46
  end
50
47
 
51
- it "should return the reputation with not_answered" do
48
+ it 'should return the reputation with not_answered' do
52
49
  expect(reputation[:not_answered]).to_not eq nil
53
50
  end
54
51
 
55
- it "should return the reputation with measured" do
52
+ it 'should return the reputation with measured' do
56
53
  expect(reputation[:measured]).to_not eq nil
57
54
  end
58
55
 
59
- it "should return the reputation with solution_index" do
56
+ it 'should return the reputation with solution_index' do
60
57
  expect(reputation[:solution_index]).to_not eq nil
61
58
  end
62
59
 
63
- it "should return the reputation with would_return" do
60
+ it 'should return the reputation with would_return' do
64
61
  expect(reputation[:would_return]).to_not eq nil
65
62
  end
66
63
 
67
- it "should return the reputation with grade" do
64
+ it 'should return the reputation with grade' do
68
65
  expect(reputation[:grade]).to_not eq nil
69
66
  end
70
67
 
71
- it "should return the reputation with time_to_response" do
68
+ it 'should return the reputation with time_to_response' do
72
69
  expect(reputation[:time_to_response]).to_not eq nil
73
70
  end
74
71
 
75
- it "should return the reputation with chat" do
72
+ it 'should return the reputation with chat' do
76
73
  expect(reputation[:chat]).to_not eq nil
77
74
  end
78
75
 
79
- it "should return the reputation with fone" do
76
+ it 'should return the reputation with fone' do
80
77
  expect(reputation[:fone]).to_not eq nil
81
78
  end
82
79
 
83
- it "should return the reputation with show_selo" do
80
+ it 'should return the reputation with show_selo' do
84
81
  expect(reputation[:show_selo]).to_not eq nil
85
82
  end
86
83
  end
87
- end
84
+ end
metadata CHANGED
@@ -1,91 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reclame_aqui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Givigier
8
- - Pedro Dias
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2018-08-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: bundler
14
+ name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '1.7'
21
- type: :development
19
+ version: 2.1.0
20
+ type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: '1.7'
26
+ version: 2.1.0
28
27
  - !ruby/object:Gem::Dependency
29
- name: rake
28
+ name: bundler
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
- version: '10.0'
33
+ version: 1.16.3
35
34
  type: :development
36
35
  prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - "~>"
40
39
  - !ruby/object:Gem::Version
41
- version: '10.0'
40
+ version: 1.16.3
42
41
  - !ruby/object:Gem::Dependency
43
42
  name: rspec
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - "~>"
47
46
  - !ruby/object:Gem::Version
48
- version: 3.1.0
47
+ version: 3.8.0
49
48
  type: :development
50
49
  prerelease: false
51
50
  version_requirements: !ruby/object:Gem::Requirement
52
51
  requirements:
53
52
  - - "~>"
54
53
  - !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.
54
+ version: 3.8.0
55
+ description: A gem that verify the reputation of a company on ReclameAqui.
71
56
  email:
72
- - gabriel@agrid.com.br
73
- - pedro@agrid.com.br
57
+ - gabriel@givigier.com.br
74
58
  executables: []
75
59
  extensions: []
76
60
  extra_rdoc_files: []
77
61
  files:
78
62
  - ".gitignore"
79
63
  - ".rspec"
80
- - ".rvmrc"
64
+ - Dockerfile
81
65
  - Gemfile
82
66
  - LICENSE.txt
83
67
  - README.md
84
68
  - Rakefile
69
+ - docker-compose.yml
85
70
  - lib/reclame_aqui.rb
71
+ - lib/reclame_aqui/invalid_website_exception.rb
86
72
  - lib/reclame_aqui/reputation_by_website.rb
87
73
  - lib/reclame_aqui/version.rb
88
- - reclame_aqui-0.0.1.gem
89
74
  - reclame_aqui.gemspec
90
75
  - spec/reclame_aqui/reputation_by_website_spec.rb
91
76
  - spec/reclame_aqui_spec.rb
@@ -102,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
87
  requirements:
103
88
  - - ">="
104
89
  - !ruby/object:Gem::Version
105
- version: '0'
90
+ version: '2.3'
106
91
  required_rubygems_version: !ruby/object:Gem::Requirement
107
92
  requirements:
108
93
  - - ">="
@@ -110,10 +95,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
95
  version: '0'
111
96
  requirements: []
112
97
  rubyforge_project:
113
- rubygems_version: 2.1.11
98
+ rubygems_version: 2.6.3
114
99
  signing_key:
115
100
  specification_version: 4
116
- summary: Company verification in ReclameAqui.
101
+ summary: Company verification on ReclameAqui.
117
102
  test_files:
118
103
  - spec/reclame_aqui/reputation_by_website_spec.rb
119
104
  - spec/reclame_aqui_spec.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm --create use ruby-2.1.5@reclame_aqui
Binary file