epubforge 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +17 -10
  3. data/VERSION +1 -1
  4. data/bin/epubforge +1 -1
  5. data/config/actions/epub.rb +50 -0
  6. data/config/actions/forge.rb +34 -13
  7. data/config/actions/git.rb +106 -0
  8. data/config/actions/help.rb +13 -13
  9. data/config/actions/html.rb +33 -0
  10. data/config/actions/mobi.rb +60 -0
  11. data/config/actions/new.rb +182 -0
  12. data/config/actions/word_count.rb +26 -24
  13. data/config/{actions → actions_to_ignore}/generate.rb +1 -1
  14. data/config/{actions → actions_to_ignore}/generate_chapter.rb +0 -0
  15. data/config/{actions → actions_to_ignore}/git_backup.rb +2 -2
  16. data/config/{actions → actions_to_ignore}/globals.rb +1 -1
  17. data/config/{actions → actions_to_ignore}/kindle.rb +3 -3
  18. data/config/{actions → actions_to_ignore}/local_action.rb +1 -1
  19. data/config/{actions → actions_to_ignore}/mobify.rb +3 -3
  20. data/config/actions_to_ignore/notes_to_epub.rb +19 -0
  21. data/config/actions_to_ignore/notes_to_kindle.rb +18 -0
  22. data/config/{actions → actions_to_ignore}/spell.rb +1 -1
  23. data/config/{actions → actions_to_ignore}/version.rb +3 -3
  24. data/config/{actions → actions_to_ignore}/wrap_scene_notes_in_hidden_div.rb +1 -1
  25. data/config/converters/epub_to_mobi.calibre.rb +8 -0
  26. data/config/converters/epub_to_mobi.kindlegen.rb +11 -0
  27. data/config/html_translators/default_kramdown.html_translator.rb +9 -0
  28. data/config/html_translators/default_markdown.html_translator.rb +10 -0
  29. data/config/html_translators/default_markdown_pandoc.html_translator.rb +10 -0
  30. data/config/html_translators/default_textile_pandoc.html_translator.rb +8 -0
  31. data/config/html_translators/default_xhtml.html_translator.rb +7 -0
  32. data/config/html_translators/fallback_html.html_translator.rb +9 -0
  33. data/config/html_translators/fallback_markdown.html_translator.rb +8 -0
  34. data/config/html_translators/fallback_textile.html_translator.rb +7 -0
  35. data/config/html_translators/fallback_txt.html_translator.rb +8 -0
  36. data/config/html_translators/fallback_unknown.html_translator.rb +7 -0
  37. data/lib/epubforge.rb +37 -82
  38. data/lib/{action/thor_action.rb → epubforge/action/action.rb} +89 -69
  39. data/lib/epubforge/action/action2.rb +109 -0
  40. data/lib/epubforge/action/action_definition.rb +62 -0
  41. data/lib/epubforge/action/actions_lookup.rb +45 -0
  42. data/lib/epubforge/action/chatterbox.rb +93 -0
  43. data/lib/{action → epubforge/action}/cli_command.rb +2 -2
  44. data/lib/{action → epubforge/action}/cli_sequence.rb +0 -0
  45. data/lib/{action → epubforge/action}/file_transformer.rb +0 -0
  46. data/lib/{action → epubforge/action}/hooks_interface.rb +2 -2
  47. data/lib/{action → epubforge/action}/run_description.rb +12 -9
  48. data/lib/{action → epubforge/action}/runner.rb +23 -24
  49. data/lib/{epub → epubforge/builder}/assets/asset.rb +1 -1
  50. data/lib/{epub → epubforge/builder}/assets/font.rb +1 -1
  51. data/lib/epubforge/builder/assets/html.rb +9 -0
  52. data/lib/{epub → epubforge/builder}/assets/image.rb +1 -1
  53. data/lib/epubforge/builder/assets/markdown.rb +9 -0
  54. data/lib/{epub → epubforge/builder}/assets/page.rb +12 -4
  55. data/lib/{epub → epubforge/builder}/assets/stylesheet.rb +1 -1
  56. data/lib/epubforge/builder/assets/textile.rb +9 -0
  57. data/lib/epubforge/builder/assets/xhtml.rb +9 -0
  58. data/lib/epubforge/builder/builder.rb +134 -0
  59. data/lib/{epub/builder.rb → epubforge/builder/epub.rb} +58 -161
  60. data/lib/epubforge/builder/html.rb +22 -0
  61. data/lib/epubforge/builder/packager.rb +16 -0
  62. data/lib/epubforge/core_extensions/array.rb +2 -0
  63. data/lib/{core_extensions → epubforge/core_extensions}/kernel.rb +0 -0
  64. data/lib/epubforge/core_extensions/nil_class.rb +2 -0
  65. data/lib/epubforge/core_extensions/object.rb +24 -0
  66. data/lib/{core_extensions → epubforge/core_extensions}/string.rb +1 -5
  67. data/lib/{custom_helpers.rb → epubforge/custom_helpers.rb} +0 -1
  68. data/lib/{errors.rb → epubforge/exceptions/errors.rb} +0 -0
  69. data/lib/{project → epubforge/project}/project.rb +23 -17
  70. data/lib/epubforge/utils/action_loader.rb +8 -0
  71. data/lib/epubforge/utils/class_loader.rb +102 -0
  72. data/lib/epubforge/utils/converter.rb +94 -0
  73. data/lib/{utils → epubforge/utils}/downloader.rb +0 -0
  74. data/lib/{utils → epubforge/utils}/file_orderer.rb +0 -0
  75. data/lib/epubforge/utils/file_path.rb +8 -0
  76. data/lib/epubforge/utils/html_translator.rb +126 -0
  77. data/lib/epubforge/utils/html_translator_queue.rb +113 -0
  78. data/lib/epubforge/utils/htmlizer.rb +61 -0
  79. data/lib/{utils → epubforge/utils}/misc.rb +0 -0
  80. data/lib/epubforge/utils/root_path.rb +8 -0
  81. data/lib/epubforge/utils/settings.rb +147 -0
  82. data/lib/epubforge/utils/template_evaluator.rb +7 -0
  83. data/templates/{default/book/afterword.markdown.template → project/book/afterword.markdown} +0 -0
  84. data/templates/project/book/chapter-%0000chapter%.markdown.template +4 -0
  85. data/templates/{default → project}/book/cover.xhtml.template +2 -2
  86. data/templates/{default/book/foreword.markdown.template → project/book/foreword.markdown} +0 -0
  87. data/templates/{default → project}/book/images/cover.png +0 -0
  88. data/templates/{default/book/stylesheets/stylesheet.css.template → project/book/stylesheets/stylesheet.css} +0 -0
  89. data/templates/project/book/title_page.markdown.template +5 -0
  90. data/templates/project/notes/character.%character.name_for_file%.markdown.template +15 -0
  91. data/templates/{default → project}/notes/images/cover.png +0 -0
  92. data/templates/{default/notes/stylesheets/stylesheet.css.template → project/notes/stylesheets/stylesheet.css} +0 -0
  93. data/templates/{default → project}/settings/actions/local_action.rb.example +1 -1
  94. data/templates/project/settings/config.rb.template +70 -0
  95. data/templates/project/settings/html_translators/example_translator.rb +29 -0
  96. data/templates/{default → project}/settings/wordcount.template +1 -1
  97. data/test/answers01.yml +30 -0
  98. data/test/helper.rb +62 -39
  99. data/test/misc/config.rb +5 -7
  100. data/test/test_epubforge.rb +18 -14
  101. data/test/{test_htmlizers.rb → test_html_translators.rb} +4 -8
  102. data/test/test_template_evaluator.rb +42 -0
  103. data/test/test_utils.rb +0 -11
  104. metadata +186 -189
  105. data/config/actions/gitify.rb +0 -72
  106. data/config/actions/init.rb +0 -138
  107. data/config/actions/notes_to_epub.rb +0 -18
  108. data/config/actions/notes_to_kindle.rb +0 -17
  109. data/config/htmlizers.rb +0 -70
  110. data/lib/action/actions_lookup.rb +0 -45
  111. data/lib/core_extensions/array.rb +0 -5
  112. data/lib/core_extensions/nil_class.rb +0 -5
  113. data/lib/core_extensions/object.rb +0 -5
  114. data/lib/epub/assets/html.rb +0 -8
  115. data/lib/epub/assets/markdown.rb +0 -8
  116. data/lib/epub/assets/textile.rb +0 -8
  117. data/lib/epub/assets/xhtml.rb +0 -8
  118. data/lib/epub/packager.rb +0 -16
  119. data/lib/utils/action_loader.rb +0 -7
  120. data/lib/utils/class_loader.rb +0 -102
  121. data/lib/utils/directory_builder.rb +0 -181
  122. data/lib/utils/file_path.rb +0 -152
  123. data/lib/utils/html_translator.rb +0 -100
  124. data/lib/utils/html_translator_queue.rb +0 -70
  125. data/lib/utils/htmlizer.rb +0 -92
  126. data/lib/utils/root_path.rb +0 -20
  127. data/lib/utils/settings.rb +0 -146
  128. data/lib/utils/template_evaluator.rb +0 -20
  129. data/templates/default/book/chapter-%i%.markdown.sequence +0 -4
  130. data/templates/default/book/title_page.markdown.template +0 -4
  131. data/templates/default/notes/character.named.markdown.template +0 -4
  132. data/templates/default/payload.rb +0 -65
  133. data/templates/default/settings/config.rb.form +0 -55
  134. data/templates/default/settings/htmlizers.rb +0 -0
  135. data/test/test_directory_builder.rb +0 -141
@@ -2,33 +2,36 @@ require 'time' # for Time.parse
2
2
 
3
3
  module EpubForge
4
4
  module Action
5
- class WordCount < ThorAction
6
- include_standard_options
5
+ class WordCount < Action2
6
+ # include_standard_options
7
7
 
8
8
  WORD_COUNT_FILE = "wordcount"
9
9
 
10
- description "Manage your word counts for book chapters and notes. wc (standalone) is main command"
11
- keywords :wc, :count
12
- usage "#{$PROGRAM_NAME} count <project_directory>"
13
-
14
- desc( "wc", "Countify words.")
15
- def wc( *args )
16
- before_start
17
- @report = { "Notes" => wc_one_folder( @project.notes_dir ),
18
- "Book" => wc_one_folder( @project.book_dir ) }
10
+ define_action( "wc" ) do |action|
11
+ action.help( "Manage your word counts for book chapters and notes. wc (standalone) is main command" )
12
+
13
+ # keywords :wc
14
+ # usage "#{$PROGRAM_NAME} count <project_directory>"
15
+ #
16
+ # desc( "wc", "Countify words.")
17
+ action.execute do
18
+ debugger unless @project
19
+ @report = { "Notes" => wc_one_folder( @project.notes_dir ),
20
+ "Book" => wc_one_folder( @project.book_dir ) }
19
21
 
20
- load_word_count_history
21
- calculate_todays_word_count
22
- append_word_count_history( @report )
23
- print_report
22
+ load_word_count_history
23
+ calculate_todays_word_count
24
+ append_word_count_history( @report )
25
+ print_report
24
26
 
25
- say_all_is_well "Done"
26
- @report
27
+ say_all_is_well( "Done" )
28
+ @report
29
+ end
27
30
  end
28
31
 
29
32
  protected
30
33
  def wc_one_folder( foldername )
31
- foldername.glob( ext: EpubForge::Epub::PAGE_FILE_EXTENSIONS ).inject(0) do |count, file|
34
+ foldername.glob( ext: EpubForge::Builder::PAGE_FILE_EXTENSIONS ).inject(0) do |count, file|
32
35
  count += wc_one_file( file )
33
36
  end
34
37
  end
@@ -116,12 +119,11 @@ module EpubForge
116
119
  end
117
120
 
118
121
  def print_report
119
- say "", BLUE
120
- say "Wordcount", BLUE
121
- say "---------", BLUE
122
- say "Notes: #{@report["Notes"]}", BLUE
123
- say "Book: #{@report["Book"]}", BLUE
124
- say "Today: #{@report["Today"]}", BLUE
122
+ say( "\nWordcount", :blue )
123
+ say( "---------", :blue )
124
+ say( "Notes: #{@report["Notes"]}", :blue )
125
+ say( "Book: #{@report["Book"]}", :blue )
126
+ say( "Today: #{@report["Today"]}", :blue )
125
127
  end
126
128
  end
127
129
  end
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class Generate < ThorAction
3
+ class Generate < Action
4
4
  keywords :new, :generate, :add
5
5
  description "Add something to the project (a new chapter, or a new wiki entry, etc.)"
6
6
 
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class GitBackup < ThorAction
3
+ class GitBackup < Action
4
4
  description "commit your project to the git repo and back it up"
5
5
  keywords :backup, :save, :commit
6
6
  usage "#{$PROGRAM_NAME} commit <project directory (optional if current dir)> \"optional message\""
@@ -16,7 +16,7 @@ module EpubForge
16
16
  return false
17
17
  end
18
18
 
19
- `cd #{@project.target_dir} && git commit -a -m "#{@message}" && git push`
19
+ `cd #{@project.root_dir} && git commit -a -m "#{@message}" && git push`
20
20
  end
21
21
  end
22
22
  end
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class Globals < ThorAction
3
+ class Globals < Action
4
4
  description "Set up global defaults for things like author name, publisher, etc."
5
5
  keywords :global
6
6
  usage "#{$PROGRAM_NAME} global <key>=\"<val>\" or global -i <asks you for defaults>"
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class Kindle < ThorAction
3
+ class Kindle < Action
4
4
  description "Create a .mobi book and try to push it to your Kindle (conversion requires Calibre)"
5
5
  keywords :kindle, :push, :b2k
6
6
  usage "#{$PROGRAM_NAME} b2k <project_directory>"
@@ -11,8 +11,8 @@ module EpubForge
11
11
  desc( "do:kindle", "<<OBSOLETE>> Turn your .epub file into a .mobi file. Check to see if your Kindle is connected, then pushes it." )
12
12
  def do( project, *args )
13
13
  @project = project
14
- @src_epub = @project.filename_for_epub_book.fwf_filepath
15
- @dst_mobi = @project.filename_for_mobi_book.fwf_filepath
14
+ @src_epub = @project.filename_for_book.ext("epub")
15
+ @dst_mobi = @project.filename_for_book.ext("mobi")
16
16
  end
17
17
 
18
18
  protected
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class LocalAction < ThorAction
3
+ class LocalAction < Action
4
4
  TEMPLATE = EpubForge.root( "templates", "default", "settings", "actions", "local_action.rb.example" )
5
5
 
6
6
  method_option :desc, :type => :string, :default => "Describe this module"
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class Forge < ThorAction
3
+ class Forge < Action
4
4
  # TODO: These should be user-specific settings
5
5
  KINDLE_DEVICE_DIR = "/".fwf_filepath.join( "Volumes", "Kindle" )
6
6
  KINDLE_PUSH_DIR = KINDLE_DEVICE_DIR.join( "documents", "fic-mine" )
@@ -14,8 +14,8 @@ module EpubForge
14
14
 
15
15
  @args = args
16
16
  @push, @push_to = self.push?
17
- @src_epub = @project.filename_for_epub_book.fwf_filepath
18
- @dst_mobi = @project.filename_for_mobi_book.fwf_filepath
17
+ @src_epub = @project.filename_for_book.ext("epub")
18
+ @dst_mobi = @project.filename_for_book.ext("mobi")
19
19
 
20
20
  @regenerate_epub = !!( @args.include?( "--no-cache" ) )
21
21
 
@@ -0,0 +1,19 @@
1
+ # Should be obsolete
2
+ # module EpubForge
3
+ # module Action
4
+ # class Forge < Action
5
+ # include_standard_options
6
+ #
7
+ # desc( "forge:notes", "Wraps your story notes up in a .epub (ebook) file." )
8
+ # def notes( *args )
9
+ # before_start
10
+ # builder = EpubForge::Builder::Epub.new( @project, book_dir: @project.root_dir.join("notes"),
11
+ # page_order: @project.config[:pages][:notes] )
12
+ # builder.build
13
+ # builder.package( @project.filename_for_notes.ext("epub") )
14
+ # builder.clean
15
+ # puts "Done building epub <#{@project.filename_for_notes.ext("epub")}>"
16
+ # end
17
+ # end
18
+ # end
19
+ # end
@@ -0,0 +1,18 @@
1
+ # Should be obsolete
2
+ # module EpubForge
3
+ # module Action
4
+ # class NotesToKindle < Kindle
5
+ # description "Create a .mobi book from the notes and try to push it to your Kindle"
6
+ # keywords :n2k
7
+ # usage "#{$PROGRAM_NAME} n2k <project_directory>"
8
+ #
9
+ # def do( project, args )
10
+ # @project = project
11
+ # @src_epub = @project.filename_for_notes.ext("epub")
12
+ # @dst_mobi = @project.filename_for_notes.ext("mobi")
13
+ #
14
+ # mobify
15
+ # end
16
+ # end
17
+ # end
18
+ # end
@@ -21,7 +21,7 @@ module EpubForge
21
21
  end
22
22
  end
23
23
 
24
- class Spell < ThorAction
24
+ class Spell < Action
25
25
  SPELL_CORRECTION_FILE = "spellings"
26
26
 
27
27
  description "Highlight possible misspellings, as defined by the settings file /#{SPELL_CORRECTION_FILE}."
@@ -1,14 +1,14 @@
1
1
  module EpubForge
2
2
  module Action
3
- class Version < ThorAction
4
- description "Print version (v.#{EpubForge::VERSION}, to save you the trouble)"
3
+ class Version < Action
4
+ description "Print version (v.#{EpubForge.version}, to save you the trouble)"
5
5
  keywords :version, :"--version"
6
6
  usage "#{$PROGRAM_NAME} -v"
7
7
  project_not_required
8
8
 
9
9
  desc( "do:version", "print out help for the various actions.")
10
10
  def do( project, *args )
11
- puts "epubforge v. #{EpubForge::VERSION}, Copyright Bryce Anderson. MIT License."
11
+ puts "epubforge v. #{EpubForge.version}, Copyright Bryce Anderson. MIT License."
12
12
  end
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  module EpubForge
2
2
  module Action
3
- class WrapSceneNotesInHiddenDiv < ThorAction
3
+ class WrapSceneNotesInHiddenDiv < Action
4
4
  description "Assumes scenes are in book/scene-XXXX.markdown, and that the scene description is above the first horizontal row (a.k.a. ***** in Markdown)."
5
5
  keywords :wrap_scene_notes
6
6
  usage "#{$PROGRAM_NAME} wrap_scene_notes<project_directory (optional if current directory)>\n\tfollow with 'undo' to reverse transformation."
@@ -0,0 +1,8 @@
1
+ EpubForge::Utils::Converter.new do
2
+ label :epub_to_mobi_calibre
3
+ input_format :epub
4
+ output_format :mobi
5
+ executable "ebook-convert"
6
+
7
+ help "To use #{label}, download the latest version of Calibre at http://calibre-ebook.com/download, then make sure 'ebook-convert' is in your command line's search path."
8
+ end
@@ -0,0 +1,11 @@
1
+ # My thinking is that, once the direct-from-source files are generated, further file formats can
2
+ # be handled by "converters" that take generated file X and convert to output file Y.
3
+
4
+ EpubForge::Utils::Converter.new do
5
+ label :epub_to_mobi_kindlegen
6
+ input_format :epub
7
+ output_format :mobi
8
+ executable "kindlegen"
9
+ command "{{x}} {{src}} -o {{dst}}"
10
+ help "Kindlegen is a command-line tool by Amazon, which can be downloaded at http://www.amazon.com/gp/feature.html?docId=1000765211"
11
+ end
@@ -0,0 +1,9 @@
1
+ EpubForge::Utils::HtmlTranslator.new do
2
+ name :epubforge_markdown
3
+ format :markdown
4
+ group :default # the default is :user, so user-defined ones don't have to set it
5
+
6
+ custom_proc do |filepath, *args|
7
+ Kramdown::Document.new( filepath.read ).to_html
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # # Uncomment if you'd rather use the multimarkdown executable
2
+ #
3
+ # EpubForge::Utils::HtmlTranslator.new do
4
+ # name :epubforge_multimarkdown
5
+ # format :markdown
6
+ # group :default # the default is :user, so user-defined ones don't have to set it
7
+ # executable "multimarkdown"
8
+ # cmd "{{x}} {{o}} {{f}}"
9
+ # # opts "" # the default
10
+ # end
@@ -0,0 +1,10 @@
1
+ # # Uncomment if you'd rather use the pandoc executable
2
+ #
3
+ # EpubForge::Utils::HtmlTranslator.new do
4
+ # name :epubforge_pandoc_markdown
5
+ # format :markdown
6
+ # group :default
7
+ # executable "pandoc"
8
+ # cmd "{{x}} {{o}} {{f}}"
9
+ # opts "--from=markdown --to=html"
10
+ # end
@@ -0,0 +1,8 @@
1
+ EpubForge::Utils::HtmlTranslator.new do
2
+ name :epubforge_pandoc_textile
3
+ format :textile
4
+ group :default
5
+ executable "pandoc"
6
+ cmd "{{x}} {{o}} {{f}}"
7
+ opts "--from=textile --to=html"
8
+ end
@@ -0,0 +1,7 @@
1
+ EpubForge::Utils::HtmlTranslator.new do
2
+ name :epubforge_xhtml
3
+ format :xhtml
4
+ group :default
5
+ executable "false"
6
+ cmd "cat {{f}}"
7
+ end
@@ -0,0 +1,9 @@
1
+ # Would be nice to detect and strip out the outer tags
2
+ # leaving only the content.
3
+ EpubForge::Utils::HtmlTranslator.new do
4
+ name :fallback_html
5
+ format :html
6
+ group :fallback
7
+ executable "false"
8
+ cmd "cat {{f}}"
9
+ end
@@ -0,0 +1,8 @@
1
+ # Emergency backups
2
+ EpubForge::Utils::HtmlTranslator.new do
3
+ name :fallback_markdown
4
+ format :markdown
5
+ group :fallback
6
+ executable "false"
7
+ cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
8
+ end
@@ -0,0 +1,7 @@
1
+ EpubForge::Utils::HtmlTranslator.new do
2
+ name :fallback_textile
3
+ format :textile
4
+ group :fallback
5
+ executable "false"
6
+ cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
7
+ end
@@ -0,0 +1,8 @@
1
+
2
+ EpubForge::Utils::HtmlTranslator.new do
3
+ name :fallback_txt
4
+ format :txt
5
+ group :fallback
6
+ executable "false"
7
+ cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
8
+ end
@@ -0,0 +1,7 @@
1
+ EpubForge::Utils::HtmlTranslator.new do
2
+ name :fallback_unknown
3
+ format :unknown
4
+ group :fallback
5
+ executable "false"
6
+ cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
7
+ end
data/lib/epubforge.rb CHANGED
@@ -1,63 +1,41 @@
1
- # I don't know if mentioning them in the Gemfile automatically requires them.
2
- # Let's find out.
3
- # require 'readline'
4
- # require 'singleton'
5
- # require 'builder'
6
- require 'thor'
7
- require 'optparse'
8
- require 'nokogiri'
9
- require 'xdg' # keep configuration files in sane places
10
- require 'debugger'
11
- require 'erb'
12
- require 'singleton'
13
- require 'builder'
14
- require 'pathname'
15
- require 'tmpdir' # Dir.mktmpdir
16
- require 'net/http'
17
- require 'open-uri' # needed by Utils::Downloader
18
- require 'yaml'
19
- require 'rbconfig'
20
- require 'fun_with_files'
21
- require 'fun_with_configurations'
22
-
23
- EpubForge = Module.new
24
- EpubForge::DEBUG = false
25
- # EpubForge.root responds with the gem directory
26
- FunWith::Files::RootPath.rootify( EpubForge, __FILE__.fwf_filepath.dirname.up )
27
- EpubForge::VERSION = EpubForge.root("VERSION").read
28
-
29
- def debugger?
30
- debugger if debugging?
31
- end
32
-
33
- def debugging?
34
- EpubForge::DEBUG
35
- end
36
-
37
-
38
- require_relative 'core_extensions/array'
39
- require_relative 'core_extensions/kernel'
40
- require_relative 'core_extensions/nil_class'
41
- require_relative 'core_extensions/object'
42
- require_relative 'core_extensions/string'
43
-
44
-
45
- require_relative 'utils/directory_builder'
46
- require_relative 'utils/downloader'
47
- require_relative 'utils/file_orderer'
48
- require_relative 'utils/misc'
49
- require_relative 'utils/class_loader'
50
- require_relative 'utils/action_loader'
51
- require_relative 'utils/template_evaluator'
52
-
53
-
1
+ require "thor"
2
+ require "optparse"
3
+ require "nokogiri"
4
+ require "xdg"
5
+ require "debugger"
6
+ require "erb"
7
+ require "singleton"
8
+ require "builder" # XML Builder, not our builder
9
+ require "pathname"
10
+ require "tmpdir"
11
+ require "rbconfig"
12
+ require "kramdown"
13
+ require "fun_with_gems"
14
+ require "fun_with_templates"
15
+ require "fun_with_configurations"
16
+ require "fun_with_string_colors"
17
+ require "fun_with_patterns"
18
+
19
+ FunWith::StringColors.activate
20
+ String.colorize( true )
21
+ FunWith::Patterns::GetAndSet.activate
22
+
23
+ FunWith::Gems.make_gem_fun( "EpubForge" )
54
24
 
55
25
  module EpubForge
26
+ USER_SETTINGS = XDG['CONFIG_HOME'].fwf_filepath( "epubforge" )
27
+ DEBUG = false
28
+
56
29
  ACTIONS_DIR = EpubForge.root.join( "config", "actions" )
30
+ USER_ACTIONS_DIR = USER_SETTINGS.join( "actions" )
31
+ CONVERTERS_DIR = EpubForge.root.join( "config", "converters" )
32
+ USER_CONVERTERS_DIR = USER_SETTINGS.join( "converters" )
33
+
34
+ HTML_TRANSLATORS_DIR = EpubForge.root.join( "config", "html_translators" )
35
+ USER_HTML_TRANSLATORS_DIR = USER_SETTINGS.join( "html_translators" )
36
+
57
37
  TEMPLATES_DIR = EpubForge.root.join( "templates" )
58
- USER_SETTINGS = XDG['CONFIG_HOME'].to_s.fwf_filepath.join( "epubforge" )
59
38
  USER_GLOBALS_FILE = USER_SETTINGS.join( "globals.rb" )
60
- USER_ACTIONS_DIR = USER_SETTINGS.join( "actions" )
61
39
 
62
40
  puts "Warning: Cannot create user settings folder." unless USER_ACTIONS_DIR.touch_dir
63
41
  puts "Warning: Cannot create globals file." unless USER_GLOBALS_FILE.touch
@@ -65,32 +43,9 @@ end
65
43
 
66
44
  EpubForge.install_fwc_config_from_file( EpubForge::USER_GLOBALS_FILE )
67
45
 
68
- EpubForge.config.activation_key = rand(20**32).to_s(16).gsub(/(.{5})/, '\1-')[0..-2]
69
-
70
- require_relative 'utils/html_translator'
71
- require_relative 'utils/html_translator_queue'
72
- require_relative 'utils/htmlizer'
73
-
74
- require_relative 'action/file_transformer'
75
- require_relative 'action/run_description'
76
- require_relative 'action/thor_action'
77
- require_relative 'action/actions_lookup'
78
- require_relative 'action/runner'
79
- require_relative 'action/cli_command'
80
- require_relative 'action/cli_sequence'
81
- require_relative 'custom_helpers'
82
- require_relative 'epub/builder'
83
- require_relative 'epub/packager'
84
- require_relative 'epub/assets/asset'
85
- require_relative 'epub/assets/page'
86
- require_relative 'epub/assets/html'
87
- require_relative 'epub/assets/markdown'
88
- require_relative 'epub/assets/textile'
89
- require_relative 'epub/assets/image'
90
- require_relative 'epub/assets/stylesheet'
91
- require_relative 'epub/assets/xhtml'
92
- require_relative 'project/project'
46
+ EpubForge.extend( EpubForge::CustomHelpers )
93
47
 
94
- puts "Requirements loaded" if debugging?
48
+ EpubForge::Action::Action2.loader_pattern_load_from_dir( EpubForge::ACTIONS_DIR, EpubForge::USER_ACTIONS_DIR )
49
+ EpubForge::Utils::Converter.loader_pattern_load_from_dir( EpubForge::CONVERTERS_DIR, EpubForge::USER_CONVERTERS_DIR )
50
+ EpubForge::Utils::HtmlTranslator.loader_pattern_load_from_dir( EpubForge::HTML_TRANSLATORS_DIR, EpubForge::USER_HTML_TRANSLATORS_DIR )
95
51
 
96
- puts "Done with tests inside epubforge.rb" if debugging?