class NvimConf::Writer

Public Class Methods

new(managers) click to toggle source
# File lib/nvim_conf/writer.rb, line 5
def initialize(managers)
  @managers = managers
  @configuration = NvimConf::ConfigurationBuilder.new(managers).build_configuration
end

Public Instance Methods

write() click to toggle source
# File lib/nvim_conf/writer.rb, line 10
def write
  return unless run?

  create_folder
  write_configuration
  write_documentation
end

Private Instance Methods

create_documentation_init() click to toggle source
# File lib/nvim_conf/writer.rb, line 40
def create_documentation_init
  FileUtils.remove_file(
    documentation_file_path,
    force: true
  )
  FileUtils.touch(
    documentation_file_path
  )
end
create_folder() click to toggle source
# File lib/nvim_conf/writer.rb, line 36
def create_folder
  FileUtils.mkdir_p(folder_path)
end
create_init() click to toggle source
# File lib/nvim_conf/writer.rb, line 50
def create_init
  FileUtils.remove_file(
    init_file_path,
    force: true
  )
  FileUtils.touch(
    init_file_path
  )
end
documentation_file_path() click to toggle source
# File lib/nvim_conf/writer.rb, line 71
def documentation_file_path
  folder_path + "Init.md"
end
folder_path() click to toggle source
# File lib/nvim_conf/writer.rb, line 83
def folder_path
  @folder_path = Pathname.new(@configuration[:output_folder]).expand_path
end
init_file_name() click to toggle source
# File lib/nvim_conf/writer.rb, line 79
def init_file_name
  @configuration[:schema] == :nvim ? "init.lua" : "init.vim"
end
init_file_path() click to toggle source
# File lib/nvim_conf/writer.rb, line 75
def init_file_path
  folder_path + init_file_name
end
run?() click to toggle source
# File lib/nvim_conf/writer.rb, line 20
def run?
  @configuration[:write]
end
write_configuration() click to toggle source
# File lib/nvim_conf/writer.rb, line 60
def write_configuration
  create_init
  File.open(init_file_path, "w+") do |file|
    NvimConf::Writers::Code::Orchestrator.new(
      @managers,
      file,
      @configuration
    ).aggregate_writes
  end
end
write_documentation() click to toggle source
# File lib/nvim_conf/writer.rb, line 24
def write_documentation
  create_documentation_init

  File.open(documentation_file_path, "w+") do |file|
    NvimConf::Writers::Documentation::Orchestrator.new(
      @managers,
      Utils::IoOperator.new(file),
      @configuration
    ).aggregate_writes
  end
end