Class: MakePDF::Processor::Site
- Inherits:
-
Object
- Object
- MakePDF::Processor::Site
- Includes:
- MakePDF::PathManip
- Defined in:
- lib/make_pdf/jekyll.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #<<(doc) ⇒ Object
- #default_options ⇒ Object
-
#initialize(site, **options) ⇒ Site
constructor
A new instance of Site.
- #make_options(options, *more_options) ⇒ Object
- #process ⇒ Object
- #queue(processor) ⇒ Object
Methods included from MakePDF::PathManip
Constructor Details
#initialize(site, **options) ⇒ Site
Returns a new instance of Site.
140 141 142 143 144 145 146 147 |
# File 'lib/make_pdf/jekyll.rb', line 140 def initialize(site, **) config = site.config["make-pdf"]||{} @logger = MakePDF::Logger.new(logger: ::Jekyll.logger, level: (config["log-map-level"] || :debug)) @site = site @options = .merge((@site.config["make-pdf"], )) @queue = [] logger.debug("Initialized with #{self.}.") end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
118 119 120 |
# File 'lib/make_pdf/jekyll.rb', line 118 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
118 119 120 |
# File 'lib/make_pdf/jekyll.rb', line 118 def @options end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
118 119 120 |
# File 'lib/make_pdf/jekyll.rb', line 118 def site @site end |
Instance Method Details
#<<(doc) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/make_pdf/jekyll.rb', line 154 def <<(doc) processor = Processor.new(self, doc, **@options) if processor.valid? queue(processor) else logger.info("Skip #{doc.name} => #{processor.reason}") end end |
#default_options ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/make_pdf/jekyll.rb', line 120 def return { output_base_path: site.source, input_location: path_of(site.dest), input_base_url: relative_path_of(site.baseurl[1..]), input_host: site.config["url"].match(Regexp.new("^[^:]*://\([^/]+\)/?.*$"))[1], input_scheme: "file" }.freeze end |
#make_options(options, *more_options) ⇒ Object
130 131 132 133 134 135 136 137 138 |
# File 'lib/make_pdf/jekyll.rb', line 130 def (, *) return {} if .nil? [ , ].flatten .reduce(:merge) .transform_keys do |key| key.to_s.sub("-", "_").to_sym end end |
#process ⇒ Object
163 164 165 166 167 |
# File 'lib/make_pdf/jekyll.rb', line 163 def process @queue.each do |processor| processor.process(**@options) end end |
#queue(processor) ⇒ Object
149 150 151 152 |
# File 'lib/make_pdf/jekyll.rb', line 149 def queue(processor) logger.info("Adding #{processor.name} to queue") @queue.push(processor) end |