Class: Obfusc::ShowCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/obfusc/commands/show_command.rb

Overview

Perform tasks related ‘show` command

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, source) ⇒ ShowCommand

Returns a new instance of ShowCommand.



7
8
9
10
# File 'lib/obfusc/commands/show_command.rb', line 7

def initialize(config, source)
  @config = config
  @source = source
end

Class Method Details

.call(config, *args) ⇒ Object



12
13
14
15
16
# File 'lib/obfusc/commands/show_command.rb', line 12

def self.call(config, *args)
  source = args.first
  model = new(config, source)
  model.public_send(File.exist?(source.to_s) ? :run : :show_usage)
end

Instance Method Details

#runObject



18
19
20
21
22
23
# File 'lib/obfusc/commands/show_command.rb', line 18

def run
  files.each do |from, to|
    puts "#{from}:"
    puts "---> #{to}"
  end
end

#show_usageObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/obfusc/commands/show_command.rb', line 25

def show_usage
  usage = <<-TEXT.gsub('      ', '')
  Usage:
  $ obfusc show <source>

  Files:
    source: Relative or absolute directory where obfuscated files are stored. (Default to current directory)
  TEXT
  puts usage
end