flatrack 0.0.1.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +61 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/flatrack +0 -0
- data/flatrack.gemspec +31 -0
- data/lib/flatrack/app.rb +12 -0
- data/lib/flatrack/asset_extensions.rb +9 -0
- data/lib/flatrack/rake/tasks.rb +9 -0
- data/lib/flatrack/renderer/base.rb +21 -0
- data/lib/flatrack/renderer.rb +23 -0
- data/lib/flatrack/request.rb +49 -0
- data/lib/flatrack/response/view_context.rb +75 -0
- data/lib/flatrack/response.rb +75 -0
- data/lib/flatrack/version.rb +3 -0
- data/lib/flatrack.rb +37 -0
- data/lib/rake/asset_tasks.rb +106 -0
- data/renderers/erb.rb +11 -0
- data/renderers/html.rb +11 -0
- data/renderers/rb.rb +17 -0
- data/spec/spec_helper.rb +9 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 069be5f2f4982c44837bc6529a43e087c9abeee2
|
4
|
+
data.tar.gz: e50462d7742e4c32eba46b4dc0e4ed7067db24c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 87476f39909af938c08d85c1021ea22593566edd9e4c160d90c602feabb06f8f03fd1f37459fb47b251e4934212fc3003cdfc01c9ed0baf3512057bfc8be4dcc
|
7
|
+
data.tar.gz: 2fa43b09d45be828162c4fb3552767cb0f86d306b815d95ad21a038881879ad2acce95d0b571b15e15feb5e1abf541494a36c9dd5f9b9832ca8e7a21862979c7
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
flatrack (0.0.1)
|
5
|
+
activesupport
|
6
|
+
coffee-script
|
7
|
+
rack
|
8
|
+
rake
|
9
|
+
sass
|
10
|
+
sprockets
|
11
|
+
thor
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
activesupport (4.0.2)
|
17
|
+
i18n (~> 0.6, >= 0.6.4)
|
18
|
+
minitest (~> 4.2)
|
19
|
+
multi_json (~> 1.3)
|
20
|
+
thread_safe (~> 0.1)
|
21
|
+
tzinfo (~> 0.3.37)
|
22
|
+
atomic (1.1.14)
|
23
|
+
coffee-script (2.2.0)
|
24
|
+
coffee-script-source
|
25
|
+
execjs
|
26
|
+
coffee-script-source (1.6.3)
|
27
|
+
diff-lcs (1.2.5)
|
28
|
+
execjs (2.0.2)
|
29
|
+
hike (1.2.3)
|
30
|
+
i18n (0.6.9)
|
31
|
+
minitest (4.7.5)
|
32
|
+
multi_json (1.8.2)
|
33
|
+
rack (1.5.2)
|
34
|
+
rake (10.1.0)
|
35
|
+
rspec (2.14.1)
|
36
|
+
rspec-core (~> 2.14.0)
|
37
|
+
rspec-expectations (~> 2.14.0)
|
38
|
+
rspec-mocks (~> 2.14.0)
|
39
|
+
rspec-core (2.14.7)
|
40
|
+
rspec-expectations (2.14.4)
|
41
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
42
|
+
rspec-mocks (2.14.4)
|
43
|
+
sass (3.2.12)
|
44
|
+
sprockets (2.10.1)
|
45
|
+
hike (~> 1.2)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
rack (~> 1.0)
|
48
|
+
tilt (~> 1.1, != 1.3.0)
|
49
|
+
thor (0.18.1)
|
50
|
+
thread_safe (0.1.3)
|
51
|
+
atomic
|
52
|
+
tilt (1.4.1)
|
53
|
+
tzinfo (0.3.38)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 1.5)
|
60
|
+
flatrack!
|
61
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jason Waldrip
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Flat::Rack
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'flat-rack'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install flat-rack
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/flat-rack/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/flatrack
ADDED
File without changes
|
data/flatrack.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'flatrack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "flatrack"
|
8
|
+
spec.version = FlatRack::VERSION
|
9
|
+
spec.authors = ["Jason Waldrip"]
|
10
|
+
spec.email = ["jason@waldrip.net"]
|
11
|
+
spec.summary = 'A template based flat rack site'
|
12
|
+
spec.homepage = "https://github.com/jwaldrip/flatrack"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.files = Dir.glob File.join __dir__, '**', '*'
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'rack'
|
22
|
+
spec.add_dependency 'activesupport'
|
23
|
+
spec.add_dependency 'sass'
|
24
|
+
spec.add_dependency 'sprockets'
|
25
|
+
spec.add_dependency 'thor'
|
26
|
+
spec.add_dependency 'coffee-script'
|
27
|
+
spec.add_dependency 'rake'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
end
|
data/lib/flatrack/app.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module FlatRack
|
2
|
+
module Renderer
|
3
|
+
class Base
|
4
|
+
|
5
|
+
attr_reader :contents
|
6
|
+
|
7
|
+
def self.renders(ext = nil)
|
8
|
+
@renders = ext.to_sym
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.renders?(ext)
|
12
|
+
@renders == ext.to_sym
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(file)
|
16
|
+
@contents = File.read file
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FlatRack
|
2
|
+
module Renderer
|
3
|
+
extend self
|
4
|
+
extend ActiveSupport::Autoload
|
5
|
+
|
6
|
+
autoload :Base
|
7
|
+
|
8
|
+
def find(file)
|
9
|
+
template = (Dir[File.join 'pages', "#{file}*"] + Dir[File.join 'layouts', "#{file}*"]).first
|
10
|
+
raise FileNotFound, "could not find #{file}" unless template
|
11
|
+
ext = File.extname(template).sub(/\./, '')
|
12
|
+
|
13
|
+
Base.descendants.find { |descendant| descendant.renders?(ext) } ||
|
14
|
+
raise(RendererNotFound, "could not find a renderer for #{file}")
|
15
|
+
|
16
|
+
klass = const_get(name.split('_').map(&:capitalize).join, false)
|
17
|
+
klass.new template
|
18
|
+
rescue NameError, TypeError
|
19
|
+
raise RendererNotFound, "could not find a renderer for #{file}"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FlatRack
|
2
|
+
class Request
|
3
|
+
|
4
|
+
DEFAULT_FORMAT = 'html'
|
5
|
+
|
6
|
+
attr_reader :env, :rack_request
|
7
|
+
|
8
|
+
def initialize(env)
|
9
|
+
@rack_request = Rack::Request.new(env)
|
10
|
+
@env = env
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
env['REQUEST_PATH']
|
15
|
+
end
|
16
|
+
|
17
|
+
def headers
|
18
|
+
env.reduce({}) do |hash, (key, value)|
|
19
|
+
next hash unless /^HTTP_(?<name>.+)/ =~ key
|
20
|
+
hash.merge name.downcase.to_sym => value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def params
|
25
|
+
rack_request.params.with_indifferent_access
|
26
|
+
end
|
27
|
+
|
28
|
+
def format
|
29
|
+
(ext = File.extname path).empty? ? DEFAULT_FORMAT : ext.sub(/\./, '')
|
30
|
+
end
|
31
|
+
|
32
|
+
def response
|
33
|
+
Response.new(self).render
|
34
|
+
rescue RendererNotFound
|
35
|
+
respond_with_error(500)
|
36
|
+
rescue FileNotFound
|
37
|
+
respond_with_error(404)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def respond_with_error(code)
|
43
|
+
Response.new(self).render(file: "#{code}.html", status: code)
|
44
|
+
rescue FileNotFound
|
45
|
+
Response.new(self).render(text: code, status: code)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module FlatRack
|
2
|
+
class Response
|
3
|
+
class ViewContext
|
4
|
+
|
5
|
+
def initialize(response)
|
6
|
+
@response = response
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_binding
|
10
|
+
binding
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
@response.request.path
|
15
|
+
end
|
16
|
+
|
17
|
+
def params
|
18
|
+
@response.request.params
|
19
|
+
end
|
20
|
+
|
21
|
+
def files
|
22
|
+
Dir.glob(File.join 'pages', path, '*').map do |file|
|
23
|
+
File.basename File.basename(file, '.*'), '.*'
|
24
|
+
end - [DEFAULT_FILE]
|
25
|
+
end
|
26
|
+
|
27
|
+
def image_tag(uri, options = {})
|
28
|
+
uri = File.join('/assets', uri.to_s) + '.js' if uri.is_a? Symbol
|
29
|
+
html_tag(:img, { src: uri }.merge(options))
|
30
|
+
end
|
31
|
+
|
32
|
+
def javascript_tag(uri)
|
33
|
+
uri = File.join('/assets', uri.to_s) + '.js' if uri.is_a? Symbol
|
34
|
+
html_tag(:script, src: uri){ nil }
|
35
|
+
end
|
36
|
+
|
37
|
+
def stylesheet_tag(uri)
|
38
|
+
uri = File.join('/assets', uri.to_s) + '.css' if uri.is_a? Symbol
|
39
|
+
html_tag(:link, rel: 'stylesheet', type: 'text/css', href: uri)
|
40
|
+
end
|
41
|
+
|
42
|
+
def page_stylesheet_tag
|
43
|
+
file = @response.send(:file_for, path.to_s)
|
44
|
+
base_path = File.join File.dirname(file), File.basename(file, '.*')
|
45
|
+
stylesheet_tag base_path if stylesheet_exists?(base_path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def link_to(name, link, options={})
|
49
|
+
link = [link, options.delete(:params).to_param].join('?') if options[:params].is_a?(Hash) && options[:params].present?
|
50
|
+
html_tag(:a, { href: link }.merge(options) ){ name }
|
51
|
+
end
|
52
|
+
|
53
|
+
def html_tag(tag, options={}, &block)
|
54
|
+
[].tap do |lines|
|
55
|
+
lines << "<#{tag} " + options.map{ |k, v| "#{k}=\"#{v}\"" }.join(' ') + (block_given? ? ">" : "/>")
|
56
|
+
if block_given?
|
57
|
+
lines << yield
|
58
|
+
lines << "</#{tag}>"
|
59
|
+
end
|
60
|
+
end.compact.join("\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def stylesheet_exists?(name)
|
66
|
+
FlatRack.assets[name]
|
67
|
+
end
|
68
|
+
|
69
|
+
def javascript_exists?(name)
|
70
|
+
FlatRack.assets[name]
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module FlatRack
|
2
|
+
class Response
|
3
|
+
|
4
|
+
autoload :ViewContext, 'flatrack/response/view_context'
|
5
|
+
|
6
|
+
DEFAULT_FILE = 'index'
|
7
|
+
CONTENT_TYPES = {
|
8
|
+
html: 'text/html',
|
9
|
+
rb: 'text/html'
|
10
|
+
}
|
11
|
+
|
12
|
+
attr_reader :request
|
13
|
+
|
14
|
+
def initialize(request)
|
15
|
+
@request = request
|
16
|
+
end
|
17
|
+
|
18
|
+
def render(options={})
|
19
|
+
file, text, status, layout = options.values_at(:file, :text, :status, :layout)
|
20
|
+
set_content_type
|
21
|
+
status ||= 200
|
22
|
+
if text
|
23
|
+
render_text text, status: status
|
24
|
+
else
|
25
|
+
render_file file, status: status, layout: layout
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def headers
|
30
|
+
@headers ||= {}
|
31
|
+
end
|
32
|
+
|
33
|
+
def body
|
34
|
+
@body ||= []
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_content_type
|
38
|
+
headers['Content-Type'] = CONTENT_TYPES[request.format.to_sym]
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def render_file(file = nil, options={})
|
44
|
+
status, layout = options.values_at(:status, :layout)
|
45
|
+
layout ||= :layout
|
46
|
+
file ||= file_for(request.path)
|
47
|
+
contents = renderer_for(file).render(view_context)
|
48
|
+
contents = layout_for(layout).render(view_context){ contents } if layout
|
49
|
+
self.body << contents
|
50
|
+
[status, headers, body]
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_text(text = '', options={})
|
54
|
+
status = options[:status]
|
55
|
+
[status, headers, [text.to_s]]
|
56
|
+
end
|
57
|
+
|
58
|
+
def file_for(path)
|
59
|
+
File.directory?(File.join 'pages', path) ? File.join(path, DEFAULT_FILE) : path
|
60
|
+
end
|
61
|
+
|
62
|
+
def renderer_for(file)
|
63
|
+
Renderer.find file
|
64
|
+
end
|
65
|
+
|
66
|
+
def layout_for(file)
|
67
|
+
Renderer.find File.join("#{file}.#{request.format}")
|
68
|
+
end
|
69
|
+
|
70
|
+
def view_context
|
71
|
+
@view_context ||= ViewContext.new(self)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
data/lib/flatrack.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'flatrack/version'
|
2
|
+
require 'sprockets'
|
3
|
+
require 'active_support/all'
|
4
|
+
|
5
|
+
module FlatRack
|
6
|
+
extend ActiveSupport::Autoload
|
7
|
+
|
8
|
+
autoload :Renderer
|
9
|
+
autoload :Request
|
10
|
+
autoload :Response
|
11
|
+
autoload :App
|
12
|
+
autoload :AssetExtensions
|
13
|
+
|
14
|
+
RendererNotFound = Class.new(StandardError)
|
15
|
+
FileNotFound = Class.new StandardError
|
16
|
+
|
17
|
+
FORMATS = {
|
18
|
+
'html' => 'text/html',
|
19
|
+
'rb' => 'text/html'
|
20
|
+
}
|
21
|
+
|
22
|
+
def self.assets
|
23
|
+
@assets ||= begin
|
24
|
+
Sprockets::Environment.new.tap do |environment|
|
25
|
+
environment.append_path 'assets/images'
|
26
|
+
environment.append_path 'assets/javascripts'
|
27
|
+
environment.append_path 'assets/stylesheets'
|
28
|
+
environment.context_class.class_eval { include AssetExtensions }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
I18n.enforce_available_locales = false
|
34
|
+
|
35
|
+
Dir.glob(File.expand_path File.join __FILE__, '../../renderers/**/*.rb').each { |f| require f }
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'flatrack'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
module Rake
|
7
|
+
# Simple Sprockets compilation Rake task macro.
|
8
|
+
#
|
9
|
+
# Rake::AssetTasks.new
|
10
|
+
#
|
11
|
+
class AssetTasks < Rake::TaskLib
|
12
|
+
|
13
|
+
attr_reader :environment
|
14
|
+
attr_reader :index
|
15
|
+
attr_reader :manifest
|
16
|
+
attr_reader :output
|
17
|
+
attr_reader :keep
|
18
|
+
|
19
|
+
# Number of old assets to keep.
|
20
|
+
|
21
|
+
# Logger to use during rake tasks. Defaults to using stderr.
|
22
|
+
#
|
23
|
+
# t.logger = Logger.new($stdout)
|
24
|
+
#
|
25
|
+
attr_accessor :logger
|
26
|
+
|
27
|
+
# Returns logger level Integer.
|
28
|
+
def log_level
|
29
|
+
@logger.level
|
30
|
+
end
|
31
|
+
|
32
|
+
# Set logger level with constant or symbol.
|
33
|
+
#
|
34
|
+
# t.log_level = Logger::INFO
|
35
|
+
# t.log_level = :debug
|
36
|
+
#
|
37
|
+
def log_level=(level)
|
38
|
+
if level.is_a?(Integer)
|
39
|
+
@logger.level = level
|
40
|
+
else
|
41
|
+
@logger.level = Logger.const_get(level.to_s.upcase)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize
|
46
|
+
@environment = FlatRack.assets
|
47
|
+
@logger = Logger.new($stderr)
|
48
|
+
@logger.level = Logger::INFO
|
49
|
+
@index = environment.index
|
50
|
+
@output = "./public/assets"
|
51
|
+
@manifest = Sprockets::Manifest.new(index, output)
|
52
|
+
@keep = 2
|
53
|
+
define
|
54
|
+
end
|
55
|
+
|
56
|
+
def assets
|
57
|
+
Dir['assets/**/*.*'].map do |file|
|
58
|
+
file_basename = File.basename file
|
59
|
+
file = file.split('.').tap(&:pop).join('.') if file_basename.split('.').size > 2
|
60
|
+
File.expand_path(file).sub(/(#{environment.paths.join('|')})\//,'')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Define tasks
|
65
|
+
def define
|
66
|
+
namespace :assets do
|
67
|
+
desc 'precompile assets'
|
68
|
+
task :precompile do
|
69
|
+
with_logger do
|
70
|
+
manifest.compile(assets)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Remove all assets"
|
75
|
+
task :clobber do
|
76
|
+
with_logger do
|
77
|
+
manifest.clobber
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Clean old assets"
|
82
|
+
task :clean do
|
83
|
+
with_logger do
|
84
|
+
manifest.clean(keep)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
# Sub out environment logger with our rake task logger that
|
94
|
+
# writes to stderr.
|
95
|
+
def with_logger
|
96
|
+
if env = manifest.environment
|
97
|
+
old_logger = env.logger
|
98
|
+
env.logger = @logger
|
99
|
+
end
|
100
|
+
yield
|
101
|
+
ensure
|
102
|
+
env.logger = old_logger if env
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
data/renderers/erb.rb
ADDED
data/renderers/html.rb
ADDED
data/renderers/rb.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'flatrack/renderer/base'
|
2
|
+
|
3
|
+
class FlatRack::Renderer::Rb < FlatRack::Renderer::Base
|
4
|
+
|
5
|
+
renders :rb
|
6
|
+
|
7
|
+
def render(context)
|
8
|
+
result = nil
|
9
|
+
evaluator = Thread.start do
|
10
|
+
$SAFE = 3
|
11
|
+
result = eval contents, context
|
12
|
+
end
|
13
|
+
nil while evaluator.alive?
|
14
|
+
result
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flatrack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.dev
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Waldrip
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sass
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sprockets
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coffee-script
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.5'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.5'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- jason@waldrip.net
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- "./Gemfile"
|
147
|
+
- "./Gemfile.lock"
|
148
|
+
- "./LICENSE.txt"
|
149
|
+
- "./README.md"
|
150
|
+
- "./Rakefile"
|
151
|
+
- "./bin/flatrack"
|
152
|
+
- "./flatrack.gemspec"
|
153
|
+
- "./lib/flatrack.rb"
|
154
|
+
- "./lib/flatrack/app.rb"
|
155
|
+
- "./lib/flatrack/asset_extensions.rb"
|
156
|
+
- "./lib/flatrack/rake/tasks.rb"
|
157
|
+
- "./lib/flatrack/renderer.rb"
|
158
|
+
- "./lib/flatrack/renderer/base.rb"
|
159
|
+
- "./lib/flatrack/request.rb"
|
160
|
+
- "./lib/flatrack/response.rb"
|
161
|
+
- "./lib/flatrack/response/view_context.rb"
|
162
|
+
- "./lib/flatrack/version.rb"
|
163
|
+
- "./lib/rake/asset_tasks.rb"
|
164
|
+
- "./renderers/erb.rb"
|
165
|
+
- "./renderers/html.rb"
|
166
|
+
- "./renderers/rb.rb"
|
167
|
+
- "./spec/spec_helper.rb"
|
168
|
+
homepage: https://github.com/jwaldrip/flatrack
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">"
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: 1.3.1
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.2.0
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: A template based flat rack site
|
192
|
+
test_files: []
|