seajs-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -1
- data/README.md +8 -4
- data/lib/seajs/rails/version.rb +1 -1
- data/lib/tasks/seajs-rails.rake +11 -14
- metadata +2 -2
data/.gitattributes
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Sea.js for Rails 3.x
|
2
2
|
|
3
3
|
Integrates Sea.js into the Rails 3 Asset Pipeline.
|
4
|
+
|
4
5
|
提供一种将 Sea.js 与 Asset Pipeline 结合起来的方式,底层通过 spm-chaos-build 来实现
|
5
6
|
|
7
|
+
-----
|
8
|
+
|
6
9
|
## 安装
|
7
10
|
|
8
11
|
首先请安装好 spm-chaos-build ,参见 https://github.com/edokeh/spm-chaos-build
|
@@ -39,8 +42,7 @@ output: # 合并策略,具体参见 spm-chaos-build
|
|
39
42
|
all: []
|
40
43
|
```
|
41
44
|
|
42
|
-
ouput 项其实就是 package.json 中的 spm.output
|
43
|
-
支持 relative(只合并相对路径), all(合并所有路径) 两种方式
|
45
|
+
ouput 项其实就是 package.json 中的 spm.output,支持 relative(只合并相对路径)/ all(合并所有路径)两种方式
|
44
46
|
|
45
47
|
目录说明:
|
46
48
|
|
@@ -59,6 +61,7 @@ ouput 项其实就是 package.json 中的 spm.output
|
|
59
61
|
│ │ └─stylesheets
|
60
62
|
|
61
63
|
与普通的开发基本一致,只是在 javascripts 目录下多了一个 sea-modules 作为 Sea.js 的 base 目录
|
64
|
+
|
62
65
|
普通的业务代码依然放置在 javascripts 目录下(非 CMD 模块的 JS 也放在这里)
|
63
66
|
|
64
67
|
### 使用
|
@@ -69,8 +72,8 @@ ouput 项其实就是 package.json 中的 spm.output
|
|
69
72
|
<%= seajs_tag %>
|
70
73
|
<%= seajs_use 'blogs/show' %>
|
71
74
|
```
|
72
|
-
seajs_tag 用于引入 seajs ,并且会根据是否合并引入必要的配置
|
73
|
-
seajs_use 用于加载 CMD 模块,支持传递多个模块名称
|
75
|
+
* seajs_tag 用于引入 seajs ,并且会根据是否合并引入必要的配置
|
76
|
+
* seajs_use 用于加载 CMD 模块,支持传递多个模块名称
|
74
77
|
|
75
78
|
### 合并
|
76
79
|
|
@@ -79,6 +82,7 @@ seajs_use 用于加载 CMD 模块,支持传递多个模块名称
|
|
79
82
|
$ rake assets:precompile
|
80
83
|
|
81
84
|
Sea.js 的合并过程不会与原有的 assets pipeline 冲突,但是请将配置分开
|
85
|
+
|
82
86
|
* 需要合并的 CMD 模块文件请在 seajs_config.yml 中配置
|
83
87
|
* 而非 CMD 模块的文件请依然通过 `config.assets.precompile` 配置
|
84
88
|
|
data/lib/seajs/rails/version.rb
CHANGED
data/lib/tasks/seajs-rails.rake
CHANGED
@@ -3,9 +3,8 @@ require 'seajs/rails/version'
|
|
3
3
|
namespace :seajs do
|
4
4
|
desc "Check whether spm & spm-chaos-build is ok"
|
5
5
|
task :test_env do
|
6
|
-
|
7
|
-
|
8
|
-
rescue Errno::ENOENT
|
6
|
+
`spm-chaos-build -h`
|
7
|
+
unless $?.success?
|
9
8
|
puts 'Please intall spm-chaos-build first.'
|
10
9
|
exit 1
|
11
10
|
end
|
@@ -27,11 +26,8 @@ namespace :seajs do
|
|
27
26
|
end
|
28
27
|
|
29
28
|
namespace :compile do
|
30
|
-
task :
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
task :all => ["seajs:compile:prepare_dir",
|
29
|
+
task :all => ["seajs:test_env",
|
30
|
+
"seajs:compile:prepare_dir",
|
35
31
|
"seajs:compile:generate_json",
|
36
32
|
"seajs:compile:build",
|
37
33
|
"seajs:compile:clean"]
|
@@ -48,7 +44,7 @@ namespace :seajs do
|
|
48
44
|
|
49
45
|
seajs_config = Rails.application.config.seajs
|
50
46
|
seajs_config.load_config_from_file
|
51
|
-
pkg = {:family => seajs_config.family, :spm => {:output => seajs_config.output}}
|
47
|
+
pkg = {:family => seajs_config.family, :spm => {:output => seajs_config.output, :alias => seajs_config.alias}}
|
52
48
|
f.write pkg.to_json
|
53
49
|
end
|
54
50
|
end
|
@@ -64,13 +60,14 @@ namespace :seajs do
|
|
64
60
|
end
|
65
61
|
|
66
62
|
task :clean do
|
67
|
-
|
68
|
-
|
69
|
-
rm_rf
|
63
|
+
public_assets_path = Pathname.new(File.join(Rails.public_path, Rails.application.config.assets.prefix))
|
64
|
+
cp_r public_assets_path.join('javascripts', 'sea-modules', '.'), public_assets_path.join('sea-modules')
|
65
|
+
rm_rf public_assets_path.join('javascripts')
|
66
|
+
rm_rf public_assets_path.join('Gruntfile.js')
|
70
67
|
end
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
74
|
-
Rake::Task["assets:precompile"].enhance do
|
75
|
-
Rake::Task["seajs:compile:
|
71
|
+
Rake::Task["assets:precompile:primary"].enhance do
|
72
|
+
Rake::Task["seajs:compile:all"].invoke
|
76
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seajs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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: 2013-
|
12
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|