Class: Asciidoctor::ConfluencePublisher::Invoker

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/confluence_publisher/invoker.rb

Constant Summary collapse

DEFAULT_TEMPLATE_DIR =

default template directory for asciidoctor_confluence marcos

File.expand_path("../../../../template", __FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Invoker

Returns a new instance of Invoker.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/asciidoctor/confluence_publisher/invoker.rb', line 10

def initialize(options)
  @options = options.dup
  @options[:to_file] = nil
  @options[:catalog_assets] = true

  @options[:backend] = 'xhtml5'
  @options[:template_dirs] = Array(options[:template_dirs]) << DEFAULT_TEMPLATE_DIR
  @options[:to_file] = false
  @options[:header_footer] = false
  # confluence related configuration
  attributes = options[:attributes] || {}
  attributes['confluence_host'] ||= ENV['CONFLUENCE_HOST']
  attributes['space'] ||= ENV['SPACE']
  attributes['username'] ||= ENV['CONFLUENCE_USERNAME']
  attributes['password'] ||= ENV['CONFLUENCE_PASSWORD']
  @ancestor_id = (attributes['ancestor_id'] ||= ENV['ANCESTOR_ID'])
  check_confluence_config(attributes)

  proxy = attributes[:proxy] || ENV['CONFLUENCE_PROXY']
  skip_verify_ssl = attributes['skip_verify_ssl'].to_s == 'true'
  @confluence_client = ConfluenceApi.new(attributes['confluence_host'],
                                         attributes['space'],
                                         attributes['username'],
                                         attributes['password'],
                                         skip_verify_ssl: skip_verify_ssl,
                                         proxy: proxy)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/asciidoctor/confluence_publisher/invoker.rb', line 9

def options
  @options
end

Instance Method Details

#invoke!Object



38
39
40
41
42
43
44
# File 'lib/asciidoctor/confluence_publisher/invoker.rb', line 38

def invoke!
  input_files = options[:asciidoc_source_dir] ? Array(options[:asciidoc_source_dir]) : options[:input_files]

  input_files.map(&method(:build_file_tree)).each do |node|
    traverse_file_tree(@ancestor_id, node, &method(:convert_and_publish))
  end
end