easy_downloader 0.0.3.alpha → 0.1.0

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3.alpha
1
+ 0.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{easy_downloader}
8
- s.version = "0.0.3.alpha"
8
+ s.version = "0.1.0"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bernardo Telles"]
12
- s.date = %q{2010-12-22}
12
+ s.date = %q{2011-06-24}
13
13
  s.description = %q{ EasyDownloader reduces the amount of work required to setup and check for errors when downloading from another location. This
14
14
  is useful when, for example, a client wants to you to pick a file up from their FTP, SFTP, or regular website on a nightly basis.
15
15
  EasyDownloader gives you a one-method means of downloading those files, returns with a friendly error message if it fails
@@ -3,6 +3,8 @@ module EasyDownloader
3
3
 
4
4
  attr_reader :files, :result
5
5
 
6
+ class_attribute :load_type
7
+
6
8
  include Sftp
7
9
  include Ftp
8
10
  include Http
@@ -11,6 +13,13 @@ module EasyDownloader
11
13
  @options= Options.new(*options)
12
14
  end
13
15
 
16
+
17
+ def execute_load
18
+ [:ftp, :http, :sftp].include?(@options.type.to_sym) ?
19
+ send("#{@options.type}_#{self.class.load_type.to_s}".to_sym, @options) :
20
+ raise(NotImplementedError.new("we don't have an #{@options.type}er of this type."))
21
+ end
22
+
14
23
  def execute
15
24
  begin
16
25
  @options.result.started
@@ -27,10 +36,6 @@ module EasyDownloader
27
36
 
28
37
  private
29
38
 
30
- def execute_load
31
- raise NotImplementedError.new("#{self.class.name} does not have an 'execute_load' method.")
32
- end
33
-
34
39
  def error_message(options, e)
35
40
  raise NotImplementedError.new("#{self.class.name} does not have an 'error_message' method.")
36
41
  end
@@ -3,16 +3,7 @@ module EasyDownloader
3
3
 
4
4
  private
5
5
 
6
- def execute_load
7
- case @options.type
8
- when :ftp
9
- ftp_download(@options)
10
- when :http
11
- http_download(@options)
12
- when :sftp
13
- sftp_download(@options)
14
- end
15
- end
6
+ self.load_type= 'download'
16
7
 
17
8
  def error_message(options, e)
18
9
  message = <<-ERROR_MESSAGE
@@ -24,9 +15,11 @@ module EasyDownloader
24
15
  host: #{options.host}
25
16
  user: #{options.user}
26
17
  pass: [filtered]
27
- directory_path: #{options.remote_path}
28
- file_pattern: #{options.remote_pattern}
29
- destination: #{options.local_path}
18
+ remote_file: #{options.remote_file}
19
+ remote_path: #{options.remote_path}
20
+ remote_pattern: #{options.remote_pattern}
21
+ local_path: #{options.local_path}
22
+ local_file: #{options.local_file}
30
23
  ERROR_MESSAGE
31
24
  message
32
25
  end
@@ -1,8 +1,8 @@
1
1
  require 'active_support/core_ext/array/extract_options'
2
2
  module EasyDownloader
3
3
  class Options
4
- attr_accessor :files, :successful, :result, :load_count,
5
- :type, :host, :user, :password,
4
+ attr_accessor :files, :successful, :result, :load_count, :type,
5
+ :host, :user, :password,
6
6
  :local_path, :remote_path,
7
7
  :local_pattern, :remote_pattern,
8
8
  :local_file, :remote_file
@@ -19,10 +19,6 @@ module EasyDownloader
19
19
  end
20
20
  end
21
21
 
22
- def type
23
- @type.to_sym
24
- end
25
-
26
22
  def remote_path
27
23
  to_dir_path(@remote_path)
28
24
  end
@@ -10,7 +10,7 @@ module EasyDownloader
10
10
 
11
11
  files.map(&:name).each do |path|
12
12
  options.result.starting_path(path)
13
- options.download_count += 1 if sftp.download!("#{options.remote_path}#{path}", "#{options.local_path}#{path}")
13
+ options.load_count += 1 if sftp.download!("#{options.remote_path}#{path}", "#{options.local_path}#{path}")
14
14
  options.result.finished_path(path)
15
15
  options.result.files_downloaded << "#{options.local_path}#{path}"
16
16
  end
@@ -3,11 +3,7 @@ module EasyDownloader
3
3
 
4
4
  private
5
5
 
6
- def execute_load
7
- [:ftp, :http, :sftp].include?(@options.type) ?
8
- send("#{@options.type.to_s}_upload".to_sym, @options) :
9
- raise(NotImplementedError.new("we don't have an uploader of this type."))
10
- end
6
+ self.load_type='upload'
11
7
 
12
8
  def error_message(options, e)
13
9
  message = <<-ERROR_MESSAGE
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_downloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 296151474
5
- prerelease: true
4
+ hash: 27
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- - alpha
11
- version: 0.0.3.alpha
10
+ version: 0.1.0
12
11
  platform: ruby
13
12
  authors:
14
13
  - Bernardo Telles
@@ -16,10 +15,12 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-12-22 00:00:00 -05:00
18
+ date: 2011-06-24 00:00:00 -04:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
23
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
25
26
  requirements:
@@ -32,10 +33,10 @@ dependencies:
32
33
  - 3
33
34
  version: 3.0.3
34
35
  requirement: *id001
35
- prerelease: false
36
- type: :runtime
37
36
  name: activesupport
38
37
  - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ type: :runtime
39
40
  version_requirements: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
@@ -46,10 +47,10 @@ dependencies:
46
47
  - 0
47
48
  version: "0"
48
49
  requirement: *id002
49
- prerelease: false
50
- type: :runtime
51
50
  name: net-sftp
52
51
  - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ type: :development
53
54
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
55
  none: false
55
56
  requirements:
@@ -60,10 +61,10 @@ dependencies:
60
61
  - 0
61
62
  version: "0"
62
63
  requirement: *id003
63
- prerelease: false
64
- type: :development
65
64
  name: ruby-debug
66
65
  - !ruby/object:Gem::Dependency
66
+ prerelease: false
67
+ type: :development
67
68
  version_requirements: &id004 !ruby/object:Gem::Requirement
68
69
  none: false
69
70
  requirements:
@@ -76,10 +77,10 @@ dependencies:
76
77
  - 0
77
78
  version: 2.1.0
78
79
  requirement: *id004
79
- prerelease: false
80
- type: :development
81
80
  name: rspec
82
81
  - !ruby/object:Gem::Dependency
82
+ prerelease: false
83
+ type: :development
83
84
  version_requirements: &id005 !ruby/object:Gem::Requirement
84
85
  none: false
85
86
  requirements:
@@ -92,10 +93,10 @@ dependencies:
92
93
  - 0
93
94
  version: 1.0.0
94
95
  requirement: *id005
95
- prerelease: false
96
- type: :development
97
96
  name: bundler
98
97
  - !ruby/object:Gem::Dependency
98
+ prerelease: false
99
+ type: :development
99
100
  version_requirements: &id006 !ruby/object:Gem::Requirement
100
101
  none: false
101
102
  requirements:
@@ -108,10 +109,10 @@ dependencies:
108
109
  - 1
109
110
  version: 1.5.1
110
111
  requirement: *id006
111
- prerelease: false
112
- type: :development
113
112
  name: jeweler
114
113
  - !ruby/object:Gem::Dependency
114
+ prerelease: false
115
+ type: :development
115
116
  version_requirements: &id007 !ruby/object:Gem::Requirement
116
117
  none: false
117
118
  requirements:
@@ -122,10 +123,10 @@ dependencies:
122
123
  - 0
123
124
  version: "0"
124
125
  requirement: *id007
125
- prerelease: false
126
- type: :development
127
126
  name: rcov
128
127
  - !ruby/object:Gem::Dependency
128
+ prerelease: false
129
+ type: :development
129
130
  version_requirements: &id008 !ruby/object:Gem::Requirement
130
131
  none: false
131
132
  requirements:
@@ -136,8 +137,6 @@ dependencies:
136
137
  - 0
137
138
  version: "0"
138
139
  requirement: *id008
139
- prerelease: false
140
- type: :development
141
140
  name: yard
142
141
  description: " EasyDownloader reduces the amount of work required to setup and check for errors when downloading from another location. This \n is useful when, for example, a client wants to you to pick a file up from their FTP, SFTP, or regular website on a nightly basis.\n EasyDownloader gives you a one-method means of downloading those files, returns with a friendly error message if it fails\n (geared at cron job notifications), or returns an array of file names it downloaded."
143
142
  email: btelles@gmail.com
@@ -191,14 +190,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
190
  required_rubygems_version: !ruby/object:Gem::Requirement
192
191
  none: false
193
192
  requirements:
194
- - - ">"
193
+ - - ">="
195
194
  - !ruby/object:Gem::Version
196
- hash: 25
195
+ hash: 3
197
196
  segments:
198
- - 1
199
- - 3
200
- - 1
201
- version: 1.3.1
197
+ - 0
198
+ version: "0"
202
199
  requirements: []
203
200
 
204
201
  rubyforge_project: