Class: Lurker::Cli
- Inherits:
-
Thor
- Object
- Thor
- Lurker::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/lurker/cli.rb
Overview
A Thor definition for an lurker to HTML conversion operation
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
- #convert(lurker_path = Lurker::DEFAULT_SERVICE_PATH) ⇒ Object
- #init_docs(lurker_path = Lurker::DEFAULT_SERVICE_PATH) ⇒ Object
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
18 19 20 |
# File 'lib/lurker/cli.rb', line 18 def content @content end |
Class Method Details
.assets_root ⇒ Object
24 25 26 |
# File 'lib/lurker/cli.rb', line 24 def self.assets_root [:assets].present? ? Pathname.new([:assets]). : Lurker::BUNDLED_ASSETS_PATH end |
.templates_root ⇒ Object
20 21 22 |
# File 'lib/lurker/cli.rb', line 20 def self.templates_root [:template].present? ? Pathname.new([:templates]). : Lurker::BUNDLED_TEMPLATES_PATH end |
Instance Method Details
#convert(lurker_path = Lurker::DEFAULT_SERVICE_PATH) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/lurker/cli.rb', line 55 def convert(lurker_path=Lurker::DEFAULT_SERVICE_PATH) say_status nil, "Converting lurker to #{[:format]}" setup_schema_root! lurker_path require "#{Dir.pwd}/config/environment" if [:rails] # for backward compatibility if [:content] Lurker.service.documentation = open(File.([:content])).read end setup_rendering_engine! inside(output_path) do say_status :inside, output_path prepare_assets! if [:format] == 'pdf' convert_to_pdf else convert_to_html end cleanup_assets! end end |
#init_docs(lurker_path = Lurker::DEFAULT_SERVICE_PATH) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lurker/cli.rb', line 32 def init_docs(lurker_path=Lurker::DEFAULT_SERVICE_PATH) say_status nil, 'Creating documentation stubs' setup_schema_root! lurker_path schemas = Lurker.service.endpoints.map(&:schema) << Lurker.service.schema schemas.each do |schema| rel_path = Pathname.new(schema.documentation_uri).relative_path_from(Pathname.getwd) template 'documentation.md.tt', schema.documentation_uri, skip: true, path: rel_path end end |