jetel 0.0.11 → 0.0.12

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
2
  SHA1:
3
- metadata.gz: d062d8c13e6914a980360c03db81fb26b057b67c
4
- data.tar.gz: f04230e4ab77f352cc4f6bffcdbc77ce539a27b3
3
+ metadata.gz: 2d85a2b4a94f2f04b826ba3871f1f4945456e400
4
+ data.tar.gz: b6b901b2e38a830d0ffaaea41879627aaea8d6cb
5
5
  SHA512:
6
- metadata.gz: 6638ff96f879a01fc9dec0da9139b29314918f70e7faebb9e8b531cc25238dee81b75832730f93785692c8ee1661ae68d6a9993830c84eedfe251f29ee513d16
7
- data.tar.gz: 675fc954657e8cb2d77bc15a55304a188de110791889a6f5738cbb029a47b3bae37563188141462b1b68debb3d17e57d51c94b2a9918645a10eaf80068660a1f
6
+ metadata.gz: f1d23cafd62f464268893fa0a5643f8ef44e7f5abe6fd4a99b2c74bc7a695c80fd32fae1ff562d5c71b556076baec3eca7d556b7f3bcaa9c70b30db71077711b
7
+ data.tar.gz: d80f7a4cc858c7c67954ffe03294e5efa9ae28237a909604f42b7e01ebc84c2a639db72ac3cdbce714a61239470196b5946414e3827670a9d2e1cf24420ca05f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jetel (0.0.11)
4
+ jetel (0.0.12)
5
5
  activesupport
6
6
  aws-sdk (~> 2)
7
7
  couchbase (~> 1.3, >= 1.3.14)
@@ -14,6 +14,7 @@ PATH
14
14
  nokogiri
15
15
  pg
16
16
  pmap
17
+ rest_client (~> 1.8, >= 1.8.3)
17
18
  rubyzip
18
19
  terminal-table
19
20
  yajl-ruby (~> 1.2, >= 1.2.1)
@@ -82,7 +83,7 @@ GEM
82
83
  minitest (5.8.2)
83
84
  multi_json (1.11.2)
84
85
  multipart-post (2.0.0)
85
- netrc (0.11.0)
86
+ netrc (0.7.9)
86
87
  nokogiri (1.6.6.2)
87
88
  mini_portile (~> 0.6.0)
88
89
  parser (2.2.3.0)
@@ -96,6 +97,8 @@ GEM
96
97
  http-cookie (>= 1.0.2, < 2.0)
97
98
  mime-types (>= 1.16, < 3.0)
98
99
  netrc (~> 0.7)
100
+ rest_client (1.8.3)
101
+ netrc (~> 0.7.7)
99
102
  rspec (3.3.0)
100
103
  rspec-core (~> 3.3.0)
101
104
  rspec-expectations (~> 3.3.0)
data/jetel.gemspec CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency 'nokogiri'
32
32
  spec.add_dependency 'pg'
33
33
  spec.add_dependency 'pmap'
34
+ spec.add_dependency 'rest_client', '~> 1.8', '>= 1.8.3'
34
35
  spec.add_dependency 'rubyzip'
35
36
  spec.add_dependency 'terminal-table'
36
37
  spec.add_dependency 'yajl-ruby', '~> 1.2', '>= 1.2.1'
@@ -1,13 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
- require_relative 'downloaders'
4
-
5
3
  module Jetel
6
4
  class Downloader
7
5
  attr_reader :downloader
8
6
 
9
7
  def initialize
10
- @downloader = Downloaders::Aria.new
8
+ @downloader = Downloaders.choose_downloader.new
11
9
  end
12
10
 
13
11
  def download(file, opts = {})
@@ -1,5 +1,8 @@
1
1
  require 'active_support/inflector'
2
+ require_relative 'downloaders'
3
+
2
4
  require_relative '../extensions/extensions'
5
+ require_relative '../helpers/helpers'
3
6
 
4
7
  module Jetel
5
8
  module Downloaders
@@ -37,6 +40,14 @@ module Jetel
37
40
  # Remove nil values and return
38
41
  res.compact
39
42
  end
43
+
44
+ def choose_downloader
45
+ if Helper.which('aria2c')
46
+ return Downloaders::Aria
47
+ end
48
+
49
+ Downloaders::Ruby
50
+ end
40
51
  end
41
52
  end
42
53
  end
@@ -1,6 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'pty'
3
+ require 'rest-client'
4
+
5
+ require_relative '../../version.rb'
4
6
 
5
7
  require_relative '../base_downloader'
6
8
 
@@ -10,7 +12,30 @@ module Jetel
10
12
  def download(url, opts = BaseDownloader::OPTS_DOWNLOAD)
11
13
  super
12
14
 
13
- puts 'Not implemented'
15
+ raw = {
16
+ :headers => {
17
+ :user_agent => "jetel/#{Jetel::VERSION}"
18
+ },
19
+ :method => :get,
20
+ :url => url,
21
+ # TODO: Load from config, param or so
22
+ :verify_ssl => false
23
+ }
24
+
25
+ FileUtils.mkdir_p(opts[:dir])
26
+
27
+ filename = opts[:filename] || url.split('/').last
28
+
29
+ out_full_path = File.join(opts[:dir], filename)
30
+
31
+ File.open(out_full_path, 'w') do |file|
32
+ RestClient::Request.execute(raw) do |chunk, _x, response|
33
+ if response.code.to_s != '200'
34
+ fail ArgumentError, "Error downloading #{url}. Got response: #{response.code} #{response} #{response.body}"
35
+ end
36
+ file.write chunk
37
+ end
38
+ end
14
39
  end
15
40
  end
16
41
  end
@@ -0,0 +1,19 @@
1
+ module Jetel
2
+ module Helper
3
+ class << self
4
+ # Cross-platform way of finding an executable in the $PATH.
5
+ #
6
+ # which('ruby') #=> /usr/bin/ruby
7
+ def which(cmd)
8
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
9
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
10
+ exts.each { |ext|
11
+ exe = File.join(path, "#{cmd}#{ext}")
12
+ return exe if File.executable?(exe) && !File.directory?(exe)
13
+ }
14
+ end
15
+ return nil
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/jetel/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Jetel
4
- VERSION = '0.0.11'
4
+ VERSION = '0.0.12'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jetel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Korcak
@@ -196,6 +196,26 @@ dependencies:
196
196
  - - ">="
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
+ - !ruby/object:Gem::Dependency
200
+ name: rest_client
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - "~>"
204
+ - !ruby/object:Gem::Version
205
+ version: '1.8'
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 1.8.3
209
+ type: :runtime
210
+ prerelease: false
211
+ version_requirements: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.8'
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: 1.8.3
199
219
  - !ruby/object:Gem::Dependency
200
220
  name: rubyzip
201
221
  requirement: !ruby/object:Gem::Requirement
@@ -389,6 +409,7 @@ files:
389
409
  - lib/jetel/extensions/kernel.rb
390
410
  - lib/jetel/helpers/general_helper.rb
391
411
  - lib/jetel/helpers/helpers.rb
412
+ - lib/jetel/helpers/os_helper.rb
392
413
  - lib/jetel/lib.rb
393
414
  - lib/jetel/loaders/couchbase/couchbase.rb
394
415
  - lib/jetel/loaders/elasticsearch/elasticsearch.rb