class EpubForge::Action::Action2

Attributes

destination_root_filepath[RW]

# Instead, use these instead of destination_root. Thor gets strings instead of # filepaths, like it wants, and I get filepaths instead of strings, like I want. def destination_root_filepath

self.destination_root.fwf_filepath

end

def destination_root_filepath=(root)

@destination_root_file
self.destination_root = root.to_s

end

Public Class Methods

define_action( keyword ) { |definition| ... } click to toggle source
# File lib/epubforge/action/action2.rb, line 29
def self.define_action( keyword, &block )
  puts "defining action #{keyword}" if EpubForge.gem_test_mode?
  definition = ActionDefinition.new
  definition.keyword( keyword )
  definition.klass( self )
  
  yield definition if block_given?
  
  EpubForge::Action::Action2.loader_pattern_register_item( definition )
end
loader_pattern_load_item( file ) click to toggle source
# File lib/epubforge/action/action2.rb, line 16
def self.loader_pattern_load_item( file )
  begin
    file.fwf_filepath.load
  rescue Exception => e
    puts "Error loading #{file}: #{e.message}"
    for line in e.backtrace
      puts "\t#{line}"
    end
  end
  
  nil    # returning true will break loader
end

Public Instance Methods

add_requirement( *args, &block ) click to toggle source
# File lib/epubforge/action/action2.rb, line 74
def add_requirement( *args, &block )
  @requirements ||= []
  @requirements.push( [args, block] )
end
ebook_convert_installed?() click to toggle source
# File lib/epubforge/action/action2.rb, line 95
def ebook_convert_installed?
  executable_installed?('ebook-convert')
end
executable_installed?( name ) click to toggle source
# File lib/epubforge/action/action2.rb, line 52
def executable_installed?( name )
  name = name.to_sym
  
  if @executables.nil?
    @executables = {}
    for exe, path in (EpubForge.config[:exe_paths] || {})
      @executables[exe] = path.fwf_filepath
    end
  end
  
  @executables[name] ||= begin
    _which = `which #{name}`.strip
    (_which.length == 0) ? false : _which.fwf_filepath
  end
    
  @executables[name]  
end
git_installed?() click to toggle source
# File lib/epubforge/action/action2.rb, line 91
def git_installed?
  executable_installed?('git')
end
must_target_a_project( project_dir ) click to toggle source
# File lib/epubforge/action/action2.rb, line 85
def must_target_a_project( project_dir )
  add_requirement( project_dir ) do
    Project.is_project_dir?( project_dir )
  end
end
project_already_gitted?() click to toggle source
# File lib/epubforge/action/action2.rb, line 99
def project_already_gitted?
  @project.root_dir.join( ".git" ).directory?
end
quit_with_error( msg, errno = -1 ) click to toggle source
# File lib/epubforge/action/action2.rb, line 103
def quit_with_error( msg, errno = -1 )
  STDERR.write( "\n#{msg}\n")
  exit( errno )
end
requirements() click to toggle source
# File lib/epubforge/action/action2.rb, line 70
def requirements
  @requirements ||= []
end
requires_executable( ex, fail_msg ) click to toggle source
# File lib/epubforge/action/action2.rb, line 79
def requires_executable( ex, fail_msg )
  add_requirement( ex, fail_msg ) do
    executable_installed?( ex, fail_msg )
  end
end