comics_packager 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e21d529349f0d69d23c7ecbcf3e51120911e00c7
4
+ data.tar.gz: 34abe8aba766ea37541f27da42a964dcf2bae8f4
5
+ SHA512:
6
+ metadata.gz: df212fac4e93c39f9e27d3e64ddd86492b2f4b3ba50762f15ff8527d68c39e08af17287932788e1352ec8e51cfcf4450484ad49c5a4b1dac362d97b28b354d45
7
+ data.tar.gz: a61e987151d1923c2022d0ff008d5fa3da2f8a17d5d2dcf9b27d4e59d4f7ab908d5d86cd476c79cc42a31553231a75c661bfb68f9034f3c3731ccbeb1881d893
@@ -0,0 +1,56 @@
1
+ require "webcomics"
2
+ require_relative "version"
3
+ require_relative "comics_packager_zip"
4
+ require_relative "comics_packager_directory"
5
+
6
+ ANSI_DEFAULT = "\033[0;0m"
7
+ ANSI_RED = "\033[1;31m" # ARGV[0] color
8
+ ANSI_GREEN = "\033[1;32m" # ARGV[1] color
9
+ ANSI_BLUE = "\033[1;34m" # ARGV[2] color
10
+ ANSI_MAGENTA = "\033[1;35m" # ARGV[3] color
11
+ ANSI_CYAN = "\033[1;36m" # ARGV[4] color
12
+
13
+ case ARGV[0]
14
+ when "version"
15
+ puts "Version: #{ANSI_GREEN}#{ComicsPackager::VERSION}#{ANSI_DEFAULT}"
16
+ when "package_cbz"
17
+ if ARGV[1] == "help"
18
+ puts "#{ANSI_CYAN}Useage: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}package_cbz#{ANSI_DEFAULT} #{ANSI_GREEN}[path_to_files_to_zip]#{ANSI_DEFAULT} #{ANSI_BLUE}[input_filenames]#{ANSI_DEFAULT} #{ANSI_MAGENTA}[path_to_output_cbz]#{ANSI_DEFAULT}"
19
+ puts "#{ANSI_CYAN}Example: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}package_cbz#{ANSI_DEFAULT} #{ANSI_GREEN}'./spec/comics tests/mac_the_comic'#{ANSI_DEFAULT} #{ANSI_BLUE}'Story1/001.jpg Story1/002.jpg'#{ANSI_DEFAULT} #{ANSI_MAGENTA}./mac_the_comic_new#{ANSI_DEFAULT}"
20
+ else
21
+ package_comics_to_cbz(ARGV[1], ARGV[2].split, ARGV[3])
22
+ end
23
+ when "list_pages"
24
+ if ARGV[1] == "help"
25
+ puts "#{ANSI_CYAN}Useage: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}list_pages#{ANSI_DEFAULT} #{ANSI_GREEN}[path_to_images]#{ANSI_DEFAULT}"
26
+ puts "#{ANSI_CYAN}Example: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}list_pages#{ANSI_DEFAULT} #{ANSI_GREEN}'./spec/comics tests/mac_the_comic'#{ANSI_DEFAULT}"
27
+ else
28
+ return_an_array_of_images("cbz", ARGV[1]).each {|images| puts "#{ANSI_GREEN}#{images}#{ANSI_DEFAULT}"}
29
+ end
30
+ when "extract_all"
31
+ if ARGV[1] == "help"
32
+ puts "#{ANSI_CYAN}Useage: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}extract_all#{ANSI_DEFAULT} #{ANSI_GREEN}[source_cbz_file]#{ANSI_DEFAULT} #{ANSI_BLUE}[destination_folder]#{ANSI_DEFAULT}"
33
+ puts "#{ANSI_CYAN}Example: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}extract_all#{ANSI_DEFAULT} #{ANSI_GREEN}'./spec/comics tests/mac_the_comic'#{ANSI_DEFAULT} #{ANSI_BLUE}./mac_the_comic_new#{ANSI_DEFAULT}"
34
+ else
35
+ extract_entries_from_cbz(ARGV[1], ARGV[2])
36
+ end
37
+ =begin
38
+ # Will improve this functionlity in a future version.
39
+ when "extract"
40
+ if ARGV[1] == "help"
41
+ STDOUT.puts "Useage: comics_packager.rb #{ANSI_RED}extract#{ANSI_DEFAULT} #{ANSI_GREEN}[source_cbz_file]#{ANSI_DEFAULT} #{ANSI_BLUE}[file_to_extract]#{ANSI_DEFAULT} #{ANSI_MAGENTA}[destination_folder]#{ANSI_DEFAULT}"
42
+ STDOUT.puts "Example: comics_packager.rb #{ANSI_RED}extract#{ANSI_DEFAULT} #{ANSI_GREEN}'./spec/comics tests/mac_the_comic'#{ANSI_DEFAULT} #{ANSI_MAGENTA}./mac_the_comic_new#{ANSI_DEFAULT}"
43
+ else
44
+ Dir.mkdir(ARGV[3])
45
+ extract_file(ARGV[1], ARGV[2], ARGV[4])
46
+ end
47
+ =end
48
+ when "help"
49
+ puts "#{ANSI_CYAN}Useage: comics_packager.rb(or comics_packager.exe on Windows)#{ANSI_DEFAULT} #{ANSI_RED}[option]#{ANSI_DEFAULT}"
50
+ puts "#{ANSI_GREEN}help#{ANSI_DEFAULT} #{ANSI_CYAN}- Prints help.#{ANSI_DEFAULT}"
51
+ puts "#{ANSI_GREEN}version#{ANSI_DEFAULT} #{ANSI_CYAN}- Prints version number.#{ANSI_DEFAULT}"
52
+ puts "#{ANSI_GREEN}package_cbz#{ANSI_DEFAULT} #{ANSI_CYAN}- Packages comics by taking everything in a specified directory and packaging them into a nice .cbz file for distribution."
53
+ puts "#{ANSI_GREEN}list_pages#{ANSI_DEFAULT} #{ANSI_CYAN}- Prints a list of pages from the .cbz.#{ANSI_DEFAULT}"
54
+ puts "#{ANSI_GREEN}extract_all#{ANSI_DEFAULT} #{ANSI_CYAN}- Extract all entries from a given .cbz.#{ANSI_DEFAULT}"
55
+ end
56
+
@@ -0,0 +1,14 @@
1
+ require "fileutils"
2
+
3
+ def return_all_comics_entries(directory)
4
+ Dir.entries(directory)
5
+ end
6
+
7
+ def return_an_array_of_images(is_path_to_series_or_path_to_cbz, path_to_images = "")
8
+ case is_path_to_series_or_path_to_cbz
9
+ when "series"
10
+ return_an_array_of_pages(path_to_images)
11
+ when "cbz"
12
+ return_an_array_of_pages("", "#{path_to_images}.cbz")
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require "zip"
2
+
3
+ def extract_entries_from_cbz(source_cbz_file, destination_folder, &block)
4
+ Zip::File.open("#{source_cbz_file}.cbz") do |cbz_file|
5
+ cbz_file.each do |entry|
6
+ entry.extract("#{destination_folder}/#{entry.name}")
7
+ yield entry.name if block_given?
8
+ end
9
+ end
10
+ end
11
+
12
+ def extract_file(source_cbz_file, file_to_extract, destination_folder)
13
+ Zip::File.open("#{source_cbz_file}.cbz") do |cbz|
14
+ cbz.extract(file_to_extract, destination_folder)
15
+ end
16
+ end
17
+
18
+ def package_comics(path_to_files_to_package, input_filenames, path_to_output_package, file_extension_name, &block)
19
+ Zip::File.open("#{path_to_output_package}.#{file_extension_name}", Zip::File::CREATE) do |package|
20
+ input_filenames.each do |filename|
21
+ package.add(filename, path_to_files_to_package + '/' + filename)
22
+ yield filename if block_given?
23
+ end
24
+ end
25
+ end
26
+
27
+ def package_comics_to_cbz(path_to_files_to_zip, input_filenames, path_to_output_cbz)
28
+ package_comics(path_to_files_to_zip, input_filenames, path_to_output_cbz, "cbz")
29
+ end
30
+
31
+ def package_comics_to_zip(path_to_files_to_zip, input_filenames, path_to_output_zip)
32
+ package_comics(path_to_files_to_zip, input_filenames, path_to_output_zip, "zip")
33
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module ComicsPackager
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: comics_packager
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ralph Desir
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '10.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '10.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubyzip
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ocra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.3.6
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.3'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.3.6
75
+ - !ruby/object:Gem::Dependency
76
+ name: webcomics
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubyzip
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.1'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.1'
103
+ - !ruby/object:Gem::Dependency
104
+ name: webcomics
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.1'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.1'
117
+ description: Is a gem for packaging digital comic books.
118
+ email: battleroundscool@gmail.com
119
+ executables: []
120
+ extensions: []
121
+ extra_rdoc_files: []
122
+ files:
123
+ - lib/comics_packager.rb
124
+ - lib/comics_packager_directory.rb
125
+ - lib/comics_packager_zip.rb
126
+ - lib/version.rb
127
+ homepage: https://github.com/Mav7/Ruby-WebComics
128
+ licenses:
129
+ - GPL-2.0
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.5.1
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Is a tool for packaging digital comic books.
151
+ test_files: []