crunchbase-ruby-library 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,8 @@
3
3
  module Crunchbase
4
4
  module Model
5
5
  autoload :AcquiredBy, "crunchbase/model/acquired_by"
6
+ autoload :Acquiree, "crunchbase/model/acquiree"
7
+ autoload :Acquirer, "crunchbase/model/acquirer"
6
8
  autoload :Acquisition, "crunchbase/model/acquisition"
7
9
  autoload :Address, "crunchbase/model/address"
8
10
  autoload :AdvisoryRole, "crunchbase/model/advisory_role"
@@ -43,6 +45,7 @@ module Crunchbase
43
45
  autoload :School, "crunchbase/model/school"
44
46
  autoload :Search, "crunchbase/model/search"
45
47
  autoload :SearchResult, "crunchbase/model/search_result"
48
+ autoload :SimpleOrganization, "crunchbase/model/simple_organization"
46
49
  autoload :SubOrganization, "crunchbase/model/sub_organization"
47
50
  autoload :Video, "crunchbase/model/video"
48
51
  autoload :Website, "crunchbase/model/website"
@@ -8,13 +8,13 @@ module Crunchbase::Model
8
8
  attr_reader :announced_on, :name, :path, :created_at, :updated_at
9
9
 
10
10
  def initialize(json)
11
- property_keys.each { |v|
12
- instance_variable_set("@#{v}", json[v] || nil)
13
- }
11
+ property_keys.each { |v|
12
+ instance_variable_set("@#{v}", json[v] || nil)
13
+ }
14
14
 
15
- %w[created_at updated_at].each { |v|
16
- instance_variable_set("@#{v}", Time.at(json[v]))
17
- }
15
+ %w[created_at updated_at].each { |v|
16
+ instance_variable_set("@#{v}", Time.at(json[v]))
17
+ }
18
18
  end
19
19
 
20
20
  def property_keys
@@ -26,4 +26,4 @@ module Crunchbase::Model
26
26
  end
27
27
 
28
28
  end
29
- end
29
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Acquiree < Crunchbase::Model::SimpleOrganization
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Acquirer < Crunchbase::Model::SimpleOrganization
5
+ end
6
+ end
@@ -2,35 +2,46 @@
2
2
 
3
3
  module Crunchbase::Model
4
4
  class Acquisition < Crunchbase::Model::Entity
5
-
5
+
6
6
  RESOURCE_LIST = 'acquisitions'
7
+ RESOURCE_NAME = 'acquisitions'
7
8
 
8
- attr_reader :api_path, :web_path, :price, :price_currency_code, :price_usd,
9
- :payment_type, :acquisition_type, :acquisition_status, :disposition_of_acquired,
10
- :announced_on, :announced_on_trust_code, :completed_on, :completed_on_trust_code,
9
+ attr_reader :api_path, :web_path, :price, :price_currency_code, :price_usd,
10
+ :payment_type, :acquisition_type, :acquisition_status, :disposition_of_acquired,
11
+ :announced_on, :announced_on_trust_code, :completed_on, :completed_on_trust_code,
11
12
  :created_at, :updated_at
12
13
 
13
14
 
14
- attr_reader :acquirer, :acquiree
15
+ attr_reader :acquirer, :acquiree, :news
15
16
 
16
- attr_reader :acquirer_total_items, :acquiree_total_items
17
+ attr_reader :acquirer_total_items, :acquiree_total_items, :news_items
17
18
 
18
19
  def initialize(json)
19
20
  super
20
21
 
21
22
  unless (relationships = json['relationships']).nil?
22
- instance_relationships_object(Crunchbase::Model::Organization, 'acquiree', relationships['acquiree'])
23
+ if relationships['acquiree']['item'].nil?
24
+ instance_relationships_object(Crunchbase::Model::Organization, 'acquiree', relationships['acquiree'])
25
+ else
26
+ set_relationships_object(Crunchbase::Model::Acquiree, 'acquiree', relationships['acquiree'])
27
+ set_relationships_object(Crunchbase::Model::Acquirer, 'acquirer', relationships['acquirer'])
28
+ set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
29
+ end
23
30
  end
24
31
  end
25
32
 
26
33
  def property_keys
27
34
  %w[
28
- api_path web_path price price_currency_code price_usd
29
- payment_type acquisition_type acquisition_status disposition_of_acquired
30
- announced_on announced_on_trust_code completed_on completed_on_trust_code
35
+ api_path web_path price price_currency_code price_usd
36
+ payment_type acquisition_type acquisition_status disposition_of_acquired
37
+ announced_on announced_on_trust_code completed_on completed_on_trust_code
31
38
  created_at updated_at
32
39
  ]
33
40
  end
34
41
 
42
+ def date_keys
43
+ %w[ announced_on completed_on ]
44
+ end
45
+
35
46
  end
36
- end
47
+ end
@@ -6,27 +6,27 @@ module Crunchbase::Model
6
6
  attr_reader :type_name, :uuid
7
7
 
8
8
  def initialize(json)
9
- instance_variable_set("@type_name", json['type'] || nil)
10
- instance_variable_set("@uuid", json['uuid'] || nil)
9
+ instance_variable_set("@type_name", json['type'] || nil)
10
+ instance_variable_set("@uuid", json['uuid'] || nil)
11
11
 
12
- property_keys.each { |v|
13
- instance_variable_set("@#{v}", json['properties'][v] || nil)
14
- }
12
+ property_keys.each { |v|
13
+ instance_variable_set("@#{v}", json['properties'][v] || nil)
14
+ }
15
15
 
16
- date_keys.each { |v|
17
- instance_variable_set("@#{v}", json['properties'][v].nil? ? nil : Date.parse(json['properties'][v]))
18
- }
16
+ date_keys.each { |v|
17
+ instance_variable_set("@#{v}", json['properties'][v].nil? ? nil : Date.parse(json['properties'][v]))
18
+ }
19
19
 
20
- %w[created_at updated_at].each { |v|
20
+ %w[created_at updated_at].each { |v|
21
21
  if json['properties'][v].kind_of?(String)
22
- instance_variable_set( "@#{v}", begin Time.parse(json['properties'][v]) rescue nil end )
23
- else
24
- instance_variable_set( "@#{v}", begin Time.at(json['properties'][v]) rescue nil end )
22
+ instance_variable_set( "@#{v}", begin Time.parse(json['properties'][v]) rescue nil end )
23
+ else
24
+ instance_variable_set( "@#{v}", begin Time.at(json['properties'][v]) rescue nil end )
25
25
  end
26
- }
26
+ }
27
27
  end
28
-
29
- # Factory method to return an instance from a permalink
28
+
29
+ # Factory method to return an instance from a permalink
30
30
  def self.get(permalink)
31
31
  result = Crunchbase::API.single_entity(permalink, self::RESOURCE_NAME)
32
32
 
@@ -35,7 +35,7 @@ module Crunchbase::Model
35
35
 
36
36
  def self.list(page=nil)
37
37
  model_name = get_model_name(self::RESOURCE_LIST)
38
-
38
+
39
39
  return Crunchbase::API.list( { page: page, model_name: model_name }, self::RESOURCE_LIST )
40
40
  end
41
41
 
@@ -74,7 +74,7 @@ module Crunchbase::Model
74
74
 
75
75
  def self.parsing_from_list(list)
76
76
  return [] if list.nil?
77
-
77
+
78
78
  list.map do |l|
79
79
  self.new l if l.kind_of?(Hash)
80
80
  end.compact
@@ -82,7 +82,7 @@ module Crunchbase::Model
82
82
 
83
83
  def self.total_items_from_list(list)
84
84
  return 0 if list.nil?
85
-
85
+
86
86
  list['paging']['total_items']
87
87
  end
88
88
 
@@ -95,7 +95,7 @@ module Crunchbase::Model
95
95
  def date_keys
96
96
  []
97
97
  end
98
-
98
+
99
99
  def set_relationships_object(object_name, key, list)
100
100
  return unless list
101
101
 
@@ -114,20 +114,20 @@ module Crunchbase::Model
114
114
  return unless list['items'].respond_to?(:each)
115
115
 
116
116
  instance_variable_set "@#{key}", list['items'].inject([]) { |v, i| v << object_name.new(i) }
117
- instance_variable_set "@#{key}_total_items", list['paging']['total_items']
117
+ instance_variable_set "@#{key}_total_items", list['paging']['total_items']
118
118
  end
119
-
119
+
120
120
  def instance_relationships_object(object_name, key, item)
121
121
  return unless item
122
122
 
123
123
  instance_variable_set "@#{key}", ( object_name.new(item) || nil )
124
124
  end
125
-
125
+
126
126
  def self.get_model_name(resource_list)
127
127
  return nil unless ['organizations', 'people'].include?(resource_list)
128
128
 
129
- case resource_list
130
- when 'organizations'
129
+ case resource_list
130
+ when 'organizations'
131
131
  OrganizationSummary
132
132
  when 'people'
133
133
  PersonSummary
@@ -8,13 +8,13 @@ module Crunchbase::Model
8
8
  attr_reader :type, :name, :path, :created_at, :updated_at
9
9
 
10
10
  def initialize(json)
11
- property_keys.each { |v|
12
- instance_variable_set("@#{v}", json[v] || nil)
13
- }
11
+ property_keys.each { |v|
12
+ instance_variable_set("@#{v}", json[v] || nil)
13
+ }
14
14
 
15
- %w[created_at updated_at].each { |v|
16
- instance_variable_set("@#{v}", Time.at(json[v]))
17
- }
15
+ %w[created_at updated_at].each { |v|
16
+ instance_variable_set("@#{v}", Time.at(json[v]))
17
+ }
18
18
  end
19
19
 
20
20
  def property_keys
@@ -24,4 +24,4 @@ module Crunchbase::Model
24
24
  end
25
25
 
26
26
  end
27
- end
27
+ end
@@ -2,30 +2,30 @@
2
2
 
3
3
  module Crunchbase::Model
4
4
  class Organization < Crunchbase::Model::Entity
5
-
5
+
6
6
  RESOURCE_LIST = RESOURCE_NAME = 'organizations'
7
7
 
8
- attr_reader :permalink, :api_path, :web_path, :name, :also_known_as, :short_description, :description,
9
- :primary_role, :role_company, :role_investor, :role_group, :role_school,
10
- :founded_on, :founded_on_trust_code, :is_closed, :closed_on, :closed_on_trust_code,
11
- :num_employees_min, :num_employees_max,
12
- :total_funding_usd,
13
- :stock_exchange, :stock_symbol,
14
- :number_of_investments, :homepage_url,
8
+ attr_reader :permalink, :api_path, :web_path, :name, :also_known_as, :short_description, :description,
9
+ :primary_role, :role_company, :role_investor, :role_group, :role_school,
10
+ :founded_on, :founded_on_trust_code, :is_closed, :closed_on, :closed_on_trust_code,
11
+ :num_employees_min, :num_employees_max,
12
+ :total_funding_usd,
13
+ :stock_exchange, :stock_symbol,
14
+ :number_of_investments, :homepage_url,
15
15
  :created_at, :updated_at
16
16
 
17
- attr_reader :primary_image, :founders, :current_team, :past_team, :board_members_and_advisors,
18
- :investors, :owned_by, :sub_organizations, :headquarters, :offices, :products,
19
- :categories, :customers, :competitors, :members, :memberships, :funding_rounds, :investments,
17
+ attr_reader :primary_image, :founders, :current_team, :past_team, :board_members_and_advisors,
18
+ :investors, :owned_by, :sub_organizations, :headquarters, :offices, :products,
19
+ :categories, :customers, :competitors, :members, :memberships, :funding_rounds, :investments,
20
20
  :acquisitions, :acquired_by, :ipo, :funds, :websites, :images, :videos, :news
21
21
 
22
- attr_reader :primary_image_total_items, :founders_total_items, :current_team_total_items,
23
- :past_team_total_items, :board_members_and_advisors_total_items, :investors_total_items,
24
- :owned_by_total_items, :sub_organizations_total_items, :headquarters_total_items,
25
- :offices_total_items, :products_total_items, :categories_total_items,
26
- :customers_total_items, :competitors_total_items, :members_total_items,
27
- :memberships_total_items, :funding_rounds_total_items, :investments_total_items,
28
- :acquisitions_total_items, :acquired_by_total_items,
22
+ attr_reader :primary_image_total_items, :founders_total_items, :current_team_total_items,
23
+ :past_team_total_items, :board_members_and_advisors_total_items, :investors_total_items,
24
+ :owned_by_total_items, :sub_organizations_total_items, :headquarters_total_items,
25
+ :offices_total_items, :products_total_items, :categories_total_items,
26
+ :customers_total_items, :competitors_total_items, :members_total_items,
27
+ :memberships_total_items, :funding_rounds_total_items, :investments_total_items,
28
+ :acquisitions_total_items, :acquired_by_total_items,
29
29
  :ipo_total_items, :funds_total_items, :websites_total_items, :images_total_items,
30
30
  :videos_total_items, :news_total_items
31
31
 
@@ -64,12 +64,12 @@ module Crunchbase::Model
64
64
 
65
65
  def property_keys
66
66
  %w[
67
- permalink api_path web_path name also_known_as short_description description
68
- primary_role role_company role_investor role_group role_school
69
- founded_on founded_on_trust_code is_closed closed_on closed_on_trust_code
70
- num_employees_min num_employees_max total_funding_usd
71
- stock_exchange stock_symbol
72
- number_of_investments homepage_url
67
+ permalink api_path web_path name also_known_as short_description description
68
+ primary_role role_company role_investor role_group role_school
69
+ founded_on founded_on_trust_code is_closed closed_on closed_on_trust_code
70
+ num_employees_min num_employees_max total_funding_usd
71
+ stock_exchange stock_symbol
72
+ number_of_investments homepage_url
73
73
  created_at updated_at
74
74
  ]
75
75
  end
@@ -79,4 +79,4 @@ module Crunchbase::Model
79
79
  end
80
80
 
81
81
  end
82
- end
82
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class SimpleOrganization < Crunchbase::Model::Entity
5
+
6
+ attr_reader :type, :name, :path, :created_at, :updated_at
7
+
8
+ def initialize(json)
9
+ property_keys.each { |v|
10
+ instance_variable_set("@#{v}", json[v] || nil)
11
+ }
12
+
13
+ %w[created_at updated_at].each { |v|
14
+ instance_variable_set("@#{v}", Time.at(json[v]))
15
+ }
16
+ end
17
+
18
+ def property_keys
19
+ %w[
20
+ type name path created_at updated_at
21
+ ]
22
+ end
23
+
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Crunchbase
2
- VERSION = "0.0.8"
3
- end
2
+ VERSION = "0.0.9"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase-ruby-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-05 00:00:00.000000000 Z
12
+ date: 2015-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -94,6 +94,8 @@ files:
94
94
  - lib/crunchbase/exception.rb
95
95
  - lib/crunchbase/model.rb
96
96
  - lib/crunchbase/model/acquired_by.rb
97
+ - lib/crunchbase/model/acquiree.rb
98
+ - lib/crunchbase/model/acquirer.rb
97
99
  - lib/crunchbase/model/acquisition.rb
98
100
  - lib/crunchbase/model/address.rb
99
101
  - lib/crunchbase/model/advisory_role.rb
@@ -135,6 +137,7 @@ files:
135
137
  - lib/crunchbase/model/school.rb
136
138
  - lib/crunchbase/model/search.rb
137
139
  - lib/crunchbase/model/search_result.rb
140
+ - lib/crunchbase/model/simple_organization.rb
138
141
  - lib/crunchbase/model/sub_organization.rb
139
142
  - lib/crunchbase/model/video.rb
140
143
  - lib/crunchbase/model/website.rb
@@ -167,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
170
  version: '0'
168
171
  segments:
169
172
  - 0
170
- hash: 2310677653189889271
173
+ hash: -1931453387482519061
171
174
  required_rubygems_version: !ruby/object:Gem::Requirement
172
175
  none: false
173
176
  requirements:
@@ -176,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
179
  version: '0'
177
180
  segments:
178
181
  - 0
179
- hash: 2310677653189889271
182
+ hash: -1931453387482519061
180
183
  requirements: []
181
184
  rubyforge_project:
182
185
  rubygems_version: 1.8.23.2