roy-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +14 -0
- data/Rakefile +2 -0
- data/lib/roy-rails.rb +6 -1
- data/lib/roy/rails/version.rb +1 -1
- data/lib/roy/roy_engine.rb +12 -0
- data/lib/roy/roy_rails.rb +7 -0
- data/lib/roy/roy_template.rb +22 -0
- data/test/roy_template_test.rb +17 -0
- metadata +8 -2
data/.gitignore
ADDED
data/README.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
Package Roy as an alternate JS engine in the Rails Asset Pipeline.
|
2
2
|
|
3
|
+
## Basic Usage
|
4
|
+
- Include `roy-rails` in the Gemfile for your rails project.
|
5
|
+
- Place Roy source files under `app/assets/javascripts` with an extension of `.roy`
|
6
|
+
- Enjoy!
|
3
7
|
|
8
|
+
Generating Roy code with scaffolding also works.
|
9
|
+
|
10
|
+
## Coming Soon
|
11
|
+
|
12
|
+
Demo Rails application that uses Roy.
|
13
|
+
|
14
|
+
|
15
|
+
### TODO
|
16
|
+
- create sample rails project to test out using Roy.
|
17
|
+
- add target to ruby-roy to update the JS version of Roy
|
data/Rakefile
CHANGED
data/lib/roy-rails.rb
CHANGED
data/lib/roy/rails/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'tilt/template'
|
2
|
+
|
3
|
+
module Roy
|
4
|
+
class RoyTemplate < Tilt::Template
|
5
|
+
self.default_mime_type = 'application/javascript'
|
6
|
+
|
7
|
+
def self.engine_initialized?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize_engine
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare
|
15
|
+
@engine = RoyEngine.new(@file, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def evaluate(scope, locals, &block)
|
19
|
+
@output ||= @engine.compile(data)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'tilt'
|
4
|
+
|
5
|
+
|
6
|
+
class RoyTemplateTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_compile_template
|
9
|
+
template = Roy::RoyTemplate.new { |t| "console.log 'Hello, World!'\n" }
|
10
|
+
assert_match "(function() {\nconsole.log('Hello, World!');\n})();\n", template.render
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_compile_template_multiple_times
|
14
|
+
template = Roy::RoyTemplate.new { |t| "console.log 'Hello, World!'\n" }
|
15
|
+
3.times {assert_match "(function() {\nconsole.log('Hello, World!');\n})();\n", template.render}
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roy-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: roy-lang
|
@@ -81,6 +81,7 @@ executables: []
|
|
81
81
|
extensions: []
|
82
82
|
extra_rdoc_files: []
|
83
83
|
files:
|
84
|
+
- .gitignore
|
84
85
|
- Gemfile
|
85
86
|
- README.md
|
86
87
|
- Rakefile
|
@@ -89,9 +90,13 @@ files:
|
|
89
90
|
- lib/roy-rails.rb
|
90
91
|
- lib/roy/rails/railtie.rb
|
91
92
|
- lib/roy/rails/version.rb
|
93
|
+
- lib/roy/roy_engine.rb
|
94
|
+
- lib/roy/roy_rails.rb
|
95
|
+
- lib/roy/roy_template.rb
|
92
96
|
- roy-rails.gemspec
|
93
97
|
- test/assets_generator_test.rb
|
94
98
|
- test/controller_generator_test.rb
|
99
|
+
- test/roy_template_test.rb
|
95
100
|
- test/scaffold_generator_test.rb
|
96
101
|
- test/support/routes.rb
|
97
102
|
- test/test_helper.rb
|
@@ -133,6 +138,7 @@ summary: Roy adapter for the Rails asset pipeline.
|
|
133
138
|
test_files:
|
134
139
|
- test/assets_generator_test.rb
|
135
140
|
- test/controller_generator_test.rb
|
141
|
+
- test/roy_template_test.rb
|
136
142
|
- test/scaffold_generator_test.rb
|
137
143
|
- test/support/routes.rb
|
138
144
|
- test/test_helper.rb
|