datahunter 0.3.0 → 0.3.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: e9919f3ad7ae09cbb6e8c15d69ad969b6a7d540f
4
- data.tar.gz: 3ab09545715106aa731338edb0bbb5803d8956e5
3
+ metadata.gz: 3c02fdbf540a9f74a6060e397e0e974473b25964
4
+ data.tar.gz: edad9aff2f8ea61dd994b29049544f8c10a831d5
5
5
  SHA512:
6
- metadata.gz: 06a00c3e9c22884397dcb87563ffeb603e0dd2c382f0e3723a9825d9dbe449b0f1e14d93856a14b72269c1030e24fb2880c81af42691e7aea748752868108296
7
- data.tar.gz: 367e8b39398dd88bff9d00d6859ca1ef5aeec44b87393670dff8e1363f62c9b3ad53b18febbcb7acf21d18c8a8cb312313425a776f54b126b008ce9bb7c15078
6
+ metadata.gz: ce6db1a7c75a00cb9479f362998cb5b072b28601dc4f5e0cefe182db2804c4882f01ff0bd87a589374e6b3b77d029eef39b3b1938ba43ae2a374e456e0a96447
7
+ data.tar.gz: b1e90694f9d6b40e4d87ebe254962a993ebe48ad56eb19ebe7f88524c6428bcfd990101325de6bfc7c1130a82f7f22b6e977bbb6d899171a0cc4c62cd6ca7a89
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  /coverage/
6
6
  /doc/
7
7
  /pkg/
8
+ /packaging/
8
9
  /spec/reports/
9
10
  /tmp/
10
11
  *.bundle
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'bundler/setup'
2
3
  require 'rspec/core/rake_task'
3
4
 
4
5
  # Default directory to look in is `/specs`
@@ -7,4 +8,81 @@ RSpec::Core::RakeTask.new(:spec) do |task|
7
8
  task.rspec_opts = ['--color', '--format documentation']
8
9
  end
9
10
 
10
- task :default => :spec
11
+ task :default => :spec
12
+
13
+ PACKAGE_NAME = "datahunter"
14
+ VERSION = Datahunter::VERSION
15
+ TRAVELING_RUBY_VERSION = "20150210-2.1.5"
16
+
17
+ desc "Package your app"
18
+ task :package => ['package:linux:x86', 'package:linux:x86_64', 'package:osx']
19
+
20
+ namespace :package do
21
+ namespace :linux do
22
+ desc "Package Hunter for Linux x86"
23
+ task :x86 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86.tar.gz"] do
24
+ create_package("linux-x86")
25
+ end
26
+
27
+ desc "Package Hunter for Linux x86_64"
28
+ task :x86_64 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz"] do
29
+ create_package("linux-x86_64")
30
+ end
31
+ end
32
+
33
+ desc "Package your app for OS X"
34
+ task :osx => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz"] do
35
+ create_package("osx")
36
+ end
37
+
38
+ desc "Install gems to local directory"
39
+ task :bundle_install do
40
+ if RUBY_VERSION !~ /^2\.1\./
41
+ abort "Only ruby 2.1"
42
+ end
43
+ sh "rm -rf packaging/tmp"
44
+ sh "mkdir -p packaging/tmp"
45
+ sh "cp datahunter.gemspec Gemfile.lock packaging/tmp/"
46
+ Bundler.with_clean_env do
47
+ sh "cd packaging/tmp && env BUNDLE_IGNORE_CONFIG=1 bundle install --path packaging/vendor"
48
+ end
49
+ sh "rm -rf packaging/tmp"
50
+ # sh "rm -f packaging/vendor/*/*/cache/*"
51
+ end
52
+ end
53
+
54
+ file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86.tar.gz" do
55
+ download_runtime("linux-x86")
56
+ end
57
+
58
+ file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz" do
59
+ download_runtime("linux-x86_64")
60
+ end
61
+
62
+ file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz" do
63
+ download_runtime("osx")
64
+ end
65
+
66
+ def create_package(target)
67
+ package_dir = "#{PACKAGE_NAME}-#{VERSION}-#{target}"
68
+ sh "rm -rf #{package_dir}"
69
+ sh "mkdir #{package_dir}"
70
+ sh "mkdir -p #{package_dir}/lib/app"
71
+ sh "cp bin/hunter bin/datahunter #{package_dir}/lib/app"
72
+ sh "mkdir #{package_dir}/lib/ruby"
73
+ sh "tar -xzf packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz -C #{package_dir}/lib/ruby"
74
+ sh "cp packaging/wrapper.sh #{package_dir}/hunter"
75
+ sh "cp -pR packaging/vendor #{package_dir}/lib/"
76
+ sh "cp datahunter.gemspec Gemfile.lock #{package_dir}/lib/vendor/"
77
+ sh "mkdir #{package_dir}/lib/vendor/.bundle"
78
+ # sh "cp packaging/bundler-config #{package_dir}/lib/vendor/.bundle/config"
79
+ if !ENV['DIR_ONLY']
80
+ sh "tar -czf #{package_dir}.tar.gz #{package_dir}"
81
+ sh "rm -rf #{package_dir}"
82
+ end
83
+ end
84
+
85
+ def download_runtime(target)
86
+ sh "cd packaging && curl -L -O --fail " +
87
+ "http://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz"
88
+ end
data/bin/hunter CHANGED
@@ -44,7 +44,7 @@ command :find do |c|
44
44
 
45
45
  Datahunter.print_coll_of_datasets_info_light sub_datasets
46
46
 
47
- case ask "### GET A DATASET ? (1/..5), show next 5 datasets? (RET) or abort? (abort)".colorize(:yellow)
47
+ case ask ("### Get dataset ? (1/..5), next 5 datasets? (RET) or abort? (abort)".colorize(:yellow))
48
48
  when '1'
49
49
  Datahunter.get_dataset sub_datasets[0]
50
50
  break
data/datahunter.gemspec CHANGED
@@ -26,10 +26,10 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "aruba-rspec"
27
27
 
28
28
  spec.add_runtime_dependency "json", "~> 1.8.1"
29
- spec.add_runtime_dependency "commander", "~> 4.3.0"
30
- spec.add_runtime_dependency "rest-client", "~> 1.7.3"
29
+ spec.add_runtime_dependency "commander", "~> 4.3.1"
30
+ spec.add_runtime_dependency "rest-client", "~> 1.8.0"
31
31
  spec.add_runtime_dependency "launchy", "~> 2.4.3"
32
32
  spec.add_runtime_dependency "colorize", "~> 0.7.5"
33
33
  spec.add_runtime_dependency "downloadr", "0.0.41"
34
- spec.add_runtime_dependency "addressable", "~> 2.3.7"
34
+ spec.add_runtime_dependency "addressable", "~> 2.3.8"
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Datahunter
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/spec/hunter_spec.rb CHANGED
@@ -1,9 +1,32 @@
1
1
  require 'spec_helper'
2
+ require 'launchy'
3
+ require 'downloadr'
4
+ require 'addressable/uri'
2
5
 
3
- describe 'Hunter CLI' do
6
+ describe 'Hunter' do
4
7
 
8
+ before(:each) do
9
+ @datasets = [{"description"=>"Comparison of developments in GDP", "created-ds"=>"2015-02-21T18:04:50.831Z", "tags"=>["labour", "gdp", "market", "the"], "_id"=>"54e8c8c2a8268b5c235ac62f", "publisher"=>"Office for National Statistics", "updated"=>"2015-02-18T09:22:22.556Z", "created"=>"2011-12-11T11:39:23.142Z", "spatial"=>["england", "scotland"], "title"=>"GDP and the Labour Market", "modified-ds"=>"2015-02-21T18:04:50.831Z", "uri"=>"URI Not Available", "huntscore"=>5.0, "resources"=>[{"title"=>"GDP and the Labour Market", "url"=>"http://webarchive.nationalarchives.gov.uk228166.xml", "format"=>""}, {"title"=>"GDP and the Labour Market", "url"=>"http://www.ons.gov.uk/ons/dcp19975_228158.xml", "format"=>""}], "temporal"=>["2011", "2012"]},
10
+ {"description"=>"Regional Gross Value Added (GVA)", "created-ds"=>"2015-02-21T18:06:09.304Z", "tags"=>["gross", "regional"], "_id"=>"54e8c911a8268b5c235ac855", "publisher"=>"Office for National Statistics", "updated"=>"2014-12-18T10:19:46.273Z", "created"=>"2013-12-19T09:29:03.755Z", "spatial"=>["england", "scotland"], "title"=>"Regional Gross Value Added (Production approach)", "modified-ds"=>"2015-02-21T18:06:09.304Z", "uri"=>"URI Not Available", "huntscore"=>5.0, "resources"=>[], "temporal"=>["2013", "2014"]}]
11
+
12
+ @url = "http://data.consumerfinance.gov/api/views.json"
13
+ @bad_url = "https://www.data.gouv.fr/fr/datasets/population/"
14
+ @invalid_url = "foo bar"
15
+ end
16
+
17
+ describe 'download a file' do
18
+
19
+ it 'should raise an error with an invalid uri' do
20
+ lambda { Datahunter.download_file @invalid_url }.should raise_error(Launchy::ApplicationNotFoundError)
21
+ end
22
+
23
+ it 'should open the browser if the file extension is not acceptable' do
24
+ lambda { Datahunter.download_file @bad_url }.should_not raise_error
25
+
26
+ end
5
27
 
6
- it 'find command should be working' do
7
-
28
+ it 'should ask if rename the file if the file extension is acceptable' do
29
+ lambda { Datahunter.download_file @url }.should raise_error(NoMethodError)
30
+ end
8
31
  end
9
32
  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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terpo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 4.3.0
89
+ version: 4.3.1
90
90
  type: :runtime
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: 4.3.0
96
+ version: 4.3.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rest-client
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.7.3
103
+ version: 1.8.0
104
104
  type: :runtime
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: 1.7.3
110
+ version: 1.8.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: launchy
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 2.3.7
159
+ version: 2.3.8
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 2.3.7
166
+ version: 2.3.8
167
167
  description: Command line interface to find open datasets via the Hunter API
168
168
  email:
169
169
  - nicolas.terpolilli@gmail.com