Class: RepoConfig
- Inherits:
-
Object
- Object
- RepoConfig
- Defined in:
- lib/teuton-get/repo/repo_config.rb
Overview
Create Teuton Repo config file
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(args) ⇒ RepoConfig
constructor
A new instance of RepoConfig.
- #show_list ⇒ Object
Constructor Details
#initialize(args) ⇒ RepoConfig
Returns a new instance of RepoConfig.
11 12 13 14 15 16 17 18 |
# File 'lib/teuton-get/repo/repo_config.rb', line 11 def initialize(args) @reader = args[:config_reader] @data = @reader.read @dev = args[:progress_writer] @config_dirpath = args[:config_dirpath] || "" @config_filepath = File.join(@config_dirpath, Application::CONFIGFILE) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/teuton-get/repo/repo_config.rb', line 9 def data @data end |
Class Method Details
.new_by_default ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/teuton-get/repo/repo_config.rb', line 20 def self.new_by_default config_filepath = Application.instance.get(:config_filepath) RepoConfig.new( config_reader: IniFileReader.new(config_filepath), progress_writer: TerminalWriter.new, config_dirpath: Application.instance.get(:config_dirpath) ) end |
Instance Method Details
#create ⇒ Object
30 31 32 33 34 |
# File 'lib/teuton-get/repo/repo_config.rb', line 30 def create @dev.writeln "\n==> Creating configuration files" create_dir create_ini_file end |
#show_list ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/teuton-get/repo/repo_config.rb', line 36 def show_list rows = [] rows << ["E", "NAME", "DESCRIPTION"] rows << :separator index = 0 @data.each_pair do |key, value| enable = "\u{2714}" enable = " " unless value["enable"] description = value["description"] || "?" rows << [enable, TeutonGet::Format.colorize(key, index), description] index += 1 end @dev.writeln "Repository list" @dev.write_table(rows) @dev.write "Config: " @dev.writeln "#{@reader.source}\n", color: :white end |