merb-builder 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 YOUR NAME
1
+ Copyright (c) 2008 Jonathan Younger
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
3
  require "extlib"
4
4
  require 'merb-core/tasks/merb_rake_helper'
5
+ require "spec/rake/spectask"
5
6
 
6
7
  ##############################################################################
7
8
  # Package && release
@@ -16,7 +17,7 @@ GEM_EMAIL = "jonathan@daikini.com"
16
17
 
17
18
  GEM_NAME = "merb-builder"
18
19
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
19
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.7") + PKG_BUILD
20
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.8") + PKG_BUILD
20
21
 
21
22
  RELEASE_NAME = "REL #{GEM_VERSION}"
22
23
 
@@ -34,7 +35,7 @@ spec = Gem::Specification.new do |s|
34
35
  s.author = GEM_AUTHOR
35
36
  s.email = GEM_EMAIL
36
37
  s.homepage = PROJECT_URL
37
- s.add_dependency('merb-core', '>= 0.9.7')
38
+ s.add_dependency('merb-core', '>= 0.9.8')
38
39
  s.add_dependency('builder', '>= 2.0.0')
39
40
  s.require_path = 'lib'
40
41
  s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
@@ -45,15 +46,33 @@ Rake::GemPackageTask.new(spec) do |pkg|
45
46
  end
46
47
 
47
48
  desc "Install the gem"
48
- task :install => [:package] do
49
- sh install_command(GEM_NAME, GEM_VERSION)
49
+ task :install do
50
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
50
51
  end
51
52
 
52
- namespace :jruby do
53
+ desc "Uninstall the gem"
54
+ task :uninstall do
55
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
56
+ end
53
57
 
54
- desc "Run :package and install the resulting .gem with jruby"
55
- task :install => :package do
56
- sh jinstall_command(GEM_NAME, GEM_VERSION)
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
57
62
  end
63
+ end
58
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
59
75
  end
76
+
77
+ desc 'Default: run spec examples'
78
+ task :default => 'spec'
@@ -7,14 +7,21 @@ module Merb::Template
7
7
  # ==== Parameters
8
8
  # path<String>:: Path to the template file.
9
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.
10
11
  # mod<Class, Module>::
11
12
  # The class or module wherein this method should be defined.
12
- def self.compile_template(io, name, mod)
13
+ def self.compile_template(io, name, locals, mod)
13
14
  path = File.expand_path(io.path)
14
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
15
19
  mod.send(method, %{
16
- def #{name}
20
+ def #{name}(_locals={})
17
21
  @_engine = 'builder'
22
+
23
+ #{assigns}
24
+
18
25
  config = (Merb.config[:builder] || {}).inject({}) do |c, (k, v)|
19
26
  c[k.to_sym] = v
20
27
  c
@@ -12,7 +12,7 @@ describe "Builder" do
12
12
  c.body.should == @xml.target!
13
13
  end
14
14
 
15
- it "should be able to render partial Builder templates" do
15
+ it "should be able to render partial Builder templates and use locals" do
16
16
  c = dispatch_to(PartialBuilder, :index, :format => "xml")
17
17
  @xml.hello "World"
18
18
  c.body.should == @xml.target!
@@ -1 +1 @@
1
- xml.hello 'World'
1
+ xml.hello world
@@ -1,2 +1,2 @@
1
1
  xml.instruct!
2
- xml << partial(:partial_builder)
2
+ xml << partial(:partial_builder, :world => "World")
@@ -1,4 +1,3 @@
1
- $TESTING=true
2
1
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
2
  require "rubygems"
4
3
  require "merb-core"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Younger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-09 00:00:00 +03:00
12
+ date: 2008-10-06 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.7
23
+ version: 0.9.8
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: builder