Class: EpubForge::Action::Action2
- Inherits:
-
Object
- Object
- EpubForge::Action::Action2
show all
- Includes:
- Chatterbox, FunWith::Patterns::Loader
- Defined in:
- lib/epubforge/action/action2.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Chatterbox
#ask, #ask_from_menu, #ask_prettily, #no?, #say, #say_all_is_well, #say_error, #say_instruction, #yes?, #yes_prettily?
Instance Attribute Details
#destination_root_filepath ⇒ Object
# 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
50
51
52
|
# File 'lib/epubforge/action/action2.rb', line 50
def destination_root_filepath
@destination_root_filepath
end
|
Class Method Details
.define_action(keyword) {|definition| ... } ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# 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) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# 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 end
|
Instance Method Details
#add_requirement(*args, &block) ⇒ Object
74
75
76
77
|
# File 'lib/epubforge/action/action2.rb', line 74
def add_requirement( *args, &block )
@requirements ||= []
@requirements.push( [args, block] )
end
|
#ebook_convert_installed? ⇒ Boolean
95
96
97
|
# File 'lib/epubforge/action/action2.rb', line 95
def ebook_convert_installed?
executable_installed?('ebook-convert')
end
|
#executable_installed?(name) ⇒ Boolean
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# 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? ⇒ Boolean
91
92
93
|
# File 'lib/epubforge/action/action2.rb', line 91
def git_installed?
executable_installed?('git')
end
|
#must_target_a_project(project_dir) ⇒ Object
85
86
87
88
89
|
# 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? ⇒ Boolean
99
100
101
|
# 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 )) ⇒ Object
103
104
105
106
|
# File 'lib/epubforge/action/action2.rb', line 103
def quit_with_error( msg, errno = -1 )
STDERR.write( "\n#{msg}\n")
exit( errno )
end
|
#requirements ⇒ Object
70
71
72
|
# File 'lib/epubforge/action/action2.rb', line 70
def requirements
@requirements ||= []
end
|
#requires_executable(ex, fail_msg) ⇒ Object
79
80
81
82
83
|
# 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
|