Class: Epuber::Command::FromFile

Inherits:
Epuber::Command show all
Defined in:
lib/epuber/command/from_file.rb

Instance Method Summary collapse

Methods inherited from Epuber::Command

run

Constructor Details

#initialize(argv) ⇒ FromFile

Returns a new instance of FromFile.

Parameters:

  • argv (CLAide::ARGV)


16
17
18
19
20
# File 'lib/epuber/command/from_file.rb', line 16

def initialize(argv)
  @filepath = argv.arguments!.first

  super(argv)
end

Instance Method Details

#runObject



32
33
34
35
36
# File 'lib/epuber/command/from_file.rb', line 32

def run
  super

  FromFileExecutor.new(@filepath).run
end

#validate!Object



22
23
24
25
26
27
28
29
30
# File 'lib/epuber/command/from_file.rb', line 22

def validate!
  super

  help! 'You must specify path to existing EPUB file' if @filepath.nil?
  help! "File #{@filepath} doesn't exists" unless File.exist?(@filepath)

  existing = Dir.glob('*.bookspec')
  help! "Can't reinit this folder, #{existing.first} already exists." unless existing.empty?
end