stitch_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/lib/assets/javascripts/stitch_rails.js +60 -0
- data/lib/stitch_rails.rb +34 -0
- data/stitch_rails.gemspec +51 -0
- metadata +81 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://ruby.taobao.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.8.3)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rdoc
|
10
|
+
json (1.6.5)
|
11
|
+
rake (0.9.2.2)
|
12
|
+
rdoc (3.12)
|
13
|
+
json (~> 1.4)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.0.0)
|
20
|
+
jeweler (~> 1.8.3)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Ian Yang
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= stitch_rails
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to stitch_rails
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Ian Yang. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "stitch_rails"
|
18
|
+
gem.homepage = "http://github.com/doitian/stitch_rails"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "coffee CommonJS"
|
21
|
+
gem.description = "coffee CommonJS"
|
22
|
+
gem.email = "me@iany.me"
|
23
|
+
gem.authors = ["Ian Yang"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,60 @@
|
|
1
|
+
// https://gist.github.com/1153919
|
2
|
+
|
3
|
+
(function(/*! Stitch !*/) {
|
4
|
+
if (!this.require) {
|
5
|
+
|
6
|
+
var modules = {},
|
7
|
+
cache = {},
|
8
|
+
require = function(name, root) {
|
9
|
+
var module = cache[name], path = expand(root, name), fn;
|
10
|
+
if (module) {
|
11
|
+
return module;
|
12
|
+
} else if (fn = modules[path] || modules[path = expand(path, './index')]) {
|
13
|
+
module = {id: name, exports: {}};
|
14
|
+
try {
|
15
|
+
cache[name] = module.exports;
|
16
|
+
|
17
|
+
fn(module.exports, function(name) {
|
18
|
+
return require(name, dirname(path));
|
19
|
+
}, module);
|
20
|
+
|
21
|
+
return cache[name] = module.exports;
|
22
|
+
} catch (err) {
|
23
|
+
delete cache[name];
|
24
|
+
throw err;
|
25
|
+
}
|
26
|
+
} else {
|
27
|
+
throw 'module "' + name + '" not found';
|
28
|
+
}
|
29
|
+
},
|
30
|
+
expand = function(root, name) {
|
31
|
+
var results = [], parts, part;
|
32
|
+
if (/^\.\.?(\/|$)/.test(name)) {
|
33
|
+
parts = [root, name].join('/').split('/');
|
34
|
+
} else {
|
35
|
+
parts = name.split('/');
|
36
|
+
}
|
37
|
+
for (var i = 0, length = parts.length; i < length; i++) {
|
38
|
+
part = parts[i];
|
39
|
+
if (part == '..') {
|
40
|
+
results.pop();
|
41
|
+
} else if (part != '.' && part != '') {
|
42
|
+
results.push(part);
|
43
|
+
}
|
44
|
+
}
|
45
|
+
return results.join('/');
|
46
|
+
},
|
47
|
+
dirname = function(path) {
|
48
|
+
return path.split('/').slice(0, -1).join('/');
|
49
|
+
};
|
50
|
+
|
51
|
+
this.require = function(name) {
|
52
|
+
return require(name, '');
|
53
|
+
}
|
54
|
+
|
55
|
+
this.require.define = function(bundle) {
|
56
|
+
for (var key in bundle)
|
57
|
+
modules[key] = bundle[key];
|
58
|
+
};
|
59
|
+
}
|
60
|
+
}).call(this)
|
data/lib/stitch_rails.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Stitch
|
2
|
+
class StitchyCoffeeScriptTemplate < Tilt::Template
|
3
|
+
self.default_mime_type = 'application/javascript'
|
4
|
+
|
5
|
+
def self.engine_initialized?
|
6
|
+
defined? ::CoffeeScript
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize_engine
|
10
|
+
require_template_library 'coffee_script'
|
11
|
+
end
|
12
|
+
|
13
|
+
def prepare
|
14
|
+
options[:bare] = true
|
15
|
+
end
|
16
|
+
|
17
|
+
def evaluate(scope, locals, &block)
|
18
|
+
@output ||= "\nrequire.define({'#{ module_name(scope) }': function(exports, require, module) {\n" + CoffeeScript.compile(data, options) + "\n}});\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
# this might need to be customisable to generate the desired module names
|
23
|
+
# this implementation lops off the first segment of the path
|
24
|
+
def module_name(scope)
|
25
|
+
scope.logical_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Railtie < Rails::Railtie
|
30
|
+
initializer 'stitch.configure_rails_initialization' do |app|
|
31
|
+
app.assets.register_engine '.coffee', StitchyCoffeeScriptTemplate
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "stitch_rails"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ian Yang"]
|
12
|
+
s.date = "2012-02-18"
|
13
|
+
s.description = "coffee CommonJS"
|
14
|
+
s.email = "me@iany.me"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/assets/javascripts/stitch_rails.js",
|
27
|
+
"lib/stitch_rails.rb",
|
28
|
+
"stitch_rails.gemspec"
|
29
|
+
]
|
30
|
+
s.homepage = "http://github.com/doitian/stitch_rails"
|
31
|
+
s.licenses = ["MIT"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = "1.8.11"
|
34
|
+
s.summary = "coffee CommonJS"
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
41
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
42
|
+
else
|
43
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
44
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
45
|
+
end
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stitch_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ian Yang
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &16561100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *16561100
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: jeweler
|
27
|
+
requirement: &16560620 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.8.3
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *16560620
|
36
|
+
description: coffee CommonJS
|
37
|
+
email: me@iany.me
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files:
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.rdoc
|
43
|
+
files:
|
44
|
+
- Gemfile
|
45
|
+
- Gemfile.lock
|
46
|
+
- LICENSE.txt
|
47
|
+
- README.rdoc
|
48
|
+
- Rakefile
|
49
|
+
- VERSION
|
50
|
+
- lib/assets/javascripts/stitch_rails.js
|
51
|
+
- lib/stitch_rails.rb
|
52
|
+
- stitch_rails.gemspec
|
53
|
+
homepage: http://github.com/doitian/stitch_rails
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
hash: -4055819192455207869
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.11
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: coffee CommonJS
|
81
|
+
test_files: []
|