Class: EpubForge::Project
Constant Summary collapse
- SETTINGS_FOLDER =
"settings"- CONFIG_FILE_NAME =
"config.rb"- PROJECT_ACTIONS_DIRECTORY =
"actions"
Instance Attribute Summary collapse
-
#actions_dir ⇒ Object
readonly
Returns the value of attribute actions_dir.
-
#book_dir ⇒ Object
readonly
Returns the value of attribute book_dir.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#filename_for_epub_book ⇒ Object
readonly
Returns the value of attribute filename_for_epub_book.
-
#filename_for_epub_notes ⇒ Object
readonly
Returns the value of attribute filename_for_epub_notes.
-
#filename_for_mobi_book ⇒ Object
readonly
Returns the value of attribute filename_for_mobi_book.
-
#filename_for_mobi_notes ⇒ Object
readonly
Returns the value of attribute filename_for_mobi_notes.
-
#notes_dir ⇒ Object
readonly
Returns the value of attribute notes_dir.
-
#project_basename ⇒ Object
readonly
Returns the value of attribute project_basename.
-
#target_dir ⇒ Object
readonly
Returns the value of attribute target_dir.
Class Method Summary collapse
-
.is_project_dir?(dir) ⇒ Boolean
TODO: should test be more definitive?.
Instance Method Summary collapse
- #actions_directory ⇒ Object
- #chapters ⇒ Object
-
#default_project_basename ⇒ Object
shorthand string that ‘names’ the project, like the_vampire_of_the_leeky_hills.
-
#initialize(target_dir) ⇒ Project
constructor
A new instance of Project.
- #load_configuration ⇒ Object
- #project_exists? ⇒ Boolean
- #settings_folder(*args) ⇒ Object
Constructor Details
#initialize(target_dir) ⇒ Project
Returns a new instance of Project.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/project/project.rb', line 12 def initialize( target_dir ) @target_dir = FunWith::Files::FilePath.new( target_dir ). load_configuration @notes_dir = config.notes_dir || @target_dir.join( "notes" ) @book_dir = config.book_dir || @target_dir.join( "book" ) @project_basename = default_project_basename @filename_for_epub_book = @target_dir.join( "#{default_project_basename}.epub" ) @filename_for_mobi_book = @target_dir.join( "#{default_project_basename}.mobi" ) @filename_for_epub_notes = @target_dir.join( "#{default_project_basename}.notes.epub" ) @filename_for_mobi_notes = @target_dir.join( "#{default_project_basename}.notes.mobi" ) end |
Instance Attribute Details
#actions_dir ⇒ Object (readonly)
Returns the value of attribute actions_dir.
7 8 9 |
# File 'lib/project/project.rb', line 7 def actions_dir @actions_dir end |
#book_dir ⇒ Object (readonly)
Returns the value of attribute book_dir.
7 8 9 |
# File 'lib/project/project.rb', line 7 def book_dir @book_dir end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/project/project.rb', line 7 def config @config end |
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
7 8 9 |
# File 'lib/project/project.rb', line 7 def config_file @config_file end |
#filename_for_epub_book ⇒ Object (readonly)
Returns the value of attribute filename_for_epub_book.
7 8 9 |
# File 'lib/project/project.rb', line 7 def filename_for_epub_book @filename_for_epub_book end |
#filename_for_epub_notes ⇒ Object (readonly)
Returns the value of attribute filename_for_epub_notes.
7 8 9 |
# File 'lib/project/project.rb', line 7 def filename_for_epub_notes @filename_for_epub_notes end |
#filename_for_mobi_book ⇒ Object (readonly)
Returns the value of attribute filename_for_mobi_book.
7 8 9 |
# File 'lib/project/project.rb', line 7 def filename_for_mobi_book @filename_for_mobi_book end |
#filename_for_mobi_notes ⇒ Object (readonly)
Returns the value of attribute filename_for_mobi_notes.
7 8 9 |
# File 'lib/project/project.rb', line 7 def filename_for_mobi_notes @filename_for_mobi_notes end |
#notes_dir ⇒ Object (readonly)
Returns the value of attribute notes_dir.
7 8 9 |
# File 'lib/project/project.rb', line 7 def notes_dir @notes_dir end |
#project_basename ⇒ Object (readonly)
Returns the value of attribute project_basename.
7 8 9 |
# File 'lib/project/project.rb', line 7 def project_basename @project_basename end |
#target_dir ⇒ Object (readonly)
Returns the value of attribute target_dir.
7 8 9 |
# File 'lib/project/project.rb', line 7 def target_dir @target_dir end |
Class Method Details
.is_project_dir?(dir) ⇒ Boolean
TODO: should test be more definitive?
33 34 35 36 37 38 |
# File 'lib/project/project.rb', line 33 def self.is_project_dir?( dir ) dir = dir && (dir.is_a?(String) || dir.is_a?(FunWith::Files::FilePath)) ? dir.fwf_filepath : nil return false if dir.nil? ( dir.exist? && dir.join( SETTINGS_FOLDER, CONFIG_FILE_NAME ).exist? && dir.join( "book" ).directory? ) ? dir : false end |
Instance Method Details
#actions_directory ⇒ Object
53 54 55 |
# File 'lib/project/project.rb', line 53 def actions_directory settings_folder( ACTIONS_DIRECTORY ) end |
#chapters ⇒ Object
57 58 59 |
# File 'lib/project/project.rb', line 57 def chapters @book_dir.glob("chapter-????.*") end |
#default_project_basename ⇒ Object
shorthand string that ‘names’ the project, like the_vampire_of_the_leeky_hills. Variable-ish, used within filenames
28 29 30 |
# File 'lib/project/project.rb', line 28 def default_project_basename config.filename || @target_dir.basename.to_s.gsub( /\.epubforge$/ , '' ) end |
#load_configuration ⇒ Object
61 62 63 |
# File 'lib/project/project.rb', line 61 def load_configuration self.install_fwc_config_from_file( config_file ) end |
#project_exists? ⇒ Boolean
40 41 42 |
# File 'lib/project/project.rb', line 40 def project_exists? @target_dir.exist? && config_file.exist? end |
#settings_folder(*args) ⇒ Object
44 45 46 47 |
# File 'lib/project/project.rb', line 44 def settings_folder(*args) @settings_folder ||= @target_dir.join( SETTINGS_FOLDER ) @settings_folder.join( *args ) end |