class Gitdocs::Initializer

Public Class Methods

database() click to toggle source

@return [String]

# File lib/gitdocs/initializer.rb, line 51
def self.database
  @database ||= File.join(root_dirname, 'config.db')
end
database=(value) click to toggle source

@param [nil, String] value @return [nil]

# File lib/gitdocs/initializer.rb, line 57
def self.database=(value)
  return if value.nil?
  @database = value
end
foreground() click to toggle source

@return [Boolean]

# File lib/gitdocs/initializer.rb, line 63
def self.foreground
  @foreground ||= false
end
foreground=(value) click to toggle source
# File lib/gitdocs/initializer.rb, line 67
def self.foreground=(value)
  return if value.nil?
  @foreground = value
end
initialize_all() click to toggle source

@return [nil]

# File lib/gitdocs/initializer.rb, line 7
def self.initialize_all
  initialize_database
  initialize_old_paths
end
initialize_database() click to toggle source

@return [nil]

# File lib/gitdocs/initializer.rb, line 13
def self.initialize_database
  FileUtils.mkdir_p(root_dirname)
  ActiveRecord::Base.establish_connection(
    adapter: 'sqlite3',
    database: database
  )
  ActiveRecord::Migrator.migrate(
    File.expand_path('../migration', __FILE__)
  )
end
initialize_old_paths() click to toggle source

@return [nil]

# File lib/gitdocs/initializer.rb, line 25
def self.initialize_old_paths
  old_path_dirname = File.expand_path('paths', root_dirname)
  return unless File.exist?(old_path_dirname)

  File.read(old_path_dirname).split("\n").each do |path|
    begin
      Share.create_by_path!(path)
    rescue # rubocop:disable HandleExceptions
      # Nothing to do, because we want the process to keep going.
    end
  end
end
root_dirname() click to toggle source

@return [String]

# File lib/gitdocs/initializer.rb, line 39
def self.root_dirname
  @root_dirname ||= File.expand_path('.gitdocs', ENV['HOME'])
end
root_dirname=(value) click to toggle source

@param [nil, String] value @return [nil]

# File lib/gitdocs/initializer.rb, line 45
def self.root_dirname=(value)
  return if value.nil?
  @root_dirname = value
end
verbose() click to toggle source

@return [Boolean]

# File lib/gitdocs/initializer.rb, line 73
def self.verbose
  @verbose ||= false
end
verbose=(value) click to toggle source

@param [Boolean] value

# File lib/gitdocs/initializer.rb, line 78
def self.verbose=(value)
  @verbose = !!value # rubocop:disable DoubleNegation
end