datahunter 0.1.9 → 0.1.11
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 +4 -4
- data/bin/hunter +8 -5
- data/lib/datahunter/base.rb +14 -0
- data/lib/datahunter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a339421a60af0ce4169a8ea2aaaa52303252a3d6
|
4
|
+
data.tar.gz: bf8bfb5220db28bf00ab4c3ef423d2e62162cd5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f1fefb00bc70b63b2fc55292014724a8b8b23d25c6045a0da1d806d291942477097ab691b825f81920607f04f12657ee391f2cd814674a84c2f214f596e26cf
|
7
|
+
data.tar.gz: 1bc61fd641e7e2d5dafe45bfb6acda511b23c8b2c708cf777cd42dadc492be73530999e0feca5e353d141cf7b6f6f5435d094e6b6ee5357ed01a5990ead4c207
|
data/bin/hunter
CHANGED
@@ -10,7 +10,7 @@ require 'colorize'
|
|
10
10
|
require 'downloadr'
|
11
11
|
|
12
12
|
program :version, Datahunter::VERSION
|
13
|
-
program :description, 'Find
|
13
|
+
program :description, 'Find an download Open Datasets directly from your terminal'
|
14
14
|
program :help_formatter, :compact
|
15
15
|
|
16
16
|
command :find do |c|
|
@@ -53,11 +53,10 @@ command :find do |c|
|
|
53
53
|
|
54
54
|
case ask "### get the data? (y/n)".colorize(:yellow)
|
55
55
|
when 'y'
|
56
|
-
if datasets[index]
|
56
|
+
if datasets[index].has_key?("resources")
|
57
57
|
Datahunter.download_the_data datasets[index]
|
58
58
|
else
|
59
|
-
|
60
|
-
Launchy.open(datasets[index]["uri"], options = {})
|
59
|
+
Datahunter.open_in_browser datasets[index]["uri"]
|
61
60
|
end
|
62
61
|
break
|
63
62
|
|
@@ -177,7 +176,11 @@ command :get do |c|
|
|
177
176
|
when 200
|
178
177
|
ds = JSON.parse(response.body)
|
179
178
|
puts
|
180
|
-
|
179
|
+
if ds.has_key?("resources")
|
180
|
+
Datahunter.download_the_data ds
|
181
|
+
else
|
182
|
+
Datahunter.open_in_browser ds["uri"]
|
183
|
+
end
|
181
184
|
when 500
|
182
185
|
puts "Invalid ID".colorize(:red)
|
183
186
|
end
|
data/lib/datahunter/base.rb
CHANGED
@@ -56,6 +56,15 @@ module Datahunter
|
|
56
56
|
Datahunter.download_file(resources[dl]["url"], resources[dl]["format"], dataset["uri"])
|
57
57
|
end
|
58
58
|
|
59
|
+
def self.open_in_browser url
|
60
|
+
if url =~ /\A#{URI::regexp}\z/
|
61
|
+
puts "You can't download this dataset directly, but you should from there"
|
62
|
+
Launchy.open(url, options = {})
|
63
|
+
else
|
64
|
+
Datahunter.print_bad_uri_message
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
59
68
|
## Messages: feedback and excuses
|
60
69
|
|
61
70
|
def self.print_feedback_request
|
@@ -80,6 +89,11 @@ module Datahunter
|
|
80
89
|
"if you just want to give us a feedback, don't hesitate!".colorize(:red)
|
81
90
|
end
|
82
91
|
|
92
|
+
def self.print_bad_uri_message
|
93
|
+
puts "The URL given by the publisher is not valid. We'll try to find out why "\
|
94
|
+
"as soon as we can!".colorize(:red)
|
95
|
+
end
|
96
|
+
|
83
97
|
private
|
84
98
|
|
85
99
|
def self.print_downloadable_links resources
|
data/lib/datahunter/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Terpo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|