crunchbase_academic 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +6 -0
- data/crunchbase_academic.gemspec +24 -0
- data/lib/crunchbase_academic/api.rb +53 -0
- data/lib/crunchbase_academic/common.rb +11 -0
- data/lib/crunchbase_academic/organization.rb +14 -0
- data/lib/crunchbase_academic/person.rb +19 -0
- data/lib/crunchbase_academic/version.rb +3 -0
- data/lib/crunchbase_academic.rb +8 -0
- data/spec/crunchbase_academic_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fcd5a338321941ccb3bbdf48dc8c765d7bf553c9
|
4
|
+
data.tar.gz: 633c1160070d16ea7a49a86c3d781c54f832e7c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75aff44fa9701fefc5b0f75d8d344c16404a4f5ab533d5ed7ffff57eb524896bdda6a710f2756ffb56fa34d694d9313a824e565c642cbba90e96a590839f7486
|
7
|
+
data.tar.gz: 2b22a3edab12a71cc33317dac4e58bc5918787e35ddd032154575ca6ba9d3b423415d60cb7221bf6c4ffc7550307ed73fb73a1ce04faccf04e8bd25102a709a3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 timakin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# CrunchbaseV2
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'crunchbase_academic'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install crunchbase_academic
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
$ require 'crunchbase_academic'
|
22
|
+
$ CrunchbaseAcademic::API.key = 'your_api_auth_key'
|
23
|
+
$ test = CrunchbaseAcademic::Person('steve-jobs')
|
24
|
+
$ puts test.founded_company
|
25
|
+
$ # It'll show the parameters of jobs owned companies.
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'crunchbase_academic/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "crunchbase_academic"
|
8
|
+
spec.version = CrunchbaseAcademic::VERSION
|
9
|
+
spec.authors = ["timakin"]
|
10
|
+
spec.email = ["timaki.st@gmail.com"]
|
11
|
+
spec.description = "Gemfile for academic reporting with CrunchBaseAPI ver2.0"
|
12
|
+
spec.summary = "Gemfile for academic reporting with CrunchBaseAPI ver2.0"
|
13
|
+
spec.homepage = "https://github.com/timakin/crunchbase_academic"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'timeout'
|
5
|
+
|
6
|
+
# ==function list==
|
7
|
+
# API.key registration
|
8
|
+
# Access to authorized JSON api weblink.
|
9
|
+
# =================
|
10
|
+
module CrunchbaseAcademic
|
11
|
+
class API
|
12
|
+
class << self; attr_accessor :timeout_limit, :key end
|
13
|
+
CB_URL = 'http://api.crunchbase.com/v/2/'
|
14
|
+
@timeout_limit = 60
|
15
|
+
|
16
|
+
def self.fetch(permalink, object)
|
17
|
+
uri = CB_URL + "#{object}/#{permalink}"
|
18
|
+
get_json_response(uri)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.get_json_response(uri)
|
24
|
+
raise CrunchException, "API key required, visit http://developer.crunchbase.com" unless @key
|
25
|
+
uri = uri + "#{uri.match('\?') ? "&" : "?"}user_key=#{@key}"
|
26
|
+
|
27
|
+
resp = Timeout::timeout(@timeout_limit) {
|
28
|
+
get_url_following_redirects(uri, @redirect_limit)
|
29
|
+
}
|
30
|
+
resp = resp.gsub(/[[:cntrl:]]/, '')
|
31
|
+
|
32
|
+
parsed_info = JSON.parse(resp)
|
33
|
+
raise CrunchException, parsed_info["error"] if parsed_info.class == Hash && parsed_info["error"]
|
34
|
+
|
35
|
+
return parsed_info
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.get_url_following_redirects(uri_str, limit = 10)
|
39
|
+
raise CrunchException, 'HTTP redirect too deep' if limit == 0
|
40
|
+
|
41
|
+
url = URI.parse(uri_str)
|
42
|
+
response = Net::HTTP.start(url.host, url.port) { |http| http.get(url.request_uri) }
|
43
|
+
case response
|
44
|
+
when Net::HTTPSuccess, Net::HTTPNotFound
|
45
|
+
response.body
|
46
|
+
when Net::HTTPRedirection
|
47
|
+
get_url_following_redirects(response['location'], limit - 1)
|
48
|
+
else
|
49
|
+
response.error!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CrunchbaseAcademic
|
2
|
+
class Organization < Common
|
3
|
+
OBJECT_NAME = 'organization'
|
4
|
+
attr_reader :total_funding_usd, :products, :news, :founded_on, :founded_on_year
|
5
|
+
|
6
|
+
def initialize(json)
|
7
|
+
@founded_on ||= json['data']['properties']['founded_on']
|
8
|
+
@founded_on_year ||= json['data']['properties']['founded_on_year']
|
9
|
+
@total_funding_usd ||= json['data']['properties']['total_funding_usd']
|
10
|
+
@products ||= json['data']['relationships']['products']
|
11
|
+
@news ||= json['data']['relationships']['news']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CrunchbaseAcademic
|
2
|
+
class Person < Common
|
3
|
+
OBJECT_NAME = 'person'
|
4
|
+
attr_reader :first_name, :last_name, :permalink, :birthplace,
|
5
|
+
:born_on_year, :born_month, :born_day, :born_on, :experience,
|
6
|
+
:founded_company, :degrees, :advisor_at, :investments
|
7
|
+
|
8
|
+
def initialize(json)
|
9
|
+
@permalink ||= json['data']['properties']['permalink']
|
10
|
+
@born_on ||= json['data']['properties']['born_on']
|
11
|
+
@born_on_year ||= json['data']['properties']['born_on_year']
|
12
|
+
@founded_company ||= json['data']['relationships']['founded_companies']
|
13
|
+
@experience ||= json['data']['relationships']['experience']
|
14
|
+
@advisor_at ||= json['data']['relationships']['advisor_at']
|
15
|
+
@degrees ||= json['data']['relationships']['degrees']
|
16
|
+
@investments ||= json['data']['relationships']['investments']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crunchbase_academic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- timakin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
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'
|
55
|
+
description: Gemfile for academic reporting with CrunchBaseAPI ver2.0
|
56
|
+
email:
|
57
|
+
- timaki.st@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- crunchbase_academic.gemspec
|
70
|
+
- lib/crunchbase_academic.rb
|
71
|
+
- lib/crunchbase_academic/api.rb
|
72
|
+
- lib/crunchbase_academic/common.rb
|
73
|
+
- lib/crunchbase_academic/organization.rb
|
74
|
+
- lib/crunchbase_academic/person.rb
|
75
|
+
- lib/crunchbase_academic/version.rb
|
76
|
+
- spec/crunchbase_academic_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
homepage: https://github.com/timakin/crunchbase_academic
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.0.6
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Gemfile for academic reporting with CrunchBaseAPI ver2.0
|
102
|
+
test_files:
|
103
|
+
- spec/crunchbase_academic_spec.rb
|
104
|
+
- spec/spec_helper.rb
|