Class: Nanoc::Extra::LinkCollector Private
- Inherits:
-
Object
- Object
- Nanoc::Extra::LinkCollector
- Defined in:
- lib/nanoc/extra/link_collector.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- URI_ATTRS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'a' => :href, 'audio' => :src, 'form' => :action, 'iframe' => :src, 'img' => :src, 'link' => :href, 'script' => :src, 'video' => :src, }.freeze
Instance Method Summary collapse
- #external_href?(href) ⇒ Boolean private
- #filenames_per_href ⇒ Object private
- #filenames_per_resource_uri ⇒ Object private
- #hrefs_in_file(filename) ⇒ Object private
-
#initialize(filenames, mode = nil) ⇒ LinkCollector
constructor
private
A new instance of LinkCollector.
- #resource_uris_in_file(filename) ⇒ Object private
Constructor Details
#initialize(filenames, mode = nil) ⇒ LinkCollector
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LinkCollector.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nanoc/extra/link_collector.rb', line 17 def initialize(filenames, mode = nil) Nanoc::Extra::JRubyNokogiriWarner.check_and_warn @filenames = filenames @filter = case mode when nil ->(_h) { true } when :external ->(h) { external_href?(h) } when :internal ->(h) { !external_href?(h) } else raise ArgumentError, 'Expected mode argument to be :internal, :external or nil' end end |
Instance Method Details
#external_href?(href) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/nanoc/extra/link_collector.rb', line 42 def external_href?(href) href =~ %r{^(\/\/|[a-z\-]+:)} end |
#filenames_per_href ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/nanoc/extra/link_collector.rb', line 34 def filenames_per_href grouped_filenames { |filename| hrefs_in_file(filename) } end |
#filenames_per_resource_uri ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 |
# File 'lib/nanoc/extra/link_collector.rb', line 38 def filenames_per_resource_uri grouped_filenames { |filename| resource_uris_in_file(filename) } end |
#hrefs_in_file(filename) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 |
# File 'lib/nanoc/extra/link_collector.rb', line 46 def hrefs_in_file(filename) uris_in_file filename, %w(a img) end |
#resource_uris_in_file(filename) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/nanoc/extra/link_collector.rb', line 50 def resource_uris_in_file(filename) uris_in_file filename, %w(audio form img iframe link script video) end |