Class: RRSE::Command::SetUpConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/rrse/setup-command.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  "sources" => [
    {"type" => "bitclust", "config" => "~/.bitclust/config"}
  ]
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ SetUpConfig

Returns a new instance of SetUpConfig.



16
17
18
# File 'lib/rrse/setup-command.rb', line 16

def initialize(dir)
  @dir = dir
end

Class Method Details

.short_descriptionObject



12
13
14
# File 'lib/rrse/setup-command.rb', line 12

def self.short_description
  "setup config file"
end

Instance Method Details

#optionsObject



20
21
22
23
24
# File 'lib/rrse/setup-command.rb', line 20

def options
  opts = OptionParser.new
  opts.banner = "Usage: rrse [global-options] setup-config"
  opts
end

#run(argv) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rrse/setup-command.rb', line 26

def run(argv)
  options.order!(argv)

  FileUtils.mkdir_p(@dir)
  config_path = @dir + "config"
  IO.write(config_path, YAML.dump(DEFAULT_CONFIG))
end