epubforge 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/Gemfile +26 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.rdoc +26 -0
  4. data/Rakefile +71 -0
  5. data/VERSION +1 -0
  6. data/bin/epubforge +10 -0
  7. data/config/actions/book_to_epub.rb +20 -0
  8. data/config/actions/generate.rb +24 -0
  9. data/config/actions/generate_chapter.rb +26 -0
  10. data/config/actions/git_backup.rb +23 -0
  11. data/config/actions/gitify.rb +72 -0
  12. data/config/actions/globals.rb +77 -0
  13. data/config/actions/help.rb +21 -0
  14. data/config/actions/init.rb +137 -0
  15. data/config/actions/kindle.rb +68 -0
  16. data/config/actions/notes_to_epub.rb +20 -0
  17. data/config/actions/notes_to_kindle.rb +17 -0
  18. data/config/actions/word_count.rb +126 -0
  19. data/config/actions/wrap_scene_notes_in_hidden_div.rb +118 -0
  20. data/config/htmlizers.rb +62 -0
  21. data/lib/action/actions_lookup.rb +41 -0
  22. data/lib/action/cli_command.rb +72 -0
  23. data/lib/action/cli_sequence.rb +55 -0
  24. data/lib/action/file_transformer.rb +59 -0
  25. data/lib/action/run_description.rb +24 -0
  26. data/lib/action/runner.rb +122 -0
  27. data/lib/action/thor_action.rb +149 -0
  28. data/lib/core_extensions/array.rb +5 -0
  29. data/lib/core_extensions/kernel.rb +42 -0
  30. data/lib/core_extensions/nil_class.rb +5 -0
  31. data/lib/core_extensions/object.rb +5 -0
  32. data/lib/core_extensions/string.rb +37 -0
  33. data/lib/custom_helpers.rb +60 -0
  34. data/lib/epub/assets/asset.rb +11 -0
  35. data/lib/epub/assets/html.rb +8 -0
  36. data/lib/epub/assets/image.rb +18 -0
  37. data/lib/epub/assets/markdown.rb +8 -0
  38. data/lib/epub/assets/page.rb +32 -0
  39. data/lib/epub/assets/stylesheet.rb +22 -0
  40. data/lib/epub/assets/textile.rb +8 -0
  41. data/lib/epub/builder.rb +270 -0
  42. data/lib/epub/packager.rb +16 -0
  43. data/lib/epubforge.rb +97 -0
  44. data/lib/errors.rb +8 -0
  45. data/lib/project/project.rb +65 -0
  46. data/lib/utils/action_loader.rb +7 -0
  47. data/lib/utils/class_loader.rb +83 -0
  48. data/lib/utils/directory_builder.rb +181 -0
  49. data/lib/utils/downloader.rb +58 -0
  50. data/lib/utils/file_orderer.rb +45 -0
  51. data/lib/utils/file_path.rb +152 -0
  52. data/lib/utils/html_translator.rb +99 -0
  53. data/lib/utils/html_translator_queue.rb +70 -0
  54. data/lib/utils/htmlizer.rb +92 -0
  55. data/lib/utils/misc.rb +20 -0
  56. data/lib/utils/root_path.rb +20 -0
  57. data/lib/utils/settings.rb +146 -0
  58. data/lib/utils/template_evaluator.rb +20 -0
  59. data/templates/default/book/afterword.markdown.template +4 -0
  60. data/templates/default/book/chapter-%i%.markdown.sequence +4 -0
  61. data/templates/default/book/foreword.markdown.template +6 -0
  62. data/templates/default/book/images/cover.png +0 -0
  63. data/templates/default/book/stylesheets/stylesheet.css.template +2 -0
  64. data/templates/default/book/title_page.markdown.template +4 -0
  65. data/templates/default/notes/character.named.markdown.template +4 -0
  66. data/templates/default/notes/stylesheets/stylesheet.css.template +2 -0
  67. data/templates/default/payload.rb +65 -0
  68. data/templates/default/settings/actions/local_action.rb.example +14 -0
  69. data/templates/default/settings/config.rb.form +55 -0
  70. data/templates/default/settings/htmlizers.rb +0 -0
  71. data/templates/default/settings/wordcount.template +6 -0
  72. data/test/helper.rb +22 -0
  73. data/test/misc/config.rb +7 -0
  74. data/test/sample_text/sample.markdown +30 -0
  75. data/test/sample_text/sample.textile +24 -0
  76. data/test/test_custom_helpers.rb +22 -0
  77. data/test/test_directory_builder.rb +141 -0
  78. data/test/test_epf_root.rb +9 -0
  79. data/test/test_epubforge.rb +164 -0
  80. data/test/test_htmlizers.rb +24 -0
  81. data/test/test_runner.rb +15 -0
  82. data/test/test_utils.rb +39 -0
  83. metadata +328 -0
data/lib/utils/misc.rb ADDED
@@ -0,0 +1,20 @@
1
+ module EpubForge
2
+ module Utils
3
+ class Misc
4
+ # stolen from Rails constantize method, via StackOverflow
5
+ # http://stackoverflow.com/questions/3314475/how-do-i-get-class-object-from-string-abc-in-ruby
6
+ def self.constantize( str )
7
+ names = str.split('::')
8
+ names.shift if names.empty? || names.first.empty?
9
+
10
+ constant = Object
11
+
12
+ names.each do |name|
13
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
14
+ end
15
+
16
+ constant
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module EpubForge
2
+ module Utils
3
+ module RootPath
4
+ def root( *args )
5
+ if args.length > 0
6
+ args.unshift( @root_path )
7
+ FilePath.new( *args )
8
+ else
9
+ FilePath.new( @root_path )
10
+ end
11
+ end
12
+
13
+ def set_root_path( path )
14
+ @root_path = FilePath.new( path )
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ EpubForge.extend EpubForge::Utils::RootPath
@@ -0,0 +1,146 @@
1
+ # have to make a tweak to configurator to allow it to work with project class instances
2
+ module Configurator
3
+ def self.extended(base)
4
+ if base.respond_to?(:class_eval)
5
+ base.class_eval { remove_instance_variable(:@configuration) if defined? @configuration }
6
+ else
7
+ puts "EXTENDING #{base} AS WE SPEAK"
8
+ base.instance_variable_set( :@got_extended, true )
9
+ # base.instance_variable_set( :@configuration, nil )
10
+ end
11
+ end
12
+ end
13
+
14
+ module EpubForge
15
+ module Utils
16
+ class Settings
17
+ def self.thing_to_configure( *args )
18
+ if( args.length >= 1 )
19
+ @thing_to_configure = args.first
20
+ end
21
+ @thing_to_configure
22
+ end
23
+
24
+ # Takes a configurator object and (optionally) a settings file to write it out to.
25
+ def initialize( configable, file = nil )
26
+ @configable = configable
27
+ @file = file.fwf_filepath.expand if file
28
+ install_configuration
29
+ end
30
+
31
+ def act_on_string( keqv, set = :set )
32
+ k,v = parse_kv( keqv )
33
+ if set == :unset
34
+ unset( k )
35
+ elsif set == :set
36
+ set( k, v )
37
+ end
38
+ end
39
+
40
+ def set( key, val )
41
+ setting, last_key = descend_key( key )
42
+ setting[last_key] = val
43
+ end
44
+
45
+ def unset( key )
46
+ setting, last_key = descend_key( key )
47
+ setting.delete( last_key )
48
+ end
49
+
50
+ def write_settings_file( settings_file = nil )
51
+ settings_file ||= @file
52
+ settings_file = settings_file.fwf_filepath
53
+ @depth = 0
54
+ str = indented_line("EpubForge::Utils::Settings.thing_to_configure.config do")
55
+ str += write_config( @configable.config.to_hash )
56
+ str += indented_line("end")
57
+ settings_file.write( str )
58
+ end
59
+
60
+ protected
61
+ def install_configuration
62
+ self.class.thing_to_configure( @configable )
63
+ self.class.thing_to_configure.extend( Configurator )
64
+ require @file
65
+ self.class.thing_to_configure( nil )
66
+ end
67
+
68
+ def indented_line( str )
69
+ puts " " * @depth + str + "\n"
70
+ " " * @depth + str + "\n"
71
+ end
72
+
73
+ def write_config( h )
74
+ str = ""
75
+ @depth += 2
76
+ for k, v in h
77
+ if v.is_a?(Hash)
78
+ str += indented_line( "#{k} do" )
79
+ str += write_config( v )
80
+ str += indented_line( "end" )
81
+ else
82
+ str += indented_line( "#{k} #{stringify_value( v )}" )
83
+ end
84
+ end
85
+ @depth -= 2
86
+
87
+ str
88
+ end
89
+
90
+ def stringify_value( v )
91
+ case v
92
+ when Regexp
93
+ "/#{v.source}/"
94
+ when Numeric
95
+ "#{v}"
96
+ when String
97
+ escape_string( v )
98
+ when FunWith::Files::FilePath
99
+ escape_string( v ) + ".fwf_filepath"
100
+ when Array # TODO: Is there a way to enter arrays?
101
+ "[ #{ v.map{ |item| stringify_value(item) }.join(', ') } ]"
102
+ when NilClass
103
+ "nil"
104
+ when TrueClass
105
+ "true"
106
+ when FalseClass
107
+ "false"
108
+ end
109
+ end
110
+
111
+ def escape_string( s )
112
+ s.inspect
113
+ end
114
+
115
+ # If given a hierarchical setting key like git:host:url,
116
+ # returns the hash attached to config[:git][:host], so the caller can say
117
+ # rval[:url] = "bannedsorcery.com". Creates empty hashes as it descends,
118
+ # if neccessary.
119
+ def descend_key( k )
120
+ keychain = k.split(":").map{ |key| :"#{key}" }
121
+
122
+ s = @configable.config
123
+
124
+ for key in keychain[0..-2]
125
+ s[key] ||= {}
126
+ s = s[key]
127
+ end
128
+
129
+ [s, keychain.last]
130
+ end
131
+
132
+ def parse_kv( str )
133
+ if m = str.match( /^([a-z0-9_:]+)=(.*)$/ )
134
+ discard, k, v = m.to_a
135
+ elsif m = str.match( /^([a-z0-9_:]+)$/ )
136
+ discard, k = m.to_a
137
+ v = nil
138
+ else
139
+ k = v = nil
140
+ end
141
+
142
+ [k, v]
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,20 @@
1
+ module EpubForge
2
+ module Utils
3
+ class TemplateEvaluator
4
+ attr_reader :content, :vars, :result
5
+ def initialize( content, vars = {} )
6
+ if content.is_a?(Pathname) && content.file?
7
+ @content = @content.read
8
+ else
9
+ @content = content.to_s
10
+ end
11
+
12
+ @vars = vars
13
+
14
+ @result = with_locals(@vars) do
15
+ ERB.new( @content ).result( binding )
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ You made it all the way through the book
2
+ ========================================
3
+
4
+ When I started writing this book, I had no idea someone would make it all the way to the end. Well done. Now go find something else to do.
@@ -0,0 +1,4 @@
1
+ Chapter <%= @i %>
2
+ ========<%= "=" * @i.to_s.length %>
3
+
4
+
@@ -0,0 +1,6 @@
1
+ Foreword
2
+ ========
3
+
4
+ I dedicate the book to me, without whom none of this would be written.
5
+
6
+ And to my cat, for finally getting off the keyboard and letting me type.
@@ -0,0 +1,2 @@
1
+ div#epubforge_scene_description{ display: none }
2
+
@@ -0,0 +1,4 @@
1
+ The Adventures of Writer-Man!
2
+ =============================
3
+
4
+ by Annotatia Von Helmermurmer
@@ -0,0 +1,4 @@
1
+ George
2
+ ======
3
+
4
+ He's just a guy, y'know?
@@ -0,0 +1,2 @@
1
+ div#epubforge_scene_description{ display: none }
2
+
@@ -0,0 +1,65 @@
1
+ dir '/'
2
+ dir 'book'
3
+ template 'title_page.markdown'
4
+ template 'foreword.markdown'
5
+ template 'afterword.markdown'
6
+ sequence 'scene-{04i}.markdown'
7
+ dir 'images'
8
+ file 'cover.png'
9
+ dir 'stylesheets'
10
+ template 'stylesheet.css'
11
+ dir 'notes'
12
+ sequence 'character.{name}.markdown'
13
+ dir 'settings'
14
+ template 'config'
15
+ file 'htmlizers.rb'
16
+ template 'wordcount'
17
+ dir 'actions'
18
+ file 'local_action.rb.example'
19
+
20
+
21
+ class Munition
22
+ end
23
+
24
+ class FileSequence < Munition
25
+ end
26
+
27
+ class DirectorySequence < Munition
28
+ end
29
+
30
+ class TemplateFile < Munition
31
+ end
32
+
33
+
34
+
35
+ class Payload
36
+ def initialize( src, &block )
37
+ @munitions = []
38
+ yield self if block_given?
39
+ end
40
+
41
+ def dir( name, &block )
42
+
43
+ yield if block_given?
44
+ end
45
+
46
+ def root( dir = nil )
47
+ @root = dir.fwf_filepath if dir
48
+ @root
49
+ end
50
+
51
+ def sequence( name, count )
52
+
53
+ end
54
+
55
+ def deploy( dst )
56
+ @munitions.each do |munition|
57
+ munition.deploy( dst )
58
+ end
59
+ end
60
+ end
61
+
62
+ Template::Payload.new do |t|
63
+ dir.template
64
+
65
+ end
@@ -0,0 +1,14 @@
1
+ module EpubForge
2
+ module Action
3
+ class ActionFromProjectActionsDirectory < ThorAction
4
+ description "Use this file in the actions/ folder as a template for your custom actions."
5
+ keywords :project_action
6
+ usage "#{$PROGRAM_NAME} project_action"
7
+
8
+
9
+ def do( project, *args )
10
+ puts "Do something to your project."
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,55 @@
1
+ # Used by epubforge.
2
+ FunWith::Configurations::Config.new do
3
+ metadata do
4
+ name "<%= config[:title] || "My Book" %>" # The title of the book
5
+ author "<%= config[:author] || "Author" %>" # Your moniker. Your Nom de Plume. The thing people say to get your attention.
6
+ license "<%= config[:license] || "All Rights Reserved" %>"
7
+ publisher "<%= config[:publisher] || 'My Publisher' %>"
8
+ original_publication "<%= config[:original_publication] || Time.now.strftime('%Y-%m-%d') %>" # The year this work was first published
9
+ end
10
+
11
+ filename "<%= config[:title].epf_underscorize %>" # The default filename for your ebook (no extension).
12
+
13
+
14
+ <% if config[:git] -%>
15
+ ############### GOT GIT? #####################################
16
+ git do
17
+ repo_folder "<%= config[:git][:repo] %>"
18
+ remote_host "<%= config[:git][:host] %>"
19
+ remote_user "<%= config[:git][:user] %>"
20
+ repo_id "<%= config[:git][:repo_id] %>"
21
+ end
22
+ ############### /GOT GIT? #####################################
23
+ <% end -%>
24
+
25
+
26
+ # Any pages not listed here will be added
27
+ # to the ebook after the listed pages, in alphabetical order of
28
+ # filename. In this example, the title_page.markdown file goes first,
29
+ # then the foreword.markdown page, then chapters 1 and 2 (in alphanumeric order)
30
+ # and finally the afterword. Any pages not matched will be put after the
31
+ # set of matched pages.
32
+
33
+ pages do
34
+ book [
35
+ # matches title_page.markdown, title_page.textile, or
36
+ # title_page.(any other valid extension). This will be the first
37
+ # scene/chapter/division in the book.
38
+ "title_page",
39
+ "foreword",
40
+
41
+ # filename matches chapter, followed by anything. If you have a page called
42
+ # chapter_summary that comes after, you might want to define the matcher more
43
+ # specifically, for example 'chapter-\d+' (chapter followed by dash followed by any number of numbers).
44
+ #
45
+ "chapter-*",
46
+ "afterword"
47
+ ]
48
+
49
+ notes [
50
+ # You can set the order that the notes entries appear in below.
51
+ "example89823786",
52
+ "example89723987"
53
+ ]
54
+ end
55
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ # Do not edit this file... I mean, unless you really know what you're doing.
2
+ # Then, please carry on.
3
+ - <%= Time.parse( Time.now.strftime("%Y-%m-%d") ) %>:
4
+ Notes: 0
5
+ Book: 0
6
+
data/test/helper.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'shoulda'
4
+ require 'stringio'
5
+ require 'thor'
6
+
7
+ begin
8
+ Bundler.setup(:default, :development)
9
+ rescue Bundler::BundlerError => e
10
+ $stderr.puts e.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit e.status_code
13
+ end
14
+
15
+ require 'test/unit'
16
+
17
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
18
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
19
+ require 'epubforge'
20
+
21
+ class Test::Unit::TestCase
22
+ end
@@ -0,0 +1,7 @@
1
+ FunWith::Configurations::Config.new do
2
+ wastrel :lance
3
+ obsequious do
4
+ french :raisin
5
+ italian :motorcycle
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ This is a header
2
+ ================
3
+
4
+ This is a paragraph.
5
+
6
+ * This
7
+ * is
8
+ * an
9
+ * unordered
10
+ * list
11
+
12
+ hello
13
+
14
+ 1. This
15
+ 2. is
16
+ 3. an
17
+ 3. ordered
18
+ 3. list
19
+
20
+ hello
21
+
22
+ 1. This
23
+ 1. is
24
+ 1. a sublist
25
+ 2. Next item
26
+ 1. in
27
+ 2. outer
28
+ 3. list
29
+
30
+ [This is a link](http://slashdot.org)
@@ -0,0 +1,24 @@
1
+ h1. This is a header
2
+
3
+ This is a paragraph.
4
+
5
+ p. This is also a paragraph.
6
+
7
+ p. _nicely italicized_, @carefully coded@, and *boldly bolded* text.
8
+
9
+ p(ex). This paragraph has a classname.
10
+
11
+ <pre>
12
+ class A
13
+ def bit( _of )
14
+ Ruby.code( for, you )
15
+ end
16
+ end
17
+ </pre>
18
+
19
+ # a list
20
+ ## with a sublist
21
+ ## another item
22
+
23
+ "A link":http://google.com
24
+
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ class TestCustomHelpers < Test::Unit::TestCase #
4
+ context "Testing collect_stdout" do
5
+ should "not print out" do
6
+ outer = ""
7
+ inner = ""
8
+
9
+ outer = EpubForge.collect_stdout do
10
+ puts "Hello"
11
+ inner = EpubForge.collect_stdout do
12
+ puts "Well this is awkward"
13
+ end
14
+ puts "world!"
15
+ end
16
+
17
+ assert_equal "Hello\nworld!\n", outer, "collect_stdout not working properly"
18
+ assert_equal "Well this is awkward\n", inner, "collect_stdout not working properly"
19
+ puts "============= STDOUT printing again =============="
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,141 @@
1
+ require 'helper'
2
+
3
+ DirBuilder = EpubForge::Utils::DirectoryBuilder
4
+
5
+ class TestDirectoryBuilder < Test::Unit::TestCase
6
+ context "tearing my hair out because shoulda seems borked" do
7
+ should "stop blaming shoulda for my problems" do
8
+ assert true
9
+ end
10
+
11
+ should "realize that assert statements need to be inside should blocks" do
12
+ assert "Okay, okay. I get it. Now lay off me."
13
+ end
14
+
15
+ should "figure out why the hell [].is_a?(Array) returns false" do
16
+ assert_kind_of Array, []
17
+ assert [].is_a?(Array)
18
+ # seems fine here.
19
+ # subclassing Array for use in the EpubForge module seems
20
+ # to be the culprit. Guess I'm not doing that.
21
+ end
22
+ end
23
+
24
+ context "In a temporary directory" do
25
+ should "create a temporary directory" do
26
+ DirBuilder.tmpdir do |b|
27
+ assert_equal DirBuilder, b.class #
28
+ assert b.current_path.exist?
29
+ end
30
+ end
31
+
32
+ should "write data to a new file" do
33
+ DirBuilder.tmpdir do |b|
34
+ assert_equal DirBuilder, b.class # Okay, WTF does this test fail?
35
+ assert b.current_path
36
+ assert b.current_path.exist?
37
+ b.file("widdershins.txt") do |f|
38
+ f << "Hello World"
39
+ f.flush
40
+
41
+ assert b.current_file.exist?
42
+ assert_equal 11, b.current_file.size
43
+ end
44
+ end
45
+ end
46
+
47
+ should "copy files from elsewhere into the directory" do
48
+ DirBuilder.tmpdir do |b|
49
+ assert_equal DirBuilder, b.class
50
+ src = EpubForge.root.join("Gemfile")
51
+ assert src.exist?
52
+
53
+ b.copy( EpubForge.root.join("Gemfile") )
54
+
55
+ gemfile = b.current_path.join("Gemfile")
56
+ assert gemfile.exist?
57
+ assert !gemfile.zero?
58
+ assert_equal 1, gemfile.grep( /jeweler/ ).length
59
+ end
60
+ end
61
+
62
+ should "copy files from elsewhere, renaming the file in the destination" do
63
+ DirBuilder.tmpdir do |b|
64
+ assert_equal DirBuilder, b.class
65
+ assert !b.current_path.join("helpers.rb").exist?
66
+ b.copy( EpubForge.root.join("lib", "custom_helpers.rb"), "helpers.rb" )
67
+ assert b.current_path.join("helpers.rb").exist?
68
+ end
69
+ end
70
+
71
+ should "download random crap from all over the Internet" do
72
+ DirBuilder.tmpdir do |b|
73
+ gist_url = "http://bannedsorcery.com/downloads/testfile.txt"
74
+ gist_text = "This is a file\n==============\n\n**silent**: But _bold_! [Link](http://slashdot.org)\n"
75
+ b.download( gist_url, "gist.txt" )
76
+
77
+ b.file( "gist.txt.2" ) do
78
+ b.download( gist_url )
79
+ end
80
+
81
+ assert b.current_file.nil?
82
+ assert b.current_path.join("gist.txt").exist?
83
+ assert b.current_path.join("gist.txt.2").exist?
84
+ assert_equal gist_text, b.current_path.join("gist.txt").read
85
+ end
86
+ end
87
+
88
+ should "exercise all manner of features to create a complex directory" do
89
+ DirBuilder.tmpdir do |b|
90
+ assert_equal DirBuilder, b.class
91
+ root = EpubForge.root
92
+ gemfile = root.join("Gemfile")
93
+ b.copy( gemfile )
94
+ assert gemfile.exist?
95
+ assert_equal gemfile.size, b.current_path.join("Gemfile").size
96
+
97
+ b.dir( "earth" ) do
98
+ b.dir( "air") do
99
+ b.dir( "fire" ) do
100
+ b.dir( "water" ) do
101
+ b.file( "hello.txt" )
102
+ b.file << "H"
103
+ b.file << "e"
104
+ b.file << "l"
105
+ b.file << "l"
106
+ b.file << "o"
107
+ end
108
+
109
+ assert b.current_file.nil?
110
+ end
111
+ end
112
+ end
113
+
114
+ assert "Hello", b.current_path.join("earth", "air", "fire", "water", "hello.txt").read
115
+
116
+ b.dir( "fire", "water", "earth", "air" ) do
117
+ assert b.current_path.exist?
118
+ b.copy( EpubForge.root.join("Gemfile"), "Gemfile.example" )
119
+ b.copy( EpubForge.root.join("Gemfile.lock"), "Gemfile.lock.example" )
120
+ b.copy( EpubForge.root.join("Rakefile"), "Rakefile" )
121
+
122
+ for file in %W(Gemfile.example Gemfile.lock.example Rakefile)
123
+ assert b.current_path.join(file).exist?, "#{file} should exist"
124
+ end
125
+ end
126
+
127
+ directory = ["air", "earth", "water", "fire"]
128
+ b.dir( *directory ) do
129
+ b.file( "slipstream.txt", "file contents" )
130
+ end
131
+
132
+ assert b.current_path.join(*directory).exist?
133
+ slip = b.current_path.join(*directory).join("slipstream.txt")
134
+ assert slip.exist?
135
+ assert_equal false, slip.empty?
136
+ assert_equal "file contents", b.current_path.join(*directory).join( "slipstream.txt" ).read
137
+
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ class TestDirectoryBuilder < Test::Unit::TestCase
4
+ context "testing absolute basics" do
5
+ should "provide an accurate root" do
6
+ assert_equal File.expand_path( File.join( File.dirname(__FILE__), ".." ) ), EpubForge.root.to_s
7
+ end
8
+ end
9
+ end