mangdown 0.17.5 → 0.18.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
- SHA1:
3
- metadata.gz: 5cfc7286573cbf76d3a970d404c28cae3df14fa9
4
- data.tar.gz: 7632ff0d23fbc2a957c1dc906c22d3dd8bfb0d39
2
+ SHA256:
3
+ metadata.gz: 15dbe30001d42c8b18faefe1a248710f9826ec03275a069056121abb6bfaf61d
4
+ data.tar.gz: 3f610805ad69a367342d3461c666c24802f366b8d9da3d8b1fb8bdeadbad5ca0
5
5
  SHA512:
6
- metadata.gz: 024fd523c89c29df2d92f6bf77a88c88c46e371ad58931e914730fc7e8eef6aa8bbba7d09f55952a131d2a4803523b5442dc70b4b776c5a26e08f54785588c5f
7
- data.tar.gz: afe445ef654dd458a2ae0237ebf7f96ff509e0b9f374fa9f122b2bee3d5be38e19ab2f584652ab5912e559ad96aac5c3718d6ff727d6dd93ec0572bed4de16f2
6
+ metadata.gz: 0faea9b82fbabcf2ae2b21c51acef39539c9f0450a00b37c995ccdbbde302f0bb977b95b4701536f7309c325e55986a737f0a224f15939221f428f470812994e
7
+ data.tar.gz: 67e7fabd848e64fb2f246fedb3102d86f1d2c923b3d16387b9f018d6fab308213cd57e99fae4248f9f072e9f122a7088abf6f020619fd0bb211d3519cf232cc0
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
- ![Gitten badge](http://gittens.r15.railsrumble.com//badge/jphager2/mangdown)
2
-
3
1
  ## Adapters [New]
4
2
  Check out lib/mangdown/adapter.rb and lib/mangdown/adapters/mangareader.rb for examples of how to build an adapter.
5
3
 
@@ -21,7 +19,7 @@ require 'mangdown/client'
21
19
  # Search for an exact match
22
20
  results = M.find("Dragon Ball")
23
21
 
24
- # Or if you need more flexibilty when searching for a manga,
22
+ # Or if you need more flexibilty when searching for a manga,
25
23
  # use are Regex
26
24
  results = M.find(/dragon ball(\ssd)?$/i)
27
25
 
@@ -34,7 +32,7 @@ manga.count
34
32
  # Download everything
35
33
  manga.download
36
34
 
37
- # Download a specific range
35
+ # Download a specific range
38
36
  manga.download(0, 99)
39
37
 
40
38
  # Convert all downloaded chapters to CBZ
@@ -20,11 +20,11 @@ module Mangdown
20
20
  end
21
21
 
22
22
  def is_manga?(uri = @uri)
23
- uri.slice(/#{root}(\/\d+)?(\/[^\/]+)(\.html)?/i) == uri
23
+ uri.slice(%r{#{root}(/\d+)?(/[^/]+)(\.html)?}i) == uri
24
24
  end
25
25
 
26
26
  def is_chapter?(uri = @uri)
27
- uri.slice(/#{root}(\/[^\/]+){1,2}\/(\d+|chapter-\d+\.html)/i) == uri
27
+ uri.slice(%r{#{root}(/[^/]+){1,2}/(\d+|chapter-\d+\.html)}i) == uri
28
28
  end
29
29
 
30
30
  def is_page?(uri = @uri)
@@ -18,7 +18,7 @@ module Mangdown
18
18
  return super unless @adapter.respond_to?(method)
19
19
 
20
20
  adapter.public_send(method, *args, &block)
21
- rescue => error
21
+ rescue StandardError => error
22
22
  logger.error(debug_error(method, error))
23
23
  raise Mangdown::Error, "Adapter failed: #{error.message}"
24
24
  end
@@ -25,11 +25,12 @@ module Mangdown
25
25
  self
26
26
  end
27
27
 
28
- def to_path
29
- @path ||= set_path
28
+ def path
29
+ @path ||= setup_path
30
30
  end
31
+ alias to_path path
31
32
 
32
- def set_path(dir = nil)
33
+ def setup_path(dir = nil)
33
34
  dir ||= File.join(DOWNLOAD_DIR, manga)
34
35
  path = File.join(dir, name)
35
36
  path = Tools.valid_path_name(path)
@@ -82,7 +83,7 @@ module Mangdown
82
83
  private
83
84
 
84
85
  def setup_download_dir!(dir)
85
- set_path(dir)
86
+ setup_path(dir)
86
87
  FileUtils.mkdir_p(to_path) unless Dir.exist?(to_path)
87
88
  end
88
89
 
@@ -22,7 +22,7 @@ module M
22
22
  # cbz all subdirectories in a directory
23
23
  def cbz(dir)
24
24
  Mangdown::CBZ.all(dir)
25
- rescue => error
25
+ rescue StandardError => error
26
26
  raise Mangdown::Error, "Failed to package #{dir}: #{error.message}"
27
27
  end
28
28
 
@@ -48,8 +48,8 @@ module M
48
48
  end
49
49
 
50
50
  # check if the data file is current
51
- def file_current?(f)
52
- File.exist?(f) && File.mtime(f) > (Time.now - 604_800)
51
+ def file_current?(file)
52
+ File.exist?(file) && File.mtime(file) > (Time.now - 604_800)
53
53
  end
54
54
 
55
55
  # attempt to get the list from the data file
@@ -69,7 +69,7 @@ module M
69
69
  end
70
70
  File.open(path, 'w+') { |f| f.write(list.to_yaml) }
71
71
  list
72
- rescue => error
72
+ rescue StandardError => error
73
73
  raise Mangdown::Error, "#{path} may be corrupt: #{error.message}"
74
74
  end
75
75
  end
@@ -43,7 +43,9 @@ module Mangdown
43
43
  elsif chapter_result[:skipped].any?
44
44
  skipped << chapter
45
45
  end
46
+
46
47
  next unless chapter_result[:failed].any?
48
+
47
49
  logger.error({
48
50
  msg: 'Chapter was not fully downloaded',
49
51
  uri: chapter.uri,
@@ -57,11 +59,12 @@ module Mangdown
57
59
  self
58
60
  end
59
61
 
60
- def to_path
61
- @path ||= set_path
62
+ def path
63
+ @path ||= setup_path
62
64
  end
65
+ alias to_path path
63
66
 
64
- def set_path(dir = nil)
67
+ def setup_path(dir = nil)
65
68
  dir ||= DOWNLOAD_DIR
66
69
  path = File.join(dir, name)
67
70
  @path = Tools.relative_or_absolute_path(path)
@@ -86,7 +89,7 @@ module Mangdown
86
89
  end
87
90
 
88
91
  def setup_download_dir!(dir)
89
- set_path(dir)
92
+ setup_path(dir)
90
93
  FileUtils.mkdir_p(to_path) unless Dir.exist?(to_path)
91
94
  end
92
95
 
data/lib/mangdown/page.rb CHANGED
@@ -20,14 +20,15 @@ module Mangdown
20
20
  self
21
21
  end
22
22
 
23
- def to_path
24
- @path ||= set_path
23
+ def path
24
+ @path ||= setup_path
25
25
  end
26
+ alias to_path path
26
27
 
27
28
  # Set path of page to file path if a file exists or to path
28
29
  # without file extension if file is not found. File extensions
29
30
  # are appended only after the file has been downloaded.
30
- def set_path(dir = nil)
31
+ def setup_path(dir = nil)
31
32
  dir ||= File.join(manga, chapter)
32
33
  dir = Tools.valid_path_name(dir)
33
34
  file = Dir.entries(dir).find { |f| f[name] } if Dir.exist?(dir)
@@ -45,7 +46,7 @@ module Mangdown
45
46
 
46
47
  append_file_data(dir, image)
47
48
  append_file_ext(dir)
48
- rescue => error
49
+ rescue StandardError => error
49
50
  logger.error({
50
51
  msg: 'Failed to download page',
51
52
  page: self,
@@ -61,7 +62,7 @@ module Mangdown
61
62
  end
62
63
 
63
64
  def append_file_ext(dir = nil)
64
- set_path(dir) if dir
65
+ setup_path(dir) if dir
65
66
  path = to_path
66
67
  ext = Tools.image_extension(path)
67
68
  filename = "#{path}.#{ext}"
@@ -70,14 +71,14 @@ module Mangdown
70
71
  end
71
72
 
72
73
  def file_exist?(dir = nil)
73
- set_path(dir) if dir
74
+ setup_path(dir) if dir
74
75
 
75
76
  Dir.entries(dir).any? { |file| file.to_s[to_path.basename.to_s] }
76
77
  end
77
78
 
78
79
  # cleanup existing file (all extensions)
79
80
  def delete_files!(dir)
80
- File.delete(to_path) while set_path(dir) && File.exist?(to_path)
81
+ File.delete(to_path) while setup_path(dir) && File.exist?(to_path)
81
82
  end
82
83
  end
83
84
  end
@@ -22,7 +22,7 @@ module Mangdown
22
22
  private
23
23
 
24
24
  def cbz_dir(dir)
25
- dir = dir.to_s.sub(/\/*$/, '')
25
+ dir = dir.to_s.sub(%r{/*$}, '')
26
26
 
27
27
  zip_filename = dir + '.cbz'
28
28
  return if File.exist?(zip_filename)
@@ -47,6 +47,7 @@ module Mangdown
47
47
  def each_dir_or_page(dir)
48
48
  Dir.glob(dir + '/*').each do |filename|
49
49
  next if filename.include?('.cbz')
50
+
50
51
  yield(filename)
51
52
  end
52
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mangdown
4
- VERSION = '0.17.5'
4
+ VERSION = '0.18.0'
5
5
  end
@@ -53,8 +53,8 @@ module Mangdown
53
53
  )
54
54
  end
55
55
 
56
- def test_set_path
57
- @chapter.set_path(Dir.pwd)
56
+ def test_setup_path
57
+ @chapter.setup_path(Dir.pwd)
58
58
  assert_equal "#{Dir.pwd}/name", @chapter.to_path.to_s
59
59
  end
60
60
 
@@ -64,7 +64,7 @@ module Mangdown
64
64
  alias old_hydra_streaming hydra_streaming
65
65
 
66
66
  def hydra_streaming(objects, *other_args)
67
- objects.map do |obj|
67
+ objects.map do |obj|
68
68
  next unless yield(:before, obj)
69
69
  yield(:succeeded, obj)
70
70
  yield(:body, obj, 'data')
@@ -51,10 +51,10 @@ module Mangdown
51
51
  assert_equal "#{Mangdown::DOWNLOAD_DIR}/name", manga.to_path.to_s
52
52
  end
53
53
 
54
- def test_set_path
54
+ def test_setup_path
55
55
  manga = Manga.new('uri', 'name')
56
56
 
57
- manga.set_path(Dir.pwd)
57
+ manga.setup_path(Dir.pwd)
58
58
  assert_equal "#{Dir.pwd}/name", manga.to_path.to_s
59
59
  end
60
60
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.5
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-21 00:00:00.000000000 Z
11
+ date: 2018-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: '1.8'
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
- version: '1.6'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-filemagic
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.6.13
198
+ rubygems_version: 2.7.7
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Download Manga