merb_builder 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +4 -0
- data/Rakefile +78 -0
- data/TODO +5 -0
- data/lib/merb-builder.rb +2 -0
- data/lib/merb-builder/template.rb +70 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Jonathan Younger
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require "extlib"
|
4
|
+
require 'merb-core/tasks/merb_rake_helper'
|
5
|
+
require "spec/rake/spectask"
|
6
|
+
|
7
|
+
##############################################################################
|
8
|
+
# Package && release
|
9
|
+
##############################################################################
|
10
|
+
RUBY_FORGE_PROJECT = "merb"
|
11
|
+
PROJECT_URL = "http://merbivore.com"
|
12
|
+
PROJECT_SUMMARY = "Merb plugin that provides Builder support"
|
13
|
+
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
14
|
+
|
15
|
+
GEM_AUTHOR = "Jonathan Younger"
|
16
|
+
GEM_EMAIL = "jonathan@daikini.com"
|
17
|
+
|
18
|
+
GEM_NAME = "merb_builder"
|
19
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
20
|
+
GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.9") + PKG_BUILD
|
21
|
+
|
22
|
+
RELEASE_NAME = "REL #{GEM_VERSION}"
|
23
|
+
|
24
|
+
require "extlib/tasks/release"
|
25
|
+
|
26
|
+
spec = Gem::Specification.new do |s|
|
27
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
28
|
+
s.name = GEM_NAME
|
29
|
+
s.version = GEM_VERSION
|
30
|
+
s.platform = Gem::Platform::RUBY
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
33
|
+
s.summary = PROJECT_SUMMARY
|
34
|
+
s.description = PROJECT_DESCRIPTION
|
35
|
+
s.author = GEM_AUTHOR
|
36
|
+
s.email = GEM_EMAIL
|
37
|
+
s.homepage = PROJECT_URL
|
38
|
+
s.add_dependency('merb-core', '>= 0.9.9')
|
39
|
+
s.add_dependency('builder', '>= 2.0.0')
|
40
|
+
s.require_path = 'lib'
|
41
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib}/**/*")
|
42
|
+
end
|
43
|
+
|
44
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
45
|
+
pkg.gem_spec = spec
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Install the gem"
|
49
|
+
task :install do
|
50
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Uninstall the gem"
|
54
|
+
task :uninstall do
|
55
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Create a gemspec file"
|
59
|
+
task :gemspec do
|
60
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
61
|
+
file.puts spec.to_ruby
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Run all examples (or a specific spec with TASK=xxxx)"
|
66
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
67
|
+
t.spec_opts = ["-cfs"]
|
68
|
+
t.spec_files = begin
|
69
|
+
if ENV["TASK"]
|
70
|
+
ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
|
71
|
+
else
|
72
|
+
FileList['spec/**/*_spec.rb']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Default: run spec examples'
|
78
|
+
task :default => 'spec'
|
data/TODO
ADDED
data/lib/merb-builder.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
module Merb::Template
|
2
|
+
|
3
|
+
class Builder
|
4
|
+
|
5
|
+
# Defines a method for calling a specific Builder template.
|
6
|
+
#
|
7
|
+
# ==== Parameters
|
8
|
+
# path<String>:: Path to the template file.
|
9
|
+
# name<~to_s>:: The name of the template method.
|
10
|
+
# locals<Array[Symbol]>:: A list of locals to assign from the args passed into the compiled template.
|
11
|
+
# mod<Class, Module>::
|
12
|
+
# The class or module wherein this method should be defined.
|
13
|
+
def self.compile_template(io, name, locals, mod)
|
14
|
+
path = File.expand_path(io.path)
|
15
|
+
method = mod.is_a?(Module) ? :module_eval : :instance_eval
|
16
|
+
assigns = locals.inject([]) do |a, l|
|
17
|
+
a << "#{l} = _locals[#{l.inspect}];"
|
18
|
+
end.join
|
19
|
+
mod.send(method, %{
|
20
|
+
def #{name}(_locals={})
|
21
|
+
@_engine = 'builder'
|
22
|
+
|
23
|
+
#{assigns}
|
24
|
+
|
25
|
+
config = (Merb.config[:builder] || {}).inject({}) do |c, (k, v)|
|
26
|
+
c[k.to_sym] = v
|
27
|
+
c
|
28
|
+
end
|
29
|
+
xml = ::Builder::XmlMarkup.new(config)
|
30
|
+
self.instance_eval %{#{io.read}}
|
31
|
+
xml.target!
|
32
|
+
end
|
33
|
+
})
|
34
|
+
|
35
|
+
name
|
36
|
+
end
|
37
|
+
|
38
|
+
module Mixin
|
39
|
+
def _builder_buffer(the_binding)
|
40
|
+
@_buffer = eval("xml", the_binding, __FILE__, __LINE__)
|
41
|
+
end
|
42
|
+
# ==== Parameters
|
43
|
+
# *args:: Arguments to pass to the block.
|
44
|
+
# &block:: The template block to call.
|
45
|
+
#
|
46
|
+
# ==== Returns
|
47
|
+
# String:: The output of the block.
|
48
|
+
#
|
49
|
+
# ==== Examples
|
50
|
+
# Capture being used in a .html.erb page:
|
51
|
+
#
|
52
|
+
# @foo = capture do
|
53
|
+
# xml.instruct!
|
54
|
+
# xml.foo do
|
55
|
+
# xml.bar "baz"
|
56
|
+
# end
|
57
|
+
# xml.target!
|
58
|
+
# end
|
59
|
+
def capture_builder(*args, &block)
|
60
|
+
block.call(*args)
|
61
|
+
end
|
62
|
+
|
63
|
+
def concat_builder(string, binding)
|
64
|
+
_builder_buffer(binding) << string
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
Merb::Template.register_extensions(self, %w[builder])
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb_builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Younger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-10-14 00:00:00 +03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: builder
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.0
|
34
|
+
version:
|
35
|
+
description: Merb plugin that provides Builder support
|
36
|
+
email: jonathan@daikini.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
- LICENSE
|
44
|
+
- TODO
|
45
|
+
files:
|
46
|
+
- LICENSE
|
47
|
+
- README
|
48
|
+
- Rakefile
|
49
|
+
- TODO
|
50
|
+
- lib/merb-builder
|
51
|
+
- lib/merb-builder/template.rb
|
52
|
+
- lib/merb-builder.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://merbivore.com
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project: merb
|
75
|
+
rubygems_version: 1.2.0
|
76
|
+
signing_key:
|
77
|
+
specification_version: 2
|
78
|
+
summary: Merb plugin that provides Builder support
|
79
|
+
test_files: []
|
80
|
+
|