quata 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 976dad60f84a4420bb1ec96a702f206559ae8de553887e9dd64d39b832e5e2cd
4
- data.tar.gz: fb5bbb8cc05ae02ae670be7180e5d00732f9064cc55e853dba207c9db840fbed
3
+ metadata.gz: 9f8a79d81a044a3ef2f27c500aa3bd40ccf5ad27f3cce012e214c567ad4b6590
4
+ data.tar.gz: 59bf47fc2efe048c885788a1b27f95870545bebb8d22b887d11bac65b6387457
5
5
  SHA512:
6
- metadata.gz: e8119109be5832618b25e534de4f0ff4b7b5fd33700ed9b7c4fdfb3a134277c5f2d8a69a0a5f1f9bd8b79af08fa4fcf6b2b582c8d8a6370f177492cba79bfb69
7
- data.tar.gz: e693e4238d4d990e23945094847750d4a7ba936b371bbb99641bc77d3b0c95fbac9ff09713d77f1fe222f739f03cac87f55b9a76a8f61f8bcff3030842985e68
6
+ metadata.gz: '0790bad1bd04690821b44f64b3a6c078cdeb09665083cf9a96ad797962a479c2e9f693d7ae7b1d9d4c2a331ebf2d625915615a56928edf9d7f735a1d1ec8e527'
7
+ data.tar.gz: a154712860a21fd6c374ebc34fb2d8dc4c73ec0bef33a5f34ff19e8b9fa66b0bc69af8a20e10d7d9bd0a8683b4a664b38288f6a3221dca1a886b7c1fdfcfe4eb
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- Quata - Quandl API Library and Command Line
2
- ==================================================
1
+ # Quata - Quandl API Library and Command Line
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/quata.svg)](https://badge.fury.io/rb/quata)
5
4
  [![Build Status](https://github.com/DannyBen/quata/workflows/Test/badge.svg)](https://github.com/DannyBen/quata/actions?query=workflow%3ATest)
@@ -10,12 +9,12 @@ Quata - Quandl API Library and Command Line
10
9
  Quata is a lightweight ruby library for accessing Quandl, and includes
11
10
  a command line interface.
12
11
 
13
- It provides direct access to all of the [Quandl API][1] endpoints.
12
+ It provides direct access to all of the [Nasdaq Data Link API][1]
13
+ (formerly Quandl) endpoints.
14
14
 
15
15
  ---
16
16
 
17
- Install
18
- --------------------------------------------------
17
+ ## Install
19
18
 
20
19
  ```
21
20
  $ gem install quata
@@ -28,25 +27,23 @@ gem 'quata'
28
27
  ```
29
28
 
30
29
 
31
- Features
32
- --------------------------------------------------
30
+ ## Features
33
31
 
34
32
  * Easy to use interface.
35
33
  * Use as a library or through the command line.
36
34
  * Access any Quandl endpoint directly.
37
35
  * Display output in various formats.
38
- * Save output to a file, including bulk downloads.
36
+ * Save output to a file.
39
37
  * Includes a built in file cache (disabled by default).
40
38
 
41
39
 
42
- Usage
43
- --------------------------------------------------
40
+ ## Usage
44
41
 
45
42
  First, require and initialize with your API key
46
43
 
47
44
  ```ruby
48
45
  require 'quata'
49
- quandl = Quata::API.new 'Your API Key'
46
+ quandl = Quata::API.new 'your-api-key'
50
47
  ```
51
48
 
52
49
  Now, you can access any Quandl endpoint with any optional parameter, like
@@ -130,21 +127,24 @@ quandl.save_csv "filename.csv", "datasets/WIKI/AAPL", rows: 3
130
127
  ```
131
128
 
132
129
 
133
- Command Line
134
- --------------------------------------------------
130
+ ## Command Line
135
131
 
136
132
  The command line utility `quata` acts in a similar way. To use your Quandl
137
133
  API key, simply set it in the environment variables `QUANDL_KEY`:
138
134
 
139
- `$ export QUANDL_KEY=your_key`
135
+ ```
136
+ $ export QUANDL_KEY=your_key
137
+ ```
140
138
 
141
139
  These commands are available:
142
140
 
143
- `$ quata get PATH [PARAMS...]` - print the output.
144
- `$ quata pretty PATH [PARAMS...]` - print a pretty JSON.
145
- `$ quata see PATH [PARAMS...]` - print a colored output.
146
- `$ quata url PATH [PARAMS...]` - show the constructed URL.
147
- `$ quata save FILE PATH [PARAMS...]` - save the output to a file.
141
+ ```bash
142
+ $ quata get PATH [PARAMS...] # print the output.
143
+ $ quata pretty PATH [PARAMS...] # print a pretty JSON.
144
+ $ quata see PATH [PARAMS...] # print a colored output.
145
+ $ quata url PATH [PARAMS...] # show the constructed URL.
146
+ $ quata save FILE PATH [PARAMS...] # save the output to a file.
147
+ ```
148
148
 
149
149
  Run `quata --help` for more information, or view the [full usage help][2].
150
150
 
@@ -177,17 +177,16 @@ $ quata save output.csv datasets/WIKI/AAPL rows:5
177
177
 
178
178
  # Shows the URL that Quata has constructed, good for debugging
179
179
  $ quata url datasets/WIKI/AAPL rows:5
180
- # => https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?auth_token=YOUR_KEY&rows=5
180
+ # => https://data.nasdaq.com/api/v3/datasets/WIKI/AAPL.csv?api_key=YOUR_KEY&rows=5
181
181
  ```
182
182
 
183
- Caching
184
- --------------------------------------------------
183
+ ## Caching
185
184
 
186
185
  Quata uses the [Lightly][3] gem for automatic HTTP caching.
187
186
  To take the path of least surprises, caching is disabled by default.
188
187
 
189
188
  You can enable and customize it by either passing options on
190
- initialization, or by accessing the `WebCache` object directly at
189
+ initialization, or by accessing the `Lightly` object directly at
191
190
  a later stage.
192
191
 
193
192
  ```ruby
@@ -214,12 +213,11 @@ $ quata get datasets/WIKI/AAPL
214
213
  ```
215
214
 
216
215
 
217
- Terminalcast
218
- --------------------------------------------------
216
+ ## Terminalcast
219
217
 
220
218
  ![Quata Demo](https://raw.githubusercontent.com/DannyBen/quata/master/demo.gif "Quata Demo")
221
219
 
222
- [1]: https://www.quandl.com/blog/getting-started-with-the-quandl-api
220
+ [1]: https://docs.data.nasdaq.com/docs/getting-started
223
221
  [2]: https://github.com/DannyBen/quata/blob/master/lib/quata/docopt.txt
224
222
  [3]: https://github.com/DannyBen/lightly
225
223
 
data/bin/quata CHANGED
@@ -5,5 +5,5 @@ require 'quata'
5
5
  begin
6
6
  Quata::CommandLine.execute ARGV
7
7
  rescue Quata::BadResponse => e
8
- STDERR.puts "#{e.class} - #{e.message}"
8
+ warn "#{e.class} - #{e.message}"
9
9
  end
data/lib/quata/api.rb CHANGED
@@ -3,16 +3,18 @@ require 'apicake'
3
3
  module Quata
4
4
  # Provides access to all the Quandl API endpoints
5
5
  class API < APICake::Base
6
- base_uri 'https://www.quandl.com/api/v3'
6
+ base_uri 'https://data.nasdaq.com/api/v3'
7
7
 
8
8
  attr_reader :api_key
9
9
 
10
- # TODO:
11
- # - handle format
10
+ # TODO: handle format
12
11
 
13
12
  # Initializes the API with an optional API Key, and cache settings.
14
- def initialize(api_key=nil, opts={})
15
- opts, api_key = api_key, nil if api_key.is_a?(Hash) && opts.empty?
13
+ def initialize(api_key = nil, opts = {})
14
+ if api_key.is_a?(Hash) && opts.empty?
15
+ opts = api_key
16
+ api_key = nil
17
+ end
16
18
  @api_key = api_key
17
19
  cache.disable unless opts[:use_cache]
18
20
  cache.dir = opts[:cache_dir] if opts[:cache_dir]
@@ -22,13 +24,13 @@ module Quata
22
24
  # Returns a hash that will be merged into all query strings before
23
25
  # sending the request to Quandl. This method is used by API Cake.
24
26
  def default_query
25
- { api_key: api_key }
27
+ { api_key: api_key }
26
28
  end
27
29
 
28
30
  # Forwards all arguments to #get! and converts the JSON response to CSV
29
31
  # If the response contains one or more arrays, the first array will be
30
32
  # the CSV output. Otherwise, the response itself will be used.
31
- def get_csv(path, params={})
33
+ def get_csv(path, params = {})
32
34
  path = "#{path}.csv"
33
35
  payload = get! path, params
34
36
 
@@ -39,4 +41,4 @@ module Quata
39
41
  payload.response.body
40
42
  end
41
43
  end
42
- end
44
+ end
@@ -3,12 +3,11 @@ require 'json'
3
3
  require 'lp'
4
4
 
5
5
  module Quata
6
-
7
6
  # Handles the command line interface
8
7
  class CommandLine < SuperDocopt::Base
9
8
  version VERSION
10
9
  docopt File.expand_path 'docopt.txt', __dir__
11
- subcommands ['get', 'pretty', 'see', 'url', 'save']
10
+ subcommands %w[get pretty see url save]
12
11
 
13
12
  attr_reader :path, :params, :file, :csv
14
13
 
@@ -29,12 +28,12 @@ module Quata
29
28
  end
30
29
 
31
30
  def save
32
- if csv
33
- success = quandl.save_csv file, path, params
31
+ success = if csv
32
+ quandl.save_csv file, path, params
34
33
  else
35
- success = quandl.save file, path, params
34
+ quandl.save file, path, params
36
35
  end
37
- puts success ? "Saved #{file}" : "Saving failed"
36
+ puts success ? "Saved #{file}" : 'Saving failed'
38
37
  end
39
38
 
40
39
  def pretty
@@ -54,7 +53,7 @@ module Quata
54
53
  @quandl ||= quandl!
55
54
  end
56
55
 
57
- private
56
+ private
58
57
 
59
58
  def quandl!
60
59
  API.new api_key, options
@@ -65,6 +64,7 @@ module Quata
65
64
  def translate_params(pairs)
66
65
  result = {}
67
66
  return result if pairs.empty?
67
+
68
68
  pairs.each do |pair|
69
69
  key, value = pair.split ':'
70
70
  result[key.to_sym] = value
@@ -93,6 +93,5 @@ module Quata
93
93
  def cache_life
94
94
  ENV['QUANDL_CACHE_LIFE']
95
95
  end
96
-
97
96
  end
98
97
  end
@@ -1,3 +1,3 @@
1
1
  module Quata
2
2
  class BadResponse < StandardError; end
3
- end
3
+ end
data/lib/quata/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Quata
2
- VERSION = "0.1.8"
3
- end
2
+ VERSION = '0.2.0'
3
+ end
data/lib/quata.rb CHANGED
@@ -2,3 +2,4 @@ require 'quata/version'
2
2
  require 'quata/api'
3
3
  require 'quata/command_line'
4
4
  require 'quata/exceptions'
5
+ require 'byebug' if ENV['BYEBUG']
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: super_docopt
14
+ name: apicake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: apicake
42
+ name: super_docopt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
47
+ version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.1'
54
+ version: '0.2'
55
55
  description: Easy to use API for Quandl data service with a command line interface
56
56
  email: db@dannyben.com
57
57
  executables:
@@ -70,8 +70,10 @@ files:
70
70
  homepage: https://github.com/DannyBen/quata
71
71
  licenses:
72
72
  - MIT
73
- metadata: {}
74
- post_install_message:
73
+ metadata:
74
+ rubygems_mfa_required: 'true'
75
+ post_install_message: 'WARNING: The ''quata'' gem was renamed to ''nasdaq'', please
76
+ install it instead.'
75
77
  rdoc_options: []
76
78
  require_paths:
77
79
  - lib
@@ -79,14 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
81
  requirements:
80
82
  - - ">="
81
83
  - !ruby/object:Gem::Version
82
- version: 2.3.0
84
+ version: '2.7'
83
85
  required_rubygems_version: !ruby/object:Gem::Requirement
84
86
  requirements:
85
87
  - - ">="
86
88
  - !ruby/object:Gem::Version
87
89
  version: '0'
88
90
  requirements: []
89
- rubygems_version: 3.1.2
91
+ rubygems_version: 3.4.9
90
92
  signing_key:
91
93
  specification_version: 4
92
94
  summary: Quandl API Library and Command Line