mangos 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mangos +1 -0
- data/lib/mangos/book.rb +1 -1
- data/lib/mangos/book_updater.rb +10 -1
- data/lib/mangos/package.rb +8 -0
- data/lib/mangos/update.rb +6 -0
- data/lib/mangos/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56f79d3fe8221ed638d73e158b60c45bd18092993cb3117fd0fc83c2403ffd5e
|
4
|
+
data.tar.gz: 05e239fa6821f9a47cd345b8a8b1c045d853712bd41f7e6cb8f4ca93ce6915c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fa3467468280687b46ee14b86f78c4cdb4949760d862b4b67a0454195225986f6677edcbe7ac1ec038cbde3b7bf4e4a2abb3350e243c62c01faee944c7693e7
|
7
|
+
data.tar.gz: 3bde1bfee0cf1e539d390623032fcc45ff6eee3682dc483e931a2f0044b2c10c9d926522c66218920e7834c04a3f07be8b73f7834b4cd8b98e5279a2d14b5819
|
data/bin/mangos
CHANGED
@@ -8,6 +8,7 @@ OptionParser.new do |opts|
|
|
8
8
|
opts.banner = "Usage: #{File.basename(__FILE__)} [options] [manga package directory root]"
|
9
9
|
|
10
10
|
opts.on("-f", "--force", "Process all books in the package, even ones that seem up to date")
|
11
|
+
opts.on("-m", "--migrate", "Migrate package that incorrectly used the full pathnames to generate the book keys")
|
11
12
|
|
12
13
|
opts.on("-h", "--help", "Prints this help") do
|
13
14
|
puts opts
|
data/lib/mangos/book.rb
CHANGED
data/lib/mangos/book_updater.rb
CHANGED
@@ -10,13 +10,15 @@ class Mangos::BookUpdater
|
|
10
10
|
def update
|
11
11
|
page_paths = find_page_paths
|
12
12
|
|
13
|
-
@book.
|
13
|
+
@book.old_key = @book.key
|
14
|
+
@book.key = Digest::SHA256.hexdigest(@path.basename.to_s)[0..16]
|
14
15
|
@book.page_paths = build_page_paths(page_paths)
|
15
16
|
@book.pages = page_paths.length
|
16
17
|
@book.path = @path.basename.to_s
|
17
18
|
@book.published_on = @path.mtime.to_i
|
18
19
|
@book.tags = Mangos::TagBreaker.new(@book.path).tags
|
19
20
|
|
21
|
+
fix_thumbnail_path if @package.migrate?
|
20
22
|
Mangos::Thumbnailer.new(page_paths.first, thumbnail_path).generate
|
21
23
|
end
|
22
24
|
|
@@ -32,4 +34,11 @@ class Mangos::BookUpdater
|
|
32
34
|
def thumbnail_path
|
33
35
|
@package.thumbnails_path + "#{@book.key}.jpg"
|
34
36
|
end
|
37
|
+
|
38
|
+
def fix_thumbnail_path
|
39
|
+
old_thumbnail_path = @package.thumbnails_path + "#{@book.old_key}.jpg"
|
40
|
+
if old_thumbnail_path.exist? && !thumbnail_path.exist?
|
41
|
+
old_thumbnail_path.rename(thumbnail_path)
|
42
|
+
end
|
43
|
+
end
|
35
44
|
end
|
data/lib/mangos/package.rb
CHANGED
@@ -23,6 +23,10 @@ class Mangos::Package
|
|
23
23
|
app_path + "data.json"
|
24
24
|
end
|
25
25
|
|
26
|
+
def key_mapping_path
|
27
|
+
app_path + "key_mapping.json"
|
28
|
+
end
|
29
|
+
|
26
30
|
def thumbnails_path
|
27
31
|
app_path + "img/thumbnails/"
|
28
32
|
end
|
@@ -30,4 +34,8 @@ class Mangos::Package
|
|
30
34
|
def force?
|
31
35
|
@options[:force]
|
32
36
|
end
|
37
|
+
|
38
|
+
def migrate?
|
39
|
+
@options[:migrate]
|
40
|
+
end
|
33
41
|
end
|
data/lib/mangos/update.rb
CHANGED
@@ -12,6 +12,7 @@ class Mangos::Update
|
|
12
12
|
load_data
|
13
13
|
process
|
14
14
|
save_data
|
15
|
+
save_key_mapping if @package.migrate?
|
15
16
|
puts "Done!"
|
16
17
|
end
|
17
18
|
|
@@ -27,6 +28,11 @@ class Mangos::Update
|
|
27
28
|
@package.data_path.write(@books.map { |b| b.to_hash }.to_json)
|
28
29
|
end
|
29
30
|
|
31
|
+
def save_key_mapping
|
32
|
+
puts "Writing out key mapping JSON file"
|
33
|
+
@package.key_mapping_path.write(@books.to_h { |b| [b.old_key, b.key] }.to_json)
|
34
|
+
end
|
35
|
+
|
30
36
|
def process
|
31
37
|
puts "Processing books...\n"
|
32
38
|
|
data/lib/mangos/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mangos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brenton "B-Train" Fletcher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|