minimal 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'http://gemcutter.org'
2
+
3
+ gem 'actionpack', '>=3.0.0.beta'
4
+
5
+
data/Rakefile CHANGED
@@ -2,6 +2,15 @@ require 'rake/testtask'
2
2
 
3
3
  require File.expand_path("../lib/minimal/version", __FILE__)
4
4
 
5
+ task :default => [:test]
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.pattern = "#{File.dirname(__FILE__)}/test/**/*_test.rb"
9
+ t.verbose = true
10
+ end
11
+ Rake::Task['test'].comment = "Run all tests"
12
+
13
+
5
14
  begin
6
15
  require 'jeweler'
7
16
  Jeweler::Tasks.new do |s|
@@ -1,15 +1,6 @@
1
1
  class Minimal::Template
2
2
  autoload :FormBuilderProxy, 'minimal/template/form_builder_proxy'
3
-
4
- class Handler < ActionView::Template::Handler
5
- include ActionView::Template::Handlers::Compilable
6
-
7
- def compile(template)
8
- require_dependency template.identifier
9
- klass = template.identifier =~ %r(views/(.*).rb) && $1.camelize
10
- "@output_buffer = ActiveSupport::SafeBuffer.new;#{klass}.new(self)._render(local_assigns)"
11
- end
12
- end
3
+ autoload :Handler, 'minimal/template/handler'
13
4
 
14
5
  AUTO_BUFFER = %r(render|tag|error_message_|select|debug|_to|_for)
15
6
  NO_AUTO_BUFFER = %r(form_tag|form_for)
@@ -0,0 +1,19 @@
1
+ class Minimal::Template
2
+ class Handler < ActionView::Template::Handler
3
+ include ActionView::Template::Handlers::Compilable
4
+
5
+ def compile(template)
6
+ <<-code
7
+ @output_buffer = ActiveSupport::SafeBuffer.new
8
+ require_dependency "#{template.identifier}"
9
+ #{template_class_name(template.identifier)}.new(self)._render(local_assigns)
10
+ code
11
+ end
12
+
13
+ protected
14
+
15
+ def template_class_name(path)
16
+ path =~ %r(views/(.*).rb) && $1.gsub('.', '/').camelize
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Minimal
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,3 @@
1
+ Dir[File.dirname(__FILE__) + '/**/*_test.rb'].each do |filename|
2
+ require filename
3
+ end
@@ -4,7 +4,7 @@ module Foo
4
4
  image_tag('http://no-asset-host.com/rails.png')
5
5
  debug('foo')
6
6
  javascript_tag("alert('All is good')")
7
- div_for(Record.new) { self << 'content' }
7
+ # div_for(Record.new) { self << 'content' }
8
8
  tag('br')
9
9
  content_tag(:p, 'Hello world!')
10
10
  content_tag(:p) { self << 'Hello world!' }
@@ -0,0 +1,4 @@
1
+ module MimeTypes
2
+ class Partial < Minimal::Template
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module MimeTypes
2
+ class Partial < Minimal::Template
3
+ end
4
+ end
@@ -0,0 +1,17 @@
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
@@ -7,7 +7,7 @@ class TemplateTest < Test::Unit::TestCase
7
7
 
8
8
  def view
9
9
  @view ||= ActionView::Base.new(FIXTURES_PATH).tap do |view|
10
- view.output_buffer = ActiveSupport::SafeBuffer.new
10
+ view.output_buffer = ActiveSupport::SafeBuffer.new rescue ''
11
11
  end
12
12
  end
13
13
 
@@ -104,7 +104,7 @@ class TemplateTest < Test::Unit::TestCase
104
104
  html = '<img alt="Rails" src="http://no-asset-host.com/rails.png" />' +
105
105
  "<pre class='debug_dump'>--- foo</pre>" +
106
106
  '<script type="text/javascript">//<![CDATA[alert(\'All is good\')//]]></script>' +
107
- '<div class="record" id="record_1">content</div>' +
107
+ # '<div class="record" id="record_1">content</div>' +
108
108
  '<br />' +
109
109
  '<p>Hello world!</p>' +
110
110
  '<p>Hello world!</p>' +
@@ -1,11 +1,13 @@
1
1
  $: << File.expand_path('../../lib', __FILE__)
2
2
 
3
- require 'rubygems'
3
+ # require 'rubygems'
4
+ # require 'bundler'
5
+ # Bundler.setup
6
+ # gem 'actionpack', '>=3.0.0.beta'
7
+
4
8
  require 'test/unit'
5
9
  require 'pp'
6
10
  require 'minimal'
7
- require 'action_controller'
8
- require 'active_model'
9
11
 
10
12
  alias :require_dependency :require
11
13
 
@@ -25,7 +27,7 @@ end
25
27
  module TestMethod
26
28
  def self.included(base)
27
29
  base.class_eval do
28
- def test(name, &block)
30
+ def self.test(name, &block)
29
31
  test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
30
32
  defined = instance_method(test_name) rescue false
31
33
  raise "#{test_name} is already defined in #{self}" if defined
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Sven Fuchs
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-10 00:00:00 +01:00
17
+ date: 2010-04-02 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -22,12 +27,15 @@ extensions: []
22
27
  extra_rdoc_files:
23
28
  - README.textile
24
29
  files:
30
+ - Gemfile
25
31
  - README.textile
26
32
  - Rakefile
27
33
  - lib/minimal.rb
28
34
  - lib/minimal/template.rb
29
35
  - lib/minimal/template/form_builder_proxy.rb
36
+ - lib/minimal/template/handler.rb
30
37
  - lib/minimal/version.rb
38
+ - test/all.rb
31
39
  - test/fixtures/views/foo/_partial.rb
32
40
  - test/fixtures/views/foo/form_for.rb
33
41
  - test/fixtures/views/foo/form_tag.rb
@@ -35,6 +43,9 @@ files:
35
43
  - test/fixtures/views/foo/partial.rb
36
44
  - test/fixtures/views/foo/simple.rb
37
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
38
49
  - test/template_test.rb
39
50
  - test/test_helper.rb
40
51
  has_rdoc: true
@@ -50,22 +61,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
61
  requirements:
51
62
  - - ">="
52
63
  - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
53
66
  version: "0"
54
- version:
55
67
  required_rubygems_version: !ruby/object:Gem::Requirement
56
68
  requirements:
57
69
  - - ">="
58
70
  - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
59
73
  version: "0"
60
- version:
61
74
  requirements: []
62
75
 
63
76
  rubyforge_project:
64
- rubygems_version: 1.3.5
77
+ rubygems_version: 1.3.6
65
78
  signing_key:
66
79
  specification_version: 3
67
80
  summary: Minimal templating engine inspired by Markaby & Erector
68
81
  test_files:
82
+ - test/all.rb
69
83
  - test/fixtures/views/foo/_partial.rb
70
84
  - test/fixtures/views/foo/form_for.rb
71
85
  - test/fixtures/views/foo/form_tag.rb
@@ -73,5 +87,8 @@ test_files:
73
87
  - test/fixtures/views/foo/partial.rb
74
88
  - test/fixtures/views/foo/simple.rb
75
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
76
93
  - test/template_test.rb
77
94
  - test/test_helper.rb