ruby-tapas-downloader 2.0.1 → 2.0.2

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: f1d7cdcdb5cde17aa928fc89ebfacbdf92bca457
4
- data.tar.gz: ae43b73c4d94581a915152adfa26e02b66614098
3
+ metadata.gz: 0f0fe636f9c2f5518dc74c455c8849b99c41d2c5
4
+ data.tar.gz: f78d4d669319e1d23328523c2cbab951fcc6637f
5
5
  SHA512:
6
- metadata.gz: 3c3f891b4221a29852407722e8f639a7ac7b58a32489489d51364dbccc687f729a32763533ba186cc5b6e024c003b104ed37020bcb520f70893da917c7d0c827
7
- data.tar.gz: b1b99d005782033bdd131110379a96c828f674a86b38ae267f7c563b1c895dac12f193160c9f69e55438b3ea75c6982903decb39f303281c6aed4001f8d9a6e5
6
+ metadata.gz: 9c0eade07ae42f0a3fc8ecd795457e78cf27c0c497464ef18be91c71ce5b66e425debf47bf023a33911328550d08621fe95a0f78dd7ee25321d435696e8a1fa8
7
+ data.tar.gz: 8cdfc7d654377226ccd8fada6e2c3c34c0534f58a208930babfcabf119ede9e31ce8119e0cf441626c9605edb3e34d524ccb83ce6c8fff71189aba9af896631c
@@ -7,6 +7,7 @@ require 'cgi'
7
7
  require 'logger'
8
8
  require 'pathname'
9
9
 
10
+ # Root module for Ruby Tapas downloader
10
11
  module RubyTapasDownloader
11
12
  class << self
12
13
  # The Logger for RubyTapasDownloader.
@@ -4,12 +4,11 @@ require 'user-configurations'
4
4
  require_relative '../ruby-tapas-downloader'
5
5
 
6
6
  # The Command Line Interface for Ruby Tapas Downloader.
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
7
+ class RubyTapasDownloader::CLI < Thor
8
+ # Long description for download action
9
+ def self.download_long_description
10
+ env_vars = RubyTapasDownloader::Config::CONFIG_KEYS.join(',')
11
+ <<-LONG_DESC
13
12
  To download you need to be authenticated, you have tree options:
14
13
 
15
14
  - Pass the params described before
@@ -17,80 +16,79 @@ To download you need to be authenticated, you have tree options:
17
16
  - Use `ruby-tapas-downloader configure`
18
17
 
19
18
  - Pass/export env vars: #{ env_vars }
20
- LONG_DESC
21
- end
19
+ LONG_DESC
20
+ end
22
21
 
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'
22
+ # Perform complete download procedure.
23
+ desc 'download', 'Download new content'
24
+ option(
25
+ :email, required: true, default: Config.default_email, aliases: '-e'
26
+ )
27
+ option(
28
+ :password,
29
+ required: true,
30
+ default: Config.default_password,
31
+ aliases: '-p'
32
+ )
33
+ option(
34
+ :download_path,
35
+ required: true,
36
+ default: Config.default_download_path,
37
+ aliases: '-d'
38
+ )
39
+ long_desc download_long_description
40
+ def download
41
+ create_agent
42
+ login
43
+ fetch_feed
44
+ create_catalog
45
+ download_catalog
46
+ end
47
+
48
+ # Configure user preferences
49
+ desc 'configure -e foo@bar.com -p 123 -l .', 'Configure user preferences'
50
+ option :email, required: true, aliases: '-e'
51
+ option :password, required: true, aliases: '-p'
52
+ option :download_path, required: true, aliases: '-d'
53
+ def configure
54
+ RubyTapasDownloader::Config.update(
55
+ email: email, password: password, download_path: download_path
39
56
  )
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
48
-
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
59
-
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 download_path, agent
92
- end
93
-
94
- attr_accessor :agent, :feed
95
57
  end
58
+
59
+ private
60
+
61
+ def email
62
+ options[:email]
63
+ end
64
+
65
+ def password
66
+ options[:password]
67
+ end
68
+
69
+ def download_path
70
+ options[:download_path]
71
+ end
72
+
73
+ def create_agent
74
+ @agent = Mechanize.new
75
+ end
76
+
77
+ def login
78
+ RubyTapasDownloader::Login.new(agent, email, password).login
79
+ end
80
+
81
+ def fetch_feed
82
+ @feed = RubyTapasDownloader::FeedFetcher.new(agent, email, password).fetch
83
+ end
84
+
85
+ def create_catalog
86
+ @catalog = RubyTapasDownloader::Extractors::Catalog.new.extract feed
87
+ end
88
+
89
+ def download_catalog
90
+ @catalog.download download_path, agent
91
+ end
92
+
93
+ attr_accessor :agent, :feed
96
94
  end
@@ -9,7 +9,6 @@ class RubyTapasDownloader::Config
9
9
  ]
10
10
 
11
11
  class << self
12
-
13
12
  # Retrieve urls stored in `urls.yml`.
14
13
  # @return [Hash] the urls stored in `urls.yml`.
15
14
  def urls
@@ -5,7 +5,7 @@ class RubyTapasDownloader::Downloadables::Catalog <
5
5
  # @return [Set<RubyTapasDownloader::Downloadables::Episode>] the Episodes.
6
6
  attr_reader :episodes
7
7
 
8
- def initialize episodes
8
+ def initialize(episodes)
9
9
  @episodes = episodes
10
10
  end
11
11
 
@@ -13,18 +13,18 @@ class RubyTapasDownloader::Downloadables::Catalog <
13
13
  #
14
14
  # @param basepath [String] the path to place download.
15
15
  # @param agent [Mechanize] the Mechanize agent.
16
- def download basepath, agent
16
+ def download(basepath, agent)
17
17
  RubyTapasDownloader.logger.info 'Starting download of catalog in ' \
18
18
  "`#{ basepath }'..."
19
19
  FileUtils.mkdir_p basepath
20
20
  episodes.each { |episode| episode.download basepath, agent }
21
21
  end
22
22
 
23
- def == other
23
+ def ==(other)
24
24
  episodes == other.episodes
25
25
  end
26
26
 
27
- def eql? other
27
+ def eql?(other)
28
28
  episodes.eql? other.episodes
29
29
  end
30
30
 
@@ -12,7 +12,7 @@ class RubyTapasDownloader::Downloadables::Episode <
12
12
  # for that episode.
13
13
  attr_reader :files
14
14
 
15
- def initialize title, link, files
15
+ def initialize(title, link, files)
16
16
  @title = title
17
17
  @link = link
18
18
  @files = files
@@ -25,11 +25,10 @@ class RubyTapasDownloader::Downloadables::Episode <
25
25
  @sanitized_title ||= title.downcase.gsub(/[^\w<>#?!$]+/, '-')
26
26
  end
27
27
 
28
-
29
28
  # Download the Episode.
30
29
  #
31
30
  # @param (see: RubyTapasDownloader::Downloadables::Catalog#download)
32
- def download basepath, agent
31
+ def download(basepath, agent)
33
32
  episode_path = File.join basepath, sanitized_title
34
33
  RubyTapasDownloader.logger.info 'Starting download of episode ' \
35
34
  "`#{ title }' in `#{ episode_path }'..."
@@ -37,11 +36,11 @@ class RubyTapasDownloader::Downloadables::Episode <
37
36
  files.each { |file| file.download episode_path, agent }
38
37
  end
39
38
 
40
- def == other
39
+ def ==(other)
41
40
  title == other.title && link == other.link && files == other.files
42
41
  end
43
42
 
44
- def eql? other
43
+ def eql?(other)
45
44
  title.eql?(other.title) && link.eql?(other.link) && files.eql?(other.files)
46
45
  end
47
46
 
@@ -8,7 +8,7 @@ class RubyTapasDownloader::Downloadables::File <
8
8
  # @return [String] the link to download the File.
9
9
  attr_reader :link
10
10
 
11
- def initialize name, link
11
+ def initialize(name, link)
12
12
  @name = name
13
13
  @link = link
14
14
  end
@@ -16,20 +16,20 @@ class RubyTapasDownloader::Downloadables::File <
16
16
  # Download the File.
17
17
  #
18
18
  # @param (see: RubyTapasDownloader::Downloadables::Catalog#download)
19
- def download basepath, agent
19
+ def download(basepath, agent)
20
20
  FileUtils.mkdir_p basepath
21
21
 
22
22
  file_path = File.join(basepath, name)
23
23
  RubyTapasDownloader.logger.info "Starting download of file `#{ name }' " \
24
24
  "in `#{ file_path }'..."
25
- agent.download link, file_path unless File.exists? file_path
25
+ agent.download link, file_path unless File.exist? file_path
26
26
  end
27
27
 
28
- def == other
28
+ def ==(other)
29
29
  name == other.name && link == other.link
30
30
  end
31
31
 
32
- def eql? other
32
+ def eql?(other)
33
33
  name.eql?(other.name) && link.eql?(other.link)
34
34
  end
35
35
 
@@ -2,20 +2,20 @@
2
2
  class RubyTapasDownloader::Extractors::Catalog < RubyTapasDownloader::Extractor
3
3
  # @param episode_extractor [RubyTapasDownloader::Extractors::Episode] the
4
4
  # Episode Extractor.
5
- def initialize episode_extractor =
6
- RubyTapasDownloader::Extractors::Episode.new
5
+ def initialize(episode_extractor =
6
+ RubyTapasDownloader::Extractors::Episode.new)
7
7
  @episode_extractor = episode_extractor
8
8
  end
9
9
 
10
10
  # @param feed [RSS::Rss] the feed extracted with `RSS::Parser.parse`.
11
11
  # @return [RubyTapasDownloader::Downloadables::Catalog] the Catalog extracted
12
12
  # from feed.
13
- def extract feed
13
+ def extract(feed)
14
14
  episodes = Set.new
15
15
 
16
- feed.items.each { |item|
16
+ feed.items.each do |item|
17
17
  episodes << @episode_extractor.extract(item)
18
- }
18
+ end
19
19
 
20
20
  RubyTapasDownloader::Downloadables::Catalog.new episodes
21
21
  end
@@ -2,7 +2,7 @@
2
2
  class RubyTapasDownloader::Extractors::Episode < RubyTapasDownloader::Extractor
3
3
  # @param files_extractor [RubyTapasDownloader::Extractors::Files] the
4
4
  # Files Extractor.
5
- def initialize files_extractor = RubyTapasDownloader::Extractors::Files.new
5
+ def initialize(files_extractor = RubyTapasDownloader::Extractors::Files.new)
6
6
  @files_extractor = files_extractor
7
7
  end
8
8
 
@@ -10,7 +10,7 @@ class RubyTapasDownloader::Extractors::Episode < RubyTapasDownloader::Extractor
10
10
  # `feed.items[i]`.
11
11
  # @return [RubyTapasDownloader::Downloadables::Episode] the Episode extracted
12
12
  # from feed item.
13
- def extract item
13
+ def extract(item)
14
14
  title = CGI.unescapeHTML item.title
15
15
  link = item.link
16
16
  files = @files_extractor.extract item.description
@@ -4,14 +4,14 @@ class RubyTapasDownloader::Extractors::Files < RubyTapasDownloader::Extractor
4
4
  # `feed.items[i].description`.
5
5
  # @return [Set<RubyTapasDownloader::Downloadables::File>] the Set of Files
6
6
  # extracted from feed item description.
7
- def extract item_description
7
+ def extract(item_description)
8
8
  files = Set.new
9
9
  document = REXML::Document.new item_description
10
- document.elements.each("/div[@class='blog-entry']/ul/li/a") { |element|
10
+ document.elements.each("/div[@class='blog-entry']/ul/li/a") do |element|
11
11
  name = element.text
12
12
  link = element.attribute('href').to_s
13
13
  files << RubyTapasDownloader::Downloadables::File.new(name, link)
14
- }
14
+ end
15
15
  files
16
16
  end
17
17
  end
@@ -9,7 +9,7 @@ class RubyTapasDownloader::FeedFetcher
9
9
  # @return [String] the password for the user.
10
10
  attr_reader :password
11
11
 
12
- def initialize agent, email, password
12
+ def initialize(agent, email, password)
13
13
  @agent = agent
14
14
  @email = email
15
15
  @password = password
@@ -11,7 +11,7 @@ class RubyTapasDownloader::Login
11
11
  # @return [String] the password for the user.
12
12
  attr_reader :password
13
13
 
14
- def initialize agent, email, password
14
+ def initialize(agent, email, password)
15
15
  @agent = agent
16
16
  @email = email
17
17
  @password = password
@@ -1,3 +1,4 @@
1
+ # Gem current version
1
2
  module RubyTapasDownloader
2
- VERSION = '2.0.1'
3
+ VERSION = '2.0.2'
3
4
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-tapas-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
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-12 00:00:00.000000000 Z
11
+ date: 2014-07-12 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
27
  - !ruby/object:Gem::Dependency
28
28
  name: user-configurations
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.19'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.19'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry-debugger
70
+ name: pry-byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.2'
75
+ version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.2'
82
+ version: '1.3'
83
83
  description: It downloads all episodes and attachments, organizes them for later use
84
84
  and keeps an easy to use index of episodes.
85
85
  email: ruby-tapas-downloader@leafac.com
@@ -119,17 +119,17 @@ require_paths:
119
119
  - lib
120
120
  required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.0.0
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - '>='
127
+ - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.2.2
132
+ rubygems_version: 2.2.0
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Downloader for Avdi Grimm Ruby Tapas