crunchbase_v2 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,9 +18,9 @@ module Crunchbase
18
18
  @timeout_limit = 60
19
19
  @redirect_limit = 2
20
20
  @version = '2'
21
- @base_url = 'http://api.crunchbase.com'
22
- @site_url = "http://www.crunchbase.com"
23
- @image_url = "http://images.crunchbase.com/"
21
+ @base_url = 'https://api.crunchbase.com'
22
+ @site_url = "https://www.crunchbase.com"
23
+ @image_url = "https://res.cloudinary.com/crunchbase-production/"
24
24
  @debug = false
25
25
 
26
26
  # Must be overridden in subclasses
@@ -130,16 +130,19 @@ module Crunchbase
130
130
  def self.get_url_following_redirects(uri_str, limit = 10)
131
131
  raise CrunchException, 'HTTP redirect too deep' if limit == 0
132
132
 
133
- url = URI.parse(uri_str)
134
-
133
+ uri = URI.parse(uri_str)
135
134
  if self.debug
136
- length = (uri_str.length + 10)
137
- puts "*"*length
138
- puts "*** #{url} ***"
139
- puts "*"*length
135
+ puts "*"*120
136
+ puts "*** #{uri} ***"
137
+ puts "*"*120
138
+ end
139
+
140
+ http = Net::HTTP.new(uri.host, uri.port)
141
+ http.use_ssl = true if uri.scheme == 'https'
142
+ response = http.start do |h|
143
+ h.request Net::HTTP::Get.new(uri.request_uri)
140
144
  end
141
145
 
142
- response = Net::HTTP.start(url.host, url.port) { |http| http.get(url.request_uri) }
143
146
  case response
144
147
  when Net::HTTPSuccess, Net::HTTPNotFound
145
148
  response.body
@@ -16,8 +16,13 @@ module Crunchbase
16
16
  @author = json['author']
17
17
  @posted_on = json['posted_on'] && DateTime.parse(json['posted_on'])
18
18
  @title = json['title']
19
- @created_at = json['created_at']
20
- @updated_at = json['updated_at']
19
+ @created_at = Time.at(json['created_at']).utc
20
+
21
+ unless json['updated_at'].blank?
22
+ json['updated_at'] = (json['updated_at'].to_s + "-01-01").to_datetime.to_i if json['updated_at'].to_s.length == 4
23
+
24
+ @updated_at = Time.at(json['updated_at']).utc
25
+ end
21
26
  end
22
27
 
23
28
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Crunchbase
4
- VERSION = "0.0.8"
4
+ VERSION = "0.0.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase_v2
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: 2014-08-29 00:00:00.000000000 Z
12
+ date: 2015-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -146,12 +146,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  - - ! '>='
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
+ segments:
150
+ - 0
151
+ hash: -1074293236062647351
149
152
  required_rubygems_version: !ruby/object:Gem::Requirement
150
153
  none: false
151
154
  requirements:
152
155
  - - ! '>='
153
156
  - !ruby/object:Gem::Version
154
157
  version: '0'
158
+ segments:
159
+ - 0
160
+ hash: -1074293236062647351
155
161
  requirements: []
156
162
  rubyforge_project:
157
163
  rubygems_version: 1.8.23.2