roy-rails 0.0.1 → 0.0.2

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,2 @@
1
+ pkg
2
+ .rvmrc
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
@@ -3,6 +3,8 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rake/testtask'
5
5
 
6
+ task :default => :test
7
+
6
8
  Rake::TestTask.new(:test) do |t|
7
9
  t.libs << 'lib'
8
10
  t.libs << 'test'
@@ -1,3 +1,8 @@
1
- require 'roy'
1
+ require 'roy-lang'
2
+
3
+ require 'roy/roy_rails'
4
+ require 'roy/roy_template'
5
+ require 'roy/roy_engine'
6
+
2
7
  require 'roy/rails/railtie'
3
8
  require 'roy/rails/version'
@@ -1,5 +1,5 @@
1
1
  module Roy
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,12 @@
1
+ module Roy
2
+ class RoyEngine
3
+ def initialize(file, options)
4
+ @file = file
5
+ @options = options
6
+ end
7
+
8
+ def compile(data)
9
+ Roy.compile(data)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ module Roy
2
+ class RoyRails < Rails::Engine
3
+ initializer :register_roy do |app|
4
+ app.assets.register_engine '.roy', RoyTemplate
5
+ end
6
+ end
7
+ end
@@ -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.1
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-20 00:00:00.000000000 Z
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