crunchbase-ruby-library 0.3.3 → 0.3.4

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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +5 -4
  3. data/bin/console +5 -2
  4. data/bin/setup +4 -1
  5. data/crunchbase-ruby-library.gemspec +1 -1
  6. data/lib/crunchbase/api.rb +8 -11
  7. data/lib/crunchbase/client.rb +0 -1
  8. data/lib/crunchbase/exception.rb +0 -1
  9. data/lib/crunchbase/model/acquired_by.rb +1 -1
  10. data/lib/crunchbase/model/acquisition.rb +2 -2
  11. data/lib/crunchbase/model/address.rb +1 -1
  12. data/lib/crunchbase/model/advisory_role.rb +1 -1
  13. data/lib/crunchbase/model/batch_search.rb +31 -32
  14. data/lib/crunchbase/model/board_members_and_advisor.rb +1 -1
  15. data/lib/crunchbase/model/category.rb +1 -1
  16. data/lib/crunchbase/model/competitor.rb +1 -1
  17. data/lib/crunchbase/model/current_team.rb +1 -1
  18. data/lib/crunchbase/model/customer.rb +1 -1
  19. data/lib/crunchbase/model/degree.rb +1 -1
  20. data/lib/crunchbase/model/featured_team.rb +1 -1
  21. data/lib/crunchbase/model/founded_company.rb +1 -1
  22. data/lib/crunchbase/model/founder.rb +1 -1
  23. data/lib/crunchbase/model/fund.rb +1 -1
  24. data/lib/crunchbase/model/fund_raise.rb +1 -1
  25. data/lib/crunchbase/model/funding_round.rb +2 -2
  26. data/lib/crunchbase/model/image.rb +1 -1
  27. data/lib/crunchbase/model/investment.rb +1 -1
  28. data/lib/crunchbase/model/investor.rb +1 -1
  29. data/lib/crunchbase/model/ipo.rb +1 -1
  30. data/lib/crunchbase/model/job.rb +1 -1
  31. data/lib/crunchbase/model/location.rb +1 -1
  32. data/lib/crunchbase/model/member.rb +1 -1
  33. data/lib/crunchbase/model/membership.rb +1 -1
  34. data/lib/crunchbase/model/new.rb +1 -1
  35. data/lib/crunchbase/model/office.rb +1 -1
  36. data/lib/crunchbase/model/organization.rb +1 -1
  37. data/lib/crunchbase/model/past_team.rb +1 -1
  38. data/lib/crunchbase/model/person.rb +1 -1
  39. data/lib/crunchbase/model/product.rb +1 -1
  40. data/lib/crunchbase/model/sub_organization.rb +1 -1
  41. data/lib/crunchbase/model/video.rb +1 -1
  42. data/lib/crunchbase/model/website.rb +1 -1
  43. data/lib/crunchbase/model.rb +0 -1
  44. data/lib/crunchbase/request/client.rb +0 -1
  45. data/lib/crunchbase/request.rb +0 -1
  46. data/lib/crunchbase/version.rb +2 -1
  47. data/lib/crunchbase.rb +5 -4
  48. data/spec/crunchbase/model/batch_search_spec.rb +55 -56
  49. data/spec/crunchbase.yml.example +1 -1
  50. data/spec/spec_helper.rb +1 -1
  51. metadata +24 -44
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb4d88746975ba9d6e89048085a7730e76c76067
4
+ data.tar.gz: 4f4cde945a876057ad7402734a74267f7345e964
5
+ SHA512:
6
+ metadata.gz: ad6615739035c823de4e627a5cd803f6b978b6f4b280bf995f09be1e54a694b838c25a20b449e2a98e2d0f536f6ec91b02464e4bd624cd153f56140712e4ec0a
7
+ data.tar.gz: 5e92b91af7916af18ac75bcd8bb1a3acd99eadf2aae6851b785defd0a54ece70dc7872632f5fd86a4e6bc049f94a96c72bc4c4a9c3e74fc88fd6d245d42415f1
data/README.md CHANGED
@@ -47,6 +47,7 @@ cCeate the file `config/initializers/crunchbase.rb` in your rails project and ad
47
47
  * client.search({query: "Google"}, 'organizations') # Full text search of an Organization's name, aliases
48
48
  * client.search({name: "Google"}, 'organizations') # Full text search limited to name and aliases
49
49
  * client.search({domain_name: "google.com"}, 'organizations') # Text search of an Organization's domain_name
50
+ * client.search({locations: "China,Shanghai"}, 'organizations') # Filter by location names (comma separated, AND'd together)
50
51
  * client.search({name: "encore"}, 'people') # A full-text query of name only
51
52
  * client.search({query: "encore"}, 'people') # A full-text query of name, title, and company
52
53
  * client.search({types: "investor"}, 'people') # Filter by type (currently, either this is empty, or is simply "investor")
@@ -89,11 +90,11 @@ cCeate the file `config/initializers/crunchbase.rb` in your rails project and ad
89
90
  #<Crunchbase::Model::PersonSummary: ...>
90
91
  ......
91
92
  ]
92
-
93
+
93
94
  ### Batch search
94
95
  Pass in an array of requests to perform a batch search. Following parameters should be present in each request: `type`, `uuid` and `relationships` (https://data.crunchbase.com/docs/using-the-api#batch-search-capabilities).<br/>
95
96
  Max 10 requests per search allowed.
96
-
97
+
97
98
  => requests = [
98
99
  { type: 'Organization', uuid: 'valid_uuid', relationships: ["<relationship_name>"] },
99
100
  { type: 'Person', uuid: 'valid_uuid', relationships: ["<relationship_name>"] },
@@ -106,8 +107,8 @@ Max 10 requests per search allowed.
106
107
  #<Crunchbase::Model::Organization:0x007f9bd7e84f98, ...>,
107
108
  #<Crunchbase::Model::Person:0x007f9bda0d9d78, ...>,
108
109
  #<Crunchbase::Model::Error:0x007fd6b6818758 @code="LA404", @message="Not Found - Entity invalid_uuid doesn't exist" ...> // Error object returned due to invalid uuid passed
109
- ]
110
-
110
+ ]
111
+
111
112
 
112
113
  ### How to debug in the console
113
114
 
data/bin/console CHANGED
@@ -3,9 +3,12 @@
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'crunchbase'
6
+ require 'yaml'
6
7
 
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
8
+ # Setup the user key for API
9
+ yaml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'spec', 'crunchbase.yml'))
10
+ Crunchbase::API.key = yaml['key']
11
+ Crunchbase::API.debug = yaml['debug']
9
12
 
10
13
  # (If you use this, don't forget to add pry to your Gemfile!)
11
14
  require "pry"
data/bin/setup CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env bash
2
+
2
3
  set -euo pipefail
3
4
  IFS=$'\n\t'
4
5
  set -vx
5
6
 
6
7
  bundle install
7
8
 
8
- # Do any other automated setup that you need to do here
9
+ if [ ! -f ./spec/crunchbase.yml ]; then
10
+ cp ./spec/crunchbase.yml.example ./spec/crunchbase.yml
11
+ fi
@@ -1,5 +1,5 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
2
+
3
3
  lib = File.expand_path('../lib', __FILE__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'crunchbase/version'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'net/http'
@@ -42,13 +41,13 @@ module Crunchbase
42
41
  @debug = false
43
42
 
44
43
  # Must be overridden in subclasses
45
- RESOURCE_NAME = 'undefined'
46
- RESOURCE_LIST = 'undefineds'
44
+ RESOURCE_NAME = 'undefined'.freeze
45
+ RESOURCE_LIST = 'undefineds'.freeze
47
46
 
48
- ORDER_CREATED_AT_ASC = 'created_at ASC'
49
- ORDER_CREATED_AT_DESC = 'created_at DESC'
50
- ORDER_UPDATED_AT_ASC = 'updated_at ASC'
51
- ORDER_UPDATED_AT_DESC = 'updated_at DESC'
47
+ ORDER_CREATED_AT_ASC = 'created_at ASC'.freeze
48
+ ORDER_CREATED_AT_DESC = 'created_at DESC'.freeze
49
+ ORDER_UPDATED_AT_ASC = 'updated_at ASC'.freeze
50
+ ORDER_UPDATED_AT_DESC = 'updated_at DESC'.freeze
52
51
 
53
52
  class << self
54
53
  attr_accessor :timeout_limit, :redirect_limit, :key, :debug
@@ -104,9 +103,7 @@ module Crunchbase
104
103
  end
105
104
 
106
105
  def collect_parameters(options)
107
- require 'cgi'
108
-
109
- options.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
106
+ options.map { |k, v| "#{k}=#{v}" }.join('&')
110
107
  end
111
108
 
112
109
  def organization_lists(permalink, category, options)
@@ -161,7 +158,7 @@ module Crunchbase
161
158
  http = Net::HTTP.new(uri.host, uri.port)
162
159
  http.use_ssl = true if uri.scheme == 'https'
163
160
  response = http.start do |h|
164
- h.request Net::HTTP::Get.new(uri.request_uri, {'User-Agent' => 'crunchbase-ruby-library'})
161
+ h.request Net::HTTP::Get.new(uri.request_uri, 'User-Agent' => 'crunchbase-ruby-library')
165
162
  end
166
163
 
167
164
  case response
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Crunchbase
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Crunchbase
@@ -4,7 +4,7 @@
4
4
  module Crunchbase
5
5
  module Model
6
6
  class AcquiredBy < Entity
7
- RESOURCE_LIST = 'acquired_by'
7
+ RESOURCE_LIST = 'acquired_by'.freeze
8
8
 
9
9
  attr_reader :uuid, :type_name, :api_path, :web_path, :price, :price_currency_code, :price_usd,
10
10
  :payment_type, :acquisition_type, :acquisition_status, :disposition_of_acquired,
@@ -3,8 +3,8 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Acquisition < Entity
6
- RESOURCE_LIST = 'acquisitions'
7
- RESOURCE_NAME = 'acquisitions'
6
+ RESOURCE_LIST = 'acquisitions'.freeze
7
+ RESOURCE_NAME = 'acquisitions'.freeze
8
8
 
9
9
  attr_reader :api_path, :web_path, :price, :price_currency_code, :price_usd,
10
10
  :payment_type, :acquisition_type, :acquisition_status, :disposition_of_acquired,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Address < Entity
6
- RESOURCE_LIST = 'addresses'
6
+ RESOURCE_LIST = 'addresses'.freeze
7
7
 
8
8
  attr_reader :name, :street_1, :street_2, :postal_code, :city, :city_web_path, :region, :region_code2, :region_web_path,
9
9
  :country, :country_code2, :country_code3, :country_web_path, :latitude, :longitude, :created_at, :updated_at
@@ -5,6 +5,6 @@ module Crunchbase::Model
5
5
  class AdvisoryRole < Job
6
6
  # called advisor_at from people api
7
7
 
8
- RESOURCE_LIST = 'advisor_at'
8
+ RESOURCE_LIST = 'advisor_at'.freeze
9
9
  end
10
10
  end
@@ -2,46 +2,45 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Crunchbase
5
- module Model
6
- class BatchSearch < Entity
7
- include Enumerable
5
+ module Model
6
+ class BatchSearch < Entity
7
+ include Enumerable
8
8
 
9
- attr_reader :results
9
+ attr_reader :results
10
10
 
11
- alias items results
11
+ alias items results
12
12
 
13
- def initialize(json)
14
- @results = []
13
+ def initialize(json)
14
+ @results = []
15
15
 
16
- populate_results(json)
17
- end
16
+ populate_results(json)
17
+ end
18
18
 
19
- def populate_results(json)
20
- @results = []
19
+ def populate_results(json)
20
+ @results = []
21
21
 
22
- @results = json['items'].map do |r|
23
- next Error.new(r['error']) if r.key?('error')
22
+ @results = json['items'].map do |r|
23
+ next Error.new(r['error']) if r.key?('error')
24
24
 
25
- kclass = kclass_name(r['type'])
26
- kclass.new(r)
27
- end
28
- end
25
+ kclass = kclass_name(r['type'])
26
+ kclass.new(r)
27
+ end
28
+ end
29
29
 
30
- def self.batch_search(requests)
31
- raise ConfigurationException, 'Invalid argument. Please pass in an array as an argument' unless requests.is_a?(Array)
32
- raise InvalidRequestException, "Too many requests(#{requests.length}) in batch, max allowed 10" if requests.length > 10
33
- raise MissingParamsException, 'Missing :type or :uuid parameter in some requests' if requests.any? { |request| !request.key?(:type) || !request.key?(:uuid) }
34
- return [] if requests.empty?
30
+ def self.batch_search(requests)
31
+ raise ConfigurationException, 'Invalid argument. Please pass in an array as an argument' unless requests.is_a?(Array)
32
+ raise InvalidRequestException, "Too many requests(#{requests.length}) in batch, max allowed 10" if requests.length > 10
33
+ raise MissingParamsException, 'Missing :type or :uuid parameter in some requests' if requests.any? { |request| !request.key?(:type) || !request.key?(:uuid) }
34
+ return [] if requests.empty?
35
35
 
36
- BatchSearch.new API.batch_search(requests)
37
- end
36
+ BatchSearch.new API.batch_search(requests)
37
+ end
38
38
 
39
- private
39
+ private
40
40
 
41
- def kclass_name(model_name)
42
- self.class.kclass_name(model_name.downcase)
43
- end
44
-
45
- end
46
- end
47
- end
41
+ def kclass_name(model_name)
42
+ self.class.kclass_name(model_name.downcase)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class BoardMembersAndAdvisor < Job
6
- RESOURCE_LIST = 'board_members_and_advisors'
6
+ RESOURCE_LIST = 'board_members_and_advisors'.freeze
7
7
 
8
8
  attr_reader :person
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Category < Entity
6
- RESOURCE_LIST = RESOURCE_NAME = 'categories'
6
+ RESOURCE_LIST = RESOURCE_NAME = 'categories'.freeze
7
7
 
8
8
  attr_reader :web_path, :name, :organizations_in_category, :products_in_category, :created_at, :updated_at
9
9
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Competitor < Organization
6
- RESOURCE_LIST = 'competitors'
6
+ RESOURCE_LIST = 'competitors'.freeze
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class CurrentTeam < Job
6
- RESOURCE_LIST = 'current_team'
6
+ RESOURCE_LIST = 'current_team'.freeze
7
7
 
8
8
  attr_reader :person
9
9
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Customer < Organization
6
- RESOURCE_LIST = 'customers'
6
+ RESOURCE_LIST = 'customers'.freeze
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Degree < Entity
6
- RESOURCE_LIST = 'degrees'
6
+ RESOURCE_LIST = 'degrees'.freeze
7
7
 
8
8
  attr_reader :degree_type_name, :degree_subject, :started_on, :started_on_trust_code, :is_completed,
9
9
  :completed_on, :completed_on_trust_code,
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Crunchbase::Model
4
4
  class FeaturedTeam < Job
5
- RESOURCE_LIST = 'featured_team'
5
+ RESOURCE_LIST = 'featured_team'.freeze
6
6
 
7
7
  attr_reader :person
8
8
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class FoundedCompany < Organization
6
- RESOURCE_LIST = 'founded_companies'
6
+ RESOURCE_LIST = 'founded_companies'.freeze
7
7
 
8
8
  #
9
9
  # 2015-11-03 Removed
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Founder < Person
6
- RESOURCE_LIST = 'founders'
6
+ RESOURCE_LIST = 'founders'.freeze
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Fund < Entity
6
- RESOURCE_LIST = 'funds'
6
+ RESOURCE_LIST = 'funds'.freeze
7
7
 
8
8
  attr_reader :api_path, :web_path, :name, :announced_on, :announced_on_trust_code,
9
9
  :money_raised, :money_raised_currency_code, :money_raised_usd,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class FundRaise < Entity
6
- RESOURCE_LIST = 'funds'
6
+ RESOURCE_LIST = 'funds'.freeze
7
7
 
8
8
  attr_reader :name, :path, :created_at, :updated_at
9
9
 
@@ -3,8 +3,8 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class FundingRound < Entity
6
- RESOURCE_LIST = 'funding_rounds'
7
- RESOURCE_NAME = 'funding-rounds'
6
+ RESOURCE_LIST = 'funding_rounds'.freeze
7
+ RESOURCE_NAME = 'funding-rounds'.freeze
8
8
 
9
9
  attr_reader :permalink, :api_path, :web_path, :funding_type, :series, :series_qualifier,
10
10
  :announced_on, :announced_on_trust_code, :closed_on, :closed_on_trust_code,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Image < Entity
6
- RESOURCE_LIST = 'images'
6
+ RESOURCE_LIST = 'images'.freeze
7
7
 
8
8
  attr_reader :asset_path, :asset_url, :content_type, :height, :width, :filesize, :created_at, :updated_at
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Investment < Entity
6
- RESOURCE_LIST = 'investments'
6
+ RESOURCE_LIST = 'investments'.freeze
7
7
 
8
8
  attr_reader :money_invested, :money_invested_currency_code, :money_invested_usd, :is_lead_investor,
9
9
  :announced_on, :announced_on_trust_code, :created_at, :updated_at
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Investor < Entity
6
- RESOURCE_LIST = 'investors'
6
+ RESOURCE_LIST = 'investors'.freeze
7
7
 
8
8
  attr_reader :object
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Ipo < Entity
6
- RESOURCE_LIST = RESOURCE_NAME = 'ipos'
6
+ RESOURCE_LIST = RESOURCE_NAME = 'ipos'.freeze
7
7
 
8
8
  attr_reader :api_path, :web_path, :went_public_on, :went_public_on_trust_code,
9
9
  :stock_exchange_symbol, :stock_symbol,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Job < Entity
6
- RESOURCE_LIST = 'jobs'
6
+ RESOURCE_LIST = 'jobs'.freeze
7
7
 
8
8
  attr_reader :title, :started_on, :started_on_trust_code, :ended_on, :ended_on_trust_code,
9
9
  :created_at, :updated_at
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Location < Entity
6
- RESOURCE_LIST = 'locations'
6
+ RESOURCE_LIST = 'locations'.freeze
7
7
 
8
8
  attr_reader :web_path, :name, :location_type, :parent_location_uuid,
9
9
  :city, :city_web_path,
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Member < Organization
6
- RESOURCE_LIST = 'members'
6
+ RESOURCE_LIST = 'members'.freeze
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Membership < Organization
6
- RESOURCE_LIST = 'memberships'
6
+ RESOURCE_LIST = 'memberships'.freeze
7
7
 
8
8
  attr_reader :object
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class New < Entity
6
- RESOURCE_LIST = 'news'
6
+ RESOURCE_LIST = 'news'.freeze
7
7
 
8
8
  attr_reader :title, :author, :posted_on, :posted_on_trust_code, :url, :created_at, :updated_at, :type
9
9
 
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Office < Address
6
- RESOURCE_LIST = 'offices'
6
+ RESOURCE_LIST = 'offices'.freeze
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Organization < Entity
6
- RESOURCE_LIST = RESOURCE_NAME = 'organizations'
6
+ RESOURCE_LIST = RESOURCE_NAME = 'organizations'.freeze
7
7
 
8
8
  attr_reader :permalink, :api_path, :web_path, :name, :also_known_as, :short_description, :description,
9
9
  :profile_image_url, :primary_role, :role_company, :role_investor, :role_group, :role_school,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class PastTeam < Job
6
- RESOURCE_LIST = 'past_team'
6
+ RESOURCE_LIST = 'past_team'.freeze
7
7
 
8
8
  attr_reader :person
9
9
 
@@ -4,7 +4,7 @@
4
4
  module Crunchbase
5
5
  module Model
6
6
  class Person < Entity
7
- RESOURCE_LIST = RESOURCE_NAME = 'people'
7
+ RESOURCE_LIST = RESOURCE_NAME = 'people'.freeze
8
8
 
9
9
  attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :gender, :also_known_as, :bio, :profile_image_url,
10
10
  :role_investor, :born_on, :born_on_trust_code, :is_deceased, :died_on, :died_on_trust_code, :name,
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Product < Entity
6
- RESOURCE_LIST = RESOURCE_NAME = 'products'
6
+ RESOURCE_LIST = RESOURCE_NAME = 'products'.freeze
7
7
 
8
8
  attr_reader :permalink, :api_path, :web_path, :name, :also_known_as,
9
9
  :lifecycle_stage, :short_description, :description, :profile_image_url,
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class SubOrganization < Organization
6
- RESOURCE_LIST = 'sub_organizations'
6
+ RESOURCE_LIST = 'sub_organizations'.freeze
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Video < Entity
6
- RESOURCE_LIST = 'videos'
6
+ RESOURCE_LIST = 'videos'.freeze
7
7
 
8
8
  attr_reader :title, :service_name, :url, :created_at, :updated_at
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Crunchbase::Model
5
5
  class Website < Entity
6
- RESOURCE_LIST = 'websites'
6
+ RESOURCE_LIST = 'websites'.freeze
7
7
 
8
8
  attr_reader :url, :created_at, :updated_at
9
9
  attr_reader :website_type, :website_name
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Crunchbase
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Crunchbase
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Crunchbase
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Crunchbase
3
- VERSION = '0.3.3'
4
+ VERSION = '0.3.4'.freeze
4
5
  end
data/lib/crunchbase.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'singleton'
3
4
  require 'time'
4
5
 
@@ -11,10 +12,10 @@ require 'crunchbase/api'
11
12
  require 'crunchbase/exception'
12
13
 
13
14
  module Crunchbase
14
- API_VERSION = '3.1'
15
- API_BASE_URL = 'https://api.crunchbase.com'
16
- WEB_SITE_URL = 'https://www.crunchbase.com'
17
- IMAGE_URL = 'https://res.cloudinary.com/crunchbase-production/'
15
+ API_VERSION = '3.1'.freeze
16
+ API_BASE_URL = 'https://api.crunchbase.com'.freeze
17
+ WEB_SITE_URL = 'https://www.crunchbase.com'.freeze
18
+ IMAGE_URL = 'https://res.cloudinary.com/crunchbase-production/'.freeze
18
19
 
19
20
  class << self
20
21
  end
@@ -1,69 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crunchbase::Model
4
- RSpec.describe BatchSearch do
4
+ RSpec.describe BatchSearch do
5
+ context 'perform invalid batch_search' do
6
+ it 'should raise ConfigurationException for non-array argument' do
7
+ expect { BatchSearch.batch_search({}) }.to raise_error Crunchbase::ConfigurationException
8
+ end
5
9
 
6
- context 'perform invalid batch_search' do
7
- it 'should raise ConfigurationException for non-array argument' do
8
- expect { BatchSearch.batch_search({}) }.to raise_error Crunchbase::ConfigurationException
9
- end
10
+ it 'should raise InvalidRequestException for too many requests' do
11
+ expect { BatchSearch.batch_search(Array.new(11)) }.to raise_error Crunchbase::InvalidRequestException
12
+ end
10
13
 
11
- it 'should raise InvalidRequestException for too many requests' do
12
- expect { BatchSearch.batch_search(Array.new(11)) }.to raise_error Crunchbase::InvalidRequestException
13
- end
14
+ it 'should raise MissingParamsException for invalid array item (without type and uuid fields)' do
15
+ invalid_array_arguments = [
16
+ [{}],
17
+ [{ type: 'Organization' }],
18
+ [{ type: 'Organization', uuid: 'unique_id' }, {}],
19
+ [{ type: 'Organization', uuid: 'unique_id' }, { uuid: 'unique_id' }]
20
+ ]
14
21
 
15
- it 'should raise MissingParamsException for invalid array item (without type and uuid fields)' do
16
- invalid_array_arguments = [
17
- [{}],
18
- [{ type: 'Organization' }],
19
- [{ type: 'Organization', uuid: 'unique_id' }, {}],
20
- [{ type: 'Organization', uuid: 'unique_id' }, { uuid: 'unique_id' }]
21
- ]
22
+ invalid_array_arguments.each do |invalid_argument|
23
+ expect { BatchSearch.batch_search(invalid_argument) }.to raise_error Crunchbase::MissingParamsException
24
+ end
25
+ end
22
26
 
23
- invalid_array_arguments.each do |invalid_argument|
24
- expect { BatchSearch.batch_search(invalid_argument) }.to raise_error Crunchbase::MissingParamsException
25
- end
26
- end
27
+ it 'should return an empty array for empty array argument' do
28
+ results = BatchSearch.batch_search([])
29
+ expect(results).to be_empty
30
+ end
27
31
 
28
- it 'should return an empty array for empty array argument' do
29
- results = BatchSearch.batch_search([])
30
- expect(results).to be_empty
31
- end
32
+ it 'should return an instance of Error for invalid uuid' do
33
+ invalid_request = [{ type: 'Organization', uuid: 'invalid_id' }]
34
+ results = BatchSearch.batch_search(invalid_request)
32
35
 
33
- it 'should return an instance of Error for invalid uuid' do
34
- invalid_request = [{ type: 'Organization', uuid: 'invalid_id' }]
35
- results = BatchSearch.batch_search(invalid_request)
36
+ expect(results.results.first).to be_an_instance_of(Crunchbase::Model::Error)
37
+ end
38
+ end
36
39
 
37
- expect(results.results.first).to be_an_instance_of(Crunchbase::Model::Error)
38
- end
39
- end
40
+ context 'perform valid batch_search' do
41
+ let(:requests) do
42
+ [
43
+ { type: 'Organization', uuid: 'df6628127f970b439d3e12f64f504fbb' },
44
+ { type: 'Organization', uuid: '0ea85f0296e15c42feebb786ecab2939' },
45
+ { type: 'Person', uuid: 'a01b8d46d31133337c34aa3ae9c03f22' }
46
+ ]
47
+ end
48
+ let(:batch_search) { BatchSearch.batch_search(requests) }
40
49
 
41
- context 'perform valid batch_search' do
42
- let(:requests) {
43
- [
44
- { type: 'Organization', uuid: 'df6628127f970b439d3e12f64f504fbb' },
45
- { type: 'Organization', uuid: '0ea85f0296e15c42feebb786ecab2939' },
46
- { type: 'Person', uuid: 'a01b8d46d31133337c34aa3ae9c03f22' }
47
- ]
48
- }
49
- let(:batch_search) { BatchSearch.batch_search(requests) }
50
+ it 'should return new instance of BatchSearch' do
51
+ expect(batch_search).to be_an_instance_of(BatchSearch)
52
+ end
50
53
 
51
- it 'should return new instance of BatchSearch' do
52
- expect(batch_search).to be_an_instance_of(BatchSearch)
53
- end
54
+ it 'should return an array of results' do
55
+ results = batch_search.results
56
+ expect(results).to be_an_instance_of(Array)
57
+ expect(results).not_to be_empty
58
+ end
54
59
 
55
- it 'should return an array of results' do
56
- results = batch_search.results
57
- expect(results).to be_an_instance_of(Array)
58
- expect(results).not_to be_empty
59
- end
60
-
61
- it 'should return an array of valid model objects' do
62
- results = batch_search.results
63
- expect(results[0]).to be_a(Crunchbase::Model::Organization)
64
- expect(results[1]).to be_a(Crunchbase::Model::Organization)
65
- expect(results[2]).to be_a(Crunchbase::Model::Person)
66
- end
67
- end
68
- end
69
- end
60
+ it 'should return an array of valid model objects' do
61
+ results = batch_search.results
62
+ expect(results[0]).to be_a(Crunchbase::Model::Organization)
63
+ expect(results[1]).to be_a(Crunchbase::Model::Organization)
64
+ expect(results[2]).to be_a(Crunchbase::Model::Person)
65
+ end
66
+ end
67
+ end
68
+ end
@@ -1,2 +1,2 @@
1
- user_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1
+ key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2
2
  debug: true
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,7 @@ require 'yaml'
12
12
 
13
13
  yaml = YAML.load_file(File.join(File.dirname(__FILE__), 'crunchbase.yml'))
14
14
 
15
- Crunchbase::API.key = yaml['user_key']
15
+ Crunchbase::API.key = yaml['key']
16
16
  Crunchbase::API.debug = yaml['debug']
17
17
 
18
18
  Dir[File.dirname(__FILE__) + '/crunchbase/support/*.rb'].each { |file| require file }
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase-ruby-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
5
- prerelease:
4
+ version: 0.3.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Encore Shao
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2019-01-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.6'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.6'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: pry
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '3.0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '3.0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec-its
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rubocop
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: A Ruby wrapper for Crunchbase API version 3.1
@@ -116,11 +103,11 @@ executables:
116
103
  extensions: []
117
104
  extra_rdoc_files: []
118
105
  files:
119
- - .gitignore
120
- - .rspec
121
- - .rubocop.yml
122
- - .rubocop_todo.yml
123
- - .travis.yml
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".rubocop.yml"
109
+ - ".rubocop_todo.yml"
110
+ - ".travis.yml"
124
111
  - Gemfile
125
112
  - LICENSE.txt
126
113
  - README.md
@@ -233,33 +220,26 @@ files:
233
220
  homepage: https://github.com/encoreshao/crunchbase-ruby-library
234
221
  licenses:
235
222
  - MIT
223
+ metadata: {}
236
224
  post_install_message:
237
225
  rdoc_options: []
238
226
  require_paths:
239
227
  - lib
240
228
  required_ruby_version: !ruby/object:Gem::Requirement
241
- none: false
242
229
  requirements:
243
- - - ! '>='
230
+ - - ">="
244
231
  - !ruby/object:Gem::Version
245
232
  version: '0'
246
- segments:
247
- - 0
248
- hash: -394987517701761930
249
233
  required_rubygems_version: !ruby/object:Gem::Requirement
250
- none: false
251
234
  requirements:
252
- - - ! '>='
235
+ - - ">="
253
236
  - !ruby/object:Gem::Version
254
237
  version: '0'
255
- segments:
256
- - 0
257
- hash: -394987517701761930
258
238
  requirements: []
259
239
  rubyforge_project:
260
- rubygems_version: 1.8.23.2
240
+ rubygems_version: 2.5.1
261
241
  signing_key:
262
- specification_version: 3
242
+ specification_version: 4
263
243
  summary: A Ruby wrapper for Crunchbase API v3.1
264
244
  test_files:
265
245
  - spec/crunchbase.yml.example