gumdrop 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. data/.gitignore +3 -0
  2. data/ChangeLog.md +13 -0
  3. data/Gemfile +6 -2
  4. data/Gemfile.lock +43 -3
  5. data/Rakefile +37 -21
  6. data/Readme.md +60 -158
  7. data/bin/gumdrop +2 -1
  8. data/gumdrop.gemspec +11 -4
  9. data/lib/gumdrop/builder.rb +164 -0
  10. data/lib/gumdrop/cli/external.rb +14 -9
  11. data/lib/gumdrop/cli/internal.rb +54 -22
  12. data/lib/gumdrop/cli.rb +21 -0
  13. data/lib/gumdrop/content.rb +195 -132
  14. data/lib/gumdrop/data.rb +185 -0
  15. data/lib/gumdrop/data_providers/csv.rb +18 -0
  16. data/lib/gumdrop/data_providers/pstore.rb +25 -0
  17. data/lib/gumdrop/data_providers/sqlite.rb +43 -0
  18. data/lib/gumdrop/data_providers/xml.rb +15 -0
  19. data/lib/gumdrop/data_providers/yaml_and_json.rb +18 -0
  20. data/lib/gumdrop/data_providers/yamldb.rb +18 -0
  21. data/lib/gumdrop/data_providers/yamldoc.rb +12 -0
  22. data/lib/gumdrop/generator.rb +118 -94
  23. data/lib/gumdrop/renderer.rb +272 -0
  24. data/lib/gumdrop/server.rb +36 -27
  25. data/lib/gumdrop/site.rb +283 -338
  26. data/lib/gumdrop/support/compressor.rb +52 -0
  27. data/lib/gumdrop/support/sprockets.rb +14 -23
  28. data/lib/gumdrop/support/stitch.rb +25 -14
  29. data/lib/gumdrop/support/yaml_doc_template.rb +29 -0
  30. data/lib/gumdrop/util/configurable.rb +44 -0
  31. data/lib/gumdrop/util/core_ex.rb +84 -0
  32. data/lib/gumdrop/util/eventable.rb +35 -0
  33. data/lib/gumdrop/util/hash_object.rb +70 -0
  34. data/lib/gumdrop/util/loggable.rb +44 -0
  35. data/lib/gumdrop/util/pager.rb +51 -0
  36. data/lib/gumdrop/{support → util}/proxy_handler.rb +7 -6
  37. data/lib/gumdrop/util/scanner.rb +47 -0
  38. data/lib/gumdrop/util/site_access.rb +16 -0
  39. data/lib/gumdrop/util/view_helpers.rb +50 -0
  40. data/lib/gumdrop/util/yaml_doc.rb +51 -0
  41. data/lib/gumdrop/version.rb +2 -2
  42. data/lib/gumdrop.rb +40 -77
  43. data/specs/content_spec.rb +83 -73
  44. data/specs/fixtures/expected/data-access/from-csv.html +4 -0
  45. data/specs/fixtures/expected/data-access/from-json.html +6 -0
  46. data/specs/fixtures/expected/data-access/from-sqlite.html +5 -0
  47. data/specs/fixtures/expected/data-access/from-xml.html +4 -0
  48. data/specs/fixtures/expected/data-access/from-yaml.html +5 -0
  49. data/specs/fixtures/expected/data-access/from-yamldb.html +5 -0
  50. data/specs/fixtures/expected/data-access/from-yamldoc.html +2 -0
  51. data/specs/fixtures/expected/gen-with-block/as-file.html +1 -0
  52. data/specs/fixtures/expected/gen-with-block/as-plain.html +1 -0
  53. data/specs/fixtures/expected/gen-with-block/layout-nested.html +1 -0
  54. data/specs/fixtures/expected/gen-with-block/layout-nil.html +1 -0
  55. data/specs/fixtures/expected/gen-with-block/layout-wrap.html +1 -0
  56. data/specs/fixtures/expected/gen-with-inline-render/0-as-file.html +4 -0
  57. data/specs/fixtures/expected/gen-with-inline-render/0-as-plain.html +4 -0
  58. data/specs/fixtures/expected/gen-with-inline-render/0-layout-nil.html +4 -0
  59. data/specs/fixtures/expected/gen-with-inline-render/0-layout-sub.html +4 -0
  60. data/specs/fixtures/expected/gen-with-inline-render/0-layout-wrap.html +4 -0
  61. data/specs/fixtures/expected/gen-with-inline-render/1-as-file.html +4 -0
  62. data/specs/fixtures/expected/gen-with-inline-render/1-as-plain.html +4 -0
  63. data/specs/fixtures/expected/gen-with-inline-render/1-layout-nil.html +4 -0
  64. data/specs/fixtures/expected/gen-with-inline-render/1-layout-sub.html +4 -0
  65. data/specs/fixtures/expected/gen-with-inline-render/1-layout-wrap.html +4 -0
  66. data/specs/fixtures/expected/goodbye.html +1 -0
  67. data/specs/fixtures/expected/hello.html +1 -0
  68. data/specs/fixtures/expected/image.png +0 -0
  69. data/specs/fixtures/expected/index.html +47 -0
  70. data/specs/fixtures/expected/js/sprockets-app.js +7 -0
  71. data/specs/fixtures/expected/js/stitch-app.js +65 -0
  72. data/specs/fixtures/expected/js/stitch-app.min.js +5 -0
  73. data/specs/fixtures/expected/js/stitch-app.min.src.js +65 -0
  74. data/specs/fixtures/expected/js/straight.js +8 -0
  75. data/specs/fixtures/expected/js/test-coffee.js +5 -0
  76. data/specs/fixtures/expected/pages/docs/force-abs.html +2 -0
  77. data/specs/fixtures/expected/pages/docs/index.html +2 -0
  78. data/specs/fixtures/expected/partials/hoisted-data.html +3 -0
  79. data/specs/fixtures/expected/partials/nested.html +7 -0
  80. data/specs/fixtures/expected/partials/params.html +1 -0
  81. data/specs/fixtures/expected/partials/with-layouts.html +1 -0
  82. data/specs/fixtures/expected/robots.txt +1 -0
  83. data/specs/fixtures/expected/test-multi-procs.html +4 -0
  84. data/specs/fixtures/expected/test-nested-layout.html +1 -0
  85. data/specs/fixtures/expected/test-no-layout.html +2 -0
  86. data/specs/fixtures/expected/test-yamldoc.html +1 -0
  87. data/specs/fixtures/expected/test.html +2 -0
  88. data/{templates/backbone → specs/fixtures/source}/Gemfile +8 -4
  89. data/specs/fixtures/source/Gemfile.lock +84 -0
  90. data/specs/fixtures/source/Gumdrop +60 -9
  91. data/specs/fixtures/source/data/csv_data.csv +2 -0
  92. data/specs/fixtures/source/data/json_data.json +13 -0
  93. data/specs/fixtures/source/data/sql_data.sqlite +0 -0
  94. data/specs/fixtures/source/data/xml_data.xml +4 -0
  95. data/specs/fixtures/source/data/yaml_db.yamldb +9 -0
  96. data/specs/fixtures/source/data/yaml_items.yaml +2 -0
  97. data/specs/fixtures/source/data/yamldoc.yamldoc +4 -0
  98. data/specs/fixtures/source/data-access/from-csv.html.erb +4 -0
  99. data/specs/fixtures/source/data-access/from-json.html.erb +6 -0
  100. data/specs/fixtures/source/data-access/from-sqlite.html.erb +5 -0
  101. data/specs/fixtures/source/data-access/from-xml.html.erb +5 -0
  102. data/specs/fixtures/source/data-access/from-yaml.html.erb +5 -0
  103. data/specs/fixtures/source/data-access/from-yamldb.html.erb +5 -0
  104. data/specs/fixtures/source/data-access/from-yamldoc.html.erb +2 -0
  105. data/specs/fixtures/source/gen-with-inline-render.generator +7 -0
  106. data/specs/fixtures/source/goodbye.html.erb +1 -0
  107. data/specs/fixtures/source/hello.html +1 -0
  108. data/specs/fixtures/source/image.png +0 -0
  109. data/specs/fixtures/source/index.html.erb +6 -0
  110. data/specs/fixtures/source/js/sprockets/app.js +2 -0
  111. data/specs/fixtures/source/js/sprockets/view.js.coffee +1 -0
  112. data/specs/fixtures/source/js/stitch/app.js +1 -0
  113. data/specs/fixtures/source/js/stitch/view.js.coffee +1 -0
  114. data/specs/fixtures/source/js/straight.js +8 -0
  115. data/specs/fixtures/source/js/test-coffee.js.coffee +1 -0
  116. data/specs/fixtures/source/layouts/site.layout.erb +1 -0
  117. data/specs/fixtures/source/layouts/sub.layout.erb +1 -0
  118. data/specs/fixtures/source/layouts/wrap.layout.erb +1 -0
  119. data/specs/fixtures/source/pages/_users-nested.html.erb +7 -0
  120. data/specs/fixtures/source/pages/docs/force-abs.html.erb +2 -0
  121. data/specs/fixtures/source/pages/docs/index.html.erb +2 -0
  122. data/specs/fixtures/source/partials/_post_entry.html.erb +4 -0
  123. data/specs/fixtures/source/partials/_provides_name.html.erb +1 -0
  124. data/specs/fixtures/source/partials/_user-params.html.erb +1 -0
  125. data/specs/fixtures/source/partials/_user.html.erb +1 -0
  126. data/specs/fixtures/source/partials/_user_sets_layout.html.erb +1 -0
  127. data/specs/fixtures/source/partials/hoisted-data.html.erb +6 -0
  128. data/specs/fixtures/source/partials/nested.html.erb +1 -0
  129. data/specs/fixtures/source/partials/params.html.erb +1 -0
  130. data/specs/fixtures/source/partials/with-layouts.html.erb +1 -0
  131. data/specs/fixtures/source/test-multi-procs.html.markdown.erb +3 -0
  132. data/specs/fixtures/source/test-nested-layout.html.erb +1 -0
  133. data/specs/fixtures/source/test-no-layout.html.erb +2 -0
  134. data/specs/fixtures/source/test-yamldoc.html.erb.yamldoc +4 -0
  135. data/specs/fixtures/source/test.html.erb +2 -0
  136. data/specs/hash_object_spec.rb +53 -8
  137. data/specs/render_spec.rb +10 -0
  138. data/specs/site_spec.rb +79 -0
  139. data/specs/spec_helper.rb +59 -0
  140. data/templates/blank/Gemfile +0 -4
  141. data/templates/blank/Gumdrop +180 -113
  142. data/templates/default/Gemfile +3 -8
  143. data/templates/default/Gumdrop +166 -95
  144. data/templates/default/ReadMe.md +14 -0
  145. data/templates/default/config.ru +1 -0
  146. data/templates/default/data/news/20120703.yamldoc +14 -0
  147. data/templates/default/data/news/20120704.yamldoc +8 -0
  148. data/templates/{backbone/source/feed.xml.builder.txt → default/source/feed.xml.builder} +4 -4
  149. data/templates/default/source/index.html.erb +10 -1
  150. data/templates/default/source/theme/layout/_sidebar.html +1 -0
  151. data/templates/{backbone/source/theme/templates/site.template.slim → default/source/theme/layout/site.layout.slim} +3 -3
  152. metadata +212 -63
  153. data/lib/gumdrop/context.rb +0 -135
  154. data/lib/gumdrop/data_manager.rb +0 -214
  155. data/lib/gumdrop/support/base_packager.rb +0 -60
  156. data/lib/gumdrop/support/callbacks.rb +0 -30
  157. data/lib/gumdrop/support/hash_object.rb +0 -22
  158. data/lib/gumdrop/view_helpers.rb +0 -25
  159. data/notes.md +0 -347
  160. data/specs/deferred_loader_spec.rb +0 -31
  161. data/specs/fixtures/expected/posts/post1.html +0 -1
  162. data/specs/fixtures/expected/posts/post1.js +0 -14
  163. data/specs/fixtures/expected/posts/post2.html +0 -5
  164. data/specs/fixtures/expected/sub/sub/sub/test.html +0 -5
  165. data/specs/fixtures/expected/sub/sub/sub/test2.html +0 -5
  166. data/specs/fixtures/expected/test.js +0 -14
  167. data/specs/fixtures/source/posts/post1.html.slim +0 -6
  168. data/specs/fixtures/source/posts/post1.js.coffee +0 -3
  169. data/specs/fixtures/source/posts/post2.html.erb +0 -5
  170. data/specs/fixtures/source/sub/sub/sub/test.html +0 -5
  171. data/specs/fixtures/source/sub/sub/sub/test2.html.erb +0 -5
  172. data/specs/fixtures/source/test.js.coffee +0 -4
  173. data/specs/fixtures/source/test.js.erb.coffee +0 -3
  174. data/templates/backbone/Gumdrop +0 -123
  175. data/templates/backbone/Rakefile +0 -38
  176. data/templates/backbone/app/app.js.coffee +0 -49
  177. data/templates/backbone/app/init.js.coffee +0 -10
  178. data/templates/backbone/app/models/.gitkeep +0 -0
  179. data/templates/backbone/app/utils/index.js.coffee +0 -27
  180. data/templates/backbone/app/views/home.js.coffee +0 -17
  181. data/templates/backbone/app/views/styles/home.scss +0 -8
  182. data/templates/backbone/app/views/templates/home.mustache +0 -2
  183. data/templates/backbone/config.ru +0 -20
  184. data/templates/backbone/lib/all.js.coffee +0 -18
  185. data/templates/backbone/lib/backbone.js +0 -1158
  186. data/templates/backbone/lib/hogan.js +0 -509
  187. data/templates/backbone/lib/jquery.js +0 -9266
  188. data/templates/backbone/lib/underscore.js +0 -981
  189. data/templates/backbone/powrc +0 -2
  190. data/templates/backbone/source/default.htaccess.erb +0 -27
  191. data/templates/backbone/source/favicon.ico +0 -0
  192. data/templates/backbone/source/index.html.erb +0 -2
  193. data/templates/backbone/source/theme/screen.css.sass +0 -9
  194. data/templates/backbone/source/theme/scripts/app.js.coffee +0 -4
  195. data/templates/backbone/source/theme/styles/_tools.scss +0 -434
  196. data/templates/backbone/source/theme/templates/app.template.slim +0 -14
  197. data/templates/default/Rakefile +0 -38
  198. data/templates/default/powrc +0 -2
  199. data/templates/default/source/default.htaccess.erb +0 -27
  200. data/templates/default/source/feed.xml.builder.txt +0 -23
  201. data/templates/default/source/theme/templates/site.template.slim +0 -33
@@ -0,0 +1,51 @@
1
+ require 'yaml'
2
+
3
+ module Gumdrop::Util
4
+
5
+ PARSER= /^(\s*---(.+)---\s*)/m
6
+
7
+ class YamlDoc
8
+
9
+ attr_reader :data, :body
10
+
11
+ def initialize(source, extended_support=false)
12
+ @data= {}
13
+ @body= source
14
+ @extended_support= extended_support
15
+ _compile
16
+ end
17
+
18
+ def is_yamldoc?
19
+ @is_yamldoc
20
+ end
21
+
22
+ private
23
+
24
+ def _compile
25
+ source = @body || ""
26
+
27
+ if source =~ PARSER
28
+ yaml = $2.strip
29
+ @body = source.sub($1, '')
30
+ @data= YAML.load(yaml)
31
+ @is_yamldoc= true
32
+ else
33
+ @data={ 'content' => @body } if @extended_support
34
+ @is_yamldoc= false
35
+ end
36
+
37
+ return unless @extended_support or !@is_yamldoc
38
+
39
+ content_set= false
40
+ @data.each_pair do |key, value|
41
+ if value == '_YAMLDOC_'
42
+ @data[key]= @body
43
+ content_set= true
44
+ end
45
+ end
46
+ @data['content']= @body unless content_set
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -1,5 +1,5 @@
1
1
  module Gumdrop
2
2
 
3
- VERSION = "0.8.0" unless defined?(::Gumdrop::VERSION)
4
-
3
+ VERSION= "1.0.0"
4
+
5
5
  end
data/lib/gumdrop.rb CHANGED
@@ -1,96 +1,59 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'tilt'
4
- require 'fileutils'
5
- require 'active_support/all'
4
+ require "active_support/core_ext" # One day I'll get away from you!
5
+ require 'gumdrop/util/core_ex'
6
6
 
7
+ # The simple and sweet static CMS! (and prototyping tool)
7
8
  module Gumdrop
8
9
 
9
- autoload :Context, "gumdrop/context"
10
- autoload :Content, "gumdrop/content"
11
- autoload :DataManager, "gumdrop/data_manager"
12
- autoload :Generator, "gumdrop/generator"
13
- autoload :HashObject, "gumdrop/support/hash_object"
14
- autoload :Pager, "gumdrop/data_manager"
15
- autoload :Server, "gumdrop/server"
16
- autoload :VERSION, "gumdrop/version"
17
- autoload :ViewHelpers, "gumdrop/view_helpers"
10
+ autoload :Server, 'gumdrop/server'
18
11
 
19
12
  module CLI
20
- autoload :External, "gumdrop/cli/external"
21
- autoload :Internal, "gumdrop/cli/internal"
13
+ autoload :Internal, 'gumdrop/cli/internal'
14
+ autoload :External, 'gumdrop/cli/external'
22
15
  end
23
16
 
24
17
  module Support
25
- autoload :BasePackager, "gumdrop/support/base_packager"
26
- autoload :Callbacks, "gumdrop/support/callbacks"
27
- autoload :Stitch, "gumdrop/support/stitch"
28
- autoload :Sprockets, "gumdrop/support/sprockets"
18
+ autoload :Compressor, 'gumdrop/support/compressor'
19
+ autoload :Stitch, 'gumdrop/support/stitch'
20
+ autoload :Sprockets, 'gumdrop/support/sprockets'
29
21
  end
30
-
31
- class << self
32
22
 
33
- def run(opts={})
34
- site= fetch_site opts
35
- unless site.nil?
36
- old= Dir.pwd
37
- Dir.chdir site.root_path
38
-
39
- site.build
40
-
41
- Dir.chdir old
42
-
43
- puts "\n" if opts[:subdued]
44
-
45
- else
46
- puts "Not in a valid Gumdrop site directory."
47
- end
48
- end
49
-
50
- def in_site_folder?(filename="Gumdrop")
51
- !fetch_site_file(filename).nil?
52
- end
53
-
54
- def fetch_site(opts={}, prefer_existing=true)
55
- if defined?(SITE) and prefer_existing
56
- SITE.opts= opts unless opts.empty?
57
- SITE
58
- else
59
- site_file= Gumdrop.fetch_site_file
60
- unless site_file.nil?
61
- Site.new site_file, opts
62
- else
63
- nil
64
- end
65
- end
66
- end
67
-
68
- def fetch_site_file(filename="Gumdrop")
69
- here= Dir.pwd
70
- found= File.file? File.join( here, filename )
71
- # TODO: Should be smarter -- This is a hack for Windows support "C:\"
72
- while !found and File.directory?(here) and File.dirname(here).length > 3
73
- here= File.expand_path File.join(here, '../')
74
- found= File.file? File.join( here, filename )
75
- end
76
- if found
77
- File.expand_path File.join(here, filename)
78
- else
79
- nil
80
- end
81
- end
82
-
83
- def site_dirname(filename="Gumdrop")
84
- File.dirname( fetch_site_file( filename ) )
85
- end
23
+ module Util
24
+ autoload :Configurable, 'gumdrop/util/configurable'
25
+ autoload :Eventable, 'gumdrop/util/eventable'
26
+ autoload :HashObject, 'gumdrop/util/hash_object'
27
+ autoload :Loggable, 'gumdrop/util/loggable'
28
+ autoload :Scanner, 'gumdrop/util/scanner'
29
+ autoload :SiteAccess, 'gumdrop/util/site_access'
30
+ autoload :ViewHelpers, 'gumdrop/util/view_helpers'
31
+ autoload :YamlDoc, 'gumdrop/util/yaml_doc'
32
+ end
86
33
 
87
- def change_log
88
- here= File.dirname(__FILE__)
89
- File.read File.join(here, "../ChangeLog.md")
90
- end
34
+ # Returns 'ChangeLog.md' from gem package.
35
+ def self.change_log
36
+ here= File.dirname(__FILE__)
37
+ File.read here / ".." / "ChangeLog.md"
38
+ end
91
39
 
40
+ # Returns 'ReadMe.md' from gem package.
41
+ def self.change_log
42
+ here= File.dirname(__FILE__)
43
+ File.read here / ".." / "ReadMe.md"
92
44
  end
93
-
45
+
94
46
  end
95
47
 
48
+ require 'gumdrop/cli'
49
+ require 'gumdrop/builder'
50
+ require 'gumdrop/content'
51
+ require 'gumdrop/data'
52
+ require 'gumdrop/generator'
53
+ require 'gumdrop/renderer'
96
54
  require 'gumdrop/site'
55
+ require 'gumdrop/version'
56
+
57
+ Dir[File.dirname(__FILE__) / 'gumdrop' / 'support' / '*.rb'].each do |lib|
58
+ require lib
59
+ end
@@ -1,92 +1,102 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'gumdrop'
4
- #require File.join File.dirname(__FILE__), 'diff.rb'
1
+ require_relative 'spec_helper'
5
2
 
6
- fixture_src_path= File.join ".", "specs", "fixtures", "source"
7
- fixture_exp_path= File.join ".", "specs", "fixtures", "expected"
3
+ describe Gumdrop::Content do
4
+
5
+ it "must be instantiated with a file path" do
6
+ content = content_for_source('test.html')
7
+ content.wont_be_nil
8
+ end
8
9
 
9
- def get_test_site
10
- site= Gumdrop::Site.new File.join(".", "specs", "fixtures", "source", 'Gumdrop'), :quiet=>true
11
- site.rescan
12
- end
10
+ it "it does not care if it is a real path or not" do
11
+ content = content_for_source('test.html')
12
+ content.wont_be_nil
13
+ end
13
14
 
14
- def get_expected(filename)
15
- path= File.join ".", "specs", "fixtures", "expected", filename
16
- File.read path
17
- end
15
+ describe 'generated?' do
18
16
 
19
- describe Gumdrop::Content do
20
- # before do
21
- # @ho= Gumdrop::HashObject.new one:"ONE", two:"TWO", three:'THREE'
22
- # end
17
+ it "true if it was created with a generator" do
18
+ content = content_for_source('test.html', generated:true)
19
+ content.generated?.must_equal true
20
+ end
21
+
22
+ end
23
+
24
+ # describe 'ignore?' do
23
25
 
24
- it "should process the content through all the engines specified in the file ext" do
25
-
26
- # path= File.join fixture_src_path, 'Gumdrop'
27
- # site= Gumdrop::Site.new path, :quiet=>true
28
- # site.rescan
29
- site= get_test_site
26
+ # it "false by default" do
27
+ # content = content_for_source('test.html')
28
+ # content.ignore?.must_equal false
29
+ # end
30
30
 
31
- path= File.join fixture_src_path, 'test.js.erb.coffee'
32
- content= Gumdrop::Content.new( path, site )
31
+ # it "true if ignored(true) called" do
32
+ # content = content_for_source('test.html')
33
+ # content.ignore?.must_equal false
34
+ # content.ignore true
35
+ # content.ignore?.must_equal true
36
+ # content.ignore false
37
+ # content.ignore?.must_equal false
38
+ # end
33
39
 
34
- path= File.join fixture_exp_path, 'test.js'
35
- expected= File.read path
40
+ # end
41
+
42
+ describe 'binary?' do
36
43
 
37
- content= content.render()
44
+ it "true if bin file" do
45
+ content = content_for_source('image.png')
46
+ content.binary?.must_equal true
47
+ end
38
48
 
39
- # puts content
40
- # puts expected
49
+ it "false if text file" do
50
+ content = content_for_source('test.html')
51
+ content.binary?.must_equal false
52
+ end
41
53
 
42
- content.must_equal expected
43
54
  end
44
55
 
45
- it "should relativize all absolute paths (when starts with /)" do
46
- site= get_test_site
47
- # puts site.content_hash.keys
48
-
49
- page= site.contents('posts/post1.html').first
50
- content= page.render
51
- expected= get_expected('posts/post1.html')
52
- # puts content
53
- content.must_equal expected
54
-
55
- page= site.contents('posts/post1.js').first
56
- content= page.render
57
- # puts content
58
- content.must_equal get_expected('posts/post1.js')
59
-
60
- page= site.contents('sub/sub/sub/test.html').first
61
- content= page.render
62
- # puts content
63
- content.must_equal get_expected('sub/sub/sub/test.html')
64
-
65
- page= site.contents('sub/sub/sub/test2.html').first
66
- content= page.render
67
- # puts content
68
- content.must_equal get_expected('sub/sub/sub/test2.html')
56
+ describe 'exists?' do
57
+
58
+ it "return true for existing files" do
59
+ content = content_for_source('test.html')
60
+ exist= content.exists?
61
+ exist.must_equal true
62
+ end
63
+ it "return false for missing files" do
64
+ content = content_for_source('missing.html')
65
+ content.must_be_nil
66
+
67
+ # Should a file magically disappear
68
+ content= Gumdrop::Content.new('crap.head.html')
69
+ exist= content.exists?
70
+ exist.must_equal false
71
+ end
72
+ it "return true for generated files" do
73
+ content = content_for_source('crap.html', generated:true)
74
+ exist= content.exists?
75
+ exist.must_equal true
76
+ end
77
+
69
78
  end
70
79
 
71
- # it "can be created with no arguments" do
72
- # Gumdrop::HashObject.new.must_be_instance_of Gumdrop::HashObject
73
- # end
80
+ describe 'body()' do
74
81
 
75
- # it "can be used as a standard hash" do
76
- # @ho[:one].must_equal "ONE"
77
- # end
82
+ it "returns file contents for non binary files" do
83
+ content= content_for_source 'test.html'
84
+ expected= File.read(fixture_src('test.html.erb'))
85
+ content.body.must_be_sorta_like expected
86
+ end
78
87
 
79
- # it "can be used as a standard with either a sym or string key" do
80
- # @ho[:two].must_equal "TWO"
81
- # @ho['two'].must_equal "TWO"
82
- # end
88
+ it "returns nil for binary files" do
89
+ content= content_for_source 'image.png'
90
+ content.body.must_be_nil
91
+ end
83
92
 
84
- # it "can be accessed like an object" do
85
- # @ho.three.must_equal "THREE"
86
- # end
93
+ it "returns block content when provided" do
94
+ content= Gumdrop::Content.new '', nil do
95
+ "Hello"
96
+ end
97
+ content.body.must_equal 'Hello'
98
+ end
87
99
 
88
- # it "should return nil for an unknown key" do
89
- # @ho.timmy.must_be_nil
90
- # end
100
+ end
91
101
 
92
- end
102
+ end
@@ -0,0 +1,4 @@
1
+ <body class="site"><h1>Comics</h1>
2
+ <div>X-Men art by Jim Lee</div>
3
+ <div>Spider-Man art by Erik Larsen</div>
4
+ </body>
@@ -0,0 +1,6 @@
1
+ <body class="site"><h1>Movies</h1>
2
+ <ul>
3
+ <li>Super 8</li>
4
+ <li>Star Trek</li>
5
+ <li>The Avengers</li>
6
+ </ul></body>
@@ -0,0 +1,5 @@
1
+ <body class="site"><ul>
2
+ <li>Test Title</li>
3
+ <li>Another Title</li>
4
+ </ul>
5
+ </body>
@@ -0,0 +1,4 @@
1
+ <body class="site"><ul>
2
+ <li>Bland</li>
3
+ <li>More Bland</li>
4
+ </ul></body>
@@ -0,0 +1,5 @@
1
+ <body class="site"><ul>
2
+ <li>One</li>
3
+ <li>Two</li>
4
+ </ul>
5
+ </body>
@@ -0,0 +1,5 @@
1
+ <body class="site"><ul>
2
+ <li>Transformers (1984)</li>
3
+ <li>Thundercats (1984)</li>
4
+ <li>M.A.S.K. (1985)</li>
5
+ </ul></body>
@@ -0,0 +1,2 @@
1
+ <body class="site"><h1>Fun, Fun, Fun</h1>
2
+ <p>Was had by all!</p></body>
@@ -0,0 +1 @@
1
+ Test File
@@ -0,0 +1 @@
1
+ <body class="site">Test Plain</body>
@@ -0,0 +1 @@
1
+ <body class="site"><article class="sub">Test Nested</article></body>
@@ -0,0 +1 @@
1
+ <body class="site"><wrap>Test Wrap</wrap></body>
@@ -0,0 +1,4 @@
1
+ <section class="hentry">
2
+ <h2>Test Title</h2>
3
+ <div>Test Body</div>
4
+ </section>
@@ -0,0 +1,4 @@
1
+ <body class="site"><section class="hentry">
2
+ <h2>Test Title</h2>
3
+ <div>Test Body</div>
4
+ </section></body>
@@ -0,0 +1,4 @@
1
+ <section class="hentry">
2
+ <h2>Test Title</h2>
3
+ <div>Test Body</div>
4
+ </section>
@@ -0,0 +1,4 @@
1
+ <body class="site"><article class="sub"><section class="hentry">
2
+ <h2>Test Title</h2>
3
+ <div>Test Body</div>
4
+ </section></article></body>
@@ -0,0 +1,4 @@
1
+ <body class="site"><wrap><section class="hentry">
2
+ <h2>Test Title</h2>
3
+ <div>Test Body</div>
4
+ </section></wrap></body>
@@ -0,0 +1,4 @@
1
+ <section class="hentry">
2
+ <h2>Another Title</h2>
3
+ <div></div>
4
+ </section>
@@ -0,0 +1,4 @@
1
+ <body class="site"><section class="hentry">
2
+ <h2>Another Title</h2>
3
+ <div></div>
4
+ </section></body>
@@ -0,0 +1,4 @@
1
+ <section class="hentry">
2
+ <h2>Another Title</h2>
3
+ <div></div>
4
+ </section>
@@ -0,0 +1,4 @@
1
+ <body class="site"><article class="sub"><section class="hentry">
2
+ <h2>Another Title</h2>
3
+ <div></div>
4
+ </section></article></body>
@@ -0,0 +1,4 @@
1
+ <body class="site"><wrap><section class="hentry">
2
+ <h2>Another Title</h2>
3
+ <div></div>
4
+ </section></wrap></body>
@@ -0,0 +1 @@
1
+ <body class="site"><p>Goodbye.</p></body>
@@ -0,0 +1 @@
1
+ <body class="site"><p>Hello!</p></body>
Binary file
@@ -0,0 +1,47 @@
1
+ <body class="site"><h1>Tests!</h1>
2
+ <ul>
3
+ <li><a href="data-access/from-csv.html">data-access/from-csv.html</a></li>
4
+ <li><a href="data-access/from-json.html">data-access/from-json.html</a></li>
5
+ <li><a href="data-access/from-sqlite.html">data-access/from-sqlite.html</a></li>
6
+ <li><a href="data-access/from-xml.html">data-access/from-xml.html</a></li>
7
+ <li><a href="data-access/from-yaml.html">data-access/from-yaml.html</a></li>
8
+ <li><a href="data-access/from-yamldb.html">data-access/from-yamldb.html</a></li>
9
+ <li><a href="data-access/from-yamldoc.html">data-access/from-yamldoc.html</a></li>
10
+ <li><a href="gen-with-block/as-file.html">gen-with-block/as-file.html</a></li>
11
+ <li><a href="gen-with-block/as-plain.html">gen-with-block/as-plain.html</a></li>
12
+ <li><a href="gen-with-block/layout-nested.html">gen-with-block/layout-nested.html</a></li>
13
+ <li><a href="gen-with-block/layout-nil.html">gen-with-block/layout-nil.html</a></li>
14
+ <li><a href="gen-with-block/layout-wrap.html">gen-with-block/layout-wrap.html</a></li>
15
+ <li><a href="gen-with-inline-render/0-as-file.html">gen-with-inline-render/0-as-file.html</a></li>
16
+ <li><a href="gen-with-inline-render/0-as-plain.html">gen-with-inline-render/0-as-plain.html</a></li>
17
+ <li><a href="gen-with-inline-render/0-layout-nil.html">gen-with-inline-render/0-layout-nil.html</a></li>
18
+ <li><a href="gen-with-inline-render/0-layout-sub.html">gen-with-inline-render/0-layout-sub.html</a></li>
19
+ <li><a href="gen-with-inline-render/0-layout-wrap.html">gen-with-inline-render/0-layout-wrap.html</a></li>
20
+ <li><a href="gen-with-inline-render/1-as-file.html">gen-with-inline-render/1-as-file.html</a></li>
21
+ <li><a href="gen-with-inline-render/1-as-plain.html">gen-with-inline-render/1-as-plain.html</a></li>
22
+ <li><a href="gen-with-inline-render/1-layout-nil.html">gen-with-inline-render/1-layout-nil.html</a></li>
23
+ <li><a href="gen-with-inline-render/1-layout-sub.html">gen-with-inline-render/1-layout-sub.html</a></li>
24
+ <li><a href="gen-with-inline-render/1-layout-wrap.html">gen-with-inline-render/1-layout-wrap.html</a></li>
25
+ <li><a href="goodbye.html">goodbye.html</a></li>
26
+ <li><a href="hello.html">hello.html</a></li>
27
+ <li><a href="image.png">image.png</a></li>
28
+ <li><a href="index.html">index.html</a></li>
29
+ <li><a href="js/sprockets-app.js">js/sprockets-app.js</a></li>
30
+ <li><a href="js/stitch-app.js">js/stitch-app.js</a></li>
31
+ <li><a href="js/stitch-app.min.js">js/stitch-app.min.js</a></li>
32
+ <li><a href="js/stitch-app.min.src.js">js/stitch-app.min.src.js</a></li>
33
+ <li><a href="js/straight.js">js/straight.js</a></li>
34
+ <li><a href="js/test-coffee.js">js/test-coffee.js</a></li>
35
+ <li><a href="pages/docs/force-abs.html">pages/docs/force-abs.html</a></li>
36
+ <li><a href="pages/docs/index.html">pages/docs/index.html</a></li>
37
+ <li><a href="partials/hoisted-data.html">partials/hoisted-data.html</a></li>
38
+ <li><a href="partials/nested.html">partials/nested.html</a></li>
39
+ <li><a href="partials/params.html">partials/params.html</a></li>
40
+ <li><a href="partials/with-layouts.html">partials/with-layouts.html</a></li>
41
+ <li><a href="robots.txt">robots.txt</a></li>
42
+ <li><a href="test-multi-procs.html">test-multi-procs.html</a></li>
43
+ <li><a href="test-nested-layout.html">test-nested-layout.html</a></li>
44
+ <li><a href="test-no-layout.html">test-no-layout.html</a></li>
45
+ <li><a href="test-yamldoc.html">test-yamldoc.html</a></li>
46
+ <li><a href="test.html">test.html</a></li>
47
+ </ul></body>
@@ -0,0 +1,7 @@
1
+ (function() {
2
+
3
+ alert("sprockets-view");
4
+
5
+ }).call(this);
6
+ alert("sprockets-app")
7
+ ;
@@ -0,0 +1,65 @@
1
+
2
+ (function(/*! Stitch !*/) {
3
+ if (!this.require) {
4
+ var modules = {}, cache = {};
5
+ var require = function(name, root) {
6
+ var path = expand(root, name), indexPath = expand(path, './index'), module, fn;
7
+ module = cache[path] || cache[indexPath];
8
+ if (module) {
9
+ return module;
10
+ } else if (fn = modules[path] || modules[path = indexPath]) {
11
+ module = {id: path, exports: {}};
12
+ cache[path] = module.exports;
13
+ fn(module.exports, function(name) {
14
+ return require(name, dirname(path));
15
+ }, module);
16
+ return cache[path] = module.exports;
17
+ } else {
18
+ throw 'module ' + name + ' not found';
19
+ }
20
+ };
21
+ var expand = function(root, name) {
22
+ var results = [], parts, part;
23
+ // If path is relative
24
+ if (/^\.\.?(\/|$)/.test(name)) {
25
+ parts = [root, name].join('/').split('/');
26
+ } else {
27
+ parts = name.split('/');
28
+ }
29
+ for (var i = 0, length = parts.length; i < length; i++) {
30
+ part = parts[i];
31
+ if (part == '..') {
32
+ results.pop();
33
+ } else if (part != '.' && part != '') {
34
+ results.push(part);
35
+ }
36
+ }
37
+ return results.join('/');
38
+ };
39
+ var dirname = function(path) {
40
+ return path.split('/').slice(0, -1).join('/');
41
+ };
42
+ this.require = function(name) {
43
+ return require(name, '');
44
+ };
45
+ this.require.define = function(bundle) {
46
+ for (var key in bundle) {
47
+ modules[key] = bundle[key];
48
+ }
49
+ };
50
+ this.require.modules = modules;
51
+ this.require.cache = cache;
52
+ }
53
+ return this.require.define;
54
+ }).call(this)({
55
+ "app": function(exports, require, module) {
56
+ alert("stitch-app")
57
+ }, "view.js": function(exports, require, module) {
58
+ (function() {
59
+
60
+ alert("stitch-view");
61
+
62
+ }).call(this);
63
+
64
+ }
65
+ });
@@ -0,0 +1,5 @@
1
+
2
+ (function(){if(!this.require){var modules={},cache={};var require=function(name,root){var path=expand(root,name),indexPath=expand(path,'./index'),module,fn;module=cache[path]||cache[indexPath];if(module){return module;}else if(fn=modules[path]||modules[path=indexPath]){module={id:path,exports:{}};cache[path]=module.exports;fn(module.exports,function(name){return require(name,dirname(path));},module);return cache[path]=module.exports;}else{throw'module '+name+' not found';}};var expand=function(root,name){var results=[],parts,part;if(/^\.\.?(\/|$)/.test(name)){parts=[root,name].join('/').split('/');}else{parts=name.split('/');}
3
+ for(var i=0,length=parts.length;i<length;i++){part=parts[i];if(part=='..'){results.pop();}else if(part!='.'&&part!=''){results.push(part);}}
4
+ return results.join('/');};var dirname=function(path){return path.split('/').slice(0,-1).join('/');};this.require=function(name){return require(name,'');};this.require.define=function(bundle){for(var key in bundle){modules[key]=bundle[key];}};this.require.modules=modules;this.require.cache=cache;}
5
+ return this.require.define;}).call(this)({"app":function(exports,require,module){alert("stitch-app")},"view.js":function(exports,require,module){(function(){alert("stitch-view");}).call(this);}});