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.
@@ -6,16 +6,21 @@ module AssetsHelper
6
6
  html = ''
7
7
  opts.each do |name|
8
8
  name = name.to_s
9
- if name.end_with?('.css')
10
- html << assets_css(name)
11
- elsif name.end_with?('.js')
12
- html << assets_js(name)
13
- else
14
- path = Rails.root.to_s + '/app/assets/' + name
15
- css = Dir.glob(([:css] + AssetFormat::Css::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s })
16
- js = Dir.glob(([:js] + AssetFormat::Js::EXTEND_FORMATS).map{ |f| path + '.' + f.to_s })
17
- html << assets(name + '.css') if css.length > 0
18
- html << assets(name + '.js') if js.length > 0
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
@@ -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
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "zfben_rails_assets"
6
- s.version = '0.0.7'
6
+ s.version = '0.0.8'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Ben"]
9
9
  s.email = ["ben@zfben.com"]
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.7
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-22 00:00:00.000000000 Z
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: &20373060 !ruby/object:Gem::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: *20373060
24
+ version_requirements: *19156440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: compass
27
- requirement: &20372280 !ruby/object:Gem::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: *20372280
35
+ version_requirements: *19156060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: coffee-script
38
- requirement: &20371520 !ruby/object:Gem::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: *20371520
46
+ version_requirements: *19155600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: uglifier
49
- requirement: &20371080 !ruby/object:Gem::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: *20371080
57
+ version_requirements: *19155180
58
58
  description: ''
59
59
  email:
60
60
  - ben@zfben.com