zfben_rails_assets 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile +2 -0
- data/README.md +4 -0
- data/app/models/asset_format.rb +4 -4
- data/app/models/asset_format/css.rb +1 -1
- data/app/models/asset_format/js.rb +1 -1
- data/test/assets_test.rb +27 -3
- data/test/dummy/app/assets/sass_import.sass +1 -0
- data/test/dummy/app/assets/scss_import.scss +1 -0
- data/zfben_rails_assets.gemspec +7 -15
- metadata +49 -34
- data/test/dummy/tmp/assets/blank.css +0 -1
- data/test/dummy/tmp/assets/blank.js +0 -1
- data/test/dummy/tmp/assets/coffee.js +0 -5
- data/test/dummy/tmp/assets/import.css +0 -4
- data/test/dummy/tmp/assets/import.js +0 -3
- data/test/dummy/tmp/assets/import_404.css +0 -0
- data/test/dummy/tmp/assets/import_404.js +0 -0
- data/test/dummy/tmp/assets/import_iteration.css +0 -11
- data/test/dummy/tmp/assets/import_iteration.js +0 -9
- data/test/dummy/tmp/assets/import_iteration.min.css +0 -0
- data/test/dummy/tmp/assets/import_iteration.min.js +0 -1
- data/test/dummy/tmp/assets/import_twice.css +0 -8
- data/test/dummy/tmp/assets/import_twice.js +0 -7
- data/test/dummy/tmp/assets/sass.css +0 -3
- data/test/dummy/tmp/assets/scss.css +0 -3
- data/test/dummy/tmp/assets/simple.sass +0 -3
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/app/models/asset_format.rb
CHANGED
@@ -35,10 +35,10 @@ class AssetFormat
|
|
35
35
|
@format = @option.last
|
36
36
|
path = find_file(@option[0] + '.' + @option.last)
|
37
37
|
unless path.nil?
|
38
|
-
text = read_file
|
38
|
+
text = read_file(path)
|
39
39
|
if defined?(self.class::IMPORT)
|
40
40
|
regexp = self.class::IMPORT
|
41
|
-
text = import_file
|
41
|
+
text = import_file(regexp, text)
|
42
42
|
end
|
43
43
|
if no_error?
|
44
44
|
if @option.include?('min') && self.respond_to?(:minify)
|
@@ -82,7 +82,7 @@ class AssetFormat
|
|
82
82
|
def write_file name, text
|
83
83
|
dir = Rails.root.to_s + '/tmp/assets/'
|
84
84
|
unless File.exist?(dir)
|
85
|
-
FileUtils.
|
85
|
+
FileUtils.mkdir_p(dir)
|
86
86
|
end
|
87
87
|
path = dir + File.basename(name)
|
88
88
|
File.open(path, 'w'){ |f| f.write text }
|
@@ -91,7 +91,7 @@ class AssetFormat
|
|
91
91
|
|
92
92
|
def import_file regexp, text
|
93
93
|
text.gsub(regexp){ |s|
|
94
|
-
file = find_file(regexp.match(s)
|
94
|
+
file = find_file(regexp.match(s).to_a.last)
|
95
95
|
unless file.nil?
|
96
96
|
"\n/* #{file} */\n" << import_file(regexp, read_file(file))
|
97
97
|
else
|
@@ -2,7 +2,7 @@ require 'sass/css'
|
|
2
2
|
|
3
3
|
class AssetFormat::Css < AssetFormat
|
4
4
|
CONTENT_TYPE = 'text/css'
|
5
|
-
IMPORT = /[\/\* ]*@import[
|
5
|
+
IMPORT = /[\/\* ]*@import[\s("']*(url)?[("'\s]([^\s"'\);]+)["'); \*\/]*/
|
6
6
|
EXTEND_FORMATS = [:sass, :scss]
|
7
7
|
|
8
8
|
def minify text
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class AssetFormat::Js < AssetFormat
|
2
2
|
CONTENT_TYPE = 'text/javascript'
|
3
|
-
IMPORT = /[\/\*]{2}\s*@import[ "'\(]+([^\s"'\);]+)[
|
3
|
+
IMPORT = /[\/\*]{2}\s*@import[ "'\(]+([^\s"'\);]+)[ "'\);\*\/]*/
|
4
4
|
IMPORT_COFFEE = /# *@import[ "'\(]+([^\s"'\);]+)[ "'\)]*/
|
5
5
|
EXTEND_FORMATS = [:coffee]
|
6
6
|
|
data/test/assets_test.rb
CHANGED
@@ -7,9 +7,14 @@ class ModuleTest < ActiveSupport::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class CssTest < ActiveSupport::TestCase
|
10
|
-
["@import file\n", '@import(file)', '@import("file")', '@import "file"', '@import file;', '/* @import file */'].each do |test|
|
10
|
+
["@import file\n", '@import(file)', '@import("file")', '@import "file"', '@import file;', '/* @import file */', '@import url(file);'].each do |test|
|
11
11
|
test('import regex: ' + test)do
|
12
|
-
assert_equal AssetFormat::Css::IMPORT.match(test)
|
12
|
+
assert_equal AssetFormat::Css::IMPORT.match(test).to_a.last, 'file', AssetFormat::Css::IMPORT.match(test)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
["@import file.css\n", '@import(file.css)', '@import("file.css")', '@import "file.css"', '@import file.css;', '/* @import file.css */', '@import url(file.css);'].each do |test|
|
16
|
+
test('import regex: ' + test)do
|
17
|
+
assert_equal AssetFormat::Css::IMPORT.match(test).to_a.last, 'file.css', AssetFormat::Css::IMPORT.match(test)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -17,7 +22,12 @@ end
|
|
17
22
|
class JsTest < ActiveSupport::TestCase
|
18
23
|
["// @import file\n", '//@import(file)', '//@import("file")', '//@import "file"', '//@import file;', '/* @import file */', "// aaa\n/*\n @import file\n*/"].each do |test|
|
19
24
|
test('import regex: ' + test)do
|
20
|
-
assert_equal AssetFormat::Js::IMPORT.match(test)
|
25
|
+
assert_equal AssetFormat::Js::IMPORT.match(test).to_a.last, 'file', AssetFormat::Js::IMPORT.match(test)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
["// @import file.js\n", '//@import(file.js)', '//@import("file.js")', '//@import "file.js"', '//@import file.js;', '/* @import file.js */', "// aaa\n/*\n @import file.js\n*/"].each do |test|
|
29
|
+
test('import regex: ' + test)do
|
30
|
+
assert_equal AssetFormat::Js::IMPORT.match(test).to_a.last, 'file.js', AssetFormat::Js::IMPORT.match(test)
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
@@ -105,18 +115,32 @@ class ControllerTest < ActionController::TestCase
|
|
105
115
|
assert_response :success
|
106
116
|
assert_equal @response.body, ::Sass::Engine.new(File.read(Rails.root.to_s + '/app/assets/sass.sass'), { syntax: :sass, style: :expanded }).render
|
107
117
|
end
|
118
|
+
|
119
|
+
test 'sass_import.sass' do
|
120
|
+
get :index, file: 'sass_import', format: 'css'
|
121
|
+
assert_response :success
|
122
|
+
assert @response.body.include?(File.read(Rails.root.to_s + '/app/assets/blank.css'))
|
123
|
+
end
|
108
124
|
|
109
125
|
test 'scss.css' do
|
110
126
|
get :index, file: 'scss', format: 'css'
|
111
127
|
assert_response :success
|
112
128
|
assert_equal @response.body, ::Sass::Engine.new(File.read(Rails.root.to_s + '/app/assets/scss.scss'), { syntax: :scss, style: :expanded }).render
|
113
129
|
end
|
130
|
+
|
131
|
+
test 'scss_import.scss' do
|
132
|
+
get :index, file: 'scss_import', format: 'css'
|
133
|
+
assert_response :success
|
134
|
+
assert @response.body.include?(File.read(Rails.root.to_s + '/app/assets/blank.css'))
|
135
|
+
end
|
114
136
|
|
115
137
|
test 'coffee.js' do
|
116
138
|
get :index, file: 'coffee', format: 'js'
|
117
139
|
assert_response :success
|
118
140
|
assert_equal @response.body, CoffeeScript.compile(File.read(Rails.root.to_s + '/app/assets/coffee.coffee'))
|
119
141
|
end
|
142
|
+
|
143
|
+
|
120
144
|
end
|
121
145
|
|
122
146
|
class AssetsHelperTest < ActionView::TestCase
|
@@ -0,0 +1 @@
|
|
1
|
+
@import blank.css
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "blank.css";
|
data/zfben_rails_assets.gemspec
CHANGED
@@ -1,28 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
6
|
-
s.version = '0.0.
|
5
|
+
s.name = 'zfben_rails_assets'
|
6
|
+
s.version = '0.0.14'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['Ben']
|
9
|
+
s.email = ['ben@zfben.com']
|
10
|
+
s.homepage = 'https://github.com/benz303/zfben_rails_assets'
|
11
11
|
s.summary = %q{}
|
12
12
|
s.description = %q{}
|
13
|
-
s.post_install_message =%q{********************************************************************************
|
14
|
-
Thank you for using zfben_rails_assets!
|
15
|
-
|
16
|
-
Please follow @zfben on Twitter for announcements, updates, and news.
|
17
|
-
https://twitter.com/zfben
|
18
|
-
|
19
|
-
********************************************************************************
|
20
|
-
}
|
21
13
|
|
22
14
|
s.files = `git ls-files`.split("\n")
|
23
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
-
s.require_paths = [
|
17
|
+
s.require_paths = ['lib']
|
26
18
|
|
27
19
|
s.required_ruby_version = '>= 1.9'
|
28
20
|
|
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.14
|
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: 2012-
|
12
|
+
date: 2012-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: sass
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: compass
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: coffee-script
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: uglifier
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :runtime
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: haml
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,7 +101,12 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :runtime
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
description: ''
|
81
111
|
email:
|
82
112
|
- ben@zfben.com
|
@@ -110,7 +140,9 @@ files:
|
|
110
140
|
- test/dummy/app/assets/import_twice.css
|
111
141
|
- test/dummy/app/assets/import_twice.js
|
112
142
|
- test/dummy/app/assets/sass.sass
|
143
|
+
- test/dummy/app/assets/sass_import.sass
|
113
144
|
- test/dummy/app/assets/scss.scss
|
145
|
+
- test/dummy/app/assets/scss_import.scss
|
114
146
|
- test/dummy/app/controllers/application_controller.rb
|
115
147
|
- test/dummy/app/helpers/application_helper.rb
|
116
148
|
- test/dummy/app/views/layouts/application.html.erb
|
@@ -141,29 +173,11 @@ files:
|
|
141
173
|
- test/dummy/public/javascripts/rails.js
|
142
174
|
- test/dummy/public/stylesheets/.gitkeep
|
143
175
|
- test/dummy/script/rails
|
144
|
-
- test/dummy/tmp/assets/blank.css
|
145
|
-
- test/dummy/tmp/assets/blank.js
|
146
|
-
- test/dummy/tmp/assets/coffee.js
|
147
|
-
- test/dummy/tmp/assets/import.css
|
148
|
-
- test/dummy/tmp/assets/import.js
|
149
|
-
- test/dummy/tmp/assets/import_404.css
|
150
|
-
- test/dummy/tmp/assets/import_404.js
|
151
|
-
- test/dummy/tmp/assets/import_iteration.css
|
152
|
-
- test/dummy/tmp/assets/import_iteration.js
|
153
|
-
- test/dummy/tmp/assets/import_iteration.min.css
|
154
|
-
- test/dummy/tmp/assets/import_iteration.min.js
|
155
|
-
- test/dummy/tmp/assets/import_twice.css
|
156
|
-
- test/dummy/tmp/assets/import_twice.js
|
157
|
-
- test/dummy/tmp/assets/sass.css
|
158
|
-
- test/dummy/tmp/assets/scss.css
|
159
|
-
- test/dummy/tmp/assets/simple.sass
|
160
176
|
- test/test_helper.rb
|
161
177
|
- zfben_rails_assets.gemspec
|
162
178
|
homepage: https://github.com/benz303/zfben_rails_assets
|
163
179
|
licenses: []
|
164
|
-
post_install_message:
|
165
|
-
\ Thank you for using zfben_rails_assets!\n \n Please follow @zfben on Twitter
|
166
|
-
for announcements, updates, and news.\n https://twitter.com/zfben\n\n********************************************************************************\n"
|
180
|
+
post_install_message:
|
167
181
|
rdoc_options: []
|
168
182
|
require_paths:
|
169
183
|
- lib
|
@@ -181,8 +195,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
195
|
version: '0'
|
182
196
|
requirements: []
|
183
197
|
rubyforge_project:
|
184
|
-
rubygems_version: 1.8.
|
198
|
+
rubygems_version: 1.8.23
|
185
199
|
signing_key:
|
186
200
|
specification_version: 3
|
187
201
|
summary: ''
|
188
202
|
test_files: []
|
203
|
+
has_rdoc:
|
@@ -1 +0,0 @@
|
|
1
|
-
/* blank.css */
|
@@ -1 +0,0 @@
|
|
1
|
-
// blank.js
|
File without changes
|
File without changes
|
@@ -1,11 +0,0 @@
|
|
1
|
-
|
2
|
-
/* /home/ben/dev/zfben_rails_assets/test/dummy/app/assets/import_twice.css */
|
3
|
-
|
4
|
-
/* /home/ben/dev/zfben_rails_assets/test/dummy/app/assets/blank.css */
|
5
|
-
/* blank.css */
|
6
|
-
|
7
|
-
|
8
|
-
/* /home/ben/dev/zfben_rails_assets/test/dummy/app/assets/blank.css */
|
9
|
-
/* blank.css */
|
10
|
-
|
11
|
-
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
;
|