Class: Confluence::Uploader

Inherits:
Object
  • Object
show all
Defined in:
lib/confluence/uploader.rb

Overview

Confluence::Uploader class knows how to uploaded documentation to the Confluence Space provided in the config.yml.

Uploader creates a root page with the database name from config.yml and creates nested pages for schemas and tables.

A Confluence ID of each page created by dbdoc is logged to pages.yml file stored in the user’s folder with the documentation.

Instance Method Summary collapse

Constructor Details

#initialize(local_path: Dir.pwd) ⇒ Uploader

Returns a new instance of Uploader.



18
19
20
21
22
# File 'lib/confluence/uploader.rb', line 18

def initialize(local_path: Dir.pwd)
  @config = Dbdoc::Config.new(local_path: local_path).load
  @confluence_api = Confluence::Api.new
  @doc_folder = File.join(Dir.pwd, "doc")
end

Instance Method Details

#clear_confluence_spaceObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/confluence/uploader.rb', line 42

def clear_confluence_space
  YAML.load(File.read(page_ids_file))

  space_pages.each do |page|
    page_key = page["title"]
    page_id = page["id"]

    puts "--> Deleting #{page_key} #{page_id}"

    unlog_page_id(key: page_key) if @confluence_api.delete_page(page_id: page_id)
  end
end


33
34
35
36
37
38
39
40
# File 'lib/confluence/uploader.rb', line 33

def print_space_pages
  space_pages.each do |page|
    page_title = page["title"]
    page_id = page["id"]

    puts "#{page_title}: #{page_id}"
  end
end

#space_pagesObject



29
30
31
# File 'lib/confluence/uploader.rb', line 29

def space_pages
  @confluence_api.existing_pages["results"]
end

#uploadObject



24
25
26
27
# File 'lib/confluence/uploader.rb', line 24

def upload
  create_or_updates_pages
  delete_pages_for_dropped_schemas_or_tables
end