rubyview-rails 0.0.1
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 +4 -0
- data/Gemfile.lock +107 -0
- data/README.md +20 -0
- data/Rakefile +5 -0
- data/lib/rubyview-rails.rb +1 -0
- data/lib/rubyview-rails/rubyview_builder.rb +28 -0
- data/lib/rubyview-rails/version.rb +4 -0
- data/rubyview-rails.gemspec +26 -0
- data/spec/rubyview_builder_spec.rb +61 -0
- data/spec/spec_helper.rb +7 -0
- metadata +161 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
rubyview-rails (0.0.1)
|
|
5
|
+
actionpack
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionmailer (3.1.1)
|
|
11
|
+
actionpack (= 3.1.1)
|
|
12
|
+
mail (~> 2.3.0)
|
|
13
|
+
actionpack (3.1.1)
|
|
14
|
+
activemodel (= 3.1.1)
|
|
15
|
+
activesupport (= 3.1.1)
|
|
16
|
+
builder (~> 3.0.0)
|
|
17
|
+
erubis (~> 2.7.0)
|
|
18
|
+
i18n (~> 0.6)
|
|
19
|
+
rack (~> 1.3.2)
|
|
20
|
+
rack-cache (~> 1.1)
|
|
21
|
+
rack-mount (~> 0.8.2)
|
|
22
|
+
rack-test (~> 0.6.1)
|
|
23
|
+
sprockets (~> 2.0.2)
|
|
24
|
+
activemodel (3.1.1)
|
|
25
|
+
activesupport (= 3.1.1)
|
|
26
|
+
builder (~> 3.0.0)
|
|
27
|
+
i18n (~> 0.6)
|
|
28
|
+
activerecord (3.1.1)
|
|
29
|
+
activemodel (= 3.1.1)
|
|
30
|
+
activesupport (= 3.1.1)
|
|
31
|
+
arel (~> 2.2.1)
|
|
32
|
+
tzinfo (~> 0.3.29)
|
|
33
|
+
activeresource (3.1.1)
|
|
34
|
+
activemodel (= 3.1.1)
|
|
35
|
+
activesupport (= 3.1.1)
|
|
36
|
+
activesupport (3.1.1)
|
|
37
|
+
multi_json (~> 1.0)
|
|
38
|
+
arel (2.2.1)
|
|
39
|
+
builder (3.0.0)
|
|
40
|
+
diff-lcs (1.1.3)
|
|
41
|
+
erubis (2.7.0)
|
|
42
|
+
hike (1.2.1)
|
|
43
|
+
i18n (0.6.0)
|
|
44
|
+
json (1.6.1)
|
|
45
|
+
mail (2.3.0)
|
|
46
|
+
i18n (>= 0.4.0)
|
|
47
|
+
mime-types (~> 1.16)
|
|
48
|
+
treetop (~> 1.4.8)
|
|
49
|
+
mime-types (1.16)
|
|
50
|
+
multi_json (1.0.3)
|
|
51
|
+
polyglot (0.3.2)
|
|
52
|
+
rack (1.3.5)
|
|
53
|
+
rack-cache (1.1)
|
|
54
|
+
rack (>= 0.4)
|
|
55
|
+
rack-mount (0.8.3)
|
|
56
|
+
rack (>= 1.0.0)
|
|
57
|
+
rack-ssl (1.3.2)
|
|
58
|
+
rack
|
|
59
|
+
rack-test (0.6.1)
|
|
60
|
+
rack (>= 1.0)
|
|
61
|
+
rails (3.1.1)
|
|
62
|
+
actionmailer (= 3.1.1)
|
|
63
|
+
actionpack (= 3.1.1)
|
|
64
|
+
activerecord (= 3.1.1)
|
|
65
|
+
activeresource (= 3.1.1)
|
|
66
|
+
activesupport (= 3.1.1)
|
|
67
|
+
bundler (~> 1.0)
|
|
68
|
+
railties (= 3.1.1)
|
|
69
|
+
railties (3.1.1)
|
|
70
|
+
actionpack (= 3.1.1)
|
|
71
|
+
activesupport (= 3.1.1)
|
|
72
|
+
rack-ssl (~> 1.3.2)
|
|
73
|
+
rake (>= 0.8.7)
|
|
74
|
+
rdoc (~> 3.4)
|
|
75
|
+
thor (~> 0.14.6)
|
|
76
|
+
rake (0.9.2.2)
|
|
77
|
+
rdoc (3.11)
|
|
78
|
+
json (~> 1.4)
|
|
79
|
+
rspec (2.7.0)
|
|
80
|
+
rspec-core (~> 2.7.0)
|
|
81
|
+
rspec-expectations (~> 2.7.0)
|
|
82
|
+
rspec-mocks (~> 2.7.0)
|
|
83
|
+
rspec-core (2.7.1)
|
|
84
|
+
rspec-expectations (2.7.0)
|
|
85
|
+
diff-lcs (~> 1.1.2)
|
|
86
|
+
rspec-mocks (2.7.0)
|
|
87
|
+
sprockets (2.0.3)
|
|
88
|
+
hike (~> 1.2)
|
|
89
|
+
rack (~> 1.0)
|
|
90
|
+
tilt (~> 1.1, != 1.3.0)
|
|
91
|
+
thor (0.14.6)
|
|
92
|
+
tilt (1.3.3)
|
|
93
|
+
treetop (1.4.10)
|
|
94
|
+
polyglot
|
|
95
|
+
polyglot (>= 0.3.1)
|
|
96
|
+
tzinfo (0.3.30)
|
|
97
|
+
|
|
98
|
+
PLATFORMS
|
|
99
|
+
ruby
|
|
100
|
+
|
|
101
|
+
DEPENDENCIES
|
|
102
|
+
bundler
|
|
103
|
+
json
|
|
104
|
+
rails (>= 3.1.0)
|
|
105
|
+
rake
|
|
106
|
+
rspec
|
|
107
|
+
rubyview-rails!
|
data/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Rubyview-Rails — Rubyview templates for Rails views
|
|
2
|
+
|
|
3
|
+
[Rubyview](https://github.com/mattgillooly/rubyview) is a template-less view layer for your Rails apps.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`gem install rubyview-rails`
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Rubyview-Rails provides a Rails 3 template handler allowing you to create
|
|
12
|
+
view templates using Rubyview. Any template with a `.rubyview` will be handled by Rails.
|
|
13
|
+
|
|
14
|
+
The Rubyview template handler will interpret your template as a regular Ruby method, and render the return value as its output.
|
|
15
|
+
|
|
16
|
+
"Hello #{@world}!"
|
|
17
|
+
|
|
18
|
+
## Authors
|
|
19
|
+
|
|
20
|
+
* [Matt Gillooly](https://github.com/mattgillooly)
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'rubyview-rails/rubyview_builder'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'action_view'
|
|
2
|
+
module ActionView
|
|
3
|
+
module Template::Handlers
|
|
4
|
+
if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR < 1
|
|
5
|
+
class RubyviewBuilder < Template::Handler
|
|
6
|
+
include Compilable
|
|
7
|
+
|
|
8
|
+
self.default_format = Mime::JSON
|
|
9
|
+
|
|
10
|
+
def compile(template)
|
|
11
|
+
template.source
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
else
|
|
15
|
+
class RubyviewBuilder
|
|
16
|
+
def default_format
|
|
17
|
+
Mime::JSON
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.call(template)
|
|
21
|
+
template.source
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
ActionView::Template.register_template_handler :rubyview, ActionView::Template::Handlers::RubyviewBuilder
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "rubyview-rails/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "rubyview-rails"
|
|
7
|
+
s.version = RubyviewRails::VERSION
|
|
8
|
+
s.authors = ["Matt Gillooly"]
|
|
9
|
+
s.email = ["matt@mattgillooly.com"]
|
|
10
|
+
s.homepage = "http://github.com/mattgillooly/rubyview-rails"
|
|
11
|
+
s.summary = %q{Use Rubyview for Rails View templates}
|
|
12
|
+
s.description = s.summary
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
16
|
+
s.require_paths = ["lib"]
|
|
17
|
+
|
|
18
|
+
s.add_dependency "actionpack"
|
|
19
|
+
|
|
20
|
+
s.add_development_dependency 'bundler'
|
|
21
|
+
s.add_development_dependency 'rake'
|
|
22
|
+
s.add_development_dependency 'rspec'
|
|
23
|
+
s.add_development_dependency 'json' unless RUBY_VERSION =~ /^1.9/
|
|
24
|
+
s.add_development_dependency 'rails', ENV["RAILS_VERSION"] || ">= 3.1.0"
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Rubyview template handler' do
|
|
4
|
+
|
|
5
|
+
Handler = ActionView::Template::Handlers::RubyviewBuilder
|
|
6
|
+
ViewTemplate = Struct.new(:source)
|
|
7
|
+
|
|
8
|
+
class MyContext
|
|
9
|
+
def initialize(a, b)
|
|
10
|
+
@foo, @bar = a, b
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let( :handler ) { Handler.new }
|
|
15
|
+
|
|
16
|
+
let( :simple_template ) do
|
|
17
|
+
ViewTemplate.new(<<EOF
|
|
18
|
+
require 'json'
|
|
19
|
+
|
|
20
|
+
hello = 'world'
|
|
21
|
+
h = {}
|
|
22
|
+
|
|
23
|
+
h['hello'] = hello
|
|
24
|
+
h.to_json
|
|
25
|
+
EOF
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
let( :interpolated_template ) do
|
|
30
|
+
ViewTemplate.new("
|
|
31
|
+
require 'json'
|
|
32
|
+
|
|
33
|
+
h = { :foo => @foo,
|
|
34
|
+
:bar => @bar }
|
|
35
|
+
|
|
36
|
+
h.to_json"
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "#{Rails.version}" do
|
|
41
|
+
before do
|
|
42
|
+
Rails.stub_chain(:application, :config, :rubyview_format).and_return( :plain )
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should use JSON as its default output format' do
|
|
46
|
+
handler.default_format.should == Mime::JSON
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should compile a simple template to JSON' do
|
|
50
|
+
result = eval( Handler.call simple_template )
|
|
51
|
+
result.should == '{"hello":"world"}'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should compile an interpolated template to JSON' do
|
|
55
|
+
c = MyContext.new('1', '23')
|
|
56
|
+
result = c.instance_eval( Handler.call interpolated_template )
|
|
57
|
+
result.should == '{"foo":"1","bar":"23"}'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rubyview-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 29
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.0.1
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Matt Gillooly
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2011-10-24 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: actionpack
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 3
|
|
29
|
+
segments:
|
|
30
|
+
- 0
|
|
31
|
+
version: "0"
|
|
32
|
+
type: :runtime
|
|
33
|
+
version_requirements: *id001
|
|
34
|
+
- !ruby/object:Gem::Dependency
|
|
35
|
+
name: bundler
|
|
36
|
+
prerelease: false
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
hash: 3
|
|
43
|
+
segments:
|
|
44
|
+
- 0
|
|
45
|
+
version: "0"
|
|
46
|
+
type: :development
|
|
47
|
+
version_requirements: *id002
|
|
48
|
+
- !ruby/object:Gem::Dependency
|
|
49
|
+
name: rake
|
|
50
|
+
prerelease: false
|
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
hash: 3
|
|
57
|
+
segments:
|
|
58
|
+
- 0
|
|
59
|
+
version: "0"
|
|
60
|
+
type: :development
|
|
61
|
+
version_requirements: *id003
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: rspec
|
|
64
|
+
prerelease: false
|
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
66
|
+
none: false
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
hash: 3
|
|
71
|
+
segments:
|
|
72
|
+
- 0
|
|
73
|
+
version: "0"
|
|
74
|
+
type: :development
|
|
75
|
+
version_requirements: *id004
|
|
76
|
+
- !ruby/object:Gem::Dependency
|
|
77
|
+
name: json
|
|
78
|
+
prerelease: false
|
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
80
|
+
none: false
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
hash: 3
|
|
85
|
+
segments:
|
|
86
|
+
- 0
|
|
87
|
+
version: "0"
|
|
88
|
+
type: :development
|
|
89
|
+
version_requirements: *id005
|
|
90
|
+
- !ruby/object:Gem::Dependency
|
|
91
|
+
name: rails
|
|
92
|
+
prerelease: false
|
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
|
94
|
+
none: false
|
|
95
|
+
requirements:
|
|
96
|
+
- - ">="
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
hash: 3
|
|
99
|
+
segments:
|
|
100
|
+
- 3
|
|
101
|
+
- 1
|
|
102
|
+
- 0
|
|
103
|
+
version: 3.1.0
|
|
104
|
+
type: :development
|
|
105
|
+
version_requirements: *id006
|
|
106
|
+
description: Use Rubyview for Rails View templates
|
|
107
|
+
email:
|
|
108
|
+
- matt@mattgillooly.com
|
|
109
|
+
executables: []
|
|
110
|
+
|
|
111
|
+
extensions: []
|
|
112
|
+
|
|
113
|
+
extra_rdoc_files: []
|
|
114
|
+
|
|
115
|
+
files:
|
|
116
|
+
- Gemfile
|
|
117
|
+
- Gemfile.lock
|
|
118
|
+
- README.md
|
|
119
|
+
- Rakefile
|
|
120
|
+
- lib/rubyview-rails.rb
|
|
121
|
+
- lib/rubyview-rails/rubyview_builder.rb
|
|
122
|
+
- lib/rubyview-rails/version.rb
|
|
123
|
+
- rubyview-rails.gemspec
|
|
124
|
+
- spec/rubyview_builder_spec.rb
|
|
125
|
+
- spec/spec_helper.rb
|
|
126
|
+
homepage: http://github.com/mattgillooly/rubyview-rails
|
|
127
|
+
licenses: []
|
|
128
|
+
|
|
129
|
+
post_install_message:
|
|
130
|
+
rdoc_options: []
|
|
131
|
+
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
none: false
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
hash: 3
|
|
140
|
+
segments:
|
|
141
|
+
- 0
|
|
142
|
+
version: "0"
|
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
|
+
none: false
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
hash: 3
|
|
149
|
+
segments:
|
|
150
|
+
- 0
|
|
151
|
+
version: "0"
|
|
152
|
+
requirements: []
|
|
153
|
+
|
|
154
|
+
rubyforge_project:
|
|
155
|
+
rubygems_version: 1.8.11
|
|
156
|
+
signing_key:
|
|
157
|
+
specification_version: 3
|
|
158
|
+
summary: Use Rubyview for Rails View templates
|
|
159
|
+
test_files: []
|
|
160
|
+
|
|
161
|
+
has_rdoc:
|