crunchbase-wrapper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7223ea0e45004b00f80958bddafdcc20e820d73a
4
+ data.tar.gz: 4b2e73336ebf9019358165e647df18a55de71368
5
+ SHA512:
6
+ metadata.gz: e8657ca34936765004e666a061131c44ef38fb940e6f42736f74993b6f1b4540951a9876ad586a4f6bf70c8c2310fb0f7b7bb814409978bd6123a56ea29d5e94
7
+ data.tar.gz: d65f66ac3c969a56bf03eb969d2a90a79e937a4280dfdddda5a28534023de86ee7b7a3d5c252e3777cf5ce140545a8690096e4d284dce7624937ac84f8fe5190
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in crunchbase-wrapper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Fábio Batista
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,29 @@
1
+ # Crunchbase::Wrapper
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'crunchbase-wrapper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install crunchbase-wrapper
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'crunchbase/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "crunchbase-wrapper"
8
+ spec.version = Crunchbase::VERSION
9
+ spec.authors = ["Fábio Batista"]
10
+ spec.email = ["fbatista@gmail.com"]
11
+ spec.description = %q{A Ruby Wrapper for the Crunchbase v2 REST API}
12
+ spec.summary = %q{A Ruby Wrapper for the Crunchbase v2 REST API}
13
+ spec.homepage = ""
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
+
24
+ spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "vcr"
26
+ spec.add_development_dependency "webmock"
27
+
28
+ spec.add_dependency "faraday"
29
+ spec.add_dependency "json"
30
+ spec.add_dependency "hashie"
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class Acquisition
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def self.find(uuid)
20
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/acquisition/#{uuid}", user_key: Crunchbase.config.user_key)
21
+
22
+ raise "Error" if response.status != 200
23
+
24
+ raw = Hashie::Mash.new(JSON.parse(response.body))
25
+ new(raw.data, raw.metadata)
26
+ rescue
27
+ nil
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class Category
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def self.all(options = {})
20
+ opts = options.merge({user_key: Crunchbase.config.user_key})
21
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/categories", opts)
22
+
23
+ raise "Error" if response.status != 200
24
+
25
+ # ignore paging
26
+ raw = Hashie::Mash.new(JSON.parse(response.body))
27
+ collection = raw.data.items
28
+ collection.map { |item| new(item, raw.metadata) }
29
+ rescue
30
+ []
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class FundRaise
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def self.find(uuid)
20
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/fund-raise/#{uuid}", user_key: Crunchbase.config.user_key)
21
+
22
+ raise "Error" if response.status != 200
23
+
24
+ raw = Hashie::Mash.new(JSON.parse(response.body))
25
+ new(raw.data, raw.metadata)
26
+ rescue
27
+ nil
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class FundingRound
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def self.find(uuid)
20
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/funding-round/#{uuid}", user_key: Crunchbase.config.user_key)
21
+
22
+ raise "Error" if response.status != 200
23
+
24
+ raw = Hashie::Mash.new(JSON.parse(response.body))
25
+ new(raw.data, raw.metadata)
26
+ rescue
27
+ nil
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class IPO
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def self.find(uuid)
20
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/ipo/#{uuid}", user_key: Crunchbase.config.user_key)
21
+
22
+ raise "Error" if response.status != 200
23
+
24
+ raw = Hashie::Mash.new(JSON.parse(response.body))
25
+ new(raw.data, raw.metadata)
26
+ rescue
27
+ nil
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class Location
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def self.all(options = {})
20
+ opts = options.merge({user_key: Crunchbase.config.user_key})
21
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/locations", opts)
22
+
23
+ raise "Error" if response.status != 200
24
+
25
+ # ignore paging
26
+ raw = Hashie::Mash.new(JSON.parse(response.body))
27
+ collection = raw.data.items
28
+ collection.map { |item| new(item, raw.metadata) }
29
+ rescue
30
+ []
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,54 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class Organization
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def load_details
20
+ if properties
21
+ return self
22
+ else
23
+ Organization.find(path.sub("organization/", ''))
24
+ end
25
+ end
26
+
27
+ def self.all(options = {})
28
+ opts = options.merge({user_key: Crunchbase.config.user_key})
29
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/organizations", opts)
30
+
31
+ raise "Error" if response.status != 200
32
+
33
+ # ignore paging
34
+ raw = Hashie::Mash.new(JSON.parse(response.body))
35
+ collection = raw.data.items
36
+ collection.map { |item| new(item, raw.metadata) }
37
+ rescue => e
38
+ []
39
+ end
40
+
41
+ def self.find(permalink)
42
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/organization/#{permalink}", user_key: Crunchbase.config.user_key)
43
+
44
+ raise "Error" if response.status != 200
45
+
46
+ raw = Hashie::Mash.new(JSON.parse(response.body))
47
+
48
+ new(raw.data, raw.metadata)
49
+ rescue
50
+ nil
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,53 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class Person
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def load_details
20
+ if properties
21
+ return self
22
+ else
23
+ Person.find(path.sub("person/", ''))
24
+ end
25
+ end
26
+
27
+ def self.all(options = {})
28
+ opts = options.merge({user_key: Crunchbase.config.user_key})
29
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/people", opts)
30
+
31
+ raise "Error" if response.status != 200
32
+
33
+ # ignore paging
34
+ raw = Hashie::Mash.new(JSON.parse(response.body))
35
+ collection = raw.data.items
36
+ collection.map { |item| new(item, raw.metadata) }
37
+ rescue
38
+ []
39
+ end
40
+
41
+ def self.find(permalink)
42
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/person/#{permalink}", user_key: Crunchbase.config.user_key)
43
+
44
+ raise "Error" if response.status != 200
45
+
46
+ raw = Hashie::Mash.new(JSON.parse(response.body))
47
+ new(raw.data, raw.metadata)
48
+ rescue
49
+ nil
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'hashie'
4
+
5
+ module Crunchbase
6
+ class Product
7
+
8
+ attr_accessor :metadata
9
+
10
+ def initialize(data, meta)
11
+ @mash = data
12
+ self.metadata = meta
13
+ end
14
+
15
+ def method_missing(method_sym, *arguments, &block)
16
+ @mash.send(method_sym, *arguments)
17
+ end
18
+
19
+ def load_details
20
+ if properties
21
+ return self
22
+ else
23
+ Product.find(path.sub("product/", ''))
24
+ end
25
+ end
26
+
27
+ def self.all(options = {})
28
+ opts = options.merge({user_key: Crunchbase.config.user_key})
29
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/products", opts)
30
+
31
+ raise "Error" if response.status != 200
32
+
33
+ # ignore paging
34
+ raw = Hashie::Mash.new(JSON.parse(response.body))
35
+ collection = raw.data.items
36
+ collection.map { |item| new(item, raw.metadata) }
37
+ rescue
38
+ []
39
+ end
40
+
41
+ def self.find(permalink)
42
+ response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/product/#{permalink}", user_key: Crunchbase.config.user_key)
43
+
44
+ raise "Error" if response.status != 200
45
+
46
+ raw = Hashie::Mash.new(JSON.parse(response.body))
47
+ new(raw.data, raw.metadata)
48
+ rescue
49
+ nil
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,3 @@
1
+ module Crunchbase
2
+ VERSION = "0.0.1"
3
+ end
data/lib/crunchbase.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'hashie'
2
+ require 'faraday'
3
+ require 'json'
4
+
5
+ require_relative "crunchbase/version"
6
+ require_relative "crunchbase/product"
7
+ require_relative "crunchbase/person"
8
+ require_relative "crunchbase/organization"
9
+ require_relative "crunchbase/location"
10
+ require_relative "crunchbase/i_p_o"
11
+ require_relative "crunchbase/funding_round"
12
+ require_relative "crunchbase/fund_raise"
13
+ require_relative "crunchbase/category"
14
+ require_relative "crunchbase/acquisition"
15
+
16
+ module Crunchbase
17
+ CONFIG = Hashie::Mash.new({
18
+ host: "http://api.crunchbase.com",
19
+ api_version_prefix: "v/2",
20
+ user_key: nil
21
+ })
22
+
23
+ def self.config
24
+ CONFIG
25
+ end
26
+
27
+ end