ruby-tapas-downloader 1.0.2 → 2.0.0

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: ead20e84b9acad5174d882fd8df88d0500ed9ea6
4
- data.tar.gz: 575b76bd539f6bf27f80fda9b9640ba890db4bc4
3
+ metadata.gz: 6f73d2efc12fc1b97b7788fb830e14c2e6039ce6
4
+ data.tar.gz: 6583cadf3527bf50d55656a64cacbd403309c506
5
5
  SHA512:
6
- metadata.gz: 82921b9f4ec176dfdd797212b711c1466c17fbfc4d5f9f47d8f73495e6a43fdec71fba4a98ab11a396f460b3179d1a60dbba36ddae345f965d93816e8271b71d
7
- data.tar.gz: 955b4d6aaeff3c24251281d25a693c88b214d85e79fb1efdc630047d5624858992a39228391f2015cdf9d3ae43c3eb6e334df872abbeeb88624ff89f635d708f
6
+ metadata.gz: a770516065e32bbd887947207a26b955bd1d1370a8fa421587744fb4fe7f38e8cb9c62f2df96b712582d5a5e5b3378c5172d9fcf74e06b21d2804c76c3434894
7
+ data.tar.gz: a33fe0b0674ff9d3d51bc3107d88667fa2ddcd772dd6f54544f97e736f26b56544c5a4f44470204bf124e5d6c85f149880b104c362d859876afb1edd7675f7d1
data/README.md CHANGED
@@ -23,7 +23,24 @@ Usage
23
23
  -----
24
24
 
25
25
  ```bash
26
- $ ruby-tapas-downloader <email> <password> <download-path>
26
+ $ ruby-tapas-downloader download -e <email> -p <password> -d <download_path>
27
+ ```
28
+
29
+ If you prefer, you can pre-configure, in that way you dont need authenticate
30
+ every download.
31
+
32
+ ```bash
33
+ $ ruby-tapas-downloader configure -e <email> -p <password> -d <download_path>
34
+ ```
35
+
36
+ One other alternative is to pass/export env vars:
37
+
38
+ ```bash
39
+ $ export RUBY_TAPAS_DOWNLOADER_EMAIL=someone@example.com
40
+ $ export RUBY_TAPAS_DOWNLOADER_PASSWORD=123
41
+ $ export RUBY_TAPAS_DOWNLOADER_DOWNLOAD_PATH=.
42
+
43
+ $ ruby-tapas-downloader download
27
44
  ```
28
45
 
29
46
  Warning
@@ -1,12 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- if ARGV.count != 3
4
- abort <<-USAGE
5
- Usage:
6
- $ ruby-tapas-downloader <email> <password> <download-path>
7
- USAGE
8
- end
9
-
10
3
  require_relative '../lib/ruby_tapas_downloader/cli'
11
4
 
12
- RubyTapasDownloader::CLI.new(*ARGV).download
5
+ RubyTapasDownloader::CLI.start
@@ -1,45 +1,96 @@
1
+ require 'thor'
2
+ require 'user-configurations'
3
+
1
4
  require_relative '../ruby-tapas-downloader'
2
5
 
3
6
  # The Command Line Interface for Ruby Tapas Downloader.
4
- class RubyTapasDownloader::CLI
5
- # @param email [String] the e-mail for the user.
6
- # @param password [String] the password for the user.
7
- # @param download_path [String] the path in which the download is performed.
8
- def initialize email, password, download_path
9
- @email = email
10
- @password = password
11
- @download_path = download_path
12
- end
7
+ module RubyTapasDownloader
8
+ class CLI < Thor
9
+ # Long description for download action
10
+ def self.download_long_description
11
+ env_vars = RubyTapasDownloader::Config::CONFIG_KEYS.join(',')
12
+ <<-LONG_DESC
13
+ To download you need to be authenticated, you have tree options:
13
14
 
14
- # Perform complete download procedure.
15
- def download
16
- create_agent
17
- login
18
- fetch_feed
19
- create_catalog
20
- download_catalog
21
- end
15
+ - Pass the params described before
22
16
 
23
- private
17
+ - Use `ruby-tapas-downloader configure`
24
18
 
25
- def create_agent
26
- @agent = Mechanize.new
27
- end
19
+ - Pass/export env vars: #{ env_vars }
20
+ LONG_DESC
21
+ end
28
22
 
29
- def login
30
- RubyTapasDownloader::Login.new(@agent, @email, @password).login
31
- end
23
+ # Perform complete download procedure.
24
+ desc 'download', 'Download new content'
25
+ option(
26
+ :email, required: true, default: Config.default_email, aliases: '-e'
27
+ )
28
+ option(
29
+ :password,
30
+ required: true,
31
+ default: Config.default_password,
32
+ aliases: '-p'
33
+ )
34
+ option(
35
+ :download_path,
36
+ required: true,
37
+ default: Config.default_download_path,
38
+ aliases: '-d'
39
+ )
40
+ long_desc download_long_description
41
+ def download
42
+ create_agent
43
+ login
44
+ fetch_feed
45
+ create_catalog
46
+ download_catalog
47
+ end
32
48
 
33
- def fetch_feed
34
- @feed = RubyTapasDownloader::FeedFetcher.new(@agent, @email, @password)
35
- .fetch
36
- end
49
+ # Configure user preferences
50
+ desc 'configure -e foo@bar.com -p 123 -l .', 'Configure user preferences'
51
+ option :email, required: true, aliases: '-e'
52
+ option :password, required: true, aliases: '-p'
53
+ option :download_path, required: true, aliases: '-d'
54
+ def configure
55
+ RubyTapasDownloader::Config.update(
56
+ email: email, password: password, download_path: download_path
57
+ )
58
+ end
37
59
 
38
- def create_catalog
39
- @catalog = RubyTapasDownloader::Extractors::Catalog.new.extract @feed
40
- end
60
+ private
61
+
62
+ def email
63
+ options[:email]
64
+ end
65
+
66
+ def password
67
+ options[:password]
68
+ end
69
+
70
+ def download_path
71
+ options[:download_path]
72
+ end
73
+
74
+ def create_agent
75
+ @agent = Mechanize.new
76
+ end
77
+
78
+ def login
79
+ RubyTapasDownloader::Login.new(agent, email, password).login
80
+ end
81
+
82
+ def fetch_feed
83
+ @feed = RubyTapasDownloader::FeedFetcher.new(agent, email, password).fetch
84
+ end
85
+
86
+ def create_catalog
87
+ @catalog = RubyTapasDownloader::Extractors::Catalog.new.extract feed
88
+ end
89
+
90
+ def download_catalog
91
+ @catalog.download path, agent
92
+ end
41
93
 
42
- def download_catalog
43
- @catalog.download @download_path, @agent
94
+ attr_accessor :agent, :feed
44
95
  end
45
96
  end
@@ -1,14 +1,65 @@
1
+ require 'user-configurations'
2
+
1
3
  # Retrieve configurations.
2
4
  class RubyTapasDownloader::Config
5
+ CONFIG_KEYS = [
6
+ EMAIL = 'RUBY_TAPAS_DOWNLOADER_EMAIL',
7
+ PASSWORD = 'RUBY_TAPAS_DOWNLOADER_PASSWORD',
8
+ DOWNLOAD_PATH = 'RUBY_TAPAS_DOWNLOADER_DOWNLOAD_PATH'
9
+ ]
10
+
3
11
  class << self
12
+
4
13
  # Retrieve urls stored in `urls.yml`.
5
14
  # @return [Hash] the urls stored in `urls.yml`.
6
15
  def urls
7
16
  @urls ||= YAML.load_file urls_config_path
8
17
  end
9
18
 
19
+ # Default Email
20
+ def default_email
21
+ user_configurations[EMAIL]
22
+ end
23
+
24
+ # Default Password
25
+ def default_password
26
+ user_configurations[PASSWORD]
27
+ end
28
+
29
+ # Default Download path
30
+ def default_download_path
31
+ user_configurations[DOWNLOAD_PATH]
32
+ end
33
+
34
+ # Updates user preferences
35
+ def update(email: nil, password: nil, download_path: nil)
36
+ download_path = absolute_path(download_path)
37
+
38
+ new_configs = {
39
+ EMAIL => email, PASSWORD => password, DOWNLOAD_PATH => download_path
40
+ }
41
+
42
+ user_configurations[EMAIL] = email
43
+ user_configurations[PASSWORD] = password
44
+ user_configurations[DOWNLOAD_PATH] = download_path
45
+
46
+ user_configurations.store new_configs
47
+ end
48
+
10
49
  private
11
50
 
51
+ def user_configurations
52
+ @configs ||= UserConfigurations::Configuration.new(
53
+ 'ruby-tapas-downloader'
54
+ )
55
+ end
56
+
57
+ def absolute_path(path)
58
+ return path if (Pathname.new path).absolute?
59
+
60
+ File.expand_path(Dir.pwd, path)
61
+ end
62
+
12
63
  def urls_config_path
13
64
  Pathname File.expand_path('../../../config/urls.yml', __FILE__)
14
65
  end
@@ -1,3 +1,3 @@
1
1
  module RubyTapasDownloader
2
- VERSION = '1.0.2'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,55 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-tapas-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Facchinetti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: user-configurations
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.19'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.19'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rspec
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
- - - ~>
59
+ - - "~>"
32
60
  - !ruby/object:Gem::Version
33
61
  version: '2.0'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
- - - ~>
66
+ - - "~>"
39
67
  - !ruby/object:Gem::Version
40
68
  version: '2.0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: pry-debugger
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - ~>
73
+ - - "~>"
46
74
  - !ruby/object:Gem::Version
47
75
  version: '0.2'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - ~>
80
+ - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0.2'
55
83
  description: It downloads all episodes and attachments, organizes them for later use
@@ -91,18 +119,19 @@ require_paths:
91
119
  - lib
92
120
  required_ruby_version: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - '>='
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
97
125
  required_rubygems_version: !ruby/object:Gem::Requirement
98
126
  requirements:
99
- - - '>='
127
+ - - ">="
100
128
  - !ruby/object:Gem::Version
101
129
  version: '0'
102
130
  requirements: []
103
131
  rubyforge_project:
104
- rubygems_version: 2.2.2
132
+ rubygems_version: 2.2.0
105
133
  signing_key:
106
134
  specification_version: 4
107
135
  summary: Downloader for Avdi Grimm Ruby Tapas
108
136
  test_files: []
137
+ has_rdoc: