crunchbase 0.0.4 → 0.0.5

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.
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "json"
4
-
5
3
  group :development do
6
4
  gem "rspec"
7
5
  gem "bundler", "~> 1.0.0"
data/Gemfile.lock CHANGED
@@ -7,7 +7,6 @@ GEM
7
7
  bundler (~> 1.0)
8
8
  git (>= 1.2.5)
9
9
  rake
10
- json (1.5.4)
11
10
  rake (0.9.2)
12
11
  rcov (0.9.10)
13
12
  rdoc (3.9.4)
@@ -26,7 +25,6 @@ PLATFORMS
26
25
  DEPENDENCIES
27
26
  bundler (~> 1.0.0)
28
27
  jeweler (~> 1.6.4)
29
- json
30
28
  rcov
31
29
  rdoc
32
30
  rspec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Tyler Cunnion
1
+ Copyright (c) 2011-12 Tyler Cunnion
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -2,17 +2,23 @@
2
2
 
3
3
  Library for pulling data from the CrunchBase API.
4
4
 
5
- == Usage
5
+ == Dependencies
6
+
7
+ The Crunchbase API is entirely JSON-based. By default, if present, the gem will
8
+ use the {YAJL gem}[http://github.com/brianmario/yajl-ruby]; if not, it will
9
+ fall back to the {JSON gem}[http://flori.github.com/json/]. Please ensure one
10
+ of the two is installed.
11
+
12
+ == Basic Usage
6
13
 
7
14
  require 'crunchbase'
8
15
  steve = Crunchbase::Person.get("steve-jobs")
9
- facebook = Crunchbase::Company.get("facebook")
10
-
16
+ facebook = Crunchbase::Company.get("facebook")
11
17
 
12
18
  == Copyright
13
19
 
14
- Copyright (c) 2011 Tyler Cunnion. See LICENSE.txt for
15
- further details.
16
-
17
- I am not affiliated with AOL, Crunchbase, or anyone really.
20
+ Copyright (c) 2011 Tyler Cunnion. This software is made available under the
21
+ MIT/X11 license. See LICENSE.txt for further details.
18
22
 
23
+ I am not affiliated in any way with AOL, TechCrunch, Crunchbase, or anyone
24
+ really.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/crunchbase.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{crunchbase}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Tyler Cunnion}]
12
- s.date = %q{2011-11-06}
12
+ s.date = %q{2012-02-02}
13
13
  s.email = %q{tyler.cunnion@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -28,16 +28,22 @@ Gem::Specification.new do |s|
28
28
  "lib/crunchbase/cb_object.rb",
29
29
  "lib/crunchbase/company.rb",
30
30
  "lib/crunchbase/crunch_exception.rb",
31
+ "lib/crunchbase/date_methods.rb",
31
32
  "lib/crunchbase/financial_organization.rb",
32
33
  "lib/crunchbase/investment.rb",
33
34
  "lib/crunchbase/person.rb",
35
+ "lib/crunchbase/product.rb",
34
36
  "lib/crunchbase/relationship.rb",
35
37
  "lib/crunchbase/relationships/firm_relationship.rb",
36
38
  "lib/crunchbase/relationships/person_relationship.rb",
39
+ "lib/crunchbase/relationships/provider_relationship.rb",
40
+ "lib/crunchbase/service_provider.rb",
37
41
  "spec/crunchbase/api_spec.rb",
38
42
  "spec/crunchbase/company_spec.rb",
39
43
  "spec/crunchbase/financial_organization_spec.rb",
40
44
  "spec/crunchbase/person_spec.rb",
45
+ "spec/crunchbase/product_spec.rb",
46
+ "spec/crunchbase/service_provider_spec.rb",
41
47
  "spec/fixtures/brad-fitzpatrick.js",
42
48
  "spec/fixtures/steve-jobs.js",
43
49
  "spec/spec_helper.rb"
@@ -52,14 +58,12 @@ Gem::Specification.new do |s|
52
58
  s.specification_version = 3
53
59
 
54
60
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
- s.add_runtime_dependency(%q<json>, [">= 0"])
56
61
  s.add_development_dependency(%q<rspec>, [">= 0"])
57
62
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
58
63
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
59
64
  s.add_development_dependency(%q<rcov>, [">= 0"])
60
65
  s.add_development_dependency(%q<rdoc>, [">= 0"])
61
66
  else
62
- s.add_dependency(%q<json>, [">= 0"])
63
67
  s.add_dependency(%q<rspec>, [">= 0"])
64
68
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
69
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -67,7 +71,6 @@ Gem::Specification.new do |s|
67
71
  s.add_dependency(%q<rdoc>, [">= 0"])
68
72
  end
69
73
  else
70
- s.add_dependency(%q<json>, [">= 0"])
71
74
  s.add_dependency(%q<rspec>, [">= 0"])
72
75
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
76
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
data/lib/crunchbase.rb CHANGED
@@ -1,14 +1,18 @@
1
1
  require 'crunchbase/api'
2
2
  require 'crunchbase/cb_object'
3
+ require 'crunchbase/date_methods'
3
4
  require 'crunchbase/company'
4
5
  require 'crunchbase/financial_organization'
5
6
  require 'crunchbase/investment'
6
7
  require 'crunchbase/person'
8
+ require 'crunchbase/product'
9
+ require 'crunchbase/service_provider'
7
10
  require 'crunchbase/relationship'
8
11
  require 'crunchbase/relationships/firm_relationship'
9
12
  require 'crunchbase/relationships/person_relationship'
13
+ require 'crunchbase/relationships/provider_relationship'
10
14
  require 'crunchbase/crunch_exception'
11
15
 
12
16
  module Crunchbase
13
- VERSION = "0.0.4"
17
+ VERSION = "0.0.5"
14
18
  end
@@ -1,51 +1,79 @@
1
1
  require 'net/http'
2
- require 'json'
2
+
3
+ begin
4
+ require 'yajl'
5
+ rescue LoadError
6
+ require 'json'
7
+ end
8
+
3
9
  require 'timeout'
4
10
 
5
11
  module Crunchbase
6
-
12
+
7
13
  # Handles the actual calls to the Crunchbase API through a series of class
8
14
  # methods, each referring to a CB entity type. Each method returns the raw
9
15
  # JSON returned from the API. You should probably be using the factory
10
16
  # methods provided on each entity class instead of calling these directly.
11
17
  class API
12
18
  CB_URL = 'http://api.crunchbase.com/v/1/'
13
-
19
+
14
20
  def self.person(permalink)
15
21
  fetch(permalink, 'person')
16
22
  end
17
-
23
+
18
24
  def self.company(permalink)
19
25
  fetch(permalink, 'company')
20
26
  end
21
-
27
+
22
28
  def self.financial_organization(permalink)
23
29
  fetch(permalink, 'financial-organization')
24
30
  end
25
-
31
+
26
32
  def self.product(permalink)
27
33
  fetch(permalink, 'product')
28
34
  end
29
-
35
+
30
36
  def self.service_provider(permalink)
31
37
  fetch(permalink, 'service-provider')
32
38
  end
33
-
39
+
34
40
  private
35
-
41
+
36
42
  # Fetches URI and parses JSON. Raises Timeout::Error if fetching times out.
37
43
  # Raises CrunchException if the returned JSON indicates an error.
38
44
  def self.fetch(permalink, object_name)
39
- uri = URI.parse(CB_URL + "#{object_name}/#{permalink}.js")
40
- resp = Timeout::timeout(5) {
41
- Net::HTTP.get(uri)
45
+ uri = CB_URL + "#{object_name}/#{permalink}.js"
46
+ resp = Timeout::timeout(60) {
47
+ get_url_following_redirects(uri, 5)
42
48
  }
43
- j = JSON.parse(resp)
49
+ j = parser.parse(resp)
44
50
  raise CrunchException, j["error"] if j["error"]
45
51
  return j
46
52
  end
47
-
48
-
53
+
54
+ def self.parser
55
+ if defined?(Yajl)
56
+ Yajl::Parser
57
+ else
58
+ JSON
59
+ end
60
+ end
61
+
62
+ def self.get_url_following_redirects(uri_str, limit = 10)
63
+ raise CrunchException, 'HTTP redirect too deep' if limit == 0
64
+
65
+ url = URI.parse(uri_str)
66
+ req = Net::HTTP::Get.new(url.path)
67
+ response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
68
+ case response
69
+ when Net::HTTPSuccess
70
+ response.body
71
+ when Net::HTTPRedirection
72
+ get_url_following_redirects(response['location'], limit - 1)
73
+ else
74
+ response.error!
75
+ end
76
+ end
77
+
49
78
  end
50
79
  end
51
-
@@ -1,4 +1,6 @@
1
1
  module Crunchbase
2
+
3
+ # Represents any object which can be pulled directly from the CB API.
2
4
  class CB_Object
3
5
 
4
6
  # Returns an array of tags
@@ -2,16 +2,17 @@ require 'date'
2
2
  module Crunchbase
3
3
  class Company < CB_Object
4
4
 
5
+ include Crunchbase::DateMethods
6
+
5
7
  attr_reader :name, :permalink, :crunchbase_url, :homepage_url, :blog_url,
6
8
  :blog_feed_url, :twitter_username, :category_code, :number_of_employees,
7
- :founded_year, :founded_month, :founded_day, :deadpooled_year,
8
- :deadpooled_month, :deadpooled_day, :deadpooled_url, :tag_list,
9
- :alias_list, :email_address, :phone_number, :description, :created_at,
10
- :updated_at, :overview, :image, :products, :relationships, :competitions,
11
- :providerships, :total_money_raised, :funding_rounds, :investments,
12
- :acquisition, :acquisitions, :offices, :milestones, :ipo, :video_embeds,
13
- :screenshots, :external_links
14
-
9
+ :deadpooled_url, :email_address, :phone_number, :description,
10
+ :created_at, :updated_at, :overview, :image, :relationships,
11
+ :competitions, :providerships, :total_money_raised, :funding_rounds,
12
+ :investments, :acquisition, :acquisitions, :offices, :milestones, :ipo,
13
+ :video_embeds, :screenshots, :external_links
14
+
15
+ # Factory method to return a Company instance from a permalink
15
16
  def self.get(permalink)
16
17
  j = API.company(permalink)
17
18
  c = Company.new(j)
@@ -44,10 +45,10 @@ module Crunchbase
44
45
  @updated_at = DateTime.parse(json["updated_at"])
45
46
  @overview = json["overview"]
46
47
  @image = json["image"]
47
- @products = json["products"]
48
+ @products_list = json["products"]
48
49
  @relationships = Relationship.array_from_relationship_list(json["relationships"]) if json["relationships"]
49
50
  @competitions = json["competitions"]
50
- @providerships = json["providerships"]
51
+ @providerships = Relationship.array_from_relationship_list(json["providerships"]) if json["providerships"]
51
52
  @total_money_raised = json["total_money_raised"]
52
53
  @funding_rounds = json["funding_rounds"]
53
54
  @investments = Investment.array_from_investment_list(json['investments']) if json['investments']
@@ -63,23 +64,17 @@ module Crunchbase
63
64
 
64
65
  # Returns the date the company was founded, or nil if not provided.
65
66
  def founded
66
- begin
67
- founded = Date.new(@founded_year, @founded_month, @founded_day)
68
- rescue
69
- founded = nil
70
- end
71
- return founded
67
+ @founded ||= date_from_components(@founded_year, @founded_month, @founded_day)
72
68
  end
73
69
 
74
70
  # Returns the date the company was deadpooled, or nil if not provided.
75
71
  def deadpooled
76
- begin
77
- dp = Date.new(@deadpooled_year, @deadpooled_month, @deadpooled_day)
78
- rescue
79
- dp = nil
80
- end
81
- return dp
72
+ @deadpooled ||= date_from_components(@deadpooled_year, @deadpooled_month, @deadpooled_day)
82
73
  end
83
-
74
+
75
+ def products
76
+ @products ||= @products_list.map {|p| Product.get(p['permalink']) }
77
+ end
78
+
84
79
  end
85
80
  end
@@ -0,0 +1,15 @@
1
+ module Crunchbase
2
+ module DateMethods
3
+
4
+ # Constructs a Date object from year, month, day, returns nil if it fails
5
+ def date_from_components(year, month, day)
6
+ begin
7
+ date = Date.new(year, month, day)
8
+ rescue
9
+ date = nil
10
+ end
11
+ date
12
+ end
13
+
14
+ end
15
+ end
@@ -2,13 +2,15 @@ require 'date'
2
2
  module Crunchbase
3
3
  class FinancialOrganization < CB_Object
4
4
 
5
+ include Crunchbase::DateMethods
6
+
5
7
  attr_reader :name, :permalink, :crunchbase_url, :homepage_url, :blog_url,
6
8
  :blog_feed_url, :twitter_username, :phone_number, :description,
7
- :email_address, :number_of_employees, :founded_year, :founded_month,
8
- :founded_day, :tag_list, :alias_list, :created_at, :updated_at,
9
- :overview, :image, :offices, :relationships, :investments, :milestones,
9
+ :email_address, :number_of_employees, :created_at, :updated_at,
10
+ :overview, :image, :offices, :relationships, :investments, :milestones,
10
11
  :providerships, :funds, :video_embeds, :external_links
11
12
 
13
+ # Factory method to return a FinancialOrganization instance from a permalink
12
14
  def self.get(permalink)
13
15
  j = API.financial_organization(permalink)
14
16
  f = FinancialOrganization.new(j)
@@ -40,7 +42,7 @@ module Crunchbase
40
42
  @relationships = Relationship.array_from_relationship_list(json["relationships"]) if json["relationships"]
41
43
  @investments = Investment.array_from_investment_list(json['investments']) if json['investments']
42
44
  @milestones = json['milestones']
43
- @providerships = json['providerships']
45
+ @providerships = Relationship.array_from_relationship_list(json['providerships']) if json["providerships"]
44
46
  @funds = json['funds']
45
47
  @video_embeds = json['video_embeds']
46
48
  @external_links = json['external_links']
@@ -48,12 +50,7 @@ module Crunchbase
48
50
 
49
51
  # Returns the date the financial org was founded, or nil if not provided.
50
52
  def founded
51
- begin
52
- founded = Date.new(@founded_year, @founded_month, @founded_day)
53
- rescue
54
- founded = nil
55
- end
56
- return founded
53
+ @founded ||= date_from_components(@founded_year, @founded_month, @founded_day)
57
54
  end
58
55
  end
59
56
  end
@@ -1,6 +1,8 @@
1
1
  module Crunchbase
2
2
  class Investment
3
3
 
4
+ include Crunchbase::DateMethods
5
+
4
6
  attr_reader :funding_round_code, :funding_source_url,
5
7
  :funding_source_description, :raised_amount, :raised_currency_code,
6
8
  :company_name, :company_permalink
@@ -32,12 +34,7 @@ module Crunchbase
32
34
  end
33
35
 
34
36
  def funded_date
35
- begin
36
- date = Date.new(@funded_year, @funded_month, @funded_day)
37
- rescue
38
- nil
39
- end
40
- date
37
+ @funded_date ||= date_from_components(@funded_year, @funded_month, @funded_day)
41
38
  end
42
39
 
43
40
  end
@@ -1,14 +1,16 @@
1
1
  require 'date'
2
2
  module Crunchbase
3
3
  class Person < CB_Object
4
+
5
+ include Crunchbase::DateMethods
4
6
 
5
7
  attr_reader :first_name, :last_name, :permalink, :crunchbase_url,
6
8
  :homepage_url, :birthplace, :twitter_username, :blog_url, :blog_feed_url,
7
- :affiliation_name, :born_year, :born_month, :born_day, :created_at,
8
- :updated_at, :overview, :tag_list, :alias_list, :created_at, :updated_at,
9
- :overview, :relationships, :investments, :milestones, :video_embeds,
10
- :external_links, :web_presences
9
+ :affiliation_name, :created_at, :updated_at, :overview, :created_at,
10
+ :updated_at, :overview, :relationships, :investments, :milestones,
11
+ :video_embeds, :external_links, :web_presences
11
12
 
13
+ # Factory method to return a Person instance from a permalink
12
14
  def self.get(permalink)
13
15
  j = API.person(permalink)
14
16
  p = Person.new(j)
@@ -46,12 +48,7 @@ module Crunchbase
46
48
  # Returns a date object, or nil if Date cannot be created from
47
49
  # provided information.
48
50
  def born
49
- begin
50
- born = Date.new(@born_year, @born_month, @born_day)
51
- rescue
52
- born = nil
53
- end
54
- born
51
+ @born ||= date_from_components(@born_year, @born_month, @born_day)
55
52
  end
56
53
 
57
54
  end
@@ -0,0 +1,66 @@
1
+ require 'date'
2
+ module Crunchbase
3
+ class Product < CB_Object
4
+
5
+ include Crunchbase::DateMethods
6
+
7
+ attr_reader :name, :permalink, :crunchbase_url, :homepage_url, :blog_url,
8
+ :blog_feed_url, :twitter_username, :stage_code, :deadpooled_url,
9
+ :invite_share_url, :created_at, :updated_at, :overview, :image,
10
+ :company_permalink, :company_name, :milestones, :video_embeds,
11
+ :external_links
12
+
13
+ def self.get(permalink)
14
+ j = API.product(permalink)
15
+ return Product.new(j)
16
+ end
17
+
18
+ def initialize(json)
19
+ @name = json['name']
20
+ @permalink = json['permalink']
21
+ @crunchbase_url = json['crunchbase_url']
22
+ @homepage_url = json['homepage_url']
23
+ @blog_url = json['blog_url']
24
+ @blog_feed_url = json['blog_feed_url']
25
+ @twitter_username = json['twitter_username']
26
+ @stage_code = json['stage_code']
27
+ @deadpooled_url = json['deadpooled_url']
28
+ @invite_share_url = json['invite_share_url']
29
+ @tag_list = json['tag_list']
30
+ @alias_list = json['alias_list']
31
+ @deadpooled_year = json['deadpooled_year']
32
+ @deadpooled_month = json['deadpooled_month']
33
+ @deadpooled_day = json['deadpooled_day']
34
+ @launched_year = json['launched_year']
35
+ @launched_month = json['launched_month']
36
+ @launched_day = json['launched_day']
37
+ @created_at = DateTime.parse(json['created_at'])
38
+ @updated_at = DateTime.parse(json['updated_at'])
39
+ @overview = json['overview']
40
+ @image = json['image']
41
+ @company_permalink = json['company']['permalink']
42
+ @company_name = json['company']['name']
43
+ @milestones = json['milestones']
44
+ @video_embeds = json['video_embeds']
45
+ @external_links = json['external_links']
46
+ end
47
+
48
+ # Returns the date the product was deadpooled, or nil if not provided.
49
+ def deadpooled
50
+ @deadpooled ||= date_from_components(@deadpooled_year, @deadpooled_month, @deadpooled_day)
51
+ end
52
+
53
+ # Returns the date the product was launched, or nil if not provided.
54
+ def launched
55
+ @launched ||= date_from_components(@launched_year, @launched_month, @launched_day)
56
+ end
57
+
58
+ # Lazy-loads the associated Company entity and caches it. Pass true to
59
+ # force reload.
60
+ def company(force_reload = false)
61
+ return @company unless @company.nil? or force_reload
62
+ @company = Company.get(@company_permalink)
63
+ return @company
64
+ end
65
+ end
66
+ end
@@ -1,19 +1,24 @@
1
1
  module Crunchbase
2
+ # Superclass for all relationships. Used for both the relationships and
3
+ # providerships arrays on retrieved objects.
2
4
  class Relationship
3
5
 
4
6
  attr_reader :title
5
7
 
6
8
  # Takes a relationship list (directly from the JSON hash) and returns an
7
- # array of instances of Relationship subclasses. Raises CrunchException if
8
- # the relationship is not one of the recognized types.
9
+ # array of instances of Relationship subclasses.
9
10
  def self.array_from_relationship_list(list)
10
11
  list.map do |l|
11
12
  if l["person"]
12
13
  PersonRelationship.new(l)
13
14
  elsif l["firm"]
14
15
  FirmRelationship.new(l)
16
+ elsif l["provider"]
17
+ ProviderRelationship.new(l)
15
18
  else
16
- raise CrunchException, "Relationship type not recognized"
19
+ # "Relationship type not recognized"
20
+ # TODO: Figure out how to log this
21
+ next
17
22
  end
18
23
  end
19
24
  end
@@ -0,0 +1,24 @@
1
+ module Crunchbase
2
+ class ProviderRelationship < Relationship
3
+
4
+ attr_reader :provider_name, :provider_permalink
5
+
6
+ def self.array_from_relationship_list #:nodoc:
7
+ raise CrunchException, "Method must be called from superclass Relationship"
8
+ end
9
+
10
+ def initialize(hash)
11
+ super(hash)
12
+ @provider_name = hash["provider"]["name"]
13
+ @provider_permalink = hash["provider"]["permalink"]
14
+ end
15
+
16
+ # Returns a representation of the associated person, loading from memory
17
+ # if previously fetched, unless force_reload is set to true.
18
+ def provider(force_reload=false)
19
+ return @provider unless @provider.nil? || force_reload
20
+ @provider = ServiceProvider.get(@provider_permalink)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ require 'date'
2
+ module Crunchbase
3
+ class ServiceProvider < CB_Object
4
+
5
+ attr_reader :name, :permalink, :crunchbase_url, :homepage_url,
6
+ :phone_number, :created_at, :updated_at, :overview, :image, :offices,
7
+ :providerships, :external_links
8
+
9
+ # Factory method to return a ServiceProvider instance from a permalink
10
+ def self.get(permalink)
11
+ j = API.service_provider(permalink)
12
+ s = ServiceProvider.new(j)
13
+ return s
14
+ end
15
+
16
+ def initialize(json)
17
+ @name = json["name"]
18
+ @permalink = json["permalink"]
19
+ @crunchbase_url = json["crunchbase_url"]
20
+ @homepage_url = json["homepage_url"]
21
+ @phone_number = json["phone_number"]
22
+ @tag_list = json["tag_list"]
23
+ @alias_list = json["alias_list"]
24
+ @created_at = DateTime.parse(json["created_at"])
25
+ @updated_at = DateTime.parse(json["updated_at"])
26
+ @overview = json["overview"]
27
+ @image = json["image"]
28
+ @offices = json["offices"]
29
+ @providerships = Relationship.array_from_relationship_list(json["providerships"]) if json["providerships"]
30
+ @external_links = json["external_links"]
31
+ end
32
+
33
+
34
+ end
35
+ end
@@ -17,6 +17,11 @@ module Crunchbase
17
17
  it "should raise exception on unfound person" do
18
18
  expect { API.person("not-real") }.to raise_error
19
19
  end
20
+
21
+ it "should follow redirects" do
22
+ c = Company.get("adobe")
23
+ c.name.should == "Adobe Systems"
24
+ end
20
25
 
21
26
  end
22
27
  end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe Product do
5
+
6
+ it "should pull from web api" do
7
+ product = Product.get("iphone")
8
+ product.name.should == "iPhone"
9
+ end
10
+
11
+ it "should return date for launched" do
12
+ product = Product.new({"launched_year" => 2004, "launched_month" => 2,
13
+ "launched_day" => 1, "created_at" => "Sat Dec 22 08:42:28 UTC 2007",
14
+ "updated_at" => "Sat Dec 22 08:42:28 UTC 2007", "company" => {}})
15
+ product.launched.should === Date.new(2004, 2, 1)
16
+ end
17
+
18
+ it "should return date for deadpooled" do
19
+ product = Product.new({"deadpooled_year" => 2004, "deadpooled_month" => 2,
20
+ "deadpooled_day" => 1, "created_at" => "Sat Dec 22 08:42:28 UTC 2007",
21
+ "updated_at" => "Sat Dec 22 08:42:28 UTC 2007", "company" => {}})
22
+ product.deadpooled.should === Date.new(2004, 2, 1)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
+
3
+ module Crunchbase
4
+ describe ServiceProvider do
5
+
6
+ it "should pull from web api" do
7
+ sp = ServiceProvider.get("fox-rothschild")
8
+ sp.name.should == "Fox Rothschild"
9
+ end
10
+
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-06 00:00:00.000000000Z
12
+ date: 2012-02-02 00:00:00.000000000Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: json
16
- requirement: &70148116196560 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70148116196560
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: rspec
27
- requirement: &70148116195260 !ruby/object:Gem::Requirement
16
+ requirement: &70273283484480 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,10 +21,10 @@ dependencies:
32
21
  version: '0'
33
22
  type: :development
34
23
  prerelease: false
35
- version_requirements: *70148116195260
24
+ version_requirements: *70273283484480
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: bundler
38
- requirement: &70148116194160 !ruby/object:Gem::Requirement
27
+ requirement: &70273283483700 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ~>
@@ -43,10 +32,10 @@ dependencies:
43
32
  version: 1.0.0
44
33
  type: :development
45
34
  prerelease: false
46
- version_requirements: *70148116194160
35
+ version_requirements: *70273283483700
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: jeweler
49
- requirement: &70148116193080 !ruby/object:Gem::Requirement
38
+ requirement: &70273283482860 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ~>
@@ -54,10 +43,10 @@ dependencies:
54
43
  version: 1.6.4
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *70148116193080
46
+ version_requirements: *70273283482860
58
47
  - !ruby/object:Gem::Dependency
59
48
  name: rcov
60
- requirement: &70148116191740 !ruby/object:Gem::Requirement
49
+ requirement: &70273283481660 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ! '>='
@@ -65,10 +54,10 @@ dependencies:
65
54
  version: '0'
66
55
  type: :development
67
56
  prerelease: false
68
- version_requirements: *70148116191740
57
+ version_requirements: *70273283481660
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: rdoc
71
- requirement: &70148116190380 !ruby/object:Gem::Requirement
60
+ requirement: &70273283480380 !ruby/object:Gem::Requirement
72
61
  none: false
73
62
  requirements:
74
63
  - - ! '>='
@@ -76,7 +65,7 @@ dependencies:
76
65
  version: '0'
77
66
  type: :development
78
67
  prerelease: false
79
- version_requirements: *70148116190380
68
+ version_requirements: *70273283480380
80
69
  description:
81
70
  email: tyler.cunnion@gmail.com
82
71
  executables: []
@@ -97,16 +86,22 @@ files:
97
86
  - lib/crunchbase/cb_object.rb
98
87
  - lib/crunchbase/company.rb
99
88
  - lib/crunchbase/crunch_exception.rb
89
+ - lib/crunchbase/date_methods.rb
100
90
  - lib/crunchbase/financial_organization.rb
101
91
  - lib/crunchbase/investment.rb
102
92
  - lib/crunchbase/person.rb
93
+ - lib/crunchbase/product.rb
103
94
  - lib/crunchbase/relationship.rb
104
95
  - lib/crunchbase/relationships/firm_relationship.rb
105
96
  - lib/crunchbase/relationships/person_relationship.rb
97
+ - lib/crunchbase/relationships/provider_relationship.rb
98
+ - lib/crunchbase/service_provider.rb
106
99
  - spec/crunchbase/api_spec.rb
107
100
  - spec/crunchbase/company_spec.rb
108
101
  - spec/crunchbase/financial_organization_spec.rb
109
102
  - spec/crunchbase/person_spec.rb
103
+ - spec/crunchbase/product_spec.rb
104
+ - spec/crunchbase/service_provider_spec.rb
110
105
  - spec/fixtures/brad-fitzpatrick.js
111
106
  - spec/fixtures/steve-jobs.js
112
107
  - spec/spec_helper.rb
@@ -125,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
120
  version: '0'
126
121
  segments:
127
122
  - 0
128
- hash: 344321795598271852
123
+ hash: -3154475124143607106
129
124
  required_rubygems_version: !ruby/object:Gem::Requirement
130
125
  none: false
131
126
  requirements: