quata 0.1.7 → 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: 3785f6578995449094d19d5e5b9f145ca01e63e9411aca0bd9d89d31dca94c23
4
- data.tar.gz: d00e91c46fded862496a8c16724f7315676ed8547e2ff84d7abfc66203dd4b8a
3
+ metadata.gz: 9f8a79d81a044a3ef2f27c500aa3bd40ccf5ad27f3cce012e214c567ad4b6590
4
+ data.tar.gz: 59bf47fc2efe048c885788a1b27f95870545bebb8d22b887d11bac65b6387457
5
5
  SHA512:
6
- metadata.gz: b2ab6d46f6c7f8d360feb8d7f88a42b1383367e0102ec23061cc02fe7097c6a1b447ecdb9633174d52eca628db7cd7d8e39f40f149237daa0d1d82a4b7f9f2ba
7
- data.tar.gz: 7ab03b02d6285db7da1a7e57429ae32535fb4b51214d32131b23f1b25917efb46f1ae45248a08d4a9b182f0d760bc01c7a4f8ce04dc43acf35550e79cca85222
6
+ metadata.gz: '0790bad1bd04690821b44f64b3a6c078cdeb09665083cf9a96ad797962a479c2e9f693d7ae7b1d9d4c2a331ebf2d625915615a56928edf9d7f735a1d1ec8e527'
7
+ data.tar.gz: a154712860a21fd6c374ebc34fb2d8dc4c73ec0bef33a5f34ff19e8b9fa66b0bc69af8a20e10d7d9bd0a8683b4a664b38288f6a3221dca1a886b7c1fdfcfe4eb
data/README.md CHANGED
@@ -1,23 +1,20 @@
1
- Quata - Quandl API Library and Command Line
2
- ==================================================
1
+ # Quata - Quandl API Library and Command Line
3
2
 
4
- [![Gem](https://img.shields.io/gem/v/quata.svg?style=flat-square)](https://rubygems.org/gems/quata)
5
- [![Build](https://img.shields.io/travis/DannyBen/quata/master.svg?style=flat-square)](https://travis-ci.org/DannyBen/quata)
6
- [![Maintainability](https://img.shields.io/codeclimate/maintainability/DannyBen/quata.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/quata)
7
- [![Issues](https://img.shields.io/codeclimate/issues/github/DannyBen/quata.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/quata)
8
- [![Dependencies](https://img.shields.io/gemnasium/DannyBen/quata.svg?style=flat-square)](https://gemnasium.com/DannyBen/quata)
3
+ [![Gem Version](https://badge.fury.io/rb/quata.svg)](https://badge.fury.io/rb/quata)
4
+ [![Build Status](https://github.com/DannyBen/quata/workflows/Test/badge.svg)](https://github.com/DannyBen/quata/actions?query=workflow%3ATest)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/463cd9899bf9357303ab/maintainability)](https://codeclimate.com/github/DannyBen/quata/maintainability)
9
6
 
10
7
  ---
11
8
 
12
9
  Quata is a lightweight ruby library for accessing Quandl, and includes
13
10
  a command line interface.
14
11
 
15
- 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.
16
14
 
17
15
  ---
18
16
 
19
- Install
20
- --------------------------------------------------
17
+ ## Install
21
18
 
22
19
  ```
23
20
  $ gem install quata
@@ -30,25 +27,23 @@ gem 'quata'
30
27
  ```
31
28
 
32
29
 
33
- Features
34
- --------------------------------------------------
30
+ ## Features
35
31
 
36
32
  * Easy to use interface.
37
33
  * Use as a library or through the command line.
38
34
  * Access any Quandl endpoint directly.
39
35
  * Display output in various formats.
40
- * Save output to a file, including bulk downloads.
36
+ * Save output to a file.
41
37
  * Includes a built in file cache (disabled by default).
42
38
 
43
39
 
44
- Usage
45
- --------------------------------------------------
40
+ ## Usage
46
41
 
47
42
  First, require and initialize with your API key
48
43
 
49
44
  ```ruby
50
45
  require 'quata'
51
- quandl = Quata::API.new 'Your API Key'
46
+ quandl = Quata::API.new 'your-api-key'
52
47
  ```
53
48
 
54
49
  Now, you can access any Quandl endpoint with any optional parameter, like
@@ -132,21 +127,24 @@ quandl.save_csv "filename.csv", "datasets/WIKI/AAPL", rows: 3
132
127
  ```
133
128
 
134
129
 
135
- Command Line
136
- --------------------------------------------------
130
+ ## Command Line
137
131
 
138
132
  The command line utility `quata` acts in a similar way. To use your Quandl
139
133
  API key, simply set it in the environment variables `QUANDL_KEY`:
140
134
 
141
- `$ export QUANDL_KEY=your_key`
135
+ ```
136
+ $ export QUANDL_KEY=your_key
137
+ ```
142
138
 
143
139
  These commands are available:
144
140
 
145
- `$ quata get PATH [PARAMS...]` - print the output.
146
- `$ quata pretty PATH [PARAMS...]` - print a pretty JSON.
147
- `$ quata see PATH [PARAMS...]` - print a colored output.
148
- `$ quata url PATH [PARAMS...]` - show the constructed URL.
149
- `$ 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
+ ```
150
148
 
151
149
  Run `quata --help` for more information, or view the [full usage help][2].
152
150
 
@@ -179,17 +177,16 @@ $ quata save output.csv datasets/WIKI/AAPL rows:5
179
177
 
180
178
  # Shows the URL that Quata has constructed, good for debugging
181
179
  $ quata url datasets/WIKI/AAPL rows:5
182
- # => 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
183
181
  ```
184
182
 
185
- Caching
186
- --------------------------------------------------
183
+ ## Caching
187
184
 
188
185
  Quata uses the [Lightly][3] gem for automatic HTTP caching.
189
186
  To take the path of least surprises, caching is disabled by default.
190
187
 
191
188
  You can enable and customize it by either passing options on
192
- initialization, or by accessing the `WebCache` object directly at
189
+ initialization, or by accessing the `Lightly` object directly at
193
190
  a later stage.
194
191
 
195
192
  ```ruby
@@ -216,12 +213,11 @@ $ quata get datasets/WIKI/AAPL
216
213
  ```
217
214
 
218
215
 
219
- Terminalcast
220
- --------------------------------------------------
216
+ ## Terminalcast
221
217
 
222
218
  ![Quata Demo](https://raw.githubusercontent.com/DannyBen/quata/master/demo.gif "Quata Demo")
223
219
 
224
- [1]: https://www.quandl.com/blog/getting-started-with-the-quandl-api
220
+ [1]: https://docs.data.nasdaq.com/docs/getting-started
225
221
  [2]: https://github.com/DannyBen/quata/blob/master/lib/quata/docopt.txt
226
222
  [3]: https://github.com/DannyBen/lightly
227
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
@@ -1,15 +1,13 @@
1
- require 'singleton'
2
1
  require 'super_docopt'
3
2
  require 'json'
4
- require 'awesome_print'
3
+ require 'lp'
5
4
 
6
5
  module Quata
7
-
8
6
  # Handles the command line interface
9
7
  class CommandLine < SuperDocopt::Base
10
8
  version VERSION
11
9
  docopt File.expand_path 'docopt.txt', __dir__
12
- subcommands ['get', 'pretty', 'see', 'url', 'save']
10
+ subcommands %w[get pretty see url save]
13
11
 
14
12
  attr_reader :path, :params, :file, :csv
15
13
 
@@ -30,12 +28,12 @@ module Quata
30
28
  end
31
29
 
32
30
  def save
33
- if csv
34
- success = quandl.save_csv file, path, params
31
+ success = if csv
32
+ quandl.save_csv file, path, params
35
33
  else
36
- success = quandl.save file, path, params
34
+ quandl.save file, path, params
37
35
  end
38
- puts success ? "Saved #{file}" : "Saving failed"
36
+ puts success ? "Saved #{file}" : 'Saving failed'
39
37
  end
40
38
 
41
39
  def pretty
@@ -44,7 +42,7 @@ module Quata
44
42
  end
45
43
 
46
44
  def see
47
- ap quandl.get path, params
45
+ lp quandl.get path, params
48
46
  end
49
47
 
50
48
  def url
@@ -55,7 +53,7 @@ module Quata
55
53
  @quandl ||= quandl!
56
54
  end
57
55
 
58
- private
56
+ private
59
57
 
60
58
  def quandl!
61
59
  API.new api_key, options
@@ -66,6 +64,7 @@ module Quata
66
64
  def translate_params(pairs)
67
65
  result = {}
68
66
  return result if pairs.empty?
67
+
69
68
  pairs.each do |pair|
70
69
  key, value = pair.split ':'
71
70
  result[key.to_sym] = value
@@ -94,6 +93,5 @@ module Quata
94
93
  def cache_life
95
94
  ENV['QUANDL_CACHE_LIFE']
96
95
  end
97
-
98
96
  end
99
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.7"
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.7
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: 2018-02-10 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
  - - "~>"
@@ -25,131 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: awesome_print
28
+ name: lp
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: '0.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.8'
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'
55
- - !ruby/object:Gem::Dependency
56
- name: runfile
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.10'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.10'
69
- - !ruby/object:Gem::Dependency
70
- name: runfile-tasks
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.4'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.4'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '3.6'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '3.6'
97
- - !ruby/object:Gem::Dependency
98
- name: rdoc
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '5.1'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '5.1'
111
- - !ruby/object:Gem::Dependency
112
- name: byebug
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '9.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '9.0'
125
- - !ruby/object:Gem::Dependency
126
- name: simplecov
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.15'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.15'
139
- - !ruby/object:Gem::Dependency
140
- name: yard
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0.9'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.9'
54
+ version: '0.2'
153
55
  description: Easy to use API for Quandl data service with a command line interface
154
56
  email: db@dannyben.com
155
57
  executables:
@@ -168,8 +70,10 @@ files:
168
70
  homepage: https://github.com/DannyBen/quata
169
71
  licenses:
170
72
  - MIT
171
- metadata: {}
172
- 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.'
173
77
  rdoc_options: []
174
78
  require_paths:
175
79
  - lib
@@ -177,15 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
81
  requirements:
178
82
  - - ">="
179
83
  - !ruby/object:Gem::Version
180
- version: 2.0.0
84
+ version: '2.7'
181
85
  required_rubygems_version: !ruby/object:Gem::Requirement
182
86
  requirements:
183
87
  - - ">="
184
88
  - !ruby/object:Gem::Version
185
89
  version: '0'
186
90
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.7.3
91
+ rubygems_version: 3.4.9
189
92
  signing_key:
190
93
  specification_version: 4
191
94
  summary: Quandl API Library and Command Line