minimal 0.0.3 → 0.0.5

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/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'http://gemcutter.org'
2
2
 
3
- gem 'actionpack', '>=3.0.0.beta'
3
+ gem 'actionpack', '>=3.0.0.beta2'
4
4
 
5
5
 
data/Rakefile CHANGED
@@ -1,28 +1,9 @@
1
1
  require 'rake/testtask'
2
2
 
3
- require File.expand_path("../lib/minimal/version", __FILE__)
4
-
5
3
  task :default => [:test]
6
4
 
7
5
  Rake::TestTask.new(:test) do |t|
8
6
  t.pattern = "#{File.dirname(__FILE__)}/test/**/*_test.rb"
9
7
  t.verbose = true
10
8
  end
11
- Rake::Task['test'].comment = "Run all tests"
12
-
13
-
14
- begin
15
- require 'jeweler'
16
- Jeweler::Tasks.new do |s|
17
- s.name = "minimal"
18
- s.version = Minimal::VERSION
19
- s.summary = "Minimal templating engine inspired by Markaby & Erector"
20
- s.email = "svenfuchs@artweb-design.de"
21
- s.homepage = "http://github.com/svenfuchs/minimal"
22
- s.description = "Minimal templating engine inspired by Markaby & Erector and targeted at Rails 3"
23
- s.authors = ['Sven Fuchs']
24
- s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
25
- end
26
- rescue LoadError
27
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
28
- end
9
+ Rake::Task['test'].comment = "Run all tests"
@@ -14,7 +14,7 @@ class Minimal::Template
14
14
 
15
15
  def method_missing(method, *args, &block)
16
16
  if [:form_for, :fields_for].include?(method)
17
- view.form_for(*args) { |builder| yield(Proxy.new(self, builder)) }
17
+ self << view.send(method, *args) { |builder| yield(Proxy.new(self, builder)) }
18
18
  else
19
19
  super
20
20
  end
@@ -3,7 +3,7 @@ class Minimal::Template
3
3
  autoload :Handler, 'minimal/template/handler'
4
4
 
5
5
  AUTO_BUFFER = %r(render|tag|error_message_|select|debug|_to|_for)
6
- NO_AUTO_BUFFER = %r(form_tag|form_for)
6
+ # NO_AUTO_BUFFER = %r(form_tag|form_for)
7
7
 
8
8
  TAG_NAMES = %w(a body div em fieldset h1 h2 h3 h4 head html img input label li
9
9
  link ol option p pre script select span strong table thead tbody tfoot td th tr ul)
@@ -44,7 +44,7 @@ class Minimal::Template
44
44
  end
45
45
 
46
46
  def auto_buffer?(method)
47
- AUTO_BUFFER =~ method.to_s && NO_AUTO_BUFFER !~ method.to_s
47
+ AUTO_BUFFER =~ method.to_s # && NO_AUTO_BUFFER !~ method.to_s
48
48
  end
49
49
  end
50
50
  include Base
@@ -1,3 +1,3 @@
1
1
  module Minimal
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sven Fuchs
@@ -14,47 +14,34 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-02 00:00:00 +02:00
17
+ date: 2010-04-03 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description: Minimal templating engine inspired by Markaby & Erector and targeted at Rails 3
21
+ description: Minimal templating engine inspired by Markaby & Erector and targeted at Rails 3.
22
22
  email: svenfuchs@artweb-design.de
23
23
  executables: []
24
24
 
25
25
  extensions: []
26
26
 
27
- extra_rdoc_files:
28
- - README.textile
27
+ extra_rdoc_files: []
28
+
29
29
  files:
30
- - Gemfile
31
- - README.textile
32
- - Rakefile
33
- - lib/minimal.rb
34
- - lib/minimal/template.rb
35
30
  - lib/minimal/template/form_builder_proxy.rb
36
31
  - lib/minimal/template/handler.rb
32
+ - lib/minimal/template.rb
37
33
  - lib/minimal/version.rb
38
- - test/all.rb
39
- - test/fixtures/views/foo/_partial.rb
40
- - test/fixtures/views/foo/form_for.rb
41
- - test/fixtures/views/foo/form_tag.rb
42
- - test/fixtures/views/foo/misc_helpers.rb
43
- - test/fixtures/views/foo/partial.rb
44
- - test/fixtures/views/foo/simple.rb
45
- - test/fixtures/views/foo/table.rb
46
- - test/fixtures/views/mime_types/partial.css.rb
47
- - test/fixtures/views/mime_types/partial.html.rb
48
- - test/template_handler_test.rb
49
- - test/template_test.rb
50
- - test/test_helper.rb
34
+ - lib/minimal.rb
35
+ - Gemfile
36
+ - Rakefile
37
+ - README.textile
51
38
  has_rdoc: true
52
39
  homepage: http://github.com/svenfuchs/minimal
53
40
  licenses: []
54
41
 
55
42
  post_install_message:
56
- rdoc_options:
57
- - --charset=UTF-8
43
+ rdoc_options: []
44
+
58
45
  require_paths:
59
46
  - lib
60
47
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -69,26 +56,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
56
  - - ">="
70
57
  - !ruby/object:Gem::Version
71
58
  segments:
72
- - 0
73
- version: "0"
59
+ - 1
60
+ - 3
61
+ - 6
62
+ version: 1.3.6
74
63
  requirements: []
75
64
 
76
- rubyforge_project:
65
+ rubyforge_project: "[none]"
77
66
  rubygems_version: 1.3.6
78
67
  signing_key:
79
68
  specification_version: 3
80
69
  summary: Minimal templating engine inspired by Markaby & Erector
81
- test_files:
82
- - test/all.rb
83
- - test/fixtures/views/foo/_partial.rb
84
- - test/fixtures/views/foo/form_for.rb
85
- - test/fixtures/views/foo/form_tag.rb
86
- - test/fixtures/views/foo/misc_helpers.rb
87
- - test/fixtures/views/foo/partial.rb
88
- - test/fixtures/views/foo/simple.rb
89
- - test/fixtures/views/foo/table.rb
90
- - test/fixtures/views/mime_types/partial.css.rb
91
- - test/fixtures/views/mime_types/partial.html.rb
92
- - test/template_handler_test.rb
93
- - test/template_test.rb
94
- - test/test_helper.rb
70
+ test_files: []
71
+
data/test/all.rb DELETED
@@ -1,3 +0,0 @@
1
- Dir[File.dirname(__FILE__) + '/**/*_test.rb'].each do |filename|
2
- require filename
3
- end
@@ -1,7 +0,0 @@
1
- module Foo
2
- class Partial < Minimal::Template
3
- def content
4
- p local
5
- end
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- module Foo
2
- class FormFor < Minimal::Template
3
- def content
4
- div 'foo'
5
- form_for 'foo', :url => '/foo' do |f|
6
- div { f.text_field('bar') }
7
- f.text_field('baz')
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Foo
2
- class FormTag < Minimal::Template
3
- def content
4
- div 'foo'
5
- form_tag '/foo' do
6
- div { text_field_tag('bar') }
7
- text_field_tag('baz')
8
- end
9
- end
10
- end
11
- end
@@ -1,16 +0,0 @@
1
- module Foo
2
- class MiscHelpers < Minimal::Template
3
- def content
4
- image_tag('http://no-asset-host.com/rails.png')
5
- debug('foo')
6
- javascript_tag("alert('All is good')")
7
- # div_for(Record.new) { self << 'content' }
8
- tag('br')
9
- content_tag(:p, 'Hello world!')
10
- content_tag(:p) { self << 'Hello world!' }
11
- content_tag(:p) { em 'Hello world!' }
12
- content_tag(:p) { em { self << 'Hello world!' } }
13
- link_to('foo', '#')
14
- end
15
- end
16
- end
@@ -1,12 +0,0 @@
1
- module Foo
2
- class Partial < Minimal::Template
3
- def content
4
- div do
5
- %w(foo bar).each do |local|
6
- render :partial => 'foo/partial', :locals => { :local => local }
7
- end
8
- end
9
- render :partial => 'foo/partial', :locals => { :local => 'baz' }
10
- end
11
- end
12
- end
@@ -1,18 +0,0 @@
1
- module Foo
2
- class Simple < Minimal::Template
3
- def content
4
- html do
5
- head
6
- body do
7
- h1 'plain'
8
- bar
9
- div { div 'nested' }
10
- end
11
- end
12
- end
13
-
14
- def bar
15
- p escape_once(local)
16
- end
17
- end
18
- end
@@ -1,11 +0,0 @@
1
- module Foo
2
- class Table < Minimal::Template
3
- def content
4
- table do
5
- tr do
6
- %w(foo bar baz).each { |text| td text }
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,4 +0,0 @@
1
- module MimeTypes
2
- class Partial < Minimal::Template
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module MimeTypes
2
- class Partial < Minimal::Template
3
- end
4
- end
@@ -1,17 +0,0 @@
1
- require File.expand_path('../test_helper', __FILE__)
2
-
3
- class TemplateHandlerTest < Test::Unit::TestCase
4
- def template_class_name(path)
5
- handler = Minimal::Template::Handler.new
6
- handler.send(:template_class_name, path)
7
- end
8
-
9
- test "template_class_name without a mime type" do
10
- assert_equal 'Foo::Bar', template_class_name('path/to/views/foo/bar.rb')
11
- end
12
-
13
- test "template_class_name with a mime type" do
14
- assert_equal 'Foo::Bar::Html', template_class_name('path/to/views/foo/bar.html.rb')
15
- assert_equal 'Foo::Bar::Css', template_class_name('path/to/views/foo/bar.css.rb')
16
- end
17
- end
@@ -1,117 +0,0 @@
1
- require File.expand_path('../test_helper', __FILE__)
2
-
3
- class TemplateTest < Test::Unit::TestCase
4
- def setup
5
- @view = @template = nil
6
- end
7
-
8
- def view
9
- @view ||= ActionView::Base.new(FIXTURES_PATH).tap do |view|
10
- view.output_buffer = ActiveSupport::SafeBuffer.new rescue ''
11
- end
12
- end
13
-
14
- def template
15
- @template ||= Minimal::Template.new(view)
16
- end
17
-
18
- test "capturing a block" do
19
- result = view.with_output_buffer do
20
- view.concat('foo')
21
- view.concat('bar')
22
- 'baz'
23
- end
24
- assert_equal 'foobar', result
25
- end
26
-
27
- test "capturing a helper with a block" do
28
- block = lambda do
29
- view.concat('foo')
30
- view.concat('bar')
31
- 'baz'
32
- end
33
- result = view.content_tag(:div, &lambda { view.with_output_buffer(&block) })
34
- assert_equal '<div>foobar</div>', result
35
- end
36
-
37
- test "call_view calling a non-concating helper without a block" do
38
- result = template.send(:call_view, :number_with_precision, 1234)
39
- assert_equal '1234.000', result
40
- end
41
-
42
- test "call_view calling a non-concating helper with a block" do
43
- template.send(:call_view, :content_tag, :div) do
44
- template << 'foo'
45
- template << 'bar'
46
- 'baz'
47
- end
48
- assert_equal '<div>foobar</div>', view.output_buffer
49
- end
50
-
51
- test "call_view calling a concating helper with a block" do
52
- template.send(:call_view, :form_for, 'foo', :url => '/foo') do |f|
53
- template << f.text_field('foo')
54
- template << f.text_field('bar')
55
- 'baz'
56
- end
57
- html = '<form action="/foo" method="post">' +
58
- '<input id="foo_foo" name="foo[foo]" size="30" type="text" />' +
59
- '<input id="foo_bar" name="foo[bar]" size="30" type="text" />' +
60
- '</form>'
61
- assert_equal html, view.output_buffer
62
- end
63
-
64
- # test "does not buffer but return a helper's result when :capture => true was passed'" do
65
- # result = template.a('foo', :href => '#', :capture => true)
66
- # assert_equal '<a href="#">foo</a>', result
67
- # assert_equal '', view.output_buffer
68
- # end
69
-
70
- test "simple render with local assigns" do
71
- html = '<html><head></head><body><h1>plain</h1><p>local</p><div><div>nested</div></div></body></html>'
72
- assert_equal html, view.render(:file => 'foo/simple', :locals => { :local => 'local' })
73
- end
74
-
75
- test "partial rendering" do
76
- html = '<div><p>foo</p><p>bar</p></div><p>baz</p>'
77
- assert_equal html, view.render(:file => 'foo/partial')
78
- end
79
-
80
- test "table" do
81
- html = '<table><tr><td>foo</td><td>bar</td><td>baz</td></tr></table>'
82
- assert_equal html, view.render(:file => 'foo/table')
83
- end
84
-
85
- test "form_tag with input_tags" do
86
- html = '<div>foo</div>' +
87
- '<form action="/foo" method="post">' +
88
- '<div><input id="bar" name="bar" type="text" /></div>' +
89
- '<input id="baz" name="baz" type="text" />' +
90
- '</form>'
91
- assert_equal html, view.render(:file => 'foo/form_tag')
92
- end
93
-
94
- test "form_for" do
95
- html = '<div>foo</div>' +
96
- '<form action="/foo" method="post">' +
97
- '<div><input id="foo_bar" name="foo[bar]" size="30" type="text" /></div>' +
98
- '<input id="foo_baz" name="foo[baz]" size="30" type="text" />' +
99
- '</form>'
100
- assert_equal html, view.render(:file => 'foo/form_for')
101
- end
102
-
103
- test "misc_helpers" do
104
- html = '<img alt="Rails" src="http://no-asset-host.com/rails.png" />' +
105
- "<pre class='debug_dump'>--- foo</pre>" +
106
- '<script type="text/javascript">//<![CDATA[alert(\'All is good\')//]]></script>' +
107
- # '<div class="record" id="record_1">content</div>' +
108
- '<br />' +
109
- '<p>Hello world!</p>' +
110
- '<p>Hello world!</p>' +
111
- '<p><em>Hello world!</em></p>' +
112
- '<p><em>Hello world!</em></p>' +
113
- '<a href="#">foo</a>'
114
- html
115
- assert_equal html, view.render(:file => 'foo/misc_helpers').gsub("\n", '')
116
- end
117
- end
data/test/test_helper.rb DELETED
@@ -1,52 +0,0 @@
1
- $: << File.expand_path('../../lib', __FILE__)
2
-
3
- # require 'rubygems'
4
- # require 'bundler'
5
- # Bundler.setup
6
- # gem 'actionpack', '>=3.0.0.beta'
7
-
8
- require 'test/unit'
9
- require 'pp'
10
- require 'minimal'
11
-
12
- alias :require_dependency :require
13
-
14
- Minimal::Template.send(:include, Minimal::Template::FormBuilderProxy)
15
-
16
- ActionView::Template.register_template_handler('rb', Minimal::Template::Handler)
17
-
18
- ActionView::Base.class_eval { def protect_against_forgery?; false end } # HAX
19
-
20
- FIXTURES_PATH = File.expand_path('../fixtures/views', __FILE__)
21
-
22
- class Record
23
- def self.model_name; ActiveModel::Name.new(self) end
24
- def id; 1 end
25
- end
26
-
27
- module TestMethod
28
- def self.included(base)
29
- base.class_eval do
30
- def self.test(name, &block)
31
- test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
32
- defined = instance_method(test_name) rescue false
33
- raise "#{test_name} is already defined in #{self}" if defined
34
- if block_given?
35
- define_method(test_name, &block)
36
- else
37
- define_method(test_name) do
38
- flunk "No implementation provided for #{name}"
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
-
46
- class Module
47
- include TestMethod
48
- end
49
-
50
- class Test::Unit::TestCase
51
- include TestMethod
52
- end