zfben_libjs 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zfben_libjs/lib.coffee +16 -2
- data/lib/zfben_libjs/version.rb +1 -1
- data/lib/zfben_libjs.rb +7 -2
- data/test.yml +1 -0
- metadata +12 -12
data/lib/zfben_libjs/lib.coffee
CHANGED
@@ -76,7 +76,13 @@ lib = ->
|
|
76
76
|
pending_css.push url
|
77
77
|
|
78
78
|
if pending_css.length > 0
|
79
|
-
|
79
|
+
loading_css = []
|
80
|
+
if lib.defaults.version
|
81
|
+
for url in pending_css
|
82
|
+
loading_css.push url + lib.defaults.version
|
83
|
+
else
|
84
|
+
loading_css = pending_css
|
85
|
+
LazyLoad.css(loading_css, ->
|
80
86
|
for url in pending_css
|
81
87
|
delete pending_urls[url]
|
82
88
|
loaded[url] = true
|
@@ -92,7 +98,13 @@ lib = ->
|
|
92
98
|
pending_js.push url
|
93
99
|
|
94
100
|
if js.length > 0
|
95
|
-
|
101
|
+
loading_js = []
|
102
|
+
if lib.defaults.version
|
103
|
+
for url in pending_js
|
104
|
+
loading_js.push url + lib.defaults.version
|
105
|
+
else
|
106
|
+
loading_js = pending_js
|
107
|
+
LazyLoad.js(loading_js, ->
|
96
108
|
for url in pending_js
|
97
109
|
delete pending_urls[url]
|
98
110
|
loaded[url] = true
|
@@ -147,4 +159,6 @@ lib.libs = (new_libs)->
|
|
147
159
|
)(lib_name)
|
148
160
|
return libs
|
149
161
|
|
162
|
+
lib.defaults = {}
|
163
|
+
|
150
164
|
window.lib = lib
|
data/lib/zfben_libjs/version.rb
CHANGED
data/lib/zfben_libjs.rb
CHANGED
@@ -19,7 +19,7 @@ end
|
|
19
19
|
|
20
20
|
class Libjs
|
21
21
|
def initialize config_file
|
22
|
-
@config_file = File.exists?(config_file) ? [config_file] : Dir[config_file + '*'].select{ |f| !File.directory?(f) }
|
22
|
+
@config_file = File.exists?(config_file) && !File.directory?(config_file) ? [config_file] : Dir[config_file + '*'].select{ |f| !File.directory?(f) }
|
23
23
|
if @config_file.length == 0
|
24
24
|
err config_file + ' is not exist!'
|
25
25
|
else
|
@@ -151,7 +151,7 @@ class Libjs
|
|
151
151
|
lib.push(path)
|
152
152
|
end
|
153
153
|
end
|
154
|
-
lib = lib.flatten
|
154
|
+
lib = lib.flatten.uniq
|
155
155
|
|
156
156
|
css = ''
|
157
157
|
js = ''
|
@@ -244,6 +244,7 @@ class Libjs
|
|
244
244
|
libjs << libjs_core << ';'
|
245
245
|
|
246
246
|
@urls = {}
|
247
|
+
|
247
248
|
@libs.each do |lib, path|
|
248
249
|
path = [path] unless path.class == Array
|
249
250
|
path = path.map{ |url|
|
@@ -262,6 +263,10 @@ class Libjs
|
|
262
263
|
|
263
264
|
libjs << "\n/* libs */\nlib.libs(#{@urls.to_json});lib.loaded('add', 'lazyload');"
|
264
265
|
|
266
|
+
if @config['autoVersion']
|
267
|
+
libjs << Time.now.strftime('lib.defaults.version = "?%s";')
|
268
|
+
end
|
269
|
+
|
265
270
|
if @bundle != nil && @bundle.length > 0
|
266
271
|
@bundle.each do |name, libs|
|
267
272
|
css = ''
|
data/test.yml
CHANGED
@@ -4,6 +4,7 @@ config:
|
|
4
4
|
download: false # if file isn't exists, it will be downloaded always
|
5
5
|
minify: false # use uglifier and sass engine to minify files
|
6
6
|
changeImageUrl: true # change image urls in css
|
7
|
+
autoVersion: true # add version to files url
|
7
8
|
|
8
9
|
# Files to be download and writen in lib.js
|
9
10
|
libs:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfben_libjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
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-08-
|
12
|
+
date: 2011-08-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
16
|
-
requirement: &
|
16
|
+
requirement: &10618860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10618860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &10618340 !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: *10618340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: compass
|
38
|
-
requirement: &
|
38
|
+
requirement: &10617920 !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: *10617920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: coffee-script
|
49
|
-
requirement: &
|
49
|
+
requirement: &10604080 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10604080
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: uglifier
|
60
|
-
requirement: &
|
60
|
+
requirement: &10603660 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10603660
|
69
69
|
description: ''
|
70
70
|
email:
|
71
71
|
- ben@zfben.com
|