mangdown 0.7.1 → 0.7.2

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.
@@ -1,67 +1,67 @@
1
- require_relative '../spec_helper'
2
-
3
- module Mangdown
4
- describe PopularManga do
5
- before(:all) do
6
- end
7
-
8
- context "when initialized" do
9
- before(:each) do
10
- end
11
-
12
- context "with top 20" do
13
- it "should have a manga list with top 20 mangas" do
14
- @pop2 = PopularManga.new('http://www.mangareader.net/popular', 20)
15
- expect(@pop2.mangas_list.length).to eq(20)
16
- end
17
- end
18
-
19
- context "with top 50" do
20
- it "should have a manga list with top 50 mangas" do
21
- @pop3 = PopularManga.new('http://www.mangareader.net/popular', 50)
22
- expect(@pop3.mangas_list.length).to eq(50)
23
- end
24
- end
25
-
26
- context "with top 90" do
27
- it "should have a manga list with top 90 mangas" do
28
- @pop4 = PopularManga.new('http://www.mangareader.net/popular', 90)
29
- expect(@pop4.mangas_list.length).to eq(90)
30
- end
31
- end
32
-
33
- it "should have an empty mangas array" do
34
- @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
35
- expect(@pop.mangas).to be_empty
36
- end
37
- end
38
-
39
- context "when get_manga is called" do
40
- it "should have 1 manga in mangas" do
41
- @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
42
- @pop.get_manga(1)
43
- expect(@pop.mangas.length).to eq(1)
44
- end
45
-
46
- it "should have 2 mangas in mangas" do
47
- @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
48
- @pop.get_manga(1)
49
- @pop.get_manga(2)
50
- expect(@pop.mangas.length).to eq(2)
51
- end
52
-
53
- it "should have Bleach in mangas" do
54
- @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
55
- @pop.get_manga(1)
56
- expect(@pop.mangas.length).to eq(1)
57
- end
58
-
59
- it "should only get manga once" do
60
- @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
61
- @pop.get_manga(1)
62
- @pop.get_manga(1)
63
- expect(@pop.mangas.length).to eq(1)
64
- end
65
- end
66
- end
67
- end
1
+ require_relative '../spec_helper'
2
+
3
+ module Mangdown
4
+ describe PopularManga do
5
+ before(:all) do
6
+ end
7
+
8
+ context "when initialized" do
9
+ before(:each) do
10
+ end
11
+
12
+ context "with top 20" do
13
+ it "should have a manga list with top 20 mangas" do
14
+ @pop2 = PopularManga.new('http://www.mangareader.net/popular', 20)
15
+ expect(@pop2.mangas_list.length).to eq(20)
16
+ end
17
+ end
18
+
19
+ context "with top 50" do
20
+ it "should have a manga list with top 50 mangas" do
21
+ @pop3 = PopularManga.new('http://www.mangareader.net/popular', 50)
22
+ expect(@pop3.mangas_list.length).to eq(50)
23
+ end
24
+ end
25
+
26
+ context "with top 90" do
27
+ it "should have a manga list with top 90 mangas" do
28
+ @pop4 = PopularManga.new('http://www.mangareader.net/popular', 90)
29
+ expect(@pop4.mangas_list.length).to eq(90)
30
+ end
31
+ end
32
+
33
+ it "should have an empty mangas array" do
34
+ @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
35
+ expect(@pop.mangas).to be_empty
36
+ end
37
+ end
38
+
39
+ context "when get_manga is called" do
40
+ it "should have 1 manga in mangas" do
41
+ @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
42
+ @pop.get_manga(1)
43
+ expect(@pop.mangas.length).to eq(1)
44
+ end
45
+
46
+ it "should have 2 mangas in mangas" do
47
+ @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
48
+ @pop.get_manga(1)
49
+ @pop.get_manga(2)
50
+ expect(@pop.mangas.length).to eq(2)
51
+ end
52
+
53
+ it "should have Bleach in mangas" do
54
+ @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
55
+ @pop.get_manga(1)
56
+ expect(@pop.mangas.length).to eq(1)
57
+ end
58
+
59
+ it "should only get manga once" do
60
+ @pop = PopularManga.new('http://www.mangareader.net/popular', 20)
61
+ @pop.get_manga(1)
62
+ @pop.get_manga(1)
63
+ expect(@pop.mangas.length).to eq(1)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,5 +1,5 @@
1
- require_relative '../../lib/mandown'
2
-
3
- include Mandown
4
-
5
- $chapter = Chapter.new('http://www.mangareader.net/bleach/537', 'Bleach 537')
1
+ require_relative '../../lib/mandown'
2
+
3
+ include Mandown
4
+
5
+ $chapter = Chapter.new('http://www.mangareader.net/bleach/537', 'Bleach 537')
@@ -1,39 +1,37 @@
1
- require 'rspec'
2
- require 'yaml'
3
- require_relative '../lib/mangdown'
4
-
5
- dirs = ['../../Bleach 537',
6
- '../../Pipiruma! Extra Edition -DokiDoki Summer Vacation-',
7
- '../../6 NO TRIGGER']
8
-
9
- dirs.each do |d|
10
- dir = File.expand_path(d, __FILE__)
11
- if Dir.exist?(dir)
12
- print '*'
13
- FileUtils.rm_rf(dir)
14
- end
15
- end
16
-
17
- path = File.expand_path('../../Bleach 537 - Page 1.jpg', __FILE__)
18
- if File.exist?(path)
19
- print '*'
20
- FileUtils.rm(path)
21
- end
22
-
23
- # This file was generated by the `rspec --init` command. Conventionally, all
24
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
25
- # Require this file using `require "spec_helper"` to ensure that it is only
26
- # loaded once.
27
- #
28
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
29
- RSpec.configure do |config|
30
- config.treat_symbols_as_metadata_keys_with_true_values = true
31
- config.run_all_when_everything_filtered = true
32
- config.filter_run :focus
33
-
34
- # Run specs in random order to surface order dependencies. If you find an
35
- # order dependency and want to debug it, you can fix the order by providing
36
- # the seed, which is printed after each run.
37
- # --seed 1234
38
- config.order = 'random'
39
- end
1
+ require 'rspec'
2
+ require 'yaml'
3
+ require_relative '../lib/mangdown'
4
+
5
+ dirs = ['../../Bleach 537', '../../6 NO TRIGGER']
6
+
7
+ dirs.each do |d|
8
+ dir = File.expand_path(d, __FILE__)
9
+ if Dir.exist?(dir)
10
+ print '*'
11
+ FileUtils.rm_rf(dir)
12
+ end
13
+ end
14
+
15
+ path = File.expand_path('../../Bleach 537 - Page 1.jpg', __FILE__)
16
+ if File.exist?(path)
17
+ print '*'
18
+ FileUtils.rm(path)
19
+ end
20
+
21
+ # This file was generated by the `rspec --init` command. Conventionally, all
22
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
23
+ # Require this file using `require "spec_helper"` to ensure that it is only
24
+ # loaded once.
25
+ #
26
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
27
+ RSpec.configure do |config|
28
+ config.treat_symbols_as_metadata_keys_with_true_values = true
29
+ config.run_all_when_everything_filtered = true
30
+ config.filter_run :focus
31
+
32
+ # Run specs in random order to surface order dependencies. If you find an
33
+ # order dependency and want to debug it, you can fix the order by providing
34
+ # the seed, which is printed after each run.
35
+ # --seed 1234
36
+ config.order = 'random'
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2
@@ -16,6 +16,9 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - LICENSE
20
+ - doc/help.txt
21
+ - lib/mangdown.rb
19
22
  - lib/mangdown/cbz.rb
20
23
  - lib/mangdown/chapter.rb
21
24
  - lib/mangdown/commands.rb
@@ -24,12 +27,6 @@ files:
24
27
  - lib/mangdown/page.rb
25
28
  - lib/mangdown/popular.rb
26
29
  - lib/mangdown/tools.rb
27
- - lib/mangdown.rb
28
- - scripts/cbz_dirs.rb
29
- - scripts/dl_fk_ch.rb
30
- - scripts/dl_fk_chps.rb
31
- - scripts/dl_slow.rb
32
- - scripts/get_all_fk_page.rb
33
30
  - spec/mangdown/chapter_spec.rb
34
31
  - spec/mangdown/commands_spec.rb
35
32
  - spec/mangdown/manga_spec.rb
@@ -37,8 +34,6 @@ files:
37
34
  - spec/mangdown/popular_spec.rb
38
35
  - spec/objects/make_chapter.rb
39
36
  - spec/spec_helper.rb
40
- - LICENSE
41
- - doc/help.txt
42
37
  homepage:
43
38
  licenses:
44
39
  - MIT
@@ -49,17 +44,17 @@ require_paths:
49
44
  - lib
50
45
  required_ruby_version: !ruby/object:Gem::Requirement
51
46
  requirements:
52
- - - '>='
47
+ - - ">="
53
48
  - !ruby/object:Gem::Version
54
49
  version: '0'
55
50
  required_rubygems_version: !ruby/object:Gem::Requirement
56
51
  requirements:
57
- - - '>='
52
+ - - ">="
58
53
  - !ruby/object:Gem::Version
59
54
  version: '0'
60
55
  requirements: []
61
56
  rubyforge_project:
62
- rubygems_version: 2.0.2
57
+ rubygems_version: 2.2.2
63
58
  signing_key:
64
59
  specification_version: 4
65
60
  summary: Downloads Manga
@@ -1,67 +0,0 @@
1
- require 'zip'
2
-
3
-
4
- main_dir = File.expand_path(ARGV[0] || '.')
5
-
6
- # main_dir = Dir.pwd + '/' + main_dir.to_s unless main_dir =~ /[a-zA-Z]:[\/\\]/
7
-
8
- Dir.chdir(main_dir)
9
-
10
- def check_file_or_dir_name(name)
11
- num = name.slice(/(\d+)(\.jpg)*\Z/, 1)
12
-
13
- if num
14
- while num.length < 3
15
- num = '0' + num
16
- end
17
-
18
- name.sub(/(\d+)(\.jpg)*\Z/, num + '\2')
19
- end
20
-
21
- name
22
- end
23
-
24
- def check_dir(dir)
25
- Dir.glob(dir + '/*').each do |d|
26
- next if d.include?('.cbz')
27
- yield(d)
28
- end
29
- end
30
-
31
- def validate_file_or_dir_names(dir)
32
- check_dir(dir) do |e|
33
- f = check_file_or_dir_name(e)
34
-
35
- unless f == e
36
- File.rename(e, f)
37
- end
38
- end
39
- end
40
-
41
- def cbz_dir(dir)
42
- zip_file_name = dir + '.cbz'
43
- dir += '/' unless dir[-1] == '/'
44
-
45
- Zip::File.open(zip_file_name, Zip::File::CREATE) do |zp|
46
- Dir[File.join(dir, '**', '**')].each do |file|
47
- zp.add(file.sub(dir, ''), file)
48
- end
49
- end
50
- end
51
-
52
- def cbz_sub_dirs(dir)
53
- check_dir(dir) do |d|
54
- cbz_dir(d)
55
- end
56
- end
57
-
58
- if __FILE__ == $0
59
- # Make sure all sub dirs are checked
60
- validate_file_or_dir_names(main_dir)
61
- # Make sure all sub dirs have files checked
62
- check_dir(main_dir) { |d| validate_file_or_dir_names(d)}
63
- # Create cbz files for all sub dirs
64
- cbz_sub_dirs(main_dir)
65
- # new line
66
- puts
67
- end
@@ -1,14 +0,0 @@
1
- require_relative '../lib/mangdown'
2
-
3
- if ARGV.length == 3
4
- uri, name, pages = ARGV
5
- pages = pages.to_i
6
- else
7
- puts 'Wrong number of arguments'
8
- exit
9
- end
10
-
11
- Dir.chdir('D:/Downloads/Manga/FK')
12
-
13
- fk = Mangdown::FKChapter.new(uri, name, pages)
14
- fk.download
@@ -1,25 +0,0 @@
1
- require_relative 'get_all_fk_page'
2
-
3
-
4
- module Mangdown
5
- fk_dir = 'd:/downloads/manga/FK'
6
-
7
- Dir.chdir(fk_dir)
8
-
9
- chps = ARGV[0].to_i
10
- chps = 1 unless (chps > 0 and chps < 100)
11
-
12
- # puts "chps is: #{chps}"
13
-
14
- chapters_list = get_chapters(chps)
15
-
16
- # puts chapters_list.length
17
- # puts chapters_list
18
-
19
- chapters_list.each do |ch|
20
- fk = FKChapter.new(ch[0], ch[1], ch[2])
21
- fk.download
22
- end
23
-
24
- CBZ.cbz_sub_dirs(fk_dir)
25
- end
@@ -1,77 +0,0 @@
1
- require_relative '../lib/mangdown'
2
- require 'timeout'
3
-
4
- Dir.chdir('D:/downloads/manga')
5
-
6
- module Mangdown
7
- def no_time_out(tries = 3)
8
- begin
9
- timeout(120) do
10
- yield
11
- end
12
- rescue
13
- if tries > 0
14
- tries -= 1
15
- puts "Tries left: #{tries}"
16
- no_time_out(tries)
17
- else
18
- return
19
- end
20
- end
21
- end
22
-
23
- def slow_get_chapters(m, bgn, nd)
24
- @@file_name = File.expand_path("#{m.name}_temp.yml")
25
-
26
- exists = File.exist?(@@file_name)
27
- m_from_file = YAML.load(File.open(@@file_name, 'r').read) if exists
28
-
29
- if m_from_file and (m_from_file.chapters.length > 0)
30
- frst = (m.chapters_list[bgn][1] == m_from_file.chapters.first.name)
31
- lst = (m.chapters_list[nd][1] == m_from_file.chapters.last.name)
32
-
33
- m = m_from_file if (frst and lst)
34
- else
35
- m.chapters_list[bgn..nd].each_index do |i|
36
- no_time_out {m.get_chapter(i + bgn)}
37
- end
38
- end
39
-
40
- File.open(@@file_name, 'w') {|f| f.write(m.to_yaml)}
41
- m
42
- end
43
-
44
- def slow_dl_chapters(m)
45
- Dir.mkdir(m.name) unless Dir.exist?(m.name)
46
- Dir.chdir(m.name)
47
-
48
- m.chapters.each do |chap|
49
- puts "DL - #{chap.name}.."
50
- no_time_out {chap.download}
51
- end
52
-
53
- File.delete(@@file_name)
54
- end
55
-
56
- end
57
-
58
-
59
- if __FILE__ == $0
60
- unless ARGV.length >= 2
61
- puts 'Wrong number of arguments'
62
- exit
63
- end
64
-
65
- uri, name = ARGV
66
-
67
- m = Manga.new(uri, name)
68
-
69
- bgn = ARGV[2] ? ARGV[2].to_i - 1 : 0
70
- nd = ARGV[3] ? ARGV[3].to_i - 1 : m.chapters_list.length
71
-
72
- m = slow_get_chapters(m, bgn, nd)
73
- slow_dl_chapters(m)
74
- else
75
- puts "Mangdown module included."
76
- puts "Ready.."
77
- end