quata 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +5 -3
- data/bin/quata +1 -1
- data/lib/quata/command_line.rb +99 -117
- data/lib/quata/version.rb +1 -1
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3785f6578995449094d19d5e5b9f145ca01e63e9411aca0bd9d89d31dca94c23
|
4
|
+
data.tar.gz: d00e91c46fded862496a8c16724f7315676ed8547e2ff84d7abfc66203dd4b8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2ab6d46f6c7f8d360feb8d7f88a42b1383367e0102ec23061cc02fe7097c6a1b447ecdb9633174d52eca628db7cd7d8e39f40f149237daa0d1d82a4b7f9f2ba
|
7
|
+
data.tar.gz: 7ab03b02d6285db7da1a7e57429ae32535fb4b51214d32131b23f1b25917efb46f1ae45248a08d4a9b182f0d760bc01c7a4f8ce04dc43acf35550e79cca85222
|
data/README.md
CHANGED
@@ -2,9 +2,10 @@ Quata - Quandl API Library and Command Line
|
|
2
2
|
==================================================
|
3
3
|
|
4
4
|
[![Gem](https://img.shields.io/gem/v/quata.svg?style=flat-square)](https://rubygems.org/gems/quata)
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
[![
|
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)
|
8
9
|
|
9
10
|
---
|
10
11
|
|
@@ -223,3 +224,4 @@ Terminalcast
|
|
223
224
|
[1]: https://www.quandl.com/blog/getting-started-with-the-quandl-api
|
224
225
|
[2]: https://github.com/DannyBen/quata/blob/master/lib/quata/docopt.txt
|
225
226
|
[3]: https://github.com/DannyBen/lightly
|
227
|
+
|
data/bin/quata
CHANGED
data/lib/quata/command_line.rb
CHANGED
@@ -1,117 +1,99 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require '
|
3
|
-
require 'json'
|
4
|
-
require 'awesome_print'
|
5
|
-
|
6
|
-
module Quata
|
7
|
-
|
8
|
-
# Handles the command line interface
|
9
|
-
class CommandLine
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
result[:cache_life] = cache_life.to_i if cache_life
|
101
|
-
result
|
102
|
-
end
|
103
|
-
|
104
|
-
def api_key
|
105
|
-
ENV['QUANDL_KEY']
|
106
|
-
end
|
107
|
-
|
108
|
-
def cache_dir
|
109
|
-
ENV['QUANDL_CACHE_DIR']
|
110
|
-
end
|
111
|
-
|
112
|
-
def cache_life
|
113
|
-
ENV['QUANDL_CACHE_LIFE']
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
1
|
+
require 'singleton'
|
2
|
+
require 'super_docopt'
|
3
|
+
require 'json'
|
4
|
+
require 'awesome_print'
|
5
|
+
|
6
|
+
module Quata
|
7
|
+
|
8
|
+
# Handles the command line interface
|
9
|
+
class CommandLine < SuperDocopt::Base
|
10
|
+
version VERSION
|
11
|
+
docopt File.expand_path 'docopt.txt', __dir__
|
12
|
+
subcommands ['get', 'pretty', 'see', 'url', 'save']
|
13
|
+
|
14
|
+
attr_reader :path, :params, :file, :csv
|
15
|
+
|
16
|
+
def before_execute
|
17
|
+
@path = args['PATH']
|
18
|
+
@params = translate_params args['PARAMS']
|
19
|
+
@file = args['FILE']
|
20
|
+
@csv = args['--csv']
|
21
|
+
end
|
22
|
+
|
23
|
+
def get
|
24
|
+
if csv
|
25
|
+
puts quandl.get_csv path, params
|
26
|
+
else
|
27
|
+
payload = quandl.get! path, params
|
28
|
+
puts payload.response.body
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
if csv
|
34
|
+
success = quandl.save_csv file, path, params
|
35
|
+
else
|
36
|
+
success = quandl.save file, path, params
|
37
|
+
end
|
38
|
+
puts success ? "Saved #{file}" : "Saving failed"
|
39
|
+
end
|
40
|
+
|
41
|
+
def pretty
|
42
|
+
payload = quandl.get path, params
|
43
|
+
puts JSON.pretty_generate payload
|
44
|
+
end
|
45
|
+
|
46
|
+
def see
|
47
|
+
ap quandl.get path, params
|
48
|
+
end
|
49
|
+
|
50
|
+
def url
|
51
|
+
puts quandl.url path, params
|
52
|
+
end
|
53
|
+
|
54
|
+
def quandl
|
55
|
+
@quandl ||= quandl!
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def quandl!
|
61
|
+
API.new api_key, options
|
62
|
+
end
|
63
|
+
|
64
|
+
# Convert a params array like [key:value, key:value] to a hash like
|
65
|
+
# {key: value, key: value}
|
66
|
+
def translate_params(pairs)
|
67
|
+
result = {}
|
68
|
+
return result if pairs.empty?
|
69
|
+
pairs.each do |pair|
|
70
|
+
key, value = pair.split ':'
|
71
|
+
result[key.to_sym] = value
|
72
|
+
end
|
73
|
+
result
|
74
|
+
end
|
75
|
+
|
76
|
+
def options
|
77
|
+
result = {}
|
78
|
+
return result unless cache_dir || cache_life
|
79
|
+
|
80
|
+
result[:use_cache] = true
|
81
|
+
result[:cache_dir] = cache_dir if cache_dir
|
82
|
+
result[:cache_life] = cache_life.to_i if cache_life
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
86
|
+
def api_key
|
87
|
+
ENV['QUANDL_KEY']
|
88
|
+
end
|
89
|
+
|
90
|
+
def cache_dir
|
91
|
+
ENV['QUANDL_CACHE_DIR']
|
92
|
+
end
|
93
|
+
|
94
|
+
def cache_life
|
95
|
+
ENV['QUANDL_CACHE_LIFE']
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
data/lib/quata/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
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:
|
11
|
+
date: 2018-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: super_docopt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: awesome_print
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.8'
|
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.
|
40
|
+
version: '1.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: apicake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: runfile-tasks
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
89
|
+
version: '3.6'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
96
|
+
version: '3.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rdoc
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '5.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '5.1'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: byebug
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +128,28 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
131
|
+
version: '0.15'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
138
|
+
version: '0.15'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: yard
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0.
|
145
|
+
version: '0.9'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0.
|
152
|
+
version: '0.9'
|
153
153
|
description: Easy to use API for Quandl data service with a command line interface
|
154
154
|
email: db@dannyben.com
|
155
155
|
executables:
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.7.3
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Quandl API Library and Command Line
|