zfben_libjs 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/libjs +1 -1
- data/lib/zfben_libjs.rb +295 -276
- data/zfben_libjs.gemspec +1 -2
- metadata +12 -13
- data/lib/zfben_libjs/version.rb +0 -3
data/bin/libjs
CHANGED
data/lib/zfben_libjs.rb
CHANGED
@@ -17,313 +17,332 @@ def tip msg
|
|
17
17
|
STDOUT.print "#{msg}\n".color(:green)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
def build!
|
42
|
-
tip '== Starting Build @' + @config_file
|
43
|
-
|
44
|
-
# Merge default config
|
45
|
-
@config = {
|
46
|
-
'src' => 'src',
|
47
|
-
'download' => false,
|
48
|
-
'minify' => true,
|
49
|
-
'url' => ''
|
50
|
-
}.merge(@data['config'])
|
51
|
-
|
52
|
-
@config['src'] = File.join(File.dirname(@config_file), @config['src'])
|
53
|
-
system('mkdir ' + @config['src']) unless File.exists?(@config['src'])
|
54
|
-
|
55
|
-
['source'].each do |path|
|
56
|
-
@config['src/' + path] = File.join(@config['src'], '.' + path) unless @config.has_key?('src/' + path)
|
57
|
-
system('mkdir ' + @config['src/' + path]) unless File.exists?(@config['src/' + path])
|
20
|
+
module Zfben_libjs
|
21
|
+
class Libjs
|
22
|
+
def initialize config_file
|
23
|
+
@config_file = File.exists?(config_file) && !File.directory?(config_file) ? [config_file] : Dir[config_file + '*'].select{ |f| !File.directory?(f) }
|
24
|
+
if @config_file.length == 0
|
25
|
+
err config_file + ' is not exist!'
|
26
|
+
else
|
27
|
+
@config_file = @config_file[0]
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
@data = YAML.load(File.read(@config_file))
|
32
|
+
rescue => e
|
33
|
+
err "#{@config_file} load filed!\n#{e}"
|
34
|
+
end
|
35
|
+
|
36
|
+
@path_gem = File.realpath(File.join(File.dirname(__FILE__), 'zfben_libjs'))
|
37
|
+
@path_lib = File.realpath('.')
|
38
|
+
|
39
|
+
tip "#{@config_file} load success!"
|
58
40
|
end
|
59
41
|
|
60
|
-
|
61
|
-
|
62
|
-
@config['src/' + path] = File.join(@config['src'], path) unless @config.has_key?('src/' + path)
|
63
|
-
system('mkdir ' + @config['src/' + path]) unless File.exists?(@config['src/' + path])
|
64
|
-
end
|
42
|
+
def build!
|
43
|
+
tip '== Starting Build @' + @config_file
|
65
44
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
tip '== [1/2] Starting Progress Source =='
|
81
|
-
length = @libs.length
|
82
|
-
num = 0
|
83
|
-
@libs.each do |name, urls|
|
84
|
-
num = num + 1
|
85
|
-
tip "[#{num}/#{length}] #{name}"
|
86
|
-
urls = [urls] unless urls.class == Array
|
87
|
-
urls = urls.map{ |url|
|
88
|
-
if url.include?('*')
|
89
|
-
url = Dir[url]
|
90
|
-
end
|
91
|
-
url
|
92
|
-
}.flatten.uniq.compact
|
93
|
-
lib = []
|
94
|
-
urls.each do |url|
|
95
|
-
if @libs.has_key?(url) && name != url
|
96
|
-
lib.push(url)
|
97
|
-
else
|
98
|
-
p path = File.join(@config['src/source'], name, File.basename(url))
|
99
|
-
dir = File.dirname(path)
|
100
|
-
system('mkdir ' + dir) unless File.exists?(dir)
|
101
|
-
download url, path
|
102
|
-
case get_filetype(path)
|
103
|
-
when 'css'
|
104
|
-
css = "/* @import #{url} */\n" << css_import(url, dir)
|
105
|
-
File.open(path, 'w'){ |f| f.write(css) }
|
106
|
-
images = download_images(name, url, path)
|
107
|
-
if images.length > 0
|
108
|
-
lib.push images
|
109
|
-
end
|
110
|
-
when 'js'
|
111
|
-
js = "/* @import #{url} */\n" << File.read(path)
|
112
|
-
File.open(path, 'w'){ |f| f.write(js) }
|
113
|
-
when 'rb'
|
114
|
-
script = eval(File.read(path))
|
115
|
-
css = ''
|
116
|
-
js = ''
|
117
|
-
script.each do | type, content |
|
118
|
-
case type
|
119
|
-
when :css
|
120
|
-
css << content
|
121
|
-
when :js
|
122
|
-
js << content
|
123
|
-
end
|
124
|
-
end
|
125
|
-
if css != ''
|
126
|
-
path = File.join(dir, File.basename(path, '.rb') << '.css')
|
127
|
-
File.open(path, 'w'){ |f| f.write("/* @import #{url} */\n" + css) }
|
128
|
-
elsif js != ''
|
129
|
-
path = File.join(dir, File.basename(path, '.rb') << '.js')
|
130
|
-
File.open(path, 'w'){ |f| f.write("/* @import #{url} */\n" + js) }
|
131
|
-
end
|
132
|
-
when 'sass'
|
133
|
-
options = { :syntax => :sass, :cache => false }.merge(Compass.sass_engine_options)
|
134
|
-
options[:load_paths].push File.dirname(path), File.dirname(url)
|
135
|
-
css = "/* @import #{url} */\n" + Sass::Engine.new(File.read(path), options).render
|
136
|
-
path = File.join(dir, File.basename(path) << '.css')
|
137
|
-
File.open(path, 'w'){ |f| f.write(css) }
|
138
|
-
when 'scss'
|
139
|
-
options = { :syntax => :scss, :cache => false }.merge(Compass.sass_engine_options)
|
140
|
-
options[:load_paths].push File.dirname(path), File.dirname(url)
|
141
|
-
css = "/* @import #{url} */\n" + Sass::Engine.new(File.read(path), options).render
|
142
|
-
path = File.join(dir, File.basename(path) << '.css')
|
143
|
-
File.open(path, 'w'){ |f| f.write(css) }
|
144
|
-
when 'coffee'
|
145
|
-
js = "/* @import #{url} */\n" + CoffeeScript.compile(File.read(path))
|
146
|
-
path = File.join(dir, File.basename(path) << '.js')
|
147
|
-
File.open(path, 'w'){ |f| f.write(js) }
|
148
|
-
else
|
149
|
-
lib.push url
|
150
|
-
end
|
151
|
-
lib.push(path)
|
152
|
-
end
|
45
|
+
# Merge default config
|
46
|
+
@config = {
|
47
|
+
'src' => 'src',
|
48
|
+
'download' => false,
|
49
|
+
'minify' => true,
|
50
|
+
'url' => ''
|
51
|
+
}.merge(@data['config'])
|
52
|
+
|
53
|
+
@config['src'] = File.join(File.dirname(@config_file), @config['src'])
|
54
|
+
system('mkdir ' + @config['src']) unless File.exists?(@config['src'])
|
55
|
+
|
56
|
+
['source'].each do |path|
|
57
|
+
@config['src/' + path] = File.join(@config['src'], '.' + path) unless @config.has_key?('src/' + path)
|
58
|
+
system('mkdir ' + @config['src/' + path]) unless File.exists?(@config['src/' + path])
|
153
59
|
end
|
154
|
-
lib = lib.flatten.uniq
|
155
60
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
content = "/* @import #{file} */\n" + File.read(file)
|
161
|
-
case File.extname(file)
|
162
|
-
when '.css'
|
163
|
-
css << content
|
164
|
-
file = nil
|
165
|
-
when '.js'
|
166
|
-
js << content << ';'
|
167
|
-
file = nil
|
168
|
-
end
|
169
|
-
end
|
170
|
-
file
|
171
|
-
}.compact
|
172
|
-
if css != ''
|
173
|
-
file = File.join(@config['src/source'], name + '.css')
|
174
|
-
File.open(file, 'w'){ |f| f.write(css) }
|
175
|
-
lib.push(file)
|
61
|
+
['javascripts', 'stylesheets', 'images'].each do |path|
|
62
|
+
@config['url/' + path] = @config['url'] + '/' + path unless @config.has_key?('url/' + path)
|
63
|
+
@config['src/' + path] = File.join(@config['src'], path) unless @config.has_key?('src/' + path)
|
64
|
+
system('mkdir ' + @config['src/' + path]) unless File.exists?(@config['src/' + path])
|
176
65
|
end
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
66
|
+
|
67
|
+
# Merge default libs
|
68
|
+
@libs = {
|
69
|
+
'lazyload' => 'https://raw.github.com/rgrove/lazyload/master/lazyload.js'
|
70
|
+
}.merge(@data['libs'])
|
71
|
+
|
72
|
+
@bundle = @data['bundle']
|
73
|
+
|
74
|
+
@preload = @data['preload']
|
75
|
+
|
76
|
+
if @config.has_key?('before')
|
77
|
+
load @config['before']
|
181
78
|
end
|
182
79
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
80
|
+
|
81
|
+
tip '== [1/2] Starting Progress Source =='
|
82
|
+
length = @libs.length
|
83
|
+
num = 0
|
84
|
+
@libs.each do |name, urls|
|
85
|
+
num = num + 1
|
86
|
+
tip "[#{num}/#{length}] #{name}"
|
87
|
+
urls = [urls] unless urls.class == Array
|
88
|
+
urls = urls.map{ |url|
|
89
|
+
if url.include?('*')
|
90
|
+
url = Dir[url]
|
192
91
|
end
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
92
|
+
url
|
93
|
+
}.flatten.uniq.compact
|
94
|
+
lib = []
|
95
|
+
urls.each do |url|
|
96
|
+
if @libs.has_key?(url) && name != url
|
97
|
+
lib.push(url)
|
98
|
+
else
|
99
|
+
p path = File.join(@config['src/source'], name, File.basename(url))
|
100
|
+
dir = File.dirname(path)
|
101
|
+
system('mkdir ' + dir) unless File.exists?(dir)
|
102
|
+
download url, path
|
103
|
+
case get_filetype(path)
|
104
|
+
when 'css'
|
105
|
+
css = "/* @import #{url} */\n" << css_import(url, dir)
|
106
|
+
File.open(path, 'w'){ |f| f.write(css) }
|
107
|
+
images = download_images(name, url, path)
|
108
|
+
if images.length > 0
|
109
|
+
lib.push images
|
208
110
|
end
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
111
|
+
when 'js'
|
112
|
+
js = "/* @import #{url} */\n" << File.read(path)
|
113
|
+
File.open(path, 'w'){ |f| f.write(js) }
|
114
|
+
when 'rb'
|
115
|
+
script = eval(File.read(path))
|
116
|
+
css = ''
|
117
|
+
js = ''
|
118
|
+
script.each do | type, content |
|
119
|
+
case type
|
120
|
+
when :css
|
121
|
+
css << content
|
122
|
+
when :js
|
123
|
+
js << content
|
124
|
+
end
|
125
|
+
end
|
126
|
+
if css != ''
|
127
|
+
path = File.join(dir, File.basename(path, '.rb') << '.css')
|
128
|
+
File.open(path, 'w'){ |f| f.write("/* @import #{url} */\n" + css) }
|
129
|
+
elsif js != ''
|
130
|
+
path = File.join(dir, File.basename(path, '.rb') << '.js')
|
131
|
+
File.open(path, 'w'){ |f| f.write("/* @import #{url} */\n" + js) }
|
132
|
+
end
|
133
|
+
when 'sass'
|
134
|
+
options = { :syntax => :sass, :cache => false }.merge(Compass.sass_engine_options)
|
135
|
+
options[:load_paths].push File.dirname(path), File.dirname(url)
|
136
|
+
css = "/* @import #{url} */\n" + Sass::Engine.new(File.read(path), options).render
|
137
|
+
path = File.join(dir, File.basename(path) << '.css')
|
138
|
+
File.open(path, 'w'){ |f| f.write(css) }
|
139
|
+
when 'scss'
|
140
|
+
options = { :syntax => :scss, :cache => false }.merge(Compass.sass_engine_options)
|
141
|
+
options[:load_paths].push File.dirname(path), File.dirname(url)
|
142
|
+
css = "/* @import #{url} */\n" + Sass::Engine.new(File.read(path), options).render
|
143
|
+
path = File.join(dir, File.basename(path) << '.css')
|
144
|
+
File.open(path, 'w'){ |f| f.write(css) }
|
145
|
+
when 'coffee'
|
146
|
+
js = "/* @import #{url} */\n" + CoffeeScript.compile(File.read(path))
|
147
|
+
path = File.join(dir, File.basename(path) << '.js')
|
148
|
+
File.open(path, 'w'){ |f| f.write(js) }
|
149
|
+
else
|
150
|
+
lib.push url
|
226
151
|
end
|
152
|
+
lib.push(path)
|
227
153
|
end
|
228
|
-
else
|
229
|
-
path = @libs[file]
|
230
|
-
end
|
231
|
-
path
|
232
|
-
}.compact.flatten.uniq
|
233
|
-
@libs[name] = @libs[name][0] if @libs[name].length == 1
|
234
|
-
end
|
235
|
-
|
236
|
-
tip '== [2/2] Generate lib.js =='
|
237
|
-
|
238
|
-
libjs = File.read(@libs['lazyload']) << ';'
|
239
|
-
|
240
|
-
libjs_core = File.read(File.join(@path_gem, 'lib.coffee'))
|
241
|
-
|
242
|
-
libjs_core = CoffeeScript.compile(libjs_core)
|
243
|
-
|
244
|
-
libjs << libjs_core << ';'
|
245
|
-
|
246
|
-
@urls = {}
|
247
|
-
|
248
|
-
@libs.each do |lib, path|
|
249
|
-
path = [path] unless path.class == Array
|
250
|
-
path = path.map{ |url|
|
251
|
-
case File.extname(url)
|
252
|
-
when '.css'
|
253
|
-
url = @config['url/stylesheets'] + '/' + File.basename(url)
|
254
|
-
when '.js'
|
255
|
-
url = @config['url/javascripts'] + '/' + File.basename(url)
|
256
|
-
else
|
257
|
-
url = nil
|
258
154
|
end
|
259
|
-
|
260
|
-
|
261
|
-
@urls[lib] = path
|
262
|
-
end
|
263
|
-
|
264
|
-
libjs << "\n/* libs */\nlib.libs(#{@urls.to_json});lib.loaded('add', 'lazyload');"
|
265
|
-
|
266
|
-
if @config['autoVersion']
|
267
|
-
libjs << Time.now.strftime('lib.defaults.version = "?%s";')
|
268
|
-
end
|
269
|
-
|
270
|
-
if @bundle != nil && @bundle.length > 0
|
271
|
-
@bundle.each do |name, libs|
|
155
|
+
lib = lib.flatten.uniq
|
156
|
+
|
272
157
|
css = ''
|
273
158
|
js = ''
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
lib = [lib] unless lib.class == Array
|
278
|
-
lib.each do |file|
|
279
|
-
files.push(file)
|
159
|
+
lib = lib.map{ |file|
|
160
|
+
if File.exists?(file)
|
161
|
+
content = "/* @import #{file} */\n" + File.read(file)
|
280
162
|
case File.extname(file)
|
281
163
|
when '.css'
|
282
|
-
css <<
|
164
|
+
css << content
|
165
|
+
file = nil
|
283
166
|
when '.js'
|
284
|
-
js <<
|
167
|
+
js << content << ';'
|
168
|
+
file = nil
|
285
169
|
end
|
286
170
|
end
|
287
|
-
|
288
|
-
|
289
|
-
path = []
|
290
|
-
|
171
|
+
file
|
172
|
+
}.compact
|
291
173
|
if css != ''
|
292
|
-
file = File.join(@config['src/
|
174
|
+
file = File.join(@config['src/source'], name + '.css')
|
293
175
|
File.open(file, 'w'){ |f| f.write(css) }
|
294
|
-
|
176
|
+
lib.push(file)
|
295
177
|
end
|
296
|
-
|
297
178
|
if js != ''
|
298
|
-
|
299
|
-
js << "\nif(typeof lib === 'function'){lib.loaded('add', '#{files_url}');}"
|
300
|
-
file = File.join(@config['src/javascripts'], name + '.js')
|
179
|
+
file = File.join(@config['src/source'], name + '.js')
|
301
180
|
File.open(file, 'w'){ |f| f.write(js) }
|
302
|
-
|
181
|
+
lib.push(file)
|
303
182
|
end
|
304
183
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
184
|
+
@libs[name] = lib.map{ |file|
|
185
|
+
if File.exists?(file)
|
186
|
+
case File.extname(file)
|
187
|
+
when '.js'
|
188
|
+
type = 'javascripts'
|
189
|
+
when '.css'
|
190
|
+
type = 'stylesheets'
|
191
|
+
else
|
192
|
+
type = 'images'
|
193
|
+
end
|
194
|
+
|
195
|
+
path = File.join(@config['src/' + type], File.basename(file))
|
196
|
+
|
197
|
+
tip '=> ' + path
|
198
|
+
|
199
|
+
system('cp ' + file + ' ' + path)
|
200
|
+
|
201
|
+
reg = /url\("?'?([^'")]+)'?"?\)/
|
202
|
+
if type == 'stylesheets' && @config['changeImageUrl'] && reg =~ File.read(path)
|
203
|
+
css = File.read(path).partition_all(reg).map{ |f|
|
204
|
+
if reg =~ f
|
205
|
+
if @config['url'] == ''
|
206
|
+
f = 'url("../images/' << File.basename(f.match(reg)[1]) << '")'
|
207
|
+
else
|
208
|
+
f = 'url("' + @config['url/images'] + File.basename(f.match(reg)[1]) << '")'
|
209
|
+
end
|
210
|
+
end
|
211
|
+
f
|
212
|
+
}.join('')
|
213
|
+
File.open(path, 'w'){ |f| f.write(css) }
|
214
|
+
end
|
215
|
+
if type == 'images'
|
216
|
+
path = nil
|
217
|
+
end
|
218
|
+
|
219
|
+
if @config['minify']
|
220
|
+
if type == 'stylesheets'
|
221
|
+
min = minify(File.read(path), :css)
|
222
|
+
File.open(path, 'w'){ |f| f.write(min) }
|
223
|
+
end
|
224
|
+
if type == 'javascripts'
|
225
|
+
min = minify(File.read(path), :js)
|
226
|
+
File.open(path, 'w'){ |f| f.write(min) }
|
227
|
+
end
|
228
|
+
end
|
229
|
+
else
|
230
|
+
path = @libs[file]
|
231
|
+
end
|
232
|
+
path
|
233
|
+
}.compact.flatten.uniq
|
234
|
+
@libs[name] = @libs[name][0] if @libs[name].length == 1
|
235
|
+
end
|
236
|
+
|
237
|
+
tip '== [2/2] Generate lib.js =='
|
238
|
+
|
239
|
+
libjs = File.read(@libs['lazyload']) << ';'
|
240
|
+
|
241
|
+
libjs_core = File.read(File.join(@path_gem, 'lib.coffee'))
|
242
|
+
|
243
|
+
libjs_core = CoffeeScript.compile(libjs_core)
|
244
|
+
|
245
|
+
libjs << libjs_core << ';'
|
246
|
+
|
247
|
+
@urls = {}
|
248
|
+
|
249
|
+
@libs.each do |lib, path|
|
250
|
+
path = [path] unless path.class == Array
|
251
|
+
path = path.map{ |url|
|
252
|
+
case File.extname(url)
|
253
|
+
when '.css'
|
254
|
+
url = @config['url/stylesheets'] + '/' + File.basename(url)
|
255
|
+
when '.js'
|
256
|
+
url = @config['url/javascripts'] + '/' + File.basename(url)
|
257
|
+
else
|
258
|
+
url = nil
|
259
|
+
end
|
260
|
+
url
|
261
|
+
}.compact.uniq
|
262
|
+
@urls[lib] = path
|
263
|
+
end
|
264
|
+
|
265
|
+
libjs << "\n/* libs */\nlib.libs(#{@urls.to_json});lib.loaded('add', 'lazyload');"
|
266
|
+
|
267
|
+
if @config['autoVersion']
|
268
|
+
libjs << Time.now.strftime('lib.defaults.version = "?%s";')
|
269
|
+
end
|
270
|
+
|
271
|
+
if @bundle != nil && @bundle.length > 0
|
272
|
+
@bundle.each do |name, libs|
|
273
|
+
css = ''
|
274
|
+
js = ''
|
275
|
+
files = []
|
276
|
+
libs.each do |lib|
|
277
|
+
lib = @libs[lib] if @libs.has_key?(lib)
|
278
|
+
lib = [lib] unless lib.class == Array
|
279
|
+
lib.each do |file|
|
280
|
+
files.push(file)
|
281
|
+
case File.extname(file)
|
282
|
+
when '.css'
|
283
|
+
css << File.read(file)
|
284
|
+
when '.js'
|
285
|
+
js << File.read(file) << ';'
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
path = []
|
291
|
+
|
292
|
+
if css != ''
|
293
|
+
file = File.join(@config['src/stylesheets'], name + '.css')
|
294
|
+
File.open(file, 'w'){ |f| f.write(css) }
|
295
|
+
path.push(@config['url/stylesheets'] + '/' + File.basename(file))
|
296
|
+
end
|
297
|
+
|
298
|
+
if js != ''
|
299
|
+
files_url = files.map{ |f| @config['url/javascripts'] + '/' + File.basename(f) }.join("','")
|
300
|
+
js << "\nif(typeof lib === 'function'){lib.loaded('add', '#{files_url}');}"
|
301
|
+
file = File.join(@config['src/javascripts'], name + '.js')
|
302
|
+
File.open(file, 'w'){ |f| f.write(js) }
|
303
|
+
path.push(@config['url/javascripts'] + '/' + File.basename(file))
|
304
|
+
end
|
305
|
+
|
306
|
+
if path.length > 0
|
307
|
+
path = path[0] if path.length == 0
|
308
|
+
@bundle[name] = path
|
309
|
+
else
|
310
|
+
@bundle.delete(name)
|
311
|
+
end
|
310
312
|
end
|
313
|
+
|
314
|
+
libjs << "\n/* bundle */\nlib.libs(#{@bundle.to_json});"
|
311
315
|
end
|
312
316
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
libjs
|
317
|
+
if @preload.class == Array && @preload.length > 0
|
318
|
+
libjs << "\n/* preload */\nlib('#{@preload.join(' ')}');"
|
319
|
+
end
|
320
|
+
|
321
|
+
libjs = minify(libjs, :js) if @config['minify']
|
322
|
+
File.open(File.join(@config['src/javascripts'], 'lib.js'), 'w'){ |f| f.write(libjs) }
|
323
|
+
|
324
|
+
if @config.has_key?('after')
|
325
|
+
load @config['after']
|
326
|
+
end
|
327
|
+
|
328
|
+
tip '== End Build =='
|
318
329
|
end
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
330
|
+
end
|
331
|
+
|
332
|
+
Lib_version ||= Time.now.strftime('?%s')
|
333
|
+
|
334
|
+
if Rails
|
335
|
+
module Rails
|
336
|
+
module ActionView::Helpers::AssetTagHelper
|
337
|
+
def lib *opt
|
338
|
+
html = '<script src="/javascripts/lib.js' + Lib_version + '"></script>'
|
339
|
+
unless opt[0].blank?
|
340
|
+
html += '<script>lib("' + opt[0].to_s + '");</script>'
|
341
|
+
end
|
342
|
+
return html
|
343
|
+
end
|
344
|
+
end
|
325
345
|
end
|
326
|
-
|
327
|
-
tip '== End Build =='
|
328
346
|
end
|
329
347
|
end
|
348
|
+
|
data/zfben_libjs.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "zfben_libjs/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "zfben_libjs"
|
7
|
-
s.version =
|
6
|
+
s.version = '0.0.8'
|
8
7
|
s.authors = ["Ben"]
|
9
8
|
s.email = ["ben@zfben.com"]
|
10
9
|
s.homepage = "https://github.com/benz303/zfben_libjs"
|
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.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-08-
|
12
|
+
date: 2011-08-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
16
|
-
requirement: &
|
16
|
+
requirement: &17935120 !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: *17935120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &17934660 !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: *17934660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: compass
|
38
|
-
requirement: &
|
38
|
+
requirement: &17934240 !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: *17934240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: coffee-script
|
49
|
-
requirement: &
|
49
|
+
requirement: &17933820 !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: *17933820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: uglifier
|
60
|
-
requirement: &
|
60
|
+
requirement: &17933400 !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: *17933400
|
69
69
|
description: ''
|
70
70
|
email:
|
71
71
|
- ben@zfben.com
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- lib/zfben_libjs/lib.coffee
|
83
83
|
- lib/zfben_libjs/lib.rb
|
84
84
|
- lib/zfben_libjs/libjs.yml
|
85
|
-
- lib/zfben_libjs/version.rb
|
86
85
|
- test.yml
|
87
86
|
- test/javascript/assets/callback.js
|
88
87
|
- test/javascript/fixtures/lib_fixtures.html
|
data/lib/zfben_libjs/version.rb
DELETED