Class: Build
- Inherits:
-
Object
- Object
- Build
- Defined in:
- lib/liquidoc.rb
Overview
class Action
Class Method Summary collapse
Instance Method Summary collapse
- #add_attrs!(attrs) ⇒ Object
- #add_config_file(config_file) ⇒ Object
- #add_data!(data, scope = "") ⇒ Object
- #add_search_prop!(prop) ⇒ Object
-
#attributes ⇒ Object
NOTE this section repeats in Class.AsciiDocument.
- #backend ⇒ Object
- #data ⇒ Object
- #doctype ⇒ Object
- #includes_dirs ⇒ Object
-
#initialize(build, type, data = DataObj.new) ⇒ Build
constructor
A new instance of Build.
-
#message ⇒ Object
def vars self.data end.
- #output ⇒ Object
- #prop_files_array ⇒ Object
- #props ⇒ Object
- #search ⇒ Object
- #set(key, val) ⇒ Object
- #style ⇒ Object
- #template ⇒ Object
- #validate ⇒ Object
- #variables ⇒ Object
Constructor Details
#initialize(build, type, data = DataObj.new) ⇒ Build
Returns a new instance of Build.
415 416 417 418 419 420 421 422 |
# File 'lib/liquidoc.rb', line 415 def initialize build, type, data=DataObj.new build['attributes'] = Hash.new unless build['attributes'] build['props'] = build['properties'] if build['properties'] @build = build @type = type @data = data @build['variables'] = {} unless @build['variables'] end |
Class Method Details
.set(key, val) ⇒ Object
562 563 564 |
# File 'lib/liquidoc.rb', line 562 def self.set key, val @build[key] = val end |
Instance Method Details
#add_attrs!(attrs) ⇒ Object
549 550 551 552 553 554 555 556 |
# File 'lib/liquidoc.rb', line 549 def add_attrs! attrs begin attrs.to_h unless attrs.is_a? Hash self.attributes.merge!attrs rescue raise "InvalidAttributesFormat" end end |
#add_config_file(config_file) ⇒ Object
566 567 568 569 570 571 572 573 574 575 |
# File 'lib/liquidoc.rb', line 566 def add_config_file config_file @build['props'] = Hash.new unless @build['props'] @build['props']['files'] = Array.new unless @build['props']['files'] begin files_array = @build['props']['files'].force_array @build['props']['files'] = files_array.push(config_file) rescue raise "PropertiesFilesArrayError" end end |
#add_data!(data, scope = "") ⇒ Object
462 463 464 |
# File 'lib/liquidoc.rb', line 462 def add_data! data, scope="" @data.add_data!(data, scope) end |
#add_search_prop!(prop) ⇒ Object
536 537 538 539 540 541 542 |
# File 'lib/liquidoc.rb', line 536 def add_search_prop! prop begin self.search.merge!prop rescue raise "PropertyInsertionError" end end |
#attributes ⇒ Object
NOTE this section repeats in Class.AsciiDocument
545 546 547 |
# File 'lib/liquidoc.rb', line 545 def attributes @build['attributes'] end |
#backend ⇒ Object
444 445 446 |
# File 'lib/liquidoc.rb', line 444 def backend @build['backend'] end |
#data ⇒ Object
458 459 460 |
# File 'lib/liquidoc.rb', line 458 def data @data unless @data.nil? end |
#doctype ⇒ Object
440 441 442 |
# File 'lib/liquidoc.rb', line 440 def doctype @build['doctype'] end |
#includes_dirs ⇒ Object
428 429 430 |
# File 'lib/liquidoc.rb', line 428 def includes_dirs @build['includes_dirs'] end |
#message ⇒ Object
def vars
self.data['vars']
end
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/liquidoc.rb', line 470 def # dynamically build a message, possibly appending a reason unless @build['message'] reason = ", #{@build['reason']}" if @build['reason'] case @type when "parse" text = ".. Builds `#{self.output}` parsed with the template `#{self.template}`#{reason}." when "render" case self.backend when "pdf" text = ".. Uses Asciidoctor/Prawn to generate a PDF file `#{self.output}`" text.concat("#{reason}") if reason text.concat(".") when "html5" text = ".. Compiles a standard Asciidoctor HTML5 file, `#{self.output}`" text.concat("#{reason}") if reason text.concat(".") when "jekyll" text = ".. Uses Jekyll config files:\n+\n--" files = self.props['files'] if files.is_a? String if files.include? "," files = files.split(",") else files = files.split end else unless files.is_a? Array @logger.error "The Jekyll configuration file must be a single filename, a comma-separated list of filenames, or an array of filenames." end end files.each do |file| text.concat("\n * `#{file}`") end text.concat("\n\nto generate a static site") if self.props && self.props['arguments'] text.concat(" at `#{self.props['arguments']['destination']}`") end text.concat("#{reason}") if reason text.concat(".\n--\n") end return text end else @build['message'] end end |
#output ⇒ Object
432 433 434 |
# File 'lib/liquidoc.rb', line 432 def output @build['output'] end |
#prop_files_array ⇒ Object
518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/liquidoc.rb', line 518 def prop_files_array if props if props['files'] begin props['files'].force_array if props['files'] rescue Exception => ex raise "PropertiesFilesArrayError: #{ex}" end end else Array.new end end |
#props ⇒ Object
448 449 450 |
# File 'lib/liquidoc.rb', line 448 def props @build['props'] end |
#search ⇒ Object
532 533 534 |
# File 'lib/liquidoc.rb', line 532 def search props['search'] end |
#set(key, val) ⇒ Object
558 559 560 |
# File 'lib/liquidoc.rb', line 558 def set key, val @build[key] = val end |
#style ⇒ Object
436 437 438 |
# File 'lib/liquidoc.rb', line 436 def style @build['style'] end |
#template ⇒ Object
424 425 426 |
# File 'lib/liquidoc.rb', line 424 def template @build['template'] end |
#validate ⇒ Object
577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'lib/liquidoc.rb', line 577 def validate reqs = [] case self.type when "parse" reqs = ["template,output"] when "render" reqs = ["output"] end for req in reqs if (defined?(req)).nil? raise "ActionSettingMissing" end end end |
#variables ⇒ Object
452 453 454 455 456 |
# File 'lib/liquidoc.rb', line 452 def variables # Variables added in the config build:variables: param # Not for manipulation @build['variables'] end |