trumail 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0631d4de271739d362116211ab446ded8e028778
4
- data.tar.gz: e6c3150436088ecd0fc0ab87d9e67e00c0f76786
2
+ SHA256:
3
+ metadata.gz: 0cb74da0efbcc6a10df33980752904d1da604d70033fc2d64e4f5377ec2c2194
4
+ data.tar.gz: 4207c818255761f16414cf51262a0fefb3f55530aaa9bd9a59c21a513d51dbba
5
5
  SHA512:
6
- metadata.gz: 48ec8563ad32b90290667d5d0d8d4eb4d45c47279992660031307290a69531e84457082c241f2246b6c066ac28fe6973a3aa0baeeb843380e2d79948ac1cb8aa
7
- data.tar.gz: dd3425f52b77181df757de81302bf2ecf225c6c89c2d7ed4f053f5495b10e173e81e51a91023c68fd1c75265b54bf92d20cd7e9759f0726010bb5e19749ad04f
6
+ metadata.gz: 99f2abf1eed00880a7802da867a03fe4c55a662dd3dbddab58de29e8a2ee4ef4fc491049541819d4798e484e0c5ef2200de5391f4b5aa7cacedfcb79d88f4fd1
7
+ data.tar.gz: 8c42fb15522c8fefb49d85078203ba09ce5b18918c579e988c68a27fc0a8a086db24a22295bf5fcad2b81f002b2c302a44413934c629a1c2aac68bc9e52c6db4
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'typhoeus'
4
+ require 'user_agent_db'
4
5
 
5
6
  module Trumail
6
7
  class Lookup
@@ -8,7 +9,7 @@ module Trumail
8
9
  DEFAULT_HOST ||= 'https://trumail.io'
9
10
  DEFAULT_FORMAT ||= :json
10
11
 
11
- attr_reader :email, :host, :format, :response, :hash
12
+ attr_reader :email, :hash, :host, :format, :response
12
13
 
13
14
  def initialize(email, host: DEFAULT_HOST, format: DEFAULT_FORMAT)
14
15
  @email = email
@@ -26,8 +27,11 @@ module Trumail
26
27
 
27
28
  def verify
28
29
  return @hash unless @response.nil?
29
- @response = Typhoeus.get(url).response_body
30
- @hash = parse_by_format
30
+
31
+ Typhoeus::Config.user_agent = UserAgentDB.random
32
+ @response = Typhoeus.get(url, accept_encoding: 'gzip,deflate').response_body
33
+
34
+ parse_by_format
31
35
  end
32
36
 
33
37
  def url
@@ -79,10 +83,10 @@ module Trumail
79
83
  def parse_by_format
80
84
  return @hash if @response.nil?
81
85
 
82
- case @format
83
- when :json then Trumail::Parser::Json.parse(@response)
84
- when :xml then Trumail::Parser::Xml.parse(@response)
85
- end
86
+ @hash = case @format
87
+ when :json then Trumail::Parser::Json.parse(@response)
88
+ when :xml then Trumail::Parser::Xml.parse(@response)
89
+ end
86
90
  end
87
91
 
88
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trumail
4
- VERSION ||= '0.1.0'
4
+ VERSION ||= '0.2.0'
5
5
  end
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_runtime_dependency 'ox'
26
26
  spec.add_runtime_dependency 'typhoeus'
27
+ spec.add_runtime_dependency 'user_agent_db'
27
28
 
28
29
  spec.add_development_dependency 'bundler'
29
30
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trumail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-19 00:00:00.000000000 Z
11
+ date: 2017-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: user_agent_db
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
184
  version: '0'
171
185
  requirements: []
172
186
  rubyforge_project:
173
- rubygems_version: 2.6.14
187
+ rubygems_version: 2.7.2
174
188
  signing_key:
175
189
  specification_version: 4
176
190
  summary: Trumail Ruby SDK.