datahunter 0.1.0 → 0.1.1

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: f72e1cf6090108c35f52ab1fea70c16ba583824a
4
- data.tar.gz: e102154ee89785deb91b5cd9416c36d51a1d59fc
3
+ metadata.gz: 2272bbb42482362c6e4abd579c13850e3e123278
4
+ data.tar.gz: eab3bb95e222811d5748f0b303d56bd52c5b93c6
5
5
  SHA512:
6
- metadata.gz: 491133c7dcb9baa827491874484f7754f2c497a9d3c51a23175141cc9eac80de756d11f3254db33442ac25c81630754c51b32a8d360150e400552b71b830777b
7
- data.tar.gz: c9bf04c8859e107656f2b3071961f527b27ee99e7eccbb9977209a2e36b1537e44f955f77cb44f461c8f35117adecf7cb15e20fa371534f36e401fe9ab404f76
6
+ metadata.gz: cead404cb7ea2fb67c964b8af49e65241511e4c23ebc483056980d8bd9cb8ef06ea6ba95eaf8eae2cfbeeeefcd9ce39eebe9cf655cdfdd9df59c921b9e5ff54b
7
+ data.tar.gz: 0b742fb32ef46f83d91a1bb78ccdd7b0bcbfd3f50b8321f26b6f015932e086ddd4b0e2681b5440595acabee55b314647d991b2af5daa5ec58228ac8083846ba2
data/README.md CHANGED
@@ -14,7 +14,43 @@ We believe there will be more and more data available on the web and the main is
14
14
  $ gem install datahunter
15
15
 
16
16
  ## Usage
17
- ### $ hunter find
17
+
18
+ ### Example1. $ hunter find ~> download
19
+
20
+ $ hunter find alimentaires
21
+ ### Response in 0.430501 seconds
22
+ ### Looks like we've got something for you!
23
+
24
+ title: Produits alimentaires : ingrédients, nutrition, labels
25
+
26
+ description: [Open Food Facts](http://fr.openfoodfacts.org/) répertorie les informations sur les produits alimentaires : ingrédients, informations nutritionnelles, labels etc. Les données proviennent majoritairement de la collecte citoyenne (crowdsourcing) des informations.
27
+
28
+ publisher: Open Food Facts
29
+
30
+ temporal: all
31
+
32
+ spatial: ["france", "fr", "europe", "schengen", "eu", "ue", "countries", "world", "all"]
33
+
34
+ created: 2014-05-07T02:44:58.119Z
35
+
36
+ updated: 2014-12-13T16:40:14.136Z
37
+
38
+ score: 13.427
39
+
40
+ ### get the data? (y/n)
41
+ y
42
+
43
+ 0. Ingrédients, informations nutritionnelles et données sur les produits alimentaires - CSV
44
+ 1. Ingrédients, informations nutritionnelles et données sur les produits alimentaires - RDF
45
+ 2. Description des données, exports et API de la base de produits Open Food Facts - HTML
46
+
47
+ ### which one? (0/1/...)
48
+ 0
49
+
50
+ Start downloading...
51
+ Your file has been downloaded, try to $ ls ;D
52
+
53
+ ### Example2. $ hunter find ~> open browser
18
54
  $ hunter find population france
19
55
  ### Response in 0.569162 seconds
20
56
  ### Looks like we've got something for you!
@@ -64,7 +100,7 @@ Don't hesitate to [give us any feedback about you experience with Hunter!](https
64
100
  ## Roadmap
65
101
 
66
102
  * more datasets
67
- * download datasets from the terminal (very soon :) )
103
+ * improve the download of datasets
68
104
  * more generic lib to make the API more easy to reuse
69
105
 
70
106
  ## Contributing
data/bin/hunter CHANGED
@@ -10,12 +10,17 @@ require 'colorize'
10
10
  require 'downloadr'
11
11
 
12
12
  program :version, Datahunter::VERSION
13
- program :description, 'Find Open Data directly from your terminal'
13
+ program :description, 'Find and download Open Datasets directly from your terminal'
14
+ program :help_formatter, :compact
14
15
 
15
16
  command :find do |c|
16
17
  c.syntax = 'hunter find keyword [spatial-coverage] [temporal-coverage]'
17
- c.summary = 'Returns the 3 most popular (most reused, viewed, etc) datasets corresponding '\
18
- 'to the triple keyword, spatial-coverage and temporal-coverage'
18
+ c.summary = '$ hunter find <keyword> <geo-coverage> <temporal-coverage>
19
+ * Returns the 3 most popular (most reused, viewed, etc)
20
+ datasets corresponding to the triple keyword,
21
+ spatial-coverage and temporal-coverage
22
+ * Allow you to either download the dataset or to open
23
+ your favorite browser directly at the good page'.colorize(:blue)
19
24
  c.description = c.summary
20
25
  c.example 'Find open data for the U.S. population', 'hunter find population us'
21
26
  c.action do |args, options|
@@ -81,7 +86,10 @@ end
81
86
 
82
87
  command :search do |c|
83
88
  c.syntax = 'hunter search keyword [spatial-coverage] [temporal-coverage]'
84
- c.summary = 'Returns all the datasets corresponding to the query, sorted by popularity'
89
+ c.summary = '$ hunter search <keyword> <geo-coverage> <temporal-coverage>
90
+ * Returns all the datasets corresponding to
91
+ the query, sorted by popularity.
92
+ * WARNING: this command is going to be modified soon!'.colorize(:blue)
85
93
  c.description = c.summary
86
94
  c.example 'Search open data for population', 'hunter search population'
87
95
  c.action do |args, options|
@@ -116,12 +124,14 @@ end
116
124
 
117
125
  command :about do |c|
118
126
  c.syntax = 'hunter about'
119
- c.summary = 'About Hunter'
127
+ c.summary = 'About Hunter
128
+ * Vision
129
+ * Value Proposition
130
+ * Stats
131
+ * Last datasets indexed'.colorize(:blue)
120
132
  c.description = c.summary
121
133
  c.action do |args, options|
122
- puts "
123
- ...........888888888888888..............
124
- ........8888888888888888888888..........
134
+ puts "........8888888888888888888888..........
125
135
  .....88888888888888888888888888888......
126
136
  ....8888888888888888888888888888888.....
127
137
  ...888888888888888888888888888~88888?...
@@ -143,7 +153,36 @@ $.........:8...............888888888888.
143
153
  ... .........................888........
144
154
  .... .....................:88..........
145
155
  ..... ...............8.............".colorize(:red)
146
- puts "### Hunter is still a prototype, please don't hesitate to help us make open datasets research better!".colorize(:blue)
156
+ puts
157
+ puts 'Find and download Open Datasets directly from the terminal!'.colorize(:red)
158
+ puts
159
+ puts 'We believe there will be more and more data available on the web and the main issue will be to find them and to manage each sources. So we try to do it for you: not by pre-processing them but by orienting you.'.colorize(:red)
160
+ puts
161
+ puts 'Number of datasets currently indexed: 1920'
162
+ puts
163
+ puts 'Last dataset indexed: "India Power Sector Review"'
164
+ puts
165
+ puts "### Hunter is still a prototype, please don't hesitate to help us make open datasets workflow better!".colorize(:blue)
147
166
  Datahunter.print_feedback_request
148
167
  end
149
168
  end
169
+
170
+ command :guide do |c|
171
+ c.action {puts ('$ hunter find <keyword> <geo-coverage> <temporal-coverage> '.colorize(:blue) +
172
+ '
173
+ * Returns the 3 most popular (most reused, viewed, etc) datasets corresponding to the query
174
+ * Allow you to either download the dataset or to open your favorite browser directly at the good page')
175
+
176
+ puts ('$ hunter search <keyword> <geo-coverage> <temporal-coverage>'.colorize(:blue) +
177
+ '
178
+ * Returns all the datasets corresponding to the query, sorted by popularity.
179
+ * WARNING: this command is going to be modified soon!')
180
+
181
+ puts ('$ hunter about'.colorize(:blue) +
182
+ '
183
+ * Vision
184
+ * Value Proposition
185
+ * Stats
186
+ * Last datasets indexed')}
187
+ end
188
+ default_command :guide
@@ -35,32 +35,24 @@ module Datahunter
35
35
  puts ("score: ".colorize(:green) + "#{dataset["huntscore"]}")
36
36
  puts
37
37
  end
38
-
39
- def self.print_downloadable_links dataset
40
- dataset["resources"].each_with_index do |dl, i|
41
- puts ("#{i}. ".colorize(:yellow) +
42
- "#{dl["title"]} - ".colorize(:blue) +
43
- "#{dl["format"]}".colorize(:green))
44
- end
45
- end
46
-
47
- def self.download_file url
48
- puts "Start downloading..."
49
- Downloadr::HTTP.download(url)
50
- puts "Your file has been downloaded, try to $ ls ;D".colorize(:green)
51
- end
52
-
38
+
53
39
  def self.download_the_data dataset
54
- print_downloadable_links dataset
55
- dl = ask "### which one? (0/1/...)".colorize(:yellow)
56
- dl = dl.to_i
57
- if dataset["resources"][dl]["format"] == "HTML"
58
- Launchy.open(dataset["resources"][dl]["url"], options = {})
40
+ resources = dataset["resources"]
41
+ number_of_downloadable_links = resources.size
42
+
43
+ if number_of_downloadable_links == 1
44
+ dl = 0
59
45
  else
60
- download_file dataset["resources"][dl]["url"]
46
+ Datahunter.print_downloadable_links resources
47
+ dl = ask("### which one? (0/1/...)".colorize(:yellow), Integer) {|i| i.in = 0..(number_of_downloadable_links - 1)}
61
48
  end
49
+
50
+ dl = dl.to_i
51
+ Datahunter.download_file(resources[dl]["url"], resources[dl]["format"])
62
52
  end
63
53
 
54
+ ## Messages: feedback and excuses
55
+
64
56
  def self.print_feedback_request
65
57
  case ask "### give feedback? (y/n)".colorize(:yellow)
66
58
  when 'y'
@@ -75,4 +67,24 @@ module Datahunter
75
67
  "datasets indexed soon. If you want us to find a dataset for you, or "\
76
68
  "if you just want to give us a feedback, don't hesitate!".colorize(:red)
77
69
  end
70
+
71
+ private
72
+
73
+ def self.print_downloadable_links resources
74
+ resources.each_with_index do |dl, i|
75
+ puts ("#{i}. ".colorize(:yellow) +
76
+ "#{dl["title"]} - ".colorize(:blue) +
77
+ "#{dl["format"]}".colorize(:green))
78
+ end
79
+ end
80
+
81
+ def self.download_file url, format=""
82
+ if format == "HTML"
83
+ Launchy.open(url, options = {})
84
+ else
85
+ puts "Start downloading..."
86
+ Downloadr::HTTP.download(url)
87
+ puts "Your file has been downloaded, try to $ ls ;D".colorize(:green)
88
+ end
89
+ end
78
90
  end
@@ -1,3 +1,3 @@
1
1
  module Datahunter
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
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-14 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler