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,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
- @@fc_uri = 'http://www.fakku.net/doujinshi/pipiruma-extra-edition-dokidoki-summer-vacation/read#page=1'
16
- @@fc_chapter_name = 'Pipiruma! Extra Edition -DokiDoki Summer Vacation-'
17
- @@fc_num_pages = 26
18
-
19
- f_chapter = FKChapter.new( @@fc_uri, @@fc_chapter_name, @@fc_num_pages)
20
- f_chapter.download
21
-
22
- FC_STUB_PATH = File.expand_path('../../objects/f_chapter.yml', __FILE__)
23
- File.open(FC_STUB_PATH, 'w+') do |file|
24
- file.write(f_chapter.to_yaml)
25
- end
26
-
27
- describe MRChapter do
28
- before(:each) do
29
- print 'o'
30
- @chapter = YAML.load(File.open(Mangdown::STUB_PATH, 'r').read)
31
- @chapter.get_doc(@@uri)
32
- end
33
-
34
- context "when chapter is initialized" do
35
- it "should have the right chapter uri" do
36
- expect(@chapter.uri).to eq(@@uri)
37
- end
38
-
39
- it "should get pages when initialized" do
40
- expect(@chapter.pages.size).to be > 0
41
- end
42
-
43
- it "should have the first page at the 0 index" do
44
- expect(@chapter.pages.first.filename).to eq('Bleach 537 - Page 1.jpg')
45
- end
46
-
47
- it "should have the last page at the -1 index" do
48
- expect(@chapter.pages.last.filename).to eq('Bleach 537 - Page 21.jpg')
49
- end
50
- end
51
-
52
- context "when the functions for get_pages are run" do
53
- it "should have the right chapter uri" do
54
- expect(@chapter.uri).to eq(@@uri)
55
- end
56
-
57
- # Probably can get rid of this, not using chapter_mark for functionality
58
- # xit "should get the right chapter mark from a uri" do
59
- # expect(@chapter.get_chapter_mark).to eq('Bleach 537')
60
- # end
61
-
62
- it "should get the right image link and filename from a uri" do
63
- expect(@chapter.get_page).to eq(
64
- ['http://i25.mangareader.net/bleach/537/bleach-4149721.jpg',
65
- 'Bleach 537 - Page 1'])
66
- end
67
-
68
- it "should get the right root from uri" do
69
- expect(@chapter.get_root(@@uri)).to eq('http://www.mangareader.net')
70
- end
71
-
72
- it "should get the right link to the next page from a uri" do
73
- expect(@chapter.get_next_uri).to eq(
74
- 'http://www.mangareader.net/bleach/537/2')
75
- end
76
-
77
- it "should evaluate the expression to stop get_pages" do
78
- next_chapter_uri = 'http://www.mangareader.net/bleach/538'
79
- expect(@chapter.get_doc(next_chapter_uri)).not_to eq(@chapter.name)
80
- end
81
- end
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.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
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
@@ -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
- elsif @mchapter[0].include?('fakku')
70
- klass = FKChapter
71
- end
72
-
73
- expect(@manga2.chapters[0].class).to eq(klass)
74
- end
75
- end
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
@@ -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