coffee-redux-rails 4.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/Gemfile +12 -0
- data/MIT-LICENSE +21 -0
- data/README.markdown +1 -0
- data/Rakefile +26 -0
- data/coffee-redux-rails.gemspec +21 -0
- data/lib/assets/javascripts/coffee-script.js.erb +1 -0
- data/lib/coffee-rails.rb +4 -0
- data/lib/coffee/rails/engine.rb +9 -0
- data/lib/coffee/rails/template_handler.rb +18 -0
- data/lib/coffee/rails/version.rb +5 -0
- data/lib/rails/generators/coffee/assets/assets_generator.rb +13 -0
- data/lib/rails/generators/coffee/assets/templates/javascript.js.coffee +3 -0
- data/test/assets_generator_test.rb +15 -0
- data/test/assets_test.rb +34 -0
- data/test/controller_generator_test.rb +19 -0
- data/test/scaffold_generator_test.rb +19 -0
- data/test/support/routes.rb +1 -0
- data/test/support/site/index.js.coffee +1 -0
- data/test/template_handler_test.rb +26 -0
- data/test/test_helper.rb +16 -0
- metadata +114 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.8.7
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- ree
|
6
|
+
- jruby
|
7
|
+
- rbx
|
8
|
+
script: bundle exec rake test
|
9
|
+
notifications:
|
10
|
+
email: false
|
11
|
+
campfire:
|
12
|
+
secure: "CGWvthGkBKNnTnk9YSmf9AXKoiRI33fCl5D3jU4nx3cOPu6kv2R9nMjt9EAo\nOuS4Q85qNSf4VNQ2cUPNiNYSWQ+XiTfivKvDUw/QW9r1FejYyeWarMsSBWA+\n0fADjF1M2dkDIVLgYPfwoXEv7l+j654F1KLKB69F0F/netwP9CQ="
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in coffee-rails.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rails", :git => "git://github.com/rails/rails"
|
7
|
+
gem 'activerecord-deprecated_finders', :git => 'git://github.com/rails/activerecord-deprecated_finders'
|
8
|
+
|
9
|
+
gem 'journey', github: "rails/journey"
|
10
|
+
|
11
|
+
# To use debugger
|
12
|
+
# gem 'debugger'
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2011 Santiago Pastorino
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Nothing to see here.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'lib'
|
8
|
+
t.libs << 'test'
|
9
|
+
t.pattern = 'test/**/*_test.rb'
|
10
|
+
t.verbose = false
|
11
|
+
end
|
12
|
+
|
13
|
+
specname = "coffee-rails.gemspec"
|
14
|
+
deps = `git ls-files`.split("\n") - [specname]
|
15
|
+
|
16
|
+
file specname => deps do
|
17
|
+
files = `git ls-files`.split("\n")
|
18
|
+
test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
|
21
|
+
require 'erb'
|
22
|
+
|
23
|
+
File.open specname, 'w:utf-8' do |f|
|
24
|
+
f.write ERB.new(File.read("#{specname}.erb")).result(binding)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "coffee/rails/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "coffee-redux-rails"
|
6
|
+
s.version = Coffee::Rails::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Santiago Pastorino", "Sam Goldman"]
|
9
|
+
s.email = ["sam@smartlogicsolutions.com"]
|
10
|
+
s.homepage = "https://github.com/samwgoldman/coffee-redux-rails"
|
11
|
+
s.summary = %q{CoffeeScriptRedux adapter for the Rails asset pipeline.}
|
12
|
+
s.description = %q{CoffeeScriptRedux adapter for the Rails asset pipeline.}
|
13
|
+
|
14
|
+
s.add_runtime_dependency 'coffee-script-redux', '>= 0.0.1'
|
15
|
+
s.add_runtime_dependency 'railties', '>= 4.0.0.beta', '< 5.0'
|
16
|
+
|
17
|
+
s.files = [".gitignore",".travis.yml","Gemfile","MIT-LICENSE","README.markdown","Rakefile","coffee-redux-rails.gemspec","lib/assets/javascripts/coffee-script.js.erb","lib/coffee-rails.rb","lib/coffee/rails/engine.rb","lib/coffee/rails/template_handler.rb","lib/coffee/rails/version.rb","lib/rails/generators/coffee/assets/assets_generator.rb","lib/rails/generators/coffee/assets/templates/javascript.js.coffee","test/assets_generator_test.rb","test/assets_test.rb","test/controller_generator_test.rb","test/scaffold_generator_test.rb","test/support/routes.rb","test/support/site/index.js.coffee","test/template_handler_test.rb","test/test_helper.rb"]
|
18
|
+
s.test_files = ["test/assets_generator_test.rb","test/assets_test.rb","test/controller_generator_test.rb","test/scaffold_generator_test.rb","test/support/routes.rb","test/support/site/index.js.coffee","test/template_handler_test.rb","test/test_helper.rb"]
|
19
|
+
s.executables = []
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= CoffeeScript::Source.contents %>
|
data/lib/coffee-rails.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Coffee
|
2
|
+
module Rails
|
3
|
+
class TemplateHandler
|
4
|
+
def self.erb_handler
|
5
|
+
@@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.call(template)
|
9
|
+
compiled_source = erb_handler.call(template)
|
10
|
+
"CoffeeScript.compile(begin;#{compiled_source};end)"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ActiveSupport.on_load(:action_view) do
|
17
|
+
ActionView::Template.register_template_handler :coffee, Coffee::Rails::TemplateHandler
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rails/generators/named_base"
|
2
|
+
|
3
|
+
module Coffee
|
4
|
+
module Generators
|
5
|
+
class AssetsGenerator < ::Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
def copy_coffee
|
9
|
+
template "javascript.js.coffee", File.join('app/assets/javascripts', class_path, "#{file_name}.js.coffee")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/coffee/assets/assets_generator'
|
3
|
+
|
4
|
+
class AssetGeneratorTest < Rails::Generators::TestCase
|
5
|
+
tests Coffee::Generators::AssetsGenerator
|
6
|
+
|
7
|
+
destination File.expand_path("../tmp", __FILE__)
|
8
|
+
setup :prepare_destination
|
9
|
+
|
10
|
+
def test_assets
|
11
|
+
run_generator %w(posts)
|
12
|
+
assert_no_file "app/assets/javascripts/posts.js"
|
13
|
+
assert_file "app/assets/javascripts/posts.js.coffee"
|
14
|
+
end
|
15
|
+
end
|
data/test/assets_test.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'coffee-rails'
|
3
|
+
|
4
|
+
class AssetsTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
require "rails"
|
7
|
+
require "action_controller/railtie"
|
8
|
+
require "sprockets/rails/railtie"
|
9
|
+
|
10
|
+
@app = Class.new(Rails::Application)
|
11
|
+
@app.config.active_support.deprecation = :stderr
|
12
|
+
@app.config.assets.enabled = true
|
13
|
+
@app.config.assets.cache_store = [ :file_store, "#{tmp_path}/cache" ]
|
14
|
+
@app.paths["log"] = "#{tmp_path}/log/test.log"
|
15
|
+
@app.initialize!
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
FileUtils.rm_rf "#{tmp_path}/cache"
|
20
|
+
FileUtils.rm_rf "#{tmp_path}/log"
|
21
|
+
File.delete "#{tmp_path}/coffee-script.js"
|
22
|
+
end
|
23
|
+
|
24
|
+
test "coffee-script.js is included in Sprockets environment" do
|
25
|
+
@app.assets["coffee-script"].write_to("#{tmp_path}/coffee-script.js")
|
26
|
+
|
27
|
+
assert_match "/lib/assets/javascripts/coffee-script.js.erb", @app.assets["coffee-script"].pathname.to_s
|
28
|
+
assert_match "CoffeeScript Compiler", File.open("#{tmp_path}/coffee-script.js").read
|
29
|
+
end
|
30
|
+
|
31
|
+
def tmp_path
|
32
|
+
"#{File.dirname(__FILE__)}/tmp"
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/rails/controller/controller_generator'
|
3
|
+
require 'rails/generators/coffee/assets/assets_generator'
|
4
|
+
|
5
|
+
class ControllerGeneratorTest < Rails::Generators::TestCase
|
6
|
+
tests Rails::Generators::ControllerGenerator
|
7
|
+
|
8
|
+
destination File.expand_path("../tmp", __FILE__)
|
9
|
+
setup do
|
10
|
+
prepare_destination
|
11
|
+
copy_routes
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_assets
|
15
|
+
run_generator %w(posts --javascript-engine=coffee --orm=false)
|
16
|
+
assert_no_file "app/assets/javascripts/posts.js"
|
17
|
+
assert_file "app/assets/javascripts/posts.js.coffee"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/rails/scaffold/scaffold_generator'
|
3
|
+
require 'rails/generators/coffee/assets/assets_generator'
|
4
|
+
|
5
|
+
class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
6
|
+
tests Rails::Generators::ScaffoldGenerator
|
7
|
+
|
8
|
+
destination File.expand_path("../tmp", __FILE__)
|
9
|
+
setup do
|
10
|
+
prepare_destination
|
11
|
+
copy_routes
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_assets
|
15
|
+
run_generator %w(posts --javascript-engine=coffee --orm=false)
|
16
|
+
assert_no_file "app/assets/javascripts/posts.js"
|
17
|
+
assert_file "app/assets/javascripts/posts.js.coffee"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# routes dummy file
|
@@ -0,0 +1 @@
|
|
1
|
+
alert 'hello world'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'coffee-rails'
|
4
|
+
|
5
|
+
class SiteController < ActionController::Base
|
6
|
+
self.view_paths = File.expand_path("../support", __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
DummyApp = ActionDispatch::Routing::RouteSet.new
|
10
|
+
DummyApp.draw do
|
11
|
+
get "site/index"
|
12
|
+
end
|
13
|
+
|
14
|
+
class TemplateHandlerTest < ActiveSupport::TestCase
|
15
|
+
include Rack::Test::Methods
|
16
|
+
|
17
|
+
def app
|
18
|
+
@app ||= DummyApp
|
19
|
+
end
|
20
|
+
|
21
|
+
test "coffee views are served as javascript" do
|
22
|
+
get "/site/index.js"
|
23
|
+
|
24
|
+
assert_match "alert('hello world');\n", last_response.body
|
25
|
+
end
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require 'rails'
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
# For generators
|
8
|
+
require 'rails/generators/test_case'
|
9
|
+
|
10
|
+
def copy_routes
|
11
|
+
routes = File.expand_path("../support/routes.rb", __FILE__)
|
12
|
+
destination = File.join(destination_root, "config")
|
13
|
+
|
14
|
+
FileUtils.mkdir_p(destination)
|
15
|
+
FileUtils.cp routes, destination
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coffee-redux-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.0.0.beta
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Santiago Pastorino
|
9
|
+
- Sam Goldman
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-11-03 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: coffee-script-redux
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.0.1
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: railties
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 4.0.0.beta
|
39
|
+
- - <
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '5.0'
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 4.0.0.beta
|
50
|
+
- - <
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '5.0'
|
53
|
+
description: CoffeeScriptRedux adapter for the Rails asset pipeline.
|
54
|
+
email:
|
55
|
+
- sam@smartlogicsolutions.com
|
56
|
+
executables: []
|
57
|
+
extensions: []
|
58
|
+
extra_rdoc_files: []
|
59
|
+
files:
|
60
|
+
- .gitignore
|
61
|
+
- .travis.yml
|
62
|
+
- Gemfile
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.markdown
|
65
|
+
- Rakefile
|
66
|
+
- coffee-redux-rails.gemspec
|
67
|
+
- lib/assets/javascripts/coffee-script.js.erb
|
68
|
+
- lib/coffee-rails.rb
|
69
|
+
- lib/coffee/rails/engine.rb
|
70
|
+
- lib/coffee/rails/template_handler.rb
|
71
|
+
- lib/coffee/rails/version.rb
|
72
|
+
- lib/rails/generators/coffee/assets/assets_generator.rb
|
73
|
+
- lib/rails/generators/coffee/assets/templates/javascript.js.coffee
|
74
|
+
- test/assets_generator_test.rb
|
75
|
+
- test/assets_test.rb
|
76
|
+
- test/controller_generator_test.rb
|
77
|
+
- test/scaffold_generator_test.rb
|
78
|
+
- test/support/routes.rb
|
79
|
+
- test/support/site/index.js.coffee
|
80
|
+
- test/template_handler_test.rb
|
81
|
+
- test/test_helper.rb
|
82
|
+
homepage: https://github.com/samwgoldman/coffee-redux-rails
|
83
|
+
licenses: []
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>'
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.3.1
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.8.24
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: CoffeeScriptRedux adapter for the Rails asset pipeline.
|
106
|
+
test_files:
|
107
|
+
- test/assets_generator_test.rb
|
108
|
+
- test/assets_test.rb
|
109
|
+
- test/controller_generator_test.rb
|
110
|
+
- test/scaffold_generator_test.rb
|
111
|
+
- test/support/routes.rb
|
112
|
+
- test/support/site/index.js.coffee
|
113
|
+
- test/template_handler_test.rb
|
114
|
+
- test/test_helper.rb
|