mkwebook 0.1.5 → 0.1.7

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
  SHA256:
3
- metadata.gz: 9f05f13d7aa2f3eb2d0ce89b1adc5a49996a046b417a4600212b7e2b8f4f50e9
4
- data.tar.gz: 999962eb75333d346ebac90507823254a29a50a74e6e8b84c276d62e5e51434d
3
+ metadata.gz: 0f8fc12f211be95d5f471f231318136663987e920e2dfd1345118d68eb0bc420
4
+ data.tar.gz: ec4a088bd415a554c232a85692eba1e1983d4bf75941be8f5a8a76b6578f99b3
5
5
  SHA512:
6
- metadata.gz: ef91c55e562cda474850d02750b5b460a599b5d83db40980d55e634780e160a61066a7485683e557b8ea745fc0f21cb24de90d811f48353e0e7a8cec89404279
7
- data.tar.gz: cb59bd6495a13d81d5657eb14aaaef8d3b2d1c8bfb80f50d64daa61f0ca3bac4980bc2fef0475ac623b462ef99eac0c44af07fe3173088e4edf830bd943aa1b7
6
+ metadata.gz: 1ed276076ec77a9ed76386232f77282c350ae206fa2b7d477274dc3cfe460817fcf33c9f5e05c7ed4493333df001cfaa9f81dcfcc8bab524caeecadeb04c1037
7
+ data.tar.gz: 55830b7666568be18a1cdcce720d701c9e33a2121c4e568b1656fca303c71b82911dc3ecf4bd8d4233af64f85bb27b6e7b6c540f2963eec8ef627c300ea38d6e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mkwebook (0.1.5)
4
+ mkwebook (0.1.7)
5
5
  activesupport (>= 6.1.5)
6
6
  concurrent-ruby
7
7
  ferrum (>= 0.13)
data/lib/mkwebook/app.rb CHANGED
@@ -152,7 +152,7 @@ module Mkwebook
152
152
 
153
153
  if page_link_selector = page_config[:page_link_selector]
154
154
  page_links = page_elements.flat_map do |element|
155
- element.css(page_link_selector).map { |a| a.evaluate('this.href') }
155
+ element.css(page_link_selector).map { |a| a.evaluate('this.href') rescue nil }.compact
156
156
  end.uniq
157
157
  @page_links[url] = page_links
158
158
  end
@@ -170,6 +170,7 @@ module Mkwebook
170
170
  element.css('a').each do |a|
171
171
  u = a.evaluate('this.href') rescue nil
172
172
  next unless u.present?
173
+ next unless u =~ /^https?:\/\//
173
174
  href = u.normalize_uri('.html').relative_path_from(url.normalize_uri('.html'))
174
175
  file = u.normalize_file_path('.html')
175
176
  a.evaluate <<~JS
@@ -293,12 +294,14 @@ module Mkwebook
293
294
  end
294
295
 
295
296
  elements.uniq.compact.each do |element|
297
+ puts element if @cli_options[:print_entries]
296
298
  name = element['name']
297
299
  type = element['type']
298
300
  path = element['path'].sub(%r{.*\.docset/Contents/Resources/Documents}, '')
299
301
  db.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?, ?, ?);', [name, type, path])
300
302
  end
301
303
 
304
+
302
305
  plist_content = <<-PLIST
303
306
  <?xml version="1.0" encoding="UTF-8"?>
304
307
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
data/lib/mkwebook/cli.rb CHANGED
@@ -33,6 +33,7 @@ module Mkwebook
33
33
 
34
34
  option :limit, :type => :numeric, :aliases => '-l', :desc => 'Limit number of pages, specially for debugging'
35
35
  option :list, :type => :boolean, :aliases => '-L', :desc => 'List all available Dash.app entry types'
36
+ option :print_entries, :type => :boolean, :aliases => '-p', :desc => 'Print extracted entries'
36
37
  desc 'docset', 'Create docset'
37
38
  def docset
38
39
  if options[:list]
@@ -16,6 +16,8 @@ class String
16
16
  def normalize_file_path(force_extname = nil)
17
17
  return self unless present?
18
18
  uri = URI.parse(self)
19
+ return unless uri.scheme.in? %w(http https)
20
+ return unless uri.path.present?
19
21
  file_path = uri.path[1..]
20
22
  extname = force_extname || File.extname(file_path)
21
23
  basename = File.basename(file_path, extname)
@@ -27,6 +29,8 @@ class String
27
29
  def normalize_uri(force_extname = nil)
28
30
  return self unless present?
29
31
  uri = URI.parse(self)
32
+ return unless uri.scheme.in? %w(http https)
33
+ return unless uri.path.present?
30
34
  file_path = uri.path[1..]
31
35
  extname = force_extname || File.extname(file_path)
32
36
  basename = File.basename(file_path, extname)
@@ -1,3 +1,3 @@
1
1
  module Mkwebook
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkwebook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-13 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport