datahunter 0.1.5 → 0.1.6

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
  SHA1:
3
- metadata.gz: 022539c783acd412ca9c6bef66cf404bf7553b92
4
- data.tar.gz: d0f2e4057285cf4b94c11d14f11d7b3bdac7c779
3
+ metadata.gz: 2f3c168c10533b56d7b9c37d45afb780f34a86ca
4
+ data.tar.gz: 088ef418aed953bc729bd759b762e866a745e39c
5
5
  SHA512:
6
- metadata.gz: 5b4dcd81b0e3aa38bece7bad5ce2a5dda6fe5176fa499e6af0ee9f888fcd31042a6094c946f65263c4e4169df82f05ce503e448512602593c52e5e424b92ba39
7
- data.tar.gz: 254b271330ad564a813c7e2b197a645f088d8cdffdcd4a6e4a6b1c5091b73f74adce3b1b568d0d0c75ca3fa3f2e238026ea6125c19b4b00304c8068118d63398
6
+ metadata.gz: 36b3577e2d7cb46ae4e7020d8f2d2a0e0d463b5a92d0ec97c199b7d2bfd6d2be01087a53069e79d9e8d4958cdbbb7f452ed6771a785f945fbb840dae5c291dce
7
+ data.tar.gz: e4401e26b3aac1e21c2863508ee6b59107a218a92121e4d0735b477e89c14efcadc2e7f9c48479c9259173c874c615f67fdec9bf032efd9ea83274ce439c7298
data/bin/hunter CHANGED
@@ -108,10 +108,17 @@ command :search do |c|
108
108
  puts "### Response in #{elapsed_time} seconds".colorize(:blue)
109
109
  puts "### We've found #{datasets.size} datasets corresponding to your query #{args[0].downcase}:".colorize(:blue)
110
110
  puts
111
- datasets.each do |result|
112
- puts ("#{result["title"]}".colorize(:green) + " (#{result["uri"]})")
111
+ datasets.each_with_index do |result, i|
112
+ puts ("#{i}. ".colorize(:yellow) +
113
+ "#{result["title"]}".colorize(:green) +
114
+ " id: #{result["_id"]}")
113
115
  end
114
- when 500
116
+ puts
117
+ puts ("You can get more informations about a dataset with " +
118
+ "$ hunter info <id>".colorize(:blue))
119
+ puts ("You can download directly a dataset with " +
120
+ "$ hunter get <id>".colorize(:blue))
121
+ when 204
115
122
  puts "We found nothing for your query: as every good hunter... we are still learning".colorize(:red)
116
123
  Datahunter.print_excuse_message
117
124
  Datahunter.print_feedback_request
@@ -122,6 +129,59 @@ command :search do |c|
122
129
  end
123
130
  end
124
131
 
132
+ command :info do |c|
133
+ c.syntax = 'hunter info <id>'
134
+ c.summary = 'Get informations about a dataset from its ID'.colorize(:blue)
135
+ c.description = c.summary
136
+ c.action do |args, options|
137
+
138
+ if args[0].nil?
139
+ puts "usage: $ hunter info <id>"
140
+ else
141
+ url = Datahunter.ds_url(args[0])
142
+
143
+ response = RestClient.get(url, :content_type => :json) do |response, request, result, &block|
144
+
145
+ case response.code
146
+ when 200
147
+ ds = JSON.parse(response.body)
148
+ puts
149
+ Datahunter.print_dataset_info ds
150
+ when 500
151
+ puts "Invalid ID".colorize(:red)
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+
158
+ command :get do |c|
159
+ c.syntax = 'hunter get <id>'
160
+ c.summary =
161
+ 'Get a dataset (direct download if possible, web page if not) from its ID'.colorize(:blue)
162
+ c.description = c.summary
163
+ c.action do |args, options|
164
+
165
+ if args[0].nil?
166
+ puts "usage: $ hunter get id"
167
+ else
168
+ url = Datahunter.ds_url(args[0])
169
+
170
+ response = RestClient.get(url, :content_type => :json) do |response, request, result, &block|
171
+
172
+ case response.code
173
+ when 200
174
+ ds = JSON.parse(response.body)
175
+ puts
176
+ Datahunter.download_the_data ds
177
+ when 500
178
+ puts "Invalid ID".colorize(:red)
179
+ end
180
+ end
181
+ end
182
+ end
183
+ end
184
+
125
185
  command :about do |c|
126
186
  c.syntax = 'hunter about'
127
187
  c.summary = 'About Hunter
@@ -25,6 +25,10 @@ module Datahunter
25
25
  end
26
26
  end
27
27
 
28
+ def self.ds_url id
29
+ "#{DATASETS_URL}#{id}"
30
+ end
31
+
28
32
  def self.print_dataset_info dataset
29
33
  puts ("title: ".colorize(:green) + "#{dataset["title"]}")
30
34
  puts ("description: ".colorize(:green) + "#{dataset["description"]}")
@@ -1,3 +1,3 @@
1
1
  module Datahunter
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datahunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terpo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2014-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler