zafu 0.5.0

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.
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class ZafuRubyLessTest < Test::Unit::TestCase
4
+ include RubyLess::SafeClass
5
+ include Zafu::Process::RubyLess
6
+ def helper; self.class; end
7
+ safe_method :one => {:class => String, :method => "main_one"}
8
+
9
+ context 'Parsing an attribute without dynamic strings' do
10
+ should 'not alter string' do
11
+ assert_equal '"this is a string"', rubyless_attr('this is a string')
12
+ end
13
+ end
14
+
15
+ context 'Parsing an attribute with dynamic content' do
16
+ should 'use RubyLess to translate content' do
17
+ assert_equal '"this #{main_one}"', rubyless_attr('this #{one}')
18
+ end
19
+
20
+ context 'with ruby errors' do
21
+ should 'raise a RubyLess::Error' do
22
+ assert_raises(::RubyLess::Error) do
23
+ rubyless_attr('this #{one}}')
24
+ end
25
+ end
26
+
27
+ should 'produce an error message with the original attribute' do
28
+ begin
29
+ rubyless_attr('this #{one}}')
30
+ rescue ::RubyLess::Error => err
31
+ assert_equal 'Error parsing string "this #{one}}": parse error on value "}" (tRCURLY)', err.message
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'stringio'
3
+ require 'test/unit'
4
+ require 'shoulda'
5
+ require 'zafu'
6
+ require 'zafu/test_helper'
7
+ require 'mock/params'
8
+
9
+ TestCompiler = Zafu.parser_with_rules(Zafu::All, Mock::Params)
data/test/zafu_test.rb ADDED
@@ -0,0 +1,57 @@
1
+ require 'test_helper'
2
+
3
+ class String
4
+ def blank?
5
+ self == ''
6
+ end
7
+ end
8
+
9
+ class ZafuTest < Test::Unit::TestCase
10
+ include RubyLess::SafeClass
11
+ include Zafu::TestHelper
12
+ safe_method :one => {:class => String, :method => "main_one"}
13
+
14
+ class Dummy
15
+ include RubyLess::SafeClass
16
+ safe_method :hello => String
17
+ safe_method :one => {:class => String, :method => "dummy_one"}
18
+ end
19
+ safe_method :dum => Dummy
20
+ safe_method :dum2 => {:class => Dummy, :nil => true}
21
+
22
+ context 'Compilation in a model' do
23
+ setup do
24
+ @node_context = Zafu::NodeContext.new('@test', Dummy)
25
+ end
26
+
27
+ should 'start method lookup in the template' do
28
+ assert_equal '<%= main_one %>', zafu_erb('<r:one/>')
29
+ end
30
+
31
+ should 'use the model to resolve methods' do
32
+ assert_equal '<%= @test.hello %>', zafu_erb('<r:hello/>')
33
+ end
34
+
35
+ should 'change node context by following safe_method types' do
36
+ assert_equal '<% var1 = dum -%><%= var1.hello %>', zafu_erb("<r:dum do='hello'/>")
37
+ end
38
+
39
+ context 'that can be nil' do
40
+ should 'wrap context in if' do
41
+ assert_equal '<% if var1 = dum2 -%><%= var1.hello %><% end -%>', zafu_erb("<r:dum2 do='hello'/>")
42
+ end
43
+ end
44
+ end
45
+
46
+ context 'a custom compiler' do
47
+ setup do
48
+ @compiler = TestCompiler
49
+ end
50
+
51
+ should 'execute before_process callbacks' do
52
+ res = zafu_erb("<p class='simple' do='one' class='foo\#{dum.one}'/>", self, @compiler)
53
+ assert_match %r{class='simple <%= "foo\#\{dum.dummy_one\}"}, res
54
+ end
55
+ end
56
+
57
+ end
data/zafu.gemspec ADDED
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{zafu}
8
+ s.version = "0.5.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gaspard Bucher"]
12
+ s.date = %q{2010-03-21}
13
+ s.description = %q{Provides a powerful templating language based on xhtml for rails}
14
+ s.email = %q{gaspard@teti.ch}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "History.txt",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "lib/zafu.rb",
24
+ "lib/zafu/all.rb",
25
+ "lib/zafu/compiler.rb",
26
+ "lib/zafu/controller_methods.rb",
27
+ "lib/zafu/handler.rb",
28
+ "lib/zafu/info.rb",
29
+ "lib/zafu/markup.rb",
30
+ "lib/zafu/mock_helper.rb",
31
+ "lib/zafu/node_context.rb",
32
+ "lib/zafu/parser.rb",
33
+ "lib/zafu/parsing_rules.rb",
34
+ "lib/zafu/process/ajax.rb",
35
+ "lib/zafu/process/conditional.rb",
36
+ "lib/zafu/process/context.rb",
37
+ "lib/zafu/process/html.rb",
38
+ "lib/zafu/process/ruby_less.rb",
39
+ "lib/zafu/template.rb",
40
+ "lib/zafu/test_helper.rb",
41
+ "rails/init.rb",
42
+ "script/console",
43
+ "script/destroy",
44
+ "script/generate",
45
+ "test/markup_test.rb",
46
+ "test/mock/params.rb",
47
+ "test/node_context_test.rb",
48
+ "test/ruby_less_test.rb",
49
+ "test/test_helper.rb",
50
+ "test/zafu_test.rb",
51
+ "zafu.gemspec"
52
+ ]
53
+ s.homepage = %q{http://zenadmin.org/zafu}
54
+ s.rdoc_options = ["--charset=UTF-8"]
55
+ s.require_paths = ["lib"]
56
+ s.rubygems_version = %q{1.3.6}
57
+ s.summary = %q{Provides a powerful templating language based on xhtml for rails}
58
+ s.test_files = [
59
+ "test/markup_test.rb",
60
+ "test/mock/params.rb",
61
+ "test/node_context_test.rb",
62
+ "test/ruby_less_test.rb",
63
+ "test/test_helper.rb",
64
+ "test/zafu_test.rb"
65
+ ]
66
+
67
+ if s.respond_to? :specification_version then
68
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
69
+ s.specification_version = 3
70
+
71
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
72
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
73
+ s.add_runtime_dependency(%q<rubyless>, [">= 0.4.0"])
74
+ else
75
+ s.add_dependency(%q<shoulda>, [">= 0"])
76
+ s.add_dependency(%q<rubyless>, [">= 0.4.0"])
77
+ end
78
+ else
79
+ s.add_dependency(%q<shoulda>, [">= 0"])
80
+ s.add_dependency(%q<rubyless>, [">= 0.4.0"])
81
+ end
82
+ end
83
+
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zafu
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
10
+ platform: ruby
11
+ authors:
12
+ - Gaspard Bucher
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-21 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rubyless
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ - 4
42
+ - 0
43
+ version: 0.4.0
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ description: Provides a powerful templating language based on xhtml for rails
47
+ email: gaspard@teti.ch
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - README.rdoc
54
+ files:
55
+ - .gitignore
56
+ - History.txt
57
+ - README.rdoc
58
+ - Rakefile
59
+ - lib/zafu.rb
60
+ - lib/zafu/all.rb
61
+ - lib/zafu/compiler.rb
62
+ - lib/zafu/controller_methods.rb
63
+ - lib/zafu/handler.rb
64
+ - lib/zafu/info.rb
65
+ - lib/zafu/markup.rb
66
+ - lib/zafu/mock_helper.rb
67
+ - lib/zafu/node_context.rb
68
+ - lib/zafu/parser.rb
69
+ - lib/zafu/parsing_rules.rb
70
+ - lib/zafu/process/ajax.rb
71
+ - lib/zafu/process/conditional.rb
72
+ - lib/zafu/process/context.rb
73
+ - lib/zafu/process/html.rb
74
+ - lib/zafu/process/ruby_less.rb
75
+ - lib/zafu/template.rb
76
+ - lib/zafu/test_helper.rb
77
+ - rails/init.rb
78
+ - script/console
79
+ - script/destroy
80
+ - script/generate
81
+ - test/markup_test.rb
82
+ - test/mock/params.rb
83
+ - test/node_context_test.rb
84
+ - test/ruby_less_test.rb
85
+ - test/test_helper.rb
86
+ - test/zafu_test.rb
87
+ - zafu.gemspec
88
+ has_rdoc: true
89
+ homepage: http://zenadmin.org/zafu
90
+ licenses: []
91
+
92
+ post_install_message:
93
+ rdoc_options:
94
+ - --charset=UTF-8
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ requirements: []
112
+
113
+ rubyforge_project:
114
+ rubygems_version: 1.3.6
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Provides a powerful templating language based on xhtml for rails
118
+ test_files:
119
+ - test/markup_test.rb
120
+ - test/mock/params.rb
121
+ - test/node_context_test.rb
122
+ - test/ruby_less_test.rb
123
+ - test/test_helper.rb
124
+ - test/zafu_test.rb