stitch_rails 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -0
- data/README.md +71 -0
- data/VERSION +1 -1
- data/lib/stitch_rails.rb +2 -0
- data/stitch_rails.gemspec +7 -4
- metadata +20 -9
- data/README.rdoc +0 -19
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# stitch_rails
|
2
|
+
|
3
|
+
Inspired by <https://gist.github.com/1153919>
|
4
|
+
|
5
|
+
Brings `require` to Rails Sprockets.
|
6
|
+
|
7
|
+
All `.coffee` file will be wrapped as `require.define`.
|
8
|
+
|
9
|
+
`require("foo/bar")` will load file `app/assets/javascripts/foo/bar.js.coffee` and execute it.
|
10
|
+
|
11
|
+
## Example
|
12
|
+
|
13
|
+
**Gemfile**:
|
14
|
+
|
15
|
+
gem 'stitch_rails', '0.0.3'
|
16
|
+
|
17
|
+
|
18
|
+
**config/application.rb**:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
module YourApp
|
22
|
+
class Application < Rails::Application
|
23
|
+
# .... omit ....
|
24
|
+
|
25
|
+
# file names listed here are not wraped in `require.define`, so they
|
26
|
+
# are executed immediatly. Handy for an app start point. Otherwise you
|
27
|
+
# have add an .js file to require your start file. Suffix should not be added here.
|
28
|
+
config.stitch.excludes = %w(application spec jasminerice)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
**app/assets/javascripts/application.js.coffee**:
|
34
|
+
|
35
|
+
```coffee-script
|
36
|
+
# These are sprockets require that used to includes js files. Since
|
37
|
+
# .coffee file are wrapped as module, the js code is only executed when
|
38
|
+
# javascript function `require` is invoked.
|
39
|
+
#
|
40
|
+
#= require jquery
|
41
|
+
#
|
42
|
+
# Must load stitch_rails before any other coffee file, it defines the global method `require`
|
43
|
+
#
|
44
|
+
#= require stitch_rails
|
45
|
+
#= require_tree ./
|
46
|
+
#= require_this
|
47
|
+
#
|
48
|
+
# Since this file is in stitch excludes, code here are executed when it is loaded:
|
49
|
+
|
50
|
+
$ ->
|
51
|
+
Greet = require('models/greet')
|
52
|
+
greet = new Greet()
|
53
|
+
greet.sayHi()
|
54
|
+
```
|
55
|
+
|
56
|
+
***app/assets/javascripts/models/greet.js.coffee***
|
57
|
+
|
58
|
+
```coffee-script
|
59
|
+
class Greet
|
60
|
+
sayHi: ->
|
61
|
+
alert 'Hello, World'
|
62
|
+
|
63
|
+
module.exports = Greet
|
64
|
+
```
|
65
|
+
|
66
|
+
See more about CommonJS module in <http://wiki.commonjs.org/wiki/Modules/1.1>
|
67
|
+
|
68
|
+
## TODO
|
69
|
+
|
70
|
+
- Make it work for Sprockets without Rails
|
71
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/stitch_rails.rb
CHANGED
data/stitch_rails.gemspec
CHANGED
@@ -5,22 +5,22 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "stitch_rails"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ian Yang"]
|
12
|
-
s.date = "2012-02-
|
12
|
+
s.date = "2012-02-27"
|
13
13
|
s.description = "coffee CommonJS"
|
14
14
|
s.email = "me@iany.me"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
"Gemfile",
|
21
21
|
"Gemfile.lock",
|
22
22
|
"LICENSE.txt",
|
23
|
-
"README.
|
23
|
+
"README.md",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"lib/assets/javascripts/stitch_rails.js.coffee",
|
@@ -37,13 +37,16 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.specification_version = 3
|
38
38
|
|
39
39
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
+
s.add_runtime_dependency(%q<tilt>, [">= 0"])
|
40
41
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
41
42
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
42
43
|
else
|
44
|
+
s.add_dependency(%q<tilt>, [">= 0"])
|
43
45
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
44
46
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
45
47
|
end
|
46
48
|
else
|
49
|
+
s.add_dependency(%q<tilt>, [">= 0"])
|
47
50
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
51
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stitch_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: tilt
|
16
|
+
requirement: &8527160 !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: *8527160
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: bundler
|
16
|
-
requirement: &
|
27
|
+
requirement: &8526680 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ~>
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: 1.0.0
|
22
33
|
type: :development
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *8526680
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: jeweler
|
27
|
-
requirement: &
|
38
|
+
requirement: &8526200 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
@@ -32,19 +43,19 @@ dependencies:
|
|
32
43
|
version: 1.8.3
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *8526200
|
36
47
|
description: coffee CommonJS
|
37
48
|
email: me@iany.me
|
38
49
|
executables: []
|
39
50
|
extensions: []
|
40
51
|
extra_rdoc_files:
|
41
52
|
- LICENSE.txt
|
42
|
-
- README.
|
53
|
+
- README.md
|
43
54
|
files:
|
44
55
|
- Gemfile
|
45
56
|
- Gemfile.lock
|
46
57
|
- LICENSE.txt
|
47
|
-
- README.
|
58
|
+
- README.md
|
48
59
|
- Rakefile
|
49
60
|
- VERSION
|
50
61
|
- lib/assets/javascripts/stitch_rails.js.coffee
|
@@ -65,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
76
|
version: '0'
|
66
77
|
segments:
|
67
78
|
- 0
|
68
|
-
hash:
|
79
|
+
hash: -1438919120205210059
|
69
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
81
|
none: false
|
71
82
|
requirements:
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
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
|
-
|