coco-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'coco/rails/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'coco-rails'
7
+ s.version = Coco::Rails::VERSION
8
+ s.authors = ['Jacob Swanner']
9
+ s.email = ['jacob@jacobswanner.com']
10
+ s.homepage = 'https://github.com/jswanner/coco-rails'
11
+ s.summary = 'Coco adapter for the Rails asset pipeline.'
12
+ s.description = 'Coco adapter for the Rails asset pipeline.'
13
+
14
+ s.add_runtime_dependency 'ruby-coco'
15
+ s.add_runtime_dependency 'railties', '~> 3.1', '< 4.0'
16
+ s.add_runtime_dependency 'tilt', '~> 1.1', '!= 1.3.0'
17
+ s.add_runtime_dependency 'sprockets', '~> 2.0'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.require_paths = ['lib']
22
+ end
@@ -0,0 +1 @@
1
+ <%= Coco::Source.contents %>
@@ -0,0 +1,5 @@
1
+ require 'ruby-coco'
2
+ require 'coco/rails/engine'
3
+ require 'coco/rails/template_handler'
4
+ require 'coco/rails/version'
5
+ require 'sprockets/coco'
@@ -0,0 +1,9 @@
1
+ require 'rails/engine'
2
+
3
+ module Coco
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ config.app_generators.javascript_engine :coco
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ module Coco
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
+ "Coco.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 :co, Coco::Rails::TemplateHandler
18
+ end
@@ -0,0 +1,5 @@
1
+ module Coco
2
+ module Rails
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require "rails/generators/named_base"
2
+
3
+ module Coco
4
+ module Generators
5
+ class AssetsGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_co
9
+ template "javascript.js.co", File.join('app/assets/javascripts', class_path, "#{file_name}.js.co")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use Coco in this file: http://satyr.github.com/coco/
@@ -0,0 +1,37 @@
1
+ require 'sprockets'
2
+ require 'tilt'
3
+
4
+ module Sprockets
5
+ class CocoTemplate < Tilt::Template
6
+ self.default_mime_type = 'application/javascript'
7
+ @@default_bare = false
8
+
9
+ def self.default_bare
10
+ @@default_bare
11
+ end
12
+
13
+ def self.default_bare=(value)
14
+ @@default_bare = value
15
+ end
16
+
17
+ def self.engine_initialized?
18
+ defined? ::Coco
19
+ end
20
+
21
+ def initialize_engine
22
+ require_template_library 'ruby-coco'
23
+ end
24
+
25
+ def prepare
26
+ if !options.key?(:bare)
27
+ options[:bare] = self.class.default_bare
28
+ end
29
+ end
30
+
31
+ def evaluate(scope, locals, &block)
32
+ @output ||= Coco.compile(data, options)
33
+ end
34
+ end
35
+
36
+ register_engine '.co', CocoTemplate
37
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coco-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jacob Swanner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruby-coco
16
+ requirement: &70153143100200 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70153143100200
25
+ - !ruby/object:Gem::Dependency
26
+ name: railties
27
+ requirement: &70153143099440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.1'
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: '4.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: *70153143099440
39
+ - !ruby/object:Gem::Dependency
40
+ name: tilt
41
+ requirement: &70153143115000 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.1'
47
+ - - ! '!='
48
+ - !ruby/object:Gem::Version
49
+ version: 1.3.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: *70153143115000
53
+ - !ruby/object:Gem::Dependency
54
+ name: sprockets
55
+ requirement: &70153143113920 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: *70153143113920
64
+ description: Coco adapter for the Rails asset pipeline.
65
+ email:
66
+ - jacob@jacobswanner.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .gitignore
72
+ - Gemfile
73
+ - Rakefile
74
+ - coco-rails.gemspec
75
+ - lib/assets/javascripts/coco.js.erb
76
+ - lib/coco-rails.rb
77
+ - lib/coco/rails/engine.rb
78
+ - lib/coco/rails/template_handler.rb
79
+ - lib/coco/rails/version.rb
80
+ - lib/rails/generators/coco/assets/assets_generator.rb
81
+ - lib/rails/generators/coco/assets/templates/javascript.js.co
82
+ - lib/sprockets/coco.rb
83
+ homepage: https://github.com/jswanner/coco-rails
84
+ licenses: []
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.11
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Coco adapter for the Rails asset pipeline.
107
+ test_files: []