Class: Gitrob::CLI::Commands::Configure

Inherits:
Gitrob::CLI::Command show all
Defined in:
lib/gitrob/cli/commands/configure.rb

Defined Under Namespace

Classes: ConfigurationError, ConfigurationFileCorrupt, ConfigurationFileNotFound, ConfigurationFileNotReadable

Constant Summary collapse

CONFIGURATION_FILE_PATH =
File.join(Dir.home, ".gitrobrc")

Instance Attribute Summary

Attributes inherited from Gitrob::CLI::Command

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Gitrob::CLI::Command

#debug, #debugging_enabled?, #error, #fatal, #info, #output, #progress_bar, start, #task, #thread_pool, #warn

Constructor Details

#initialize(options) ⇒ Configure

Returns a new instance of Configure.



12
13
14
15
16
17
18
19
20
# File 'lib/gitrob/cli/commands/configure.rb', line 12

def initialize(options)
  @options = options
  info("Starting Gitrob configuration wizard")
  return unless agree_to_overwrite?
  config = gather_configuration
  task("Saving configuration to #{CONFIGURATION_FILE_PATH}") do
    save_configuration(config)
  end
end

Class Method Details

.configured?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/gitrob/cli/commands/configure.rb', line 22

def self.configured?
  File.exist?(CONFIGURATION_FILE_PATH)
end

.load_configuration!Object



26
27
28
29
30
31
32
33
34
# File 'lib/gitrob/cli/commands/configure.rb', line 26

def self.load_configuration!
  fail ConfigurationFileNotFound \
    unless File.exist?(CONFIGURATION_FILE_PATH)
  fail ConfigurationFileNotReadable \
    unless File.readable?(CONFIGURATION_FILE_PATH)
  YAML.load(File.read(CONFIGURATION_FILE_PATH))
rescue Psych::SyntaxError
  raise ConfigurationFileCorrupt
end