mangdown 0.16.0 → 0.16.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 238181d8ba1817789cb0a1dc8a69a3dafd6cf811
4
- data.tar.gz: 26f7195a357234d613f65ebb98779d2643ccf0f7
3
+ metadata.gz: 322812e01eff29a30192673634873fcd286770c3
4
+ data.tar.gz: 97d4cc14476ec3a43d0ba11af6e9c541b65f3d63
5
5
  SHA512:
6
- metadata.gz: 7df1eb96cd3eb36838ae7b2551a3ccd54dc7a17fb9ab4925ecc4f3989cd5fa0b9f1d5579ec0c819eb42ddd419916524ec67007a2ad6c15c6eeca565adf96bdf4
7
- data.tar.gz: 7ff2cd14861ac3bce9b72f06050cc679cd8638bcb630af5096b14c35c1f86f40e031149f6db3529d4ea96989ad7503b968785276e28706c48447e67e102e9997
6
+ metadata.gz: 8697dd6bd034b1634494ae62dae674271d8864cdefb2b905c3dd7ffc901a604bb3e5593c90a0a2a1ce4fcc5e2e2bb3c66f042a555d8a249c84bba5d6fdd927e4
7
+ data.tar.gz: bd1051ea8ea0e0974157b48d4f249fdc37fc34dfa9137ce0531be7d003ddd4dc0036bfa81683e25565e1427730c5b207c9c3de25f7a0ea1a20e3352d7c8f7191
@@ -4,69 +4,70 @@ require_relative '../mangdown'
4
4
 
5
5
  # Simple client for Mangdown
6
6
  module M
7
- module_function
7
+ class << self
8
8
 
9
- DATA_FILE_PATH = Dir.home + '/.manga_list.yml'
10
- HELP_FILE_PATH = File.expand_path(
11
- '../../README.md', File.dirname(__FILE__)
12
- )
9
+ DATA_FILE_PATH = Dir.home + '/.manga_list.yml'
10
+ HELP_FILE_PATH = File.expand_path(
11
+ '../../README.md', File.dirname(__FILE__)
12
+ )
13
13
 
14
- MANGA_PAGES = ['http://www.mangareader.net/alphabetical'].freeze
14
+ MANGA_PAGES = ['http://www.mangareader.net/alphabetical'].freeze
15
15
 
16
- # return a list of hash with :uri and :name of mangas found in list
17
- def find(search)
18
- search = Regexp.new(/^#{search}$/) if search.respond_to?(:to_str)
16
+ # return a list of hash with :uri and :name of mangas found in list
17
+ def find(search)
18
+ search = Regexp.new(/^#{search}$/) if search.respond_to?(:to_str)
19
19
 
20
- current_manga_list.select { |manga| manga[:name] =~ search }
21
- end
20
+ current_manga_list.select { |manga| manga[:name] =~ search }
21
+ end
22
22
 
23
- # cbz all subdirectories in a directory
24
- def cbz(dir)
25
- Mangdown::CBZ.all(dir)
26
- rescue => error
27
- raise Mangdown::Error, "Failed to package #{dir}: #{error.message}"
28
- end
23
+ # cbz all subdirectories in a directory
24
+ def cbz(dir)
25
+ Mangdown::CBZ.all(dir)
26
+ rescue => error
27
+ raise Mangdown::Error, "Failed to package #{dir}: #{error.message}"
28
+ end
29
29
 
30
- # display help file
31
- def help
32
- puts File.read(HELP_FILE_PATH)
33
- end
30
+ # display help file
31
+ def help
32
+ puts File.read(HELP_FILE_PATH)
33
+ end
34
34
 
35
- # delete data file
36
- def clean_up
37
- File.delete(DATA_FILE_PATH) if File.exist?(DATA_FILE_PATH)
38
- end
35
+ # delete data file
36
+ def clean_up
37
+ File.delete(DATA_FILE_PATH) if File.exist?(DATA_FILE_PATH)
38
+ end
39
39
 
40
- private
40
+ private
41
41
 
42
- # convenience method to access the data file path
43
- def path
44
- DATA_FILE_PATH
45
- end
42
+ # convenience method to access the data file path
43
+ def path
44
+ DATA_FILE_PATH
45
+ end
46
46
 
47
- # check if the data file is current
48
- def file_current?(f)
49
- File.exist?(f) && File.mtime(f) > (Time.now - 604_800)
50
- end
47
+ # check if the data file is current
48
+ def file_current?(f)
49
+ File.exist?(f) && File.mtime(f) > (Time.now - 604_800)
50
+ end
51
51
 
52
- # attempt to get the list from the data file
53
- def data_from_file
54
- YAML.safe_load(File.read(path)) if file_current?(path)
55
- end
52
+ # attempt to get the list from the data file
53
+ def data_from_file
54
+ YAML.safe_load(File.read(path)) if file_current?(path)
55
+ end
56
56
 
57
- # get saved current manga list, if data is less than a week old
58
- # otherwise fetch new data and write it to the data file
59
- def current_manga_list
60
- data = data_from_file
61
- return Mangdown::MangaList.from_data(data) if data
57
+ # get saved current manga list, if data is less than a week old
58
+ # otherwise fetch new data and write it to the data file
59
+ def current_manga_list
60
+ data = data_from_file
61
+ return Mangdown::MangaList.from_data(data) if data
62
62
 
63
- list = MANGA_PAGES.inject([]) do |manga, uri|
64
- list = Mangdown::MDHash.new(uri: uri).to_manga_list
65
- list.merge(manga)
63
+ list = MANGA_PAGES.inject([]) do |manga, uri|
64
+ list = Mangdown::MDHash.new(uri: uri).to_manga_list
65
+ list.merge(manga)
66
+ end
67
+ File.open(path, 'w+') { |f| f.write(list.to_yaml) }
68
+ list
69
+ rescue => error
70
+ raise Mangdown::Error, "#{path} may be corrupt: #{error.message}"
66
71
  end
67
- File.open(path, 'w+') { |f| f.write(list.to_yaml) }
68
- list
69
- rescue => error
70
- raise Mangdown::Error, "#{path} may be corrupt: #{error.message}"
71
72
  end
72
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mangdown
4
- VERSION = '0.16.0'
4
+ VERSION = '0.16.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2