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.
- checksums.yaml +4 -4
- data/LICENSE +20 -20
- data/doc/help.txt +33 -33
- data/lib/mangdown.rb +19 -19
- data/lib/mangdown/cbz.rb +38 -38
- data/lib/mangdown/chapter.rb +59 -131
- data/lib/mangdown/commands.rb +57 -45
- data/lib/mangdown/manga.rb +47 -46
- data/lib/mangdown/mangdown_hash.rb +8 -8
- data/lib/mangdown/page.rb +21 -16
- data/lib/mangdown/popular.rb +63 -52
- data/lib/mangdown/tools.rb +114 -110
- data/spec/mangdown/chapter_spec.rb +82 -120
- data/spec/mangdown/commands_spec.rb +35 -35
- data/spec/mangdown/manga_spec.rb +75 -77
- data/spec/mangdown/page_spec.rb +34 -34
- data/spec/mangdown/popular_spec.rb +67 -67
- data/spec/objects/make_chapter.rb +5 -5
- data/spec/spec_helper.rb +37 -39
- metadata +7 -12
- data/scripts/cbz_dirs.rb +0 -67
- data/scripts/dl_fk_ch.rb +0 -14
- data/scripts/dl_fk_chps.rb +0 -25
- data/scripts/dl_slow.rb +0 -77
- data/scripts/get_all_fk_page.rb +0 -72
@@ -1,120 +1,82 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Mangdown
|
4
|
-
@@uri = 'http://www.mangareader.net/bleach/537'
|
5
|
-
@@chapter_name = 'Bleach 537'
|
6
|
-
|
7
|
-
chapter = MRChapter.new( @@uri, @@chapter_name )
|
8
|
-
chapter.download
|
9
|
-
|
10
|
-
STUB_PATH = File.expand_path('../../objects/chapter.yml', __FILE__)
|
11
|
-
File.open(STUB_PATH, 'w+') do |file|
|
12
|
-
file.write(chapter.to_yaml)
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
context "when chapter is downloaded" do
|
84
|
-
it "should have the right chapter uri" do
|
85
|
-
expect(@chapter.uri).to eq(@@uri)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should create a directory in the current directory" do
|
89
|
-
dir = Dir.pwd
|
90
|
-
expect(Dir.glob(dir + '/*' )).to include(dir + '/' + @chapter.name)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should download all it's pages" do
|
94
|
-
dir = Dir.pwd + '/' + @chapter.name
|
95
|
-
expect(dir).to include("mangdown/#{@chapter.name}")
|
96
|
-
@chapter.pages.each do |page|
|
97
|
-
expect(Dir.glob(dir + '/*' )).to include(dir + '/' + page.filename)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe FKChapter do
|
104
|
-
before(:each) do
|
105
|
-
@f_chapter = YAML.load(File.open(Mangdown::FC_STUB_PATH, 'r').read)
|
106
|
-
@f_chapter.get_doc(@@fc_uri)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should be downloaded' do
|
110
|
-
dir = File.expand_path("../../../#{@f_chapter.name}", __FILE__)
|
111
|
-
expect(dir).to include("mangdown/#{@f_chapter.name}")
|
112
|
-
@f_chapter.pages.each do |page|
|
113
|
-
expect(Dir.glob(dir + '/*')).to include(dir + '/' + page.filename)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mangdown
|
4
|
+
@@uri = 'http://www.mangareader.net/bleach/537'
|
5
|
+
@@chapter_name = 'Bleach 537'
|
6
|
+
|
7
|
+
chapter = MRChapter.new( @@uri, @@chapter_name )
|
8
|
+
chapter.download
|
9
|
+
|
10
|
+
STUB_PATH = File.expand_path('../../objects/chapter.yml', __FILE__)
|
11
|
+
File.open(STUB_PATH, 'w+') do |file|
|
12
|
+
file.write(chapter.to_yaml)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe MRChapter do
|
16
|
+
before(:each) do
|
17
|
+
print 'o'
|
18
|
+
@chapter = YAML.load(File.open(Mangdown::STUB_PATH, 'r').read)
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when chapter is initialized" do
|
22
|
+
# sanity check, not necessary
|
23
|
+
it "should have the right chapter uri" do
|
24
|
+
expect(@chapter.uri).to eq(@@uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should get pages when initialized" do
|
28
|
+
expect(@chapter.pages.size).to be > 0
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have the right first page at the 0 index" do
|
32
|
+
expect(@chapter.pages.first.filename).to eq(
|
33
|
+
'Bleach 537 - Page 1.jpg')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have the right last page at the -1 index" do
|
37
|
+
expect(@chapter.pages.last.filename).to eq(
|
38
|
+
'Bleach 537 - Page 21.jpg')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Move these to Tools spec
|
43
|
+
=begin
|
44
|
+
context "when the functions for get_pages are run" do
|
45
|
+
it "should have the right chapter uri" do
|
46
|
+
expect(@chapter.uri).to eq(@@uri)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should get the right image link and filename from a uri" do
|
50
|
+
expect(@chapter.get_page).to eq(
|
51
|
+
['http://i25.mangareader.net/bleach/537/bleach-4149721.jpg',
|
52
|
+
'Bleach 537 - Page 1'])
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should get the right root from uri" do
|
56
|
+
expect(@chapter.get_root(@@uri)).to eq('http://www.mangareader.net')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
=end
|
60
|
+
|
61
|
+
context "when chapter is downloaded" do
|
62
|
+
it "should have a sub directory in the current directory" do
|
63
|
+
dir = Dir.pwd
|
64
|
+
expect(Dir.glob(dir + '/*' )).to include(dir + '/' +
|
65
|
+
@chapter.name)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should download all it's pages" do
|
69
|
+
dir = Dir.pwd + '/' + @chapter.name
|
70
|
+
# expect(dir).to include("mangdown/#{@chapter.name}")
|
71
|
+
pages_in_dir = Dir.glob(dir + '/*.jpg').length
|
72
|
+
expect(pages_in_dir).to eq(@chapter.pages.length)
|
73
|
+
#@chapter.pages.each do |page|
|
74
|
+
# expect(Dir.glob(dir + '/*' )).to include(dir +
|
75
|
+
# '/' + page.filename)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
@@ -1,35 +1,35 @@
|
|
1
|
-
require 'spec_helper.rb'
|
2
|
-
|
3
|
-
module M
|
4
|
-
|
5
|
-
describe "commands" do
|
6
|
-
before(:all) do
|
7
|
-
@manga = Mangdown::Manga.new('http://www.mangareader.net/6-no-trigger',
|
8
|
-
'6 NO TRIGGER')
|
9
|
-
|
10
|
-
M.download(@manga, 1, 3)
|
11
|
-
M.cbz("./#{@manga.name}")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should find a manga with the find command" do
|
15
|
-
m = M.find('Naruto')
|
16
|
-
expect(m.first
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should find a list of manga with the find command" do
|
20
|
-
m = M.find('Trigger')
|
21
|
-
expect(m.length).to be > 1
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should download a manga with the download command" do
|
25
|
-
puts Dir.pwd
|
26
|
-
chps = Dir.glob("#{Dir.pwd}/#{@manga.name}/*/")
|
27
|
-
expect(chps.length).to eq(3)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should cbz a manga with the cbz command" do
|
31
|
-
cbz_s = Dir.glob("#{Dir.pwd}/#{@manga.name}/*.cbz")
|
32
|
-
expect(cbz_s.length).to eq(3)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
module M
|
4
|
+
|
5
|
+
describe "commands" do
|
6
|
+
before(:all) do
|
7
|
+
@manga = Mangdown::Manga.new('http://www.mangareader.net/6-no-trigger',
|
8
|
+
'6 NO TRIGGER')
|
9
|
+
|
10
|
+
M.download(@manga, 1, 3)
|
11
|
+
M.cbz("./#{@manga.name}")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should find a manga with the find command" do
|
15
|
+
m = M.find('Naruto')
|
16
|
+
expect(m.first[:name]).to eq('Naruto')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should find a list of manga with the find command" do
|
20
|
+
m = M.find('Trigger')
|
21
|
+
expect(m.length).to be > 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should download a manga with the download command" do
|
25
|
+
puts Dir.pwd
|
26
|
+
chps = Dir.glob("#{Dir.pwd}/#{@manga.name}/*/")
|
27
|
+
expect(chps.length).to eq(3)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should cbz a manga with the cbz command" do
|
31
|
+
cbz_s = Dir.glob("#{Dir.pwd}/#{@manga.name}/*.cbz")
|
32
|
+
expect(cbz_s.length).to eq(3)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/mangdown/manga_spec.rb
CHANGED
@@ -1,77 +1,75 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
module Mangdown
|
4
|
-
@@m_uri = 'http://www.mangareader.net/94/bleach.html'
|
5
|
-
@@manga_name = 'Bleach'
|
6
|
-
|
7
|
-
manga = Manga.new( @@m_uri, @@manga_name )
|
8
|
-
|
9
|
-
MANGA_STUB_PATH = File.expand_path('../../objects/manga.yml', __FILE__)
|
10
|
-
File.open(MANGA_STUB_PATH, 'w+') do |file|
|
11
|
-
file.write(manga.to_yaml)
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
describe Manga do
|
16
|
-
before(:each) do
|
17
|
-
print '@'
|
18
|
-
@manga = YAML.load(File.open(Mangdown::MANGA_STUB_PATH, 'r').read)
|
19
|
-
@manga.get_doc(@@m_uri)
|
20
|
-
end
|
21
|
-
|
22
|
-
context "When a manga is initialized" do
|
23
|
-
it "should have chapters" do
|
24
|
-
expect(@manga.chapters).to be_empty
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should have chapters listed in chapters_list" do
|
28
|
-
expect(@manga.chapters_list).not_to be_empty
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with Bleach manga" do
|
33
|
-
it "should have more that 500 chapters" do
|
34
|
-
expect(@manga.chapters_list.length).to be > 500
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should have the right first chapter" do
|
38
|
-
expect(@manga.chapters_list.first).to eq([
|
39
|
-
'http://www.mangareader.net/94-8-1/bleach/chapter-1.html',
|
40
|
-
'Bleach 1'])
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should have the right 465th chapter" do
|
44
|
-
expect(@manga.chapters_list[464]).to eq([
|
45
|
-
'http://www.mangareader.net/bleach/465',
|
46
|
-
'Bleach 465'])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when a chapter is retrieved" do
|
51
|
-
before(:all) do
|
52
|
-
@manga2 = YAML.load(File.open(Mangdown::MANGA_STUB_PATH, 'r').read)
|
53
|
-
@manga2.get_chapter(0)
|
54
|
-
@mchapter = @manga2.chapters_list[0]
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should have a chapter in chapters" do
|
58
|
-
expect(@manga2.chapters.length).to eq(1)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should have chapter 1 in chapters" do
|
62
|
-
expect(@manga2.chapters[0].name).to eq(@mchapter[1])
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should have the right chapter sub class" do
|
66
|
-
klass = Chapter
|
67
|
-
if @mchapter[0].include?('mangareader')
|
68
|
-
klass = MRChapter
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
module Mangdown
|
4
|
+
@@m_uri = 'http://www.mangareader.net/94/bleach.html'
|
5
|
+
@@manga_name = 'Bleach'
|
6
|
+
|
7
|
+
manga = Manga.new( @@m_uri, @@manga_name )
|
8
|
+
|
9
|
+
MANGA_STUB_PATH = File.expand_path('../../objects/manga.yml', __FILE__)
|
10
|
+
File.open(MANGA_STUB_PATH, 'w+') do |file|
|
11
|
+
file.write(manga.to_yaml)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
describe Manga do
|
16
|
+
before(:each) do
|
17
|
+
print '@'
|
18
|
+
@manga = YAML.load(File.open(Mangdown::MANGA_STUB_PATH, 'r').read)
|
19
|
+
@manga.get_doc(@@m_uri)
|
20
|
+
end
|
21
|
+
|
22
|
+
context "When a manga is initialized" do
|
23
|
+
it "should have chapters" do
|
24
|
+
expect(@manga.chapters).to be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have chapters listed in chapters_list" do
|
28
|
+
expect(@manga.chapters_list).not_to be_empty
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with Bleach manga" do
|
33
|
+
it "should have more that 500 chapters" do
|
34
|
+
expect(@manga.chapters_list.length).to be > 500
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the right first chapter" do
|
38
|
+
expect(@manga.chapters_list.first).to eq([
|
39
|
+
'http://www.mangareader.net/94-8-1/bleach/chapter-1.html',
|
40
|
+
'Bleach 1'])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have the right 465th chapter" do
|
44
|
+
expect(@manga.chapters_list[464]).to eq([
|
45
|
+
'http://www.mangareader.net/bleach/465',
|
46
|
+
'Bleach 465'])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when a chapter is retrieved" do
|
51
|
+
before(:all) do
|
52
|
+
@manga2 = YAML.load(File.open(Mangdown::MANGA_STUB_PATH, 'r').read)
|
53
|
+
@manga2.get_chapter(0)
|
54
|
+
@mchapter = @manga2.chapters_list[0]
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should have a chapter in chapters" do
|
58
|
+
expect(@manga2.chapters.length).to eq(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should have chapter 1 in chapters" do
|
62
|
+
expect(@manga2.chapters[0].name).to eq(@mchapter[1])
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should have the right chapter sub class" do
|
66
|
+
klass = Chapter
|
67
|
+
if @mchapter[0].include?('mangareader')
|
68
|
+
klass = MRChapter
|
69
|
+
end
|
70
|
+
|
71
|
+
expect(@manga2.chapters[0].class).to eq(klass)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/spec/mangdown/page_spec.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Mangdown
|
4
|
-
describe Page do
|
5
|
-
before(:all) do
|
6
|
-
@dir = Dir.pwd
|
7
|
-
@uri = 'http://i25.mangareader.net/bleach/537/bleach-4149721.jpg'
|
8
|
-
@filename = "Bleach 537 - Page 1"
|
9
|
-
@page = Page.new( @uri, @filename )
|
10
|
-
@page.download
|
11
|
-
PAGE_STUB_PATH = File.expand_path('../../objects/page.yml', __FILE__)
|
12
|
-
File.open(PAGE_STUB_PATH, 'w+') do |file|
|
13
|
-
file.write(@page.to_yaml)
|
14
|
-
end
|
15
|
-
@page2 = YAML.load(File.open(PAGE_STUB_PATH, 'r').read)
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when page is downloaded" do
|
19
|
-
it "should download itself to the current directory" do
|
20
|
-
expect(Dir.glob(@dir + '/*')).to include(@dir + '/' + @page.filename)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when a page is compared with a page loaded from a .yml file" do
|
25
|
-
it "should compare with #eql?" do
|
26
|
-
expect(@page.eql?(@page2))
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should not compare with ==" do
|
30
|
-
expect(!@page == @page2)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mangdown
|
4
|
+
describe Page do
|
5
|
+
before(:all) do
|
6
|
+
@dir = Dir.pwd
|
7
|
+
@uri = 'http://i25.mangareader.net/bleach/537/bleach-4149721.jpg'
|
8
|
+
@filename = "Bleach 537 - Page 1"
|
9
|
+
@page = Page.new( @uri, @filename )
|
10
|
+
@page.download
|
11
|
+
PAGE_STUB_PATH = File.expand_path('../../objects/page.yml', __FILE__)
|
12
|
+
File.open(PAGE_STUB_PATH, 'w+') do |file|
|
13
|
+
file.write(@page.to_yaml)
|
14
|
+
end
|
15
|
+
@page2 = YAML.load(File.open(PAGE_STUB_PATH, 'r').read)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when page is downloaded" do
|
19
|
+
it "should download itself to the current directory" do
|
20
|
+
expect(Dir.glob(@dir + '/*')).to include(@dir + '/' + @page.filename)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when a page is compared with a page loaded from a .yml file" do
|
25
|
+
it "should compare with #eql?" do
|
26
|
+
expect(@page.eql?(@page2))
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not compare with ==" do
|
30
|
+
expect(!@page == @page2)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|