zfben_rails_assets 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/helpers/assets_helper.rb +15 -10
- data/test/assets_test.rb +4 -2
- data/zfben_rails_assets.gemspec +1 -1
- metadata +10 -10
@@ -6,16 +6,21 @@ module AssetsHelper
|
|
6
6
|
html = ''
|
7
7
|
opts.each do |name|
|
8
8
|
name = name.to_s
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
format = File.extname(name)
|
10
|
+
if Rails.env.production? && !name.include?('.min.') && (format == '.css' || format == '.js')
|
11
|
+
name = name.gsub(format, '.min' << format)
|
12
|
+
end
|
13
|
+
case format
|
14
|
+
when '.css'
|
15
|
+
html << assets_css(name)
|
16
|
+
when '.js'
|
17
|
+
html << assets_js(name)
|
18
|
+
else
|
19
|
+
path = Rails.root.to_s + '/app/assets/' + name
|
20
|
+
css = Dir.glob(([:css] + AssetFormat::Css::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s })
|
21
|
+
js = Dir.glob(([:js] + AssetFormat::Js::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s })
|
22
|
+
html << assets(name + '.css') if css.length > 0
|
23
|
+
html << assets(name + '.js') if js.length > 0
|
19
24
|
end
|
20
25
|
end
|
21
26
|
html
|
data/test/assets_test.rb
CHANGED
@@ -117,6 +117,7 @@ end
|
|
117
117
|
|
118
118
|
class AssetsHelperTest < ActionView::TestCase
|
119
119
|
setup do
|
120
|
+
Rails.env = 'test'
|
120
121
|
Rails.configuration.action_controller[:asset_host] = nil
|
121
122
|
Rails.configuration.action_controller[:asset_path] = nil
|
122
123
|
Rails.configuration.action_controller[:asset_version] = nil
|
@@ -135,11 +136,12 @@ class AssetsHelperTest < ActionView::TestCase
|
|
135
136
|
end
|
136
137
|
|
137
138
|
test 'assets in production' do
|
139
|
+
Rails.env = 'production'
|
138
140
|
Rails.configuration.action_controller[:asset_host] = 'http://assets.com'
|
139
141
|
Rails.configuration.action_controller[:asset_path] = 'assets_path'
|
140
142
|
Rails.configuration.action_controller[:asset_version] = 'version'
|
141
|
-
assert_equal assets('blank.css'), '<link rel="stylesheet" href="http://assets.com/assets_path/version/blank.css" />'
|
142
|
-
assert_equal assets('blank.js'), '<script src="http://assets.com/assets_path/version/blank.js"></script>'
|
143
|
+
assert_equal assets('blank.css'), '<link rel="stylesheet" href="http://assets.com/assets_path/version/blank.min.css" />'
|
144
|
+
assert_equal assets('blank.js'), '<script src="http://assets.com/assets_path/version/blank.min.js"></script>'
|
143
145
|
assert_equal assets('blank'), assets('blank.css') << assets('blank.js')
|
144
146
|
end
|
145
147
|
end
|
data/zfben_rails_assets.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfben_rails_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &19156440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19156440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: compass
|
27
|
-
requirement: &
|
27
|
+
requirement: &19156060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19156060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: coffee-script
|
38
|
-
requirement: &
|
38
|
+
requirement: &19155600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *19155600
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: uglifier
|
49
|
-
requirement: &
|
49
|
+
requirement: &19155180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *19155180
|
58
58
|
description: ''
|
59
59
|
email:
|
60
60
|
- ben@zfben.com
|