class EpubForge::Action::Action
Constants
- BLUE
- CLEAR
- GREEN
- MAGENTA
- ON_BLUE
- ON_YELLOW
- RED
- YELLOW
Protected Instance Methods
add_requirement( *args, &block )
click to toggle source
# File lib/epubforge/action/action.rb, line 205 def add_requirement( *args, &block ) @requirements ||= [] @requirements.push( [args, block] ) end
ask_prettily( statement )
click to toggle source
# File lib/epubforge/action/action.rb, line 171 def ask_prettily( statement ) ask( statement, BLUE ) end
before_start()
click to toggle source
# File lib/epubforge/action/action.rb, line 239 def before_start variablize_options( :project, :debug, :help, :verbose ) # @project = @options[:project] # @debug = @options[:debug] # @help = @options[:help] # @verbose = @options[:verbose] @project = Project.new( @project ) unless @project.nil? end
ebook_convert_installed?()
click to toggle source
# File lib/epubforge/action/action.rb, line 226 def ebook_convert_installed? executable_installed?('ebook-convert') end
executable_installed?( name )
click to toggle source
hope this doesn’t break anything. Sure enough, it broke a lot of things. def destination_root=( root )
@destination_stack ||= [] @destination_stack << (root ? root.fwf_filepath.expand : '')
end
# File lib/epubforge/action/action.rb, line 183 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/action.rb, line 222 def git_installed? executable_installed?('git') end
must_target_a_project( project_dir )
click to toggle source
# File lib/epubforge/action/action.rb, line 216 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/action.rb, line 230 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/action.rb, line 234 def quit_with_error( msg, errno = -1 ) STDERR.write( "\n#{msg}\n") exit( errno ) end
requirements()
click to toggle source
# File lib/epubforge/action/action.rb, line 201 def requirements @requirements ||= [] end
requires_executable( ex, fail_msg )
click to toggle source
# File lib/epubforge/action/action.rb, line 210 def requires_executable( ex, fail_msg ) add_requirement( ex, fail_msg ) do executable_installed?( ex, fail_msg ) end end
say_all_is_well( statement )
click to toggle source
# File lib/epubforge/action/action.rb, line 140 def say_all_is_well( statement ) say( statement, GREEN ) end
say_error( statement )
click to toggle source
# File lib/epubforge/action/action.rb, line 132 def say_error( statement ) say( "ERROR : #{statement}", RED + ON_BLUE ) end
say_instruction( statement )
click to toggle source
# File lib/epubforge/action/action.rb, line 136 def say_instruction( statement ) say( statement, YELLOW ) end
say_subtly( statement )
click to toggle source
# File lib/epubforge/action/action.rb, line 144 def say_subtly( statement ) say( statement, MAGENTA ) end
say_when_debugging( *args )
click to toggle source
# File lib/epubforge/action/action.rb, line 128 def say_when_debugging( *args ) say( *args ) if @debug end
say_when_verbose( *args )
click to toggle source
# File lib/epubforge/action/action.rb, line 124 def say_when_verbose( *args ) say( *args ) if @verbose end
variablize_options( *symbols )
click to toggle source
takes a series of symbols or an array of symbols for each symbol, creates an instance var from @options
# File lib/epubforge/action/action.rb, line 250 def variablize_options( *symbols ) symbols.flatten! # in case someone passes an array for sym in symbols self.instance_variable_set( :"@#{sym}", @options[sym] ) end end
yes_prettily?( statement )
click to toggle source
# File lib/epubforge/action/action.rb, line 148 def yes_prettily?( statement ) yes?( statement, BLUE ) end