gumdrop 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/ChangeLog.md +13 -0
- data/Gemfile +6 -2
- data/Gemfile.lock +43 -3
- data/Rakefile +37 -21
- data/Readme.md +60 -158
- data/bin/gumdrop +2 -1
- data/gumdrop.gemspec +11 -4
- data/lib/gumdrop/builder.rb +164 -0
- data/lib/gumdrop/cli/external.rb +14 -9
- data/lib/gumdrop/cli/internal.rb +54 -22
- data/lib/gumdrop/cli.rb +21 -0
- data/lib/gumdrop/content.rb +195 -132
- data/lib/gumdrop/data.rb +185 -0
- data/lib/gumdrop/data_providers/csv.rb +18 -0
- data/lib/gumdrop/data_providers/pstore.rb +25 -0
- data/lib/gumdrop/data_providers/sqlite.rb +43 -0
- data/lib/gumdrop/data_providers/xml.rb +15 -0
- data/lib/gumdrop/data_providers/yaml_and_json.rb +18 -0
- data/lib/gumdrop/data_providers/yamldb.rb +18 -0
- data/lib/gumdrop/data_providers/yamldoc.rb +12 -0
- data/lib/gumdrop/generator.rb +118 -94
- data/lib/gumdrop/renderer.rb +272 -0
- data/lib/gumdrop/server.rb +36 -27
- data/lib/gumdrop/site.rb +283 -338
- data/lib/gumdrop/support/compressor.rb +52 -0
- data/lib/gumdrop/support/sprockets.rb +14 -23
- data/lib/gumdrop/support/stitch.rb +25 -14
- data/lib/gumdrop/support/yaml_doc_template.rb +29 -0
- data/lib/gumdrop/util/configurable.rb +44 -0
- data/lib/gumdrop/util/core_ex.rb +84 -0
- data/lib/gumdrop/util/eventable.rb +35 -0
- data/lib/gumdrop/util/hash_object.rb +70 -0
- data/lib/gumdrop/util/loggable.rb +44 -0
- data/lib/gumdrop/util/pager.rb +51 -0
- data/lib/gumdrop/{support → util}/proxy_handler.rb +7 -6
- data/lib/gumdrop/util/scanner.rb +47 -0
- data/lib/gumdrop/util/site_access.rb +16 -0
- data/lib/gumdrop/util/view_helpers.rb +50 -0
- data/lib/gumdrop/util/yaml_doc.rb +51 -0
- data/lib/gumdrop/version.rb +2 -2
- data/lib/gumdrop.rb +40 -77
- data/specs/content_spec.rb +83 -73
- data/specs/fixtures/expected/data-access/from-csv.html +4 -0
- data/specs/fixtures/expected/data-access/from-json.html +6 -0
- data/specs/fixtures/expected/data-access/from-sqlite.html +5 -0
- data/specs/fixtures/expected/data-access/from-xml.html +4 -0
- data/specs/fixtures/expected/data-access/from-yaml.html +5 -0
- data/specs/fixtures/expected/data-access/from-yamldb.html +5 -0
- data/specs/fixtures/expected/data-access/from-yamldoc.html +2 -0
- data/specs/fixtures/expected/gen-with-block/as-file.html +1 -0
- data/specs/fixtures/expected/gen-with-block/as-plain.html +1 -0
- data/specs/fixtures/expected/gen-with-block/layout-nested.html +1 -0
- data/specs/fixtures/expected/gen-with-block/layout-nil.html +1 -0
- data/specs/fixtures/expected/gen-with-block/layout-wrap.html +1 -0
- data/specs/fixtures/expected/gen-with-inline-render/0-as-file.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/0-as-plain.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/0-layout-nil.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/0-layout-sub.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/0-layout-wrap.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/1-as-file.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/1-as-plain.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/1-layout-nil.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/1-layout-sub.html +4 -0
- data/specs/fixtures/expected/gen-with-inline-render/1-layout-wrap.html +4 -0
- data/specs/fixtures/expected/goodbye.html +1 -0
- data/specs/fixtures/expected/hello.html +1 -0
- data/specs/fixtures/expected/image.png +0 -0
- data/specs/fixtures/expected/index.html +47 -0
- data/specs/fixtures/expected/js/sprockets-app.js +7 -0
- data/specs/fixtures/expected/js/stitch-app.js +65 -0
- data/specs/fixtures/expected/js/stitch-app.min.js +5 -0
- data/specs/fixtures/expected/js/stitch-app.min.src.js +65 -0
- data/specs/fixtures/expected/js/straight.js +8 -0
- data/specs/fixtures/expected/js/test-coffee.js +5 -0
- data/specs/fixtures/expected/pages/docs/force-abs.html +2 -0
- data/specs/fixtures/expected/pages/docs/index.html +2 -0
- data/specs/fixtures/expected/partials/hoisted-data.html +3 -0
- data/specs/fixtures/expected/partials/nested.html +7 -0
- data/specs/fixtures/expected/partials/params.html +1 -0
- data/specs/fixtures/expected/partials/with-layouts.html +1 -0
- data/specs/fixtures/expected/robots.txt +1 -0
- data/specs/fixtures/expected/test-multi-procs.html +4 -0
- data/specs/fixtures/expected/test-nested-layout.html +1 -0
- data/specs/fixtures/expected/test-no-layout.html +2 -0
- data/specs/fixtures/expected/test-yamldoc.html +1 -0
- data/specs/fixtures/expected/test.html +2 -0
- data/{templates/backbone → specs/fixtures/source}/Gemfile +8 -4
- data/specs/fixtures/source/Gemfile.lock +84 -0
- data/specs/fixtures/source/Gumdrop +60 -9
- data/specs/fixtures/source/data/csv_data.csv +2 -0
- data/specs/fixtures/source/data/json_data.json +13 -0
- data/specs/fixtures/source/data/sql_data.sqlite +0 -0
- data/specs/fixtures/source/data/xml_data.xml +4 -0
- data/specs/fixtures/source/data/yaml_db.yamldb +9 -0
- data/specs/fixtures/source/data/yaml_items.yaml +2 -0
- data/specs/fixtures/source/data/yamldoc.yamldoc +4 -0
- data/specs/fixtures/source/data-access/from-csv.html.erb +4 -0
- data/specs/fixtures/source/data-access/from-json.html.erb +6 -0
- data/specs/fixtures/source/data-access/from-sqlite.html.erb +5 -0
- data/specs/fixtures/source/data-access/from-xml.html.erb +5 -0
- data/specs/fixtures/source/data-access/from-yaml.html.erb +5 -0
- data/specs/fixtures/source/data-access/from-yamldb.html.erb +5 -0
- data/specs/fixtures/source/data-access/from-yamldoc.html.erb +2 -0
- data/specs/fixtures/source/gen-with-inline-render.generator +7 -0
- data/specs/fixtures/source/goodbye.html.erb +1 -0
- data/specs/fixtures/source/hello.html +1 -0
- data/specs/fixtures/source/image.png +0 -0
- data/specs/fixtures/source/index.html.erb +6 -0
- data/specs/fixtures/source/js/sprockets/app.js +2 -0
- data/specs/fixtures/source/js/sprockets/view.js.coffee +1 -0
- data/specs/fixtures/source/js/stitch/app.js +1 -0
- data/specs/fixtures/source/js/stitch/view.js.coffee +1 -0
- data/specs/fixtures/source/js/straight.js +8 -0
- data/specs/fixtures/source/js/test-coffee.js.coffee +1 -0
- data/specs/fixtures/source/layouts/site.layout.erb +1 -0
- data/specs/fixtures/source/layouts/sub.layout.erb +1 -0
- data/specs/fixtures/source/layouts/wrap.layout.erb +1 -0
- data/specs/fixtures/source/pages/_users-nested.html.erb +7 -0
- data/specs/fixtures/source/pages/docs/force-abs.html.erb +2 -0
- data/specs/fixtures/source/pages/docs/index.html.erb +2 -0
- data/specs/fixtures/source/partials/_post_entry.html.erb +4 -0
- data/specs/fixtures/source/partials/_provides_name.html.erb +1 -0
- data/specs/fixtures/source/partials/_user-params.html.erb +1 -0
- data/specs/fixtures/source/partials/_user.html.erb +1 -0
- data/specs/fixtures/source/partials/_user_sets_layout.html.erb +1 -0
- data/specs/fixtures/source/partials/hoisted-data.html.erb +6 -0
- data/specs/fixtures/source/partials/nested.html.erb +1 -0
- data/specs/fixtures/source/partials/params.html.erb +1 -0
- data/specs/fixtures/source/partials/with-layouts.html.erb +1 -0
- data/specs/fixtures/source/test-multi-procs.html.markdown.erb +3 -0
- data/specs/fixtures/source/test-nested-layout.html.erb +1 -0
- data/specs/fixtures/source/test-no-layout.html.erb +2 -0
- data/specs/fixtures/source/test-yamldoc.html.erb.yamldoc +4 -0
- data/specs/fixtures/source/test.html.erb +2 -0
- data/specs/hash_object_spec.rb +53 -8
- data/specs/render_spec.rb +10 -0
- data/specs/site_spec.rb +79 -0
- data/specs/spec_helper.rb +59 -0
- data/templates/blank/Gemfile +0 -4
- data/templates/blank/Gumdrop +180 -113
- data/templates/default/Gemfile +3 -8
- data/templates/default/Gumdrop +166 -95
- data/templates/default/ReadMe.md +14 -0
- data/templates/default/config.ru +1 -0
- data/templates/default/data/news/20120703.yamldoc +14 -0
- data/templates/default/data/news/20120704.yamldoc +8 -0
- data/templates/{backbone/source/feed.xml.builder.txt → default/source/feed.xml.builder} +4 -4
- data/templates/default/source/index.html.erb +10 -1
- data/templates/default/source/theme/layout/_sidebar.html +1 -0
- data/templates/{backbone/source/theme/templates/site.template.slim → default/source/theme/layout/site.layout.slim} +3 -3
- metadata +212 -63
- data/lib/gumdrop/context.rb +0 -135
- data/lib/gumdrop/data_manager.rb +0 -214
- data/lib/gumdrop/support/base_packager.rb +0 -60
- data/lib/gumdrop/support/callbacks.rb +0 -30
- data/lib/gumdrop/support/hash_object.rb +0 -22
- data/lib/gumdrop/view_helpers.rb +0 -25
- data/notes.md +0 -347
- data/specs/deferred_loader_spec.rb +0 -31
- data/specs/fixtures/expected/posts/post1.html +0 -1
- data/specs/fixtures/expected/posts/post1.js +0 -14
- data/specs/fixtures/expected/posts/post2.html +0 -5
- data/specs/fixtures/expected/sub/sub/sub/test.html +0 -5
- data/specs/fixtures/expected/sub/sub/sub/test2.html +0 -5
- data/specs/fixtures/expected/test.js +0 -14
- data/specs/fixtures/source/posts/post1.html.slim +0 -6
- data/specs/fixtures/source/posts/post1.js.coffee +0 -3
- data/specs/fixtures/source/posts/post2.html.erb +0 -5
- data/specs/fixtures/source/sub/sub/sub/test.html +0 -5
- data/specs/fixtures/source/sub/sub/sub/test2.html.erb +0 -5
- data/specs/fixtures/source/test.js.coffee +0 -4
- data/specs/fixtures/source/test.js.erb.coffee +0 -3
- data/templates/backbone/Gumdrop +0 -123
- data/templates/backbone/Rakefile +0 -38
- data/templates/backbone/app/app.js.coffee +0 -49
- data/templates/backbone/app/init.js.coffee +0 -10
- data/templates/backbone/app/models/.gitkeep +0 -0
- data/templates/backbone/app/utils/index.js.coffee +0 -27
- data/templates/backbone/app/views/home.js.coffee +0 -17
- data/templates/backbone/app/views/styles/home.scss +0 -8
- data/templates/backbone/app/views/templates/home.mustache +0 -2
- data/templates/backbone/config.ru +0 -20
- data/templates/backbone/lib/all.js.coffee +0 -18
- data/templates/backbone/lib/backbone.js +0 -1158
- data/templates/backbone/lib/hogan.js +0 -509
- data/templates/backbone/lib/jquery.js +0 -9266
- data/templates/backbone/lib/underscore.js +0 -981
- data/templates/backbone/powrc +0 -2
- data/templates/backbone/source/default.htaccess.erb +0 -27
- data/templates/backbone/source/favicon.ico +0 -0
- data/templates/backbone/source/index.html.erb +0 -2
- data/templates/backbone/source/theme/screen.css.sass +0 -9
- data/templates/backbone/source/theme/scripts/app.js.coffee +0 -4
- data/templates/backbone/source/theme/styles/_tools.scss +0 -434
- data/templates/backbone/source/theme/templates/app.template.slim +0 -14
- data/templates/default/Rakefile +0 -38
- data/templates/default/powrc +0 -2
- data/templates/default/source/default.htaccess.erb +0 -27
- data/templates/default/source/feed.xml.builder.txt +0 -23
- 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
|
data/lib/gumdrop/version.rb
CHANGED
data/lib/gumdrop.rb
CHANGED
@@ -1,96 +1,59 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'tilt'
|
4
|
-
require '
|
5
|
-
require '
|
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 :
|
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 :
|
21
|
-
autoload :
|
13
|
+
autoload :Internal, 'gumdrop/cli/internal'
|
14
|
+
autoload :External, 'gumdrop/cli/external'
|
22
15
|
end
|
23
16
|
|
24
17
|
module Support
|
25
|
-
autoload :
|
26
|
-
autoload :
|
27
|
-
autoload :
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
data/specs/content_spec.rb
CHANGED
@@ -1,92 +1,102 @@
|
|
1
|
-
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'gumdrop'
|
4
|
-
#require File.join File.dirname(__FILE__), 'diff.rb'
|
1
|
+
require_relative 'spec_helper'
|
5
2
|
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
15
|
-
path= File.join ".", "specs", "fixtures", "expected", filename
|
16
|
-
File.read path
|
17
|
-
end
|
15
|
+
describe 'generated?' do
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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 "
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
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
|
-
|
35
|
-
|
40
|
+
# end
|
41
|
+
|
42
|
+
describe 'binary?' do
|
36
43
|
|
37
|
-
|
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
|
-
|
40
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
72
|
-
# Gumdrop::HashObject.new.must_be_instance_of Gumdrop::HashObject
|
73
|
-
# end
|
80
|
+
describe 'body()' do
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
89
|
-
# @ho.timmy.must_be_nil
|
90
|
-
# end
|
100
|
+
end
|
91
101
|
|
92
|
-
end
|
102
|
+
end
|
@@ -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
|
+
Test Nil
|
@@ -0,0 +1 @@
|
|
1
|
+
<body class="site"><wrap>Test Wrap</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,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);}});
|