Class: Inplace::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/inplace.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



507
508
509
# File 'lib/inplace.rb', line 507

def initialize
  @alias = {}
end

Instance Method Details

#expand_alias(command) ⇒ Object



524
525
526
527
528
529
530
531
532
533
534
# File 'lib/inplace.rb', line 524

def expand_alias(command)
  if @alias.key?(command)
    new_command = @alias[command]

    info "expanding alias: %s: %s\n", command, new_command

    new_command
  else
    command
  end
end

#load(file) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/inplace.rb', line 511

def load(file)
  File.open(file) { |f|
    f.each_line { |line|
      line.strip!
      next if /^#/ =~ line

      if m = line.match(/^([^\s=]+)\s*=\s*(.+)/)
        @alias[m[1]] = m[2]
      end
    }
  }
end