crunchbase4 0.1.9 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 847ef68e0f7d78cb3ebeb25145c2e52381ee855a68709a6e9aa5a1f0d05b6a5d
4
- data.tar.gz: 6be09a238a9412692e782d7c4540181da32c429cb5ad27cf5b7ebc4756a24b71
3
+ metadata.gz: d55577caf7591f6f9da599815b133401620f51137d303e9f1d56ca1a37554a30
4
+ data.tar.gz: e0b0a754d0060dd9d3f566ce3cea3f6120c3bec2c3fd9dd490d6d6c1dfdaa04c
5
5
  SHA512:
6
- metadata.gz: 6f9f84bf20a0f27108fc6ec17533d82de74a538c87545cdee661d22138ca5e7002f85de42ffc448943fada30cac5ea2cd632afb237af835b44724647a6c985e8
7
- data.tar.gz: 76d2e72a670c8c35978e225604ee7b759e9910004f8d92bbf61c0ef86d563dc095a225ba5dafd4f2793c823108c96cfbeb3a0b61350c9f2380315836ae107bec
6
+ metadata.gz: 740e35d9fabbf05e930aa6a3a663143b0dee43d77ccb29b2845d79836ee2891a5b9eb4a360ba03dd2087afaea6525cafefe8beb0ed299d17d375be0eddab285f
7
+ data.tar.gz: ca15245080f46ca75779e1b694842a206a1ece5107b31b9a937a5e3ae049ff0247cf74b5e390c13290b9360ab1a4678832a7f36cb3dbe07ed1cb31d67098c7c2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crunchbase4 (0.1.8)
4
+ crunchbase4 (0.2.0)
5
5
  faraday
6
6
  faraday_curl
7
7
  faraday_middleware
@@ -38,7 +38,7 @@ GEM
38
38
  faraday-rack (1.0.0)
39
39
  faraday_curl (0.0.2)
40
40
  faraday (>= 0.9.0)
41
- faraday_middleware (1.1.0)
41
+ faraday_middleware (1.2.0)
42
42
  faraday (~> 1.0)
43
43
  hashdiff (1.0.1)
44
44
  httparty (0.20.0)
data/README.md CHANGED
@@ -26,13 +26,18 @@ Or install it yourself as:
26
26
  #### Configure your certificate for API
27
27
 
28
28
  ```ruby
29
- require 'crunchbase4'
29
+ require 'crunchbase'
30
30
 
31
- CB_CONFIG = YAML.load(File.read('crunchbase.yml'))
32
- Crunchbase.config.user_key = CB_CONFIG['user_key']
33
- Crunchbase.config.user_key = false # If you want to know the request information, can set the debug = true
31
+ config = YAML.load(File.read('spec/crunchbase.yml'))
32
+ Crunchbase.config.user_key = config['user_key']
33
+ Crunchbase.config.debug = config['debug'] || false # If you want to know the request information, can set the debug = true
34
34
  ```
35
35
 
36
+ #### If you want to use it in Rails Application, simple way to create a file `crunchbase.rb` in `config/initializers`
37
+
38
+ - and put the above info(https://github.com/ekohe/crunchbase4#configure-your-certificate-for-api) into the new file
39
+
40
+
36
41
  ## Usage
37
42
 
38
43
  #### Class: `Client` for API
@@ -44,9 +44,11 @@ module Crunchbase
44
44
  faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?
45
45
  end.post(uri, args)
46
46
 
47
- return response.body if response.status == 200
47
+ resp_body = response.body
48
+ resp_status = response.status
49
+ return resp_body if resp_status == 200
48
50
 
49
- raise Error, response.body[0]['message']
51
+ raise Error, resp_body.is_a?(Array) ? resp_body[0]['message'] : resp_body['error']
50
52
  end
51
53
 
52
54
  private
@@ -58,9 +60,11 @@ module Crunchbase
58
60
  faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?
59
61
  end.get(uri, *args)
60
62
 
61
- return response.body if response.status == 200
63
+ resp_body = response.body
64
+ resp_status = response.status
65
+ return resp_body if resp_status == 200
62
66
 
63
- raise Error, response.status == 400 ? response.body[0]['message'] : response.body['error']
67
+ raise Error, resp_body.is_a?(Array) ? resp_body[0]['message'] : resp_body['error']
64
68
  end
65
69
 
66
70
  def debug_mode?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crunchbase
4
- VERSION = '0.1.9'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crunchbase4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-04 00:00:00.000000000 Z
11
+ date: 2022-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  requirements: []
215
- rubygems_version: 3.1.6
215
+ rubygems_version: 3.0.3
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Crunchbase is a ruby wrapper base on Crunchbase V4 API