webcomics 2.0.0 → 3.0.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
2
  SHA1:
3
- metadata.gz: 11be2f1bf77430adeeb2337a11c6565e7d79870e
4
- data.tar.gz: 8edc81b3e7dfc4f1f68eb3f6d23d86865cb729b2
3
+ metadata.gz: 1e08bd5d61d611d1fb5a27b2ed3698604a3b29e4
4
+ data.tar.gz: 46488c2940ebae2ac65a514f063724f8e7019aa1
5
5
  SHA512:
6
- metadata.gz: 31639426e3e3f23a1c216b767d9601c072b0ce31ee4754a8758a177e89681101ff3648453eab282c35a1b88060bbec8c3ef280987944596a6502de02a2685db1
7
- data.tar.gz: e09b118256042f9d745cb10731c1c8b977212355a4c1aaf5b8305d9d639447c3886457a83888f036a2405d607779746dbbf9803565d79b371a9109240ccc06e5
6
+ metadata.gz: 09bbfc667d2d48570f6d2ecd5672eca394402f2ec8280ac6eb52bcc3bbd51763232b0809e68ca2c9e8d02dabd16fd398ec4f9d77c7d86eaf96da733928c743a0
7
+ data.tar.gz: 91cdcf6f7db27207995aa61b92fc7951beb4cd7921d9c85b34a0684297d9fefd4586fd8e0f325feb95907879cf76b9887dfd888e2bb1f077daad4e32c7897340
data/lib/comics_canvas.rb CHANGED
@@ -1,3 +1,15 @@
1
+ def length_of_the_comic(series_path)
2
+ return_an_array_of_comics_entries(series_path).length
3
+ end
4
+
5
+ def page_equalizer(page, series_path)
6
+ if page < 0
7
+ return $page_number = length_of_the_comic(series_path) - 1
8
+ elsif page >= length_of_the_comic(series_path)
9
+ return $page_number = 0
10
+ end
11
+ end
12
+ =begin
1
13
  module WebComics
2
14
  module ComicsCanvas
3
15
  def self.num_of_pages(series)
@@ -24,4 +36,5 @@ module WebComics
24
36
  end
25
37
  end
26
38
 
27
- end
39
+ end
40
+ =end
data/lib/comics_cbz.rb CHANGED
@@ -1,5 +1,52 @@
1
1
  require 'zip'
2
2
 
3
+ def is_this_file_a_cbz_or_zip?(file)
4
+ if File.extname(file) == ".cbz" || File.extname(file) == ".zip"
5
+ return true
6
+ else
7
+ return false
8
+ end
9
+ end
10
+
11
+ def list_cbz_files(series_path)
12
+ files_array = []
13
+ return_an_array_of_files(series_path).each do |file|
14
+ files_array.push(file) if is_this_file_a_cbz_or_zip?(file)
15
+ end
16
+
17
+ files_array
18
+ end
19
+
20
+ def list_pages_inside_a_cbz(path_to_cbz, xml_ignore = true)
21
+ files_array = []
22
+ Zip::File.open(path_to_cbz) do |file|
23
+ file.each do |pages|
24
+ files_array.push(pages.name)
25
+ end
26
+ end
27
+
28
+ return ignore_xml(files_array) if xml_ignore
29
+
30
+ files_array
31
+ end
32
+
33
+ def extract(path_to_cbz, index = 0)
34
+ Zip::File.open(path_to_cbz) do |cbz|
35
+ @page = cbz.extract(list_pages_inside_a_cbz(path_to_cbz)[index], list_pages_inside_a_cbz(path_to_cbz)[index])
36
+ end
37
+
38
+ @page
39
+ end
40
+
41
+ def ignore_xml(array)
42
+ files_array = []
43
+ array.each do |entry|
44
+ files_array.push(entry) if File.extname(entry) != ".xml"
45
+ end
46
+
47
+ files_array
48
+ end
49
+ =begin
3
50
  module WebComics
4
51
  class CBZ < ComicsDir
5
52
  attr_accessor :cbz
@@ -52,4 +99,5 @@ module WebComics
52
99
  files_list
53
100
  end
54
101
  end
55
- end
102
+ end
103
+ =end
data/lib/comics_db.rb CHANGED
@@ -1,3 +1,16 @@
1
+ def is_there_a_db_field_value_that_matches_an_asset?(field_value, assets_path)
2
+ field_values_array = []
3
+
4
+ Dir.entries(assets_path).each do |assets|
5
+ field_values_array.push(assets) if assets == field_value
6
+ end
7
+
8
+ !field_values_array.empty?
9
+ end
10
+
11
+ alias :is_there_a_db_field_value_that_matches_an_series? :is_there_a_db_field_value_that_matches_an_asset?
12
+ alias :db_assets_match? :is_there_a_db_field_value_that_matches_an_asset?
13
+ =begin
1
14
  module WebComics
2
15
  class ComicsDB
3
16
  attr_accessor :db_record
@@ -13,4 +26,5 @@ module WebComics
13
26
  !asset_names.empty?
14
27
  end
15
28
  end
16
- end
29
+ end
30
+ =end
data/lib/comics_dir.rb CHANGED
@@ -1,3 +1,75 @@
1
+
2
+ def return_an_array_of_comics_entries(directory)
3
+ entries = Dir.entries(directory)
4
+ entries.delete(".")
5
+ entries.delete("..")
6
+
7
+ entries
8
+ end
9
+
10
+ def return_comics_entries_without_file_extentions(array)
11
+ entries_array = []
12
+ array.each do |entry|
13
+ entries_array.push(File.basename(entry, ".*"))
14
+ end
15
+
16
+ entries_array
17
+ end
18
+
19
+ def is_this_series_path_a_directory?(series_path)
20
+ File.directory?(series_path)
21
+ end
22
+
23
+ def return_an_array_of_directories(series_path)
24
+ directory_array = []
25
+ return_an_array_of_comics_entries(series_path).each do |entry|
26
+ directory_array.push(entry) if is_this_series_path_a_directory?("#{series_path}/#{entry}")
27
+ end
28
+
29
+ directory_array
30
+ end
31
+
32
+ def is_this_series_path_a_file?(series_path)
33
+ File.file?(series_path)
34
+ end
35
+
36
+ def return_an_array_of_files(series_path)
37
+ files_array = []
38
+ return_an_array_of_comics_entries(series_path).each do |entry|
39
+ files_array.push(entry) if is_this_series_path_a_file?("#{series_path}/#{entry}")
40
+ end
41
+
42
+ files_array
43
+ end
44
+
45
+ def return_an_array_of_alpha_directories(series_path)
46
+ alpha_directories_array = []
47
+ return_an_array_of_directories(series_path).each do |entry|
48
+ alpha_directories_array.push(entry) if entry =~ /[a-z]/ || entry =~ /[A-Z]/
49
+ alpha_directories_array.delete_if { |entry| entry =~ /[0-9]/ }
50
+ end
51
+
52
+ alpha_directories_array
53
+ end
54
+
55
+ def return_an_array_of_numeric_directories(series_path)
56
+ numeric_directories_array = []
57
+ return_an_array_of_directories(series_path).each do |entry|
58
+ numeric_directories_array.push(entry) if entry =~ /[0-9]/
59
+ numeric_directories_array.delete_if { |entry| entry =~ /[a-z]/ || entry =~ /[A-Z]/ }
60
+ end
61
+
62
+ numeric_directories_array
63
+ end
64
+
65
+ alias :return_an_array_of_chapters :return_an_array_of_directories
66
+ alias :is_this_series_path_a_chapter? :is_this_series_path_a_directory?
67
+ alias :is_this_series_path_a_page? :is_this_series_path_a_file?
68
+ alias :return_an_array_of_comics_pages :return_an_array_of_files
69
+ alias :return_an_array_of_alpha_chapters :return_an_array_of_alpha_directories
70
+ alias :return_an_array_of_numeric_chapters :return_an_array_of_numeric_directories
71
+
72
+ =begin
1
73
  module WebComics
2
74
  class ComicsDir
3
75
  attr_accessor :series
@@ -74,4 +146,5 @@ module WebComics
74
146
  num_dirs
75
147
  end
76
148
  end
77
- end
149
+ end
150
+ =end
@@ -1,3 +1,17 @@
1
+ def return_page(series_path, page = 0)
2
+ list_pages(series_path)[page]
3
+ end
4
+
5
+ def does_this_directory_have_directories?(series_path)
6
+ if return_series_assets_directories(series_path).empty?
7
+ return false
8
+ else
9
+ return true
10
+ end
11
+ end
12
+
13
+ alias :does_this_series_have_chapters? :does_this_directory_have_directories?
14
+ =begin
1
15
  module WebComics
2
16
  module ComicsDirectoriesHelper
3
17
  def self.db_assets_match?(db_record, assets_path)
@@ -27,4 +41,5 @@ module WebComics
27
41
  end
28
42
 
29
43
  end
30
- end
44
+ end
45
+ =end
data/lib/comics_engine.rb CHANGED
@@ -1,5 +1,36 @@
1
1
  require "fileutils"
2
2
 
3
+ COMMON_COMIC_FILE_EXT_ARRY = [".jpg", ".png", ".tiff", ".bmp", ".gif"]
4
+
5
+ def return_an_array_of_entries_without_image_files(array)
6
+ array.each_index do |entry_level1|
7
+ array.delete_if { |entry_level2| entry_level2.include?(COMMON_COMIC_FILE_EXT_ARRY[entry_level1])}
8
+ end
9
+ end
10
+
11
+ def return_series_assets_directories(series_path)
12
+ return_an_array_of_entries_without_image_files(return_an_array_of_comics_entries(series_path))
13
+ end
14
+
15
+ def list_pages_from_cbz(path_to_cbz)
16
+ list_pages_inside_a_cbz(path_to_cbz).sort
17
+ end
18
+
19
+ def list_pages(series_path = "", path_to_cbz = "")
20
+ if is_this_file_a_cbz_or_zip?(path_to_cbz)
21
+ list_pages_from_cbz(path_to_cbz)
22
+ else
23
+ image_array = []
24
+ FileUtils.cd(series_path) do
25
+ return_an_array_of_comics_entries(".").each do |entry|
26
+ image_array.push(entry) if File.extname(entry) == ".jpg" || File.extname(entry) == ".png" || File.extname(entry) == ".bmp"
27
+ end
28
+ end
29
+
30
+ image_array.sort
31
+ end
32
+ end
33
+ =begin
3
34
  module WebComics
4
35
  class ComicsEngine < CBZ
5
36
  FILE_EXT_ARRY = [".jpg", ".png", ".tiff", ".bmp", ".gif"]
@@ -34,4 +65,5 @@ module WebComics
34
65
  end
35
66
 
36
67
  end
37
- end
68
+ end
69
+ =end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WebComics
2
- VERSION = "2.0.0"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webcomics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralph Desir
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-20 00:00:00.000000000 Z
12
+ date: 2016-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -106,4 +106,3 @@ signing_key:
106
106
  specification_version: 4
107
107
  summary: Ruby Web comics library
108
108
  test_files: []
109
- has_rdoc: