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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1adc211201495a73b50bd35cb27919e5c55f4fb3
4
- data.tar.gz: c824317ce83865f439729e435753b9b918af5f95
2
+ SHA256:
3
+ metadata.gz: 3785f6578995449094d19d5e5b9f145ca01e63e9411aca0bd9d89d31dca94c23
4
+ data.tar.gz: d00e91c46fded862496a8c16724f7315676ed8547e2ff84d7abfc66203dd4b8a
5
5
  SHA512:
6
- metadata.gz: 414a58117c529c0c1cd64bb4c6d19edd81b5338912e5ffc3828862dc0fe706ba481b69e98797ada4fc18b0a661af083b60b833e2e0dc0a58ea553e807c0ceb1f
7
- data.tar.gz: dc067b9125054f07c7c1b4d0fa12438c40d2a2c34a6ca295c366502b5d0477fe3e367cd61e2748179b1a74cea893af78cb1e09ffc6fc01b11c95146401b72b88
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
- [![Travis](https://img.shields.io/travis/DannyBen/quata.svg?style=flat-square)](https://travis-ci.org/DannyBen/quata)
6
- [![Code Climate](https://img.shields.io/codeclimate/github/DannyBen/quata.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/quata)
7
- [![Gemnasium](https://img.shields.io/gemnasium/DannyBen/quata.svg?style=flat-square)](https://gemnasium.com/DannyBen/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)
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
@@ -3,7 +3,7 @@
3
3
  require 'quata'
4
4
 
5
5
  begin
6
- Quata::CommandLine.instance.execute ARGV
6
+ Quata::CommandLine.execute ARGV
7
7
  rescue Quata::BadResponse => e
8
8
  STDERR.puts "#{e.class} - #{e.message}"
9
9
  end
@@ -1,117 +1,99 @@
1
- require 'singleton'
2
- require 'docopt'
3
- require 'json'
4
- require 'awesome_print'
5
-
6
- module Quata
7
-
8
- # Handles the command line interface
9
- class CommandLine
10
- include Singleton
11
-
12
- # Gets an array of arguments (e.g. ARGV), executes the command if valid
13
- # and shows usage patterns / help otherwise.
14
- def execute(argv=[])
15
- doc = File.read File.dirname(__FILE__) + '/docopt.txt'
16
- begin
17
- args = Docopt::docopt(doc, argv: argv, version: VERSION)
18
- handle args
19
- rescue Docopt::Exit => e
20
- puts e.message
21
- end
22
- end
23
-
24
- def quandl
25
- @quandl ||= quandl!
26
- end
27
-
28
- private
29
-
30
- attr_reader :path, :params, :file, :csv
31
-
32
- def quandl!
33
- API.new api_key, options
34
- end
35
-
36
- # Called when the arguments match one of the usage patterns. Will
37
- # delegate action to other, more specialized methods.
38
- def handle(args)
39
- @path = args['PATH']
40
- @params = translate_params args['PARAMS']
41
- @file = args['FILE']
42
- @csv = args['--csv']
43
-
44
- return get if args['get']
45
- return pretty if args['pretty']
46
- return see if args['see']
47
- return url if args['url']
48
- return save if args['save']
49
- end
50
-
51
- def get
52
- if csv
53
- puts quandl.get_csv path, params
54
- else
55
- payload = quandl.get! path, params
56
- puts payload.response.body
57
- end
58
- end
59
-
60
- def save
61
- if csv
62
- success = quandl.save_csv file, path, params
63
- else
64
- success = quandl.save file, path, params
65
- end
66
- puts success ? "Saved #{file}" : "Saving failed"
67
- end
68
-
69
- def pretty
70
- payload = quandl.get path, params
71
- puts JSON.pretty_generate payload
72
- end
73
-
74
- def see
75
- ap quandl.get path, params
76
- end
77
-
78
- def url
79
- puts quandl.url path, params
80
- end
81
-
82
- # Convert a params array like [key:value, key:value] to a hash like
83
- # {key: value, key: value}
84
- def translate_params(pairs)
85
- result = {}
86
- return result if pairs.empty?
87
- pairs.each do |pair|
88
- key, value = pair.split ':'
89
- result[key.to_sym] = value
90
- end
91
- result
92
- end
93
-
94
- def options
95
- result = {}
96
- return result unless cache_dir || cache_life
97
-
98
- result[:use_cache] = true
99
- result[:cache_dir] = cache_dir if cache_dir
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
@@ -1,3 +1,3 @@
1
1
  module Quata
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
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.6
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: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2018-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: docopt
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.5'
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.5'
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.6'
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.6'
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.7'
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.7'
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.4'
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.4'
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: '4.2'
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: '4.2'
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.14'
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.14'
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.8'
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.8'
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.5.1
188
+ rubygems_version: 2.7.3
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Quandl API Library and Command Line