mangdown 0.13.4 → 0.14.0

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 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require 'stringio'
3
-
4
- describe M do
5
- before do
6
- VCR.insert_cassette 'events', record: :new_episodes
7
- end
8
-
9
- after do
10
- VCR.eject_cassette
11
- end
12
-
13
- describe 'find' do
14
- it 'must return an array of MDHash' do
15
- results = M.find('Naruto')
16
- results.each do |result|
17
- result.must_be_instance_of Mangdown::MDHash
18
- end
19
- end
20
-
21
- it 'must only accept good search terms' do
22
- bad = ['@#$$#', '........', '@#%@#$%^']
23
- good = ["666 Bats", "1 2 3", "Go! For! IT!"]
24
- bad.each { |term| -> { M.find(term) }.must_raise ArgumentError }
25
- good.each { |term| -> { M.find(term) }.must_be_silent }
26
- end
27
- end
28
-
29
- describe 'cbz' do
30
- # CBZ is tested in cbz_spec.rb
31
- it 'must fail if given a bad path' do
32
- path = "super_bad_path/that/cant/possibly/exist!!!"
33
- -> { M.cbz(path) }.must_raise Errno::ENOENT
34
- end
35
-
36
- it 'must not fail if given a good path' do
37
- # Before
38
- fixtures_dir = File.expand_path('../../../fixtures', __FILE__)
39
- tmp_dir = File.expand_path('../../../../tmp', __FILE__)
40
- nisekoi_dir = tmp_dir + "/Nisekoi"
41
- FileUtils.cp_r(fixtures_dir + '/Nisekoi', tmp_dir)
42
-
43
- -> { M.cbz(nisekoi_dir) }.must_be_silent
44
-
45
- # After
46
- FileUtils.rm_r(nisekoi_dir, force: true)
47
- end
48
- end
49
-
50
- describe 'help' do
51
- it "must output instructions for the command methods" do
52
- output = SpecHelper.stdout_for { M.help }
53
- output.length.wont_be :zero?
54
- ["M.help", "M.cbz", "M.clean_up"].each do |command|
55
- output.must_match /#{command}/
56
- end
57
- end
58
- end
59
-
60
- describe 'clean_up' do
61
- it "must delete the data file" do
62
- File.open(M::DATA_FILE_PATH, 'a') { |f| f.write("HELLO!") }
63
- M.clean_up
64
- File.exist?(M::DATA_FILE_PATH).must_equal false
65
- end
66
- end
67
- end
@@ -1,32 +0,0 @@
1
- require_relative '../../spec_helper.rb'
2
-
3
- describe Mangdown::Equality do
4
- before do
5
- VCR.insert_cassette 'events', record: :new_episodes
6
- end
7
-
8
- after do
9
- VCR.eject_cassette
10
- end
11
-
12
- describe 'eql?' do
13
- it 'should return true when two objects are symantically equal' do
14
- monster1 = M.find('monster').first
15
- monster2 = M.find('monster').first
16
- (monster1 == monster2).must_equal(true)
17
- end
18
-
19
- it 'should return false when two objects are symantically unequal' do
20
- monster1 = M.find('monster').first
21
- monster2 = M.find('20th century boys').first
22
- (monster1 == monster2).must_equal(false)
23
- end
24
-
25
- it 'should return true even if different classes' do
26
- monster1 = M.find('monster').first
27
- monster2 = monster1.to_manga
28
- (monster1 == monster2).must_equal(true)
29
- end
30
- end
31
- end
32
-
@@ -1,42 +0,0 @@
1
- require_relative '../../spec_helper.rb'
2
-
3
- describe Mangdown::MangaList do
4
- before do
5
- VCR.insert_cassette 'events', record: :new_episodes
6
- end
7
-
8
- after do
9
- VCR.eject_cassette
10
- end
11
-
12
- describe 'new' do
13
- let(:mangareader) {
14
- Mangdown::MangaList.new('http://www.mangareader.net/alphabetical')
15
- }
16
- let(:mangafox) {
17
- Mangdown::MangaList.new('http://mangafox.me/manga/')
18
- }
19
- let(:multiple) { Mangdown::MangaList.new(
20
- 'http://www.mangareader.net/alphabetical',
21
- 'http://mangafox.me/manga/'
22
- ) }
23
-
24
- it 'must have a manga list with mangas (as md hashes)' do
25
- [mangareader, mangafox].each do |type|
26
- type.mangas.must_be_instance_of Array
27
- type.mangas.each do |manga|
28
- manga.must_be_instance_of Mangdown::MDHash
29
- end
30
- end
31
- end
32
-
33
- it 'must raise an ArgumentError if given a bad url' do
34
- -> { Mangdown::MangaList.new('garbage-url.com/bogus') }
35
- .must_raise ArgumentError
36
- end
37
-
38
- it 'must return a manga list with mangas from all input urls' do
39
- multiple.mangas.length.must_be :>, (mangareader.mangas.length)
40
- end
41
- end
42
- end
@@ -1,61 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe Mangdown::Manga do
4
- let(:download_path) { File.expand_path('../../../../tmp', __FILE__) }
5
- let(:manga_name) { "Romance Dawn" }
6
- let(:uri) {
7
- "http://mangafox.me/manga/romance_dawn/"
8
- }
9
-
10
- before do
11
- VCR.insert_cassette 'events', record: :new_episodes
12
- @manga = Mangdown::Manga.new(manga_name, uri)
13
- end
14
-
15
- after do
16
- VCR.eject_cassette
17
- FileUtils.rm_r("#{download_path}/#{manga_name}", force: true)
18
- end
19
-
20
- describe 'new' do
21
- it 'must return a manga' do
22
- @manga.must_be_instance_of Mangdown::Manga
23
- end
24
-
25
- it 'must have chapters' do
26
- @manga.chapters.wont_be :empty?
27
- end
28
- end
29
-
30
- describe 'download' do
31
- it 'must download to default download dir' do
32
- @manga.download
33
-
34
- dir = Mangdown::DOWNLOAD_DIR + "/#{manga_name}"
35
- Dir.exist?(dir).must_equal true
36
- end
37
-
38
- it 'must download to the given dir' do
39
- dir = Mangdown::DOWNLOAD_DIR + '/random'
40
- FileUtils.rm_r(dir, force: true) if Dir.exist?(dir)
41
-
42
- Dir.mkdir(dir)
43
- @manga.download_to(dir)
44
-
45
- Dir.exist?(dir + "/#{manga_name}").must_equal true
46
-
47
- FileUtils.rm_r(dir, force: true)
48
- end
49
-
50
- it 'must download the right number of chapters' do
51
- manga = Mangdown::Manga
52
- .new('Gantz', 'http://www.mangareader.net/97/gantz.html')
53
- manga.download(50, 52)
54
-
55
- chapters = Dir[Mangdown::DOWNLOAD_DIR + '/Gantz/*/']
56
- chapters.length.must_equal 3
57
-
58
- FileUtils.rm_r(Mangdown::DOWNLOAD_DIR + '/Gantz', force: true)
59
- end
60
- end
61
- end
@@ -1,72 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe Mangdown::Manga do
4
- let(:m_name) { "Romance Dawn" }
5
- let(:m_uri) { "http://mangafox.me/manga/romance_dawn/" }
6
-
7
- let(:c_name) { "Onepunch-Man 1" }
8
- let(:c_uri) { "http://www.mangareader.net/onepunch-man/1" }
9
-
10
- let(:c2_name) { "Naruto 542" }
11
- let(:c2_uri) { "http://mangafox.me/manga/naruto/v57/c542/1.html" }
12
-
13
- let(:p_name) { "Hikaru No Go 1 - Page 1.jpg" }
14
- let(:p_uri) {
15
- "http://i1.mangareader.net/hikaru-no-go/1/hikaru-no-go-1894067.jpg"
16
- }
17
-
18
- before do
19
- VCR.insert_cassette 'events', record: :new_episodes
20
- @md_page = Mangdown::MDHash.new(uri: p_uri, name: p_name)
21
- @md_chapter = Mangdown::MDHash.new(uri: c_uri, name: c_name)
22
- @md_manga = Mangdown::MDHash.new(uri: m_uri, name: m_name)
23
- end
24
-
25
- after do
26
- VCR.eject_cassette
27
- end
28
-
29
- describe 'new' do
30
- it 'must return a manga' do
31
- [@md_page, @md_chapter, @md_manga].each do |type|
32
- type.must_be_instance_of Mangdown::MDHash
33
- end
34
- end
35
- end
36
-
37
- describe 'to_manga' do
38
- it 'must give a manga for a manga' do
39
- @md_manga.to_manga.must_be_instance_of Mangdown::Manga
40
- end
41
-
42
- it 'must raise an exception if not a manga' do
43
- [@md_chapter, @md_page].each do |type|
44
- Proc.new { type.to_manga }.must_raise NoMethodError
45
- end
46
- end
47
- end
48
-
49
- describe 'to_chapter' do
50
- it 'must give a chapter' do
51
- @md_chapter.to_chapter.must_be_instance_of Mangdown::Chapter
52
- end
53
-
54
- it 'must raise an exception if not a chapter' do
55
- [@md_page, @md_manga].each do |type|
56
- Proc.new { type.to_chapter }.must_raise NoMethodError
57
- end
58
- end
59
- end
60
-
61
- describe 'to_page' do
62
- it 'must give a page for a page' do
63
- @md_page.to_page.must_be_instance_of Mangdown::Page
64
- end
65
-
66
- it 'must raise an exception if not a page' do
67
- [@md_chapter, @md_manga].each do |type|
68
- Proc.new { type.to_page }.must_raise NoMethodError
69
- end
70
- end
71
- end
72
- end
@@ -1,59 +0,0 @@
1
- require_relative '../../spec_helper.rb'
2
-
3
- describe Mangdown::Page do
4
- before do
5
- VCR.insert_cassette 'events', record: :new_episodes
6
- end
7
-
8
- after do
9
- VCR.eject_cassette
10
- end
11
-
12
- describe 'new' do
13
- let(:download_path) {File.expand_path('../../../../tmp', __FILE__)}
14
- let(:mangareader) {
15
- Mangdown::Page.new(
16
- "Naruto 1 - Page 1.jpg",
17
- "http://i19.mangareader.net/naruto/1/naruto-1564773.jpg"
18
- )
19
- }
20
- let(:mangafox) {
21
- Mangdown::Page.new(
22
- "i001.jpg",
23
- "http://a.mfcdn.net/store/manga/10807/000.0/compressed/i001.jpg"
24
- )
25
- }
26
- let(:mangafox2) {
27
- Mangdown::Page.new(
28
- "naruto_pilot_manga.naruto_pilot_01.jpg",
29
- "http://a.mfcdn.net/store/manga/8/01-000.0/compressed/naruto_pilot_manga.naruto_pilot_01.jpg"
30
- )
31
- }
32
-
33
- =begin
34
- it 'must have a valid name' do
35
- [mangareader, mangafox, mangafox2].each do |type|
36
- type.name.must_match(/\d{3}$/)
37
- end
38
- end
39
- =end
40
-
41
- it 'must download image to dir' do
42
- [mangareader, mangafox, mangafox2].each do |type|
43
- type.download_to(download_path)
44
- path = "#{download_path}/#{type.name}.jpeg"
45
- exists = File.exist?(path)
46
- exists.must_equal true
47
- File.delete(path) if exists
48
- end
49
- end
50
-
51
- it 'must sort pages by name' do
52
- pages = [mangareader, mangafox, mangafox2] * 20
53
- sorted = pages.shuffle.sort
54
- sort_by_name = pages.shuffle.sort_by(&:name)
55
-
56
- sorted.must_equal sort_by_name
57
- end
58
- end
59
- end
@@ -1,21 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe Mangdown::Properties do
4
- let(:mangareader) {
5
- Mangdown::Properties.new('http://www.mangareader.net/101/akira.html')
6
- }
7
- let(:mangafox) {
8
- Mangdown::Properties.new('"http://mangafox.me/manga/ashita_no_joe/')
9
- }
10
- let(:mangapanda) {
11
- Mangdown::Properties.new('http://www.mangapanda.com/fairy-tail/424')
12
- }
13
-
14
- describe 'new' do
15
- it 'must give the right info' do
16
- mangareader.type.must_equal(:mangareader)
17
- mangapanda.type.must_equal( :mangapanda)
18
- mangafox.type.must_equal( :mangafox)
19
- end
20
- end
21
- end
@@ -1,41 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe Mangdown::Tools do
4
- let(:m_uri) { "http://mangafox.me/manga/romance_dawn/" }
5
-
6
- let(:c_uri) { "http://www.mangareader.net/onepunch-man/1" }
7
-
8
- let(:c2_uri) { "http://mangafox.me/manga/naruto/v57/c542/1.html" }
9
-
10
- let(:p_uri) {
11
- "http://i1.mangareader.net/hikaru-no-go/1/hikaru-no-go-1894067.jpg"
12
- }
13
-
14
- before do
15
- VCR.insert_cassette 'events', record: :new_episodes
16
- end
17
-
18
- after do
19
- VCR.eject_cassette
20
- end
21
-
22
- describe 'get_doc' do
23
- it 'must return a Nokogiri Document' do
24
- Mangdown::Tools.get_doc(m_uri)
25
- .must_be_instance_of(Nokogiri::HTML::Document)
26
- end
27
- end
28
-
29
- describe 'get_root' do
30
- it 'must return the protocol and host of the uri' do
31
- Mangdown::Tools.get_root(m_uri)
32
- .must_equal('http://mangafox.me')
33
- Mangdown::Tools.get_root(c_uri)
34
- .must_equal('http://www.mangareader.net')
35
- Mangdown::Tools.get_root(c2_uri)
36
- .must_equal('http://mangafox.me')
37
- Mangdown::Tools.get_root(p_uri)
38
- .must_equal('http://i1.mangareader.net')
39
- end
40
- end
41
- end
@@ -1,22 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe Mangdown::Uri do
4
- let(:m_uri) { "http://mangafox.me/manga/romance_dawn/" }
5
-
6
- let(:c_uri) { "http://www.mangareader.net/onepunch-man/1" }
7
-
8
- let(:c2_uri) { "http://mangafox.me/manga/naruto/v57/c542/1.html" }
9
-
10
- let(:p_uri) {
11
- "http://i1.mangareader.net/hikaru-no-go/1/hikaru-no-go-1894067.jpg"
12
- }
13
-
14
- describe 'get_doc' do
15
- it 'must return a String object' do
16
- Mangdown::Uri.new(m_uri).must_be_instance_of(String)
17
- end
18
-
19
- it 'must return a properly encoded uri' do
20
- end
21
- end
22
- end
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require_relative '../lib/mangdown'
2
-
3
- require 'minitest/autorun'
4
- require 'webmock/minitest'
5
- require 'vcr'
6
- require 'fileutils'
7
-
8
- VCR.configure do |c|
9
- c.cassette_library_dir = 'spec/fixtures/cpo_cassettes'
10
- c.hook_into :webmock
11
- end
12
-
13
- module SpecHelper
14
- extend self
15
- def stdout_for
16
- out, temp = StringIO.new, $stdout
17
- $stdout = out
18
- yield
19
- out, $stdout = $stdout, temp
20
- out.rewind and out.read
21
- end
22
- end