mangos 0.2 → 0.3

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
  SHA256:
3
- metadata.gz: e01364f1fa0fbcc49c64794424dd000d1bfd3a9ecb54a0f6470b36f322eb1616
4
- data.tar.gz: 7361915aa667121ba302fd474562705b94ffc4f9b9a3b5c45f4c2adc3632f5ae
3
+ metadata.gz: 56f79d3fe8221ed638d73e158b60c45bd18092993cb3117fd0fc83c2403ffd5e
4
+ data.tar.gz: 05e239fa6821f9a47cd345b8a8b1c045d853712bd41f7e6cb8f4ca93ce6915c0
5
5
  SHA512:
6
- metadata.gz: 7135a8d489d0de60927f502fa0f16e08306c5222184cbbba57fba71a3f9144af01f42d34fe6e13922a11b61a76496e2cade6f12546f4e828bc9433e99c8dcc43
7
- data.tar.gz: 4183dc1045304d17062833cfa6a40f5ad30fa3f9a49000e5a34fde5003047189813690c2d6862cd36b4a1d78ceede5251ae174c946fa69420fd3355b847696e9
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
@@ -1,5 +1,5 @@
1
1
  class Mangos::Book
2
- attr_accessor :path, :page_paths, :pages, :published_on, :key, :tags
2
+ attr_accessor :path, :page_paths, :pages, :published_on, :old_key, :key, :tags
3
3
 
4
4
  def from_hash(hash)
5
5
  @path = hash["path"]
@@ -10,13 +10,15 @@ class Mangos::BookUpdater
10
10
  def update
11
11
  page_paths = find_page_paths
12
12
 
13
- @book.key = Digest::SHA256.hexdigest(@path.to_s)[0..16]
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Mangos
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
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.2'
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: 2019-11-25 00:00:00.000000000 Z
11
+ date: 2021-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler