clearbit 0.1.4 → 0.1.5

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
2
  SHA1:
3
- metadata.gz: 17c24d70918fb9e7eac659630aceb2dbfef52974
4
- data.tar.gz: adb5b3e585772fbbe15bda1409ed6a8b82486950
3
+ metadata.gz: 94181dcf96160372ef82dd215b4696aba62d39fb
4
+ data.tar.gz: a8752294bc5b63fe7d3a055c94429467131c9288
5
5
  SHA512:
6
- metadata.gz: 3ebbf52951763bb530c2e9a448d28cfc9277cce2143035422a67e852ab7ea25012168c596d24dfa1b77a86394acf0bef5fd6c9cb0905a003cef044e779dcb9fb
7
- data.tar.gz: e59b9887faf2944097ee76097868e6588b49a55b527fe3fcf724870fc459153902b8cba7bc855877e1e4562791206355e76617a9b1c40b0ba1f34dff5c23cd36
6
+ metadata.gz: f7085df982027dc0af97c63e483457c7f9e5287d9f580bee1108a9b2b13d999db394e31941ee0e44ecefb1f8ecdcad00066573db17728a01d645eef95d925d09
7
+ data.tar.gz: 8b3e2cd83dabd56cf74294cbda5f2c9d46206f0774caecd7606ce048e9c175bc6e1dbc2c90266b4e92ebff27a11bd311462af8edf95ce9f4f4100366a4dba0f4
data/README.md CHANGED
@@ -6,7 +6,9 @@ A Ruby API client to [https://clearbit.com](https://clearbit.com).
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'clearbit'
9
+ ``` ruby
10
+ gem 'clearbit'
11
+ ```
10
12
 
11
13
  And then execute:
12
14
 
@@ -20,11 +22,15 @@ Or install it yourself as:
20
22
 
21
23
  First authorize requests by setting the API key found on your [account's settings page](https://clearbit.com/keys).
22
24
 
23
- Clearbit.key = ENV['CLEARBIT_KEY']
25
+ ``` ruby
26
+ Clearbit.key = ENV['CLEARBIT_KEY']
27
+ ```
24
28
 
25
29
  Then you can lookup people by email address:
26
30
 
27
- person = Clearbit::Streaming::Person[email: 'alex@alexmaccaw.com']
31
+ ``` ruby
32
+ person = Clearbit::Streaming::Person[email: 'alex@alexmaccaw.com']
33
+ ```
28
34
 
29
35
  If the person can't be found, then `nil` will be returned.
30
36
 
@@ -34,7 +40,9 @@ See the [documentation](https://clearbit.com/docs#person-api) for more informati
34
40
 
35
41
  You can lookup company data by domain name:
36
42
 
37
- company = Clearbit::Streaming::Company[domain: 'uber.com']
43
+ ``` ruby
44
+ company = Clearbit::Streaming::Company[domain: 'uber.com']
45
+ ```
38
46
 
39
47
  If the company can't be found, then `nil` will be returned.
40
48
 
data/apihub.gemspec CHANGED
@@ -20,5 +20,6 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.3'
22
22
  spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'net-http-spy'
23
24
  spec.add_dependency 'nestful', '~> 1.0.7'
24
25
  end
@@ -1,4 +1,4 @@
1
1
  require 'clearbit'
2
2
  require 'pp'
3
3
 
4
- pp Clearbit::PersonCompany.find(email: 'alex@alexmaccaw.com')
4
+ pp Clearbit::PersonCompany.find(email: 'alex@alexmaccaw.com', given_name: 'Alex', family_name: 'MacCaw')
@@ -0,0 +1,6 @@
1
+ require 'clearbit'
2
+ require 'pp'
3
+
4
+ Clearbit::PersonCompany.version = '2015-05-30'
5
+
6
+ Clearbit::PersonCompany.find(email: 'alex@clearbit.com', webhook_url: 'http://requestb.in/18owk611')
data/lib/clearbit.rb CHANGED
@@ -3,14 +3,11 @@ require 'clearbit/version'
3
3
 
4
4
  module Clearbit
5
5
  def self.api_key=(value)
6
- Base.options Base.options.merge(
7
- auth_type: :bearer,
8
- password: value
9
- )
6
+ Base.key = value
10
7
  end
11
8
 
12
9
  def self.key=(value)
13
- self.api_key = value
10
+ Base.key = value
14
11
  end
15
12
 
16
13
  autoload :Base, 'clearbit/base'
@@ -25,4 +22,4 @@ module Clearbit
25
22
  if clearbit_key = ENV['CLEARBIT_KEY']
26
23
  Clearbit.key = clearbit_key
27
24
  end
28
- end
25
+ end
data/lib/clearbit/base.rb CHANGED
@@ -2,5 +2,14 @@ module Clearbit
2
2
  class Base < Resource
3
3
  endpoint 'https://api.clearbit.com'
4
4
  options :format => :json
5
+
6
+ def self.version=(value)
7
+ add_options headers: {'API-Version' => value}
8
+ end
9
+
10
+ def self.key=(value)
11
+ add_options auth_type: :bearer,
12
+ password: value
13
+ end
5
14
  end
6
15
  end
@@ -11,7 +11,7 @@ module Clearbit
11
11
  if old_options
12
12
  # Deprecated API
13
13
  warn '[DEPRECATION] passing multiple args to find() is deprecated'
14
- values.merge!(old_options)
14
+ (values[:request] ||= {}).merge!(old_options)
15
15
  end
16
16
 
17
17
  options = values.delete(:request) || {}
data/lib/clearbit/mash.rb CHANGED
@@ -143,12 +143,10 @@ module Clearbit
143
143
  def method_missing(method_name, *args, &blk)
144
144
  return self.[](method_name, &blk) if key?(method_name)
145
145
 
146
- underscored_name = underscore(method_name.to_s)
146
+ camelized_name = camelize(method_name.to_s)
147
147
 
148
- if key?(underscored_name)
149
- warn 'camelCased property names are deprecated. ' + '
150
- Please use underscored properties.'
151
- return self.[](underscored_name, &blk)
148
+ if key?(camelized_name)
149
+ return self.[](camelized_name, &blk)
152
150
  end
153
151
 
154
152
  match = method_name.to_s.match(/(.*?)([?=!_]?)$/)
@@ -169,17 +167,14 @@ module Clearbit
169
167
 
170
168
  protected
171
169
 
172
- def underscore(camel_cased_word)
173
- word = camel_cased_word.to_s.gsub('::', '/')
174
- word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
175
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
176
- word.tr!("-", "_")
177
- word.downcase!
178
- word
170
+ def camelize(string)
171
+ string = string.to_s
172
+ string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
173
+ string.gsub(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
179
174
  end
180
175
 
181
176
  def convert_key(key) #:nodoc:
182
- underscore(key.to_s)
177
+ key.to_s
183
178
  end
184
179
 
185
180
  def convert_value(val, duping=false) #:nodoc:
@@ -196,4 +191,4 @@ module Clearbit
196
191
  end
197
192
  end
198
193
  end
199
- end
194
+ end
@@ -11,7 +11,7 @@ module Clearbit
11
11
  if old_options
12
12
  # Deprecated API
13
13
  warn '[DEPRECATION] passing multiple args to find() is deprecated'
14
- values.merge!(old_options)
14
+ (values[:request] ||= {}).merge!(old_options)
15
15
  end
16
16
 
17
17
  options = values.delete(:request) || {}
@@ -11,7 +11,7 @@ module Clearbit
11
11
  if old_options
12
12
  # Deprecated API
13
13
  warn '[DEPRECATION] passing multiple args to find() is deprecated'
14
- values.merge!(old_options)
14
+ (values[:request] ||= {}).merge!(old_options)
15
15
  end
16
16
 
17
17
  options = values.delete(:request) || {}
@@ -15,15 +15,21 @@ module Clearbit
15
15
  end
16
16
 
17
17
  def self.options(value = nil)
18
- @options = value if value
19
- return @options if @options
20
- superclass.respond_to?(:options) ? superclass.options : {}
18
+ @options ||= {}
19
+ @options.merge!(value) if value
20
+
21
+ if superclass.respond_to?(:options)
22
+ Nestful::Helpers.deep_merge(superclass.options, @options)
23
+ else
24
+ @options
25
+ end
21
26
  end
22
27
 
23
28
  class << self
24
29
  alias_method :endpoint=, :endpoint
25
30
  alias_method :path=, :path
26
31
  alias_method :options=, :options
32
+ alias_method :add_options, :options
27
33
  end
28
34
 
29
35
  def self.url
@@ -67,4 +73,4 @@ module Clearbit
67
73
  id ? self.class.uri(id, *parts) : self.class.uri(*parts)
68
74
  end
69
75
  end
70
- end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module Clearbit
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-22 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: net-http-spy
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'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: nestful
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -69,6 +83,7 @@ files:
69
83
  - examples/company.rb
70
84
  - examples/person.rb
71
85
  - examples/person_company.rb
86
+ - examples/version.rb
72
87
  - examples/watchlist.rb
73
88
  - lib/clearbit.rb
74
89
  - lib/clearbit/base.rb