ichiban 1.2.9 → 1.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ichiban.rb +1 -1
- data/lib/ichiban/config.rb +1 -1
- data/lib/ichiban/deleter.rb +1 -1
- data/lib/ichiban/dependencies.rb +1 -1
- data/lib/ichiban/html_compiler.rb +3 -3
- data/lib/ichiban/js_compiler.rb +48 -87
- data/lib/ichiban/version.rb +1 -1
- metadata +39 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2d44498e5294a4e136fd93046d4056280e227f1
|
4
|
+
data.tar.gz: 35934ae9f79da4a76c65b57c7ad68c26fb4e629f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6077e06b1d7ddca0db15f9dd268213414e4969be3ce429b601948ecf66e8ec3f5ee64f3fd8a5845c0ed2222240767db718afa3f5ef804c40e2a5b8aa621005b8
|
7
|
+
data.tar.gz: e91d785c7208e74206832c528b26f34490a9c44ef22cdd45459945a1836e8021f98c0f88e401ff4294060964aabb83da192486034dea3e601052956f89108f59
|
data/lib/ichiban.rb
CHANGED
data/lib/ichiban/config.rb
CHANGED
@@ -8,7 +8,7 @@ module Ichiban
|
|
8
8
|
class Config
|
9
9
|
def self.load_file
|
10
10
|
config_file = File.join(Ichiban.project_root, 'config.rb')
|
11
|
-
raise "#{config_file} must exist" unless File.
|
11
|
+
raise "#{config_file} must exist" unless File.exist?(config_file)
|
12
12
|
load config_file
|
13
13
|
end
|
14
14
|
|
data/lib/ichiban/deleter.rb
CHANGED
data/lib/ichiban/dependencies.rb
CHANGED
@@ -22,7 +22,7 @@ module Ichiban
|
|
22
22
|
if @html_file.is_a?(Ichiban::HTMLFile)
|
23
23
|
ivars_for_ctx[:_current_path] = @html_file.web_path
|
24
24
|
end
|
25
|
-
ivars_for_ctx.merge!(@ivars) if @ivars
|
25
|
+
ivars_for_ctx.merge!(@ivars) if instance_variable_defined?('@ivars')
|
26
26
|
|
27
27
|
ctx = Ichiban::HTMLCompiler::Context.new(ivars_for_ctx)
|
28
28
|
|
@@ -52,7 +52,7 @@ module Ichiban
|
|
52
52
|
def wrap_in_layouts(ctx, inner_rhtml)
|
53
53
|
ctx.layout_stack.reverse.inject(inner_rhtml) do |html, layout_name|
|
54
54
|
layout_path = File.join(Ichiban.project_root, 'layouts', layout_name + '.html')
|
55
|
-
unless File.
|
55
|
+
unless File.exist?(layout_path)
|
56
56
|
raise "Layout does not exist: #{layout_path}"
|
57
57
|
end
|
58
58
|
eruby = Eruby.new(
|
@@ -100,7 +100,7 @@ module Ichiban
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def layout_stack
|
103
|
-
@_layout_stack
|
103
|
+
instance_variable_defined?('@_layout_stack') ? @_layout_stack : ['default']
|
104
104
|
end
|
105
105
|
|
106
106
|
def self.user_defined_helpers
|
data/lib/ichiban/js_compiler.rb
CHANGED
@@ -1,65 +1,70 @@
|
|
1
1
|
module Ichiban
|
2
|
-
# This class uses the UglifyJS2 binary to concatenate and minify JS source
|
2
|
+
# This class uses the UglifyJS2 binary (uglifyjs) to concatenate and minify JS source
|
3
|
+
# files. You must have uglify-js on your path.
|
3
4
|
class JSCompiler
|
4
5
|
def compile
|
5
6
|
rel = @file.rel_to 'assets/js'
|
6
7
|
Ichiban.config.js_manifests.each do |dest, sources|
|
7
8
|
if sources.include? rel
|
8
|
-
#
|
9
|
+
# Before doing anything, we compute several paths. Assume, for the sake of
|
10
|
+
# example, that dest == 'foo/bar.js'. Then the paths would be:
|
11
|
+
#
|
12
|
+
# Variable Example value
|
13
|
+
# ------------------------------------------------------------------------------
|
14
|
+
# dest foo/bar.js
|
15
|
+
# dest_folder /home/johnq/mysite/compiled/js/foo
|
16
|
+
# ugly_js_path /home/johnq/mysite/compiled/js/foo/bar.js
|
17
|
+
# map_path /home/johnq/mysite/compiled/js/foo/bar.js.map
|
18
|
+
# map_path_from_webroot /js/foo/bar.js.map
|
19
|
+
|
9
20
|
dest_folder = File.expand_path(File.join(
|
10
21
|
Ichiban.project_root, 'compiled', 'js',
|
11
22
|
File.dirname(dest)
|
12
23
|
))
|
13
|
-
|
14
|
-
|
24
|
+
|
25
|
+
ugly_js_path = File.join(Ichiban.project_root, 'compiled', 'js', dest)
|
26
|
+
|
27
|
+
map_path = ugly_js_path + '.map'
|
28
|
+
|
29
|
+
map_path_from_webroot = File.join('/js', dest + '.map')
|
30
|
+
|
31
|
+
# Make individual, uglified JS and maps.
|
32
|
+
compiled = sources.map do |src_path|
|
33
|
+
src_js = File.read File.join(Ichiban.project_root, 'assets', 'js', src_path)
|
34
|
+
ugly_js, map_json = Uglifier.compile_with_map src_js, source_map: {filename: src_path}
|
35
|
+
[
|
36
|
+
ugly_js,
|
37
|
+
SourceMap::Map.from_json(map_json)
|
38
|
+
]
|
15
39
|
end
|
16
40
|
|
17
|
-
#
|
18
|
-
|
41
|
+
# Concatenate the uglified JS and maps.
|
42
|
+
all_js, all_maps = compiled.inject do |(all_js, all_maps), (this_js, this_map)|
|
43
|
+
# all_js and this_js are strings. all_maps and this_map are instances of
|
44
|
+
# SourceMap::Map. (SourceMap::Map supports the + operator.)
|
45
|
+
[all_js + this_js, all_maps + this_map]
|
46
|
+
end
|
19
47
|
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
uglifyjs \
|
24
|
-
#{sources.join(' ')} \
|
25
|
-
--output #{File.join(Ichiban.project_root, 'compiled', 'js', dest)} \
|
26
|
-
--source-map #{map_name} \
|
27
|
-
--source-map-url /js/#{map_name} \
|
28
|
-
--source-map-root /js \
|
29
|
-
2>&1 # Redirect STDERR to STDOUT.
|
30
|
-
`
|
31
|
-
unless $?.success?
|
32
|
-
raise UglifyError, "uglifyjs command failed:\n\n#{uglify_stdout}"
|
48
|
+
# Ensure the destination folder exists.
|
49
|
+
unless File.exist? dest_folder
|
50
|
+
FileUtils.mkdir_p dest_folder
|
33
51
|
end
|
34
52
|
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
map_json = JSON.parse(File.read(map_path))
|
39
|
-
File.open map_path, 'w' do |f|
|
40
|
-
f << JSON.dump(map_json.merge('file' => dest))
|
53
|
+
# Write the compiled JS.
|
54
|
+
File.open(ugly_js_path, 'w') do |f|
|
55
|
+
f << all_js << "\n//# sourceMappingURL=#{map_path_from_webroot}"
|
41
56
|
end
|
42
57
|
|
43
|
-
#
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
File.join(Ichiban.project_root, 'compiled', 'js')
|
48
|
-
)
|
58
|
+
# Write the map.
|
59
|
+
File.open(map_path, 'w') do |f|
|
60
|
+
f << all_maps.to_json
|
61
|
+
end
|
49
62
|
|
50
|
-
# Copy each
|
51
|
-
|
52
|
-
sources.each do |filename|
|
53
|
-
folder = File.expand_path(File.join(
|
54
|
-
Ichiban.project_root, 'compiled', 'js',
|
55
|
-
File.dirname(filename)
|
56
|
-
))
|
57
|
-
unless File.exists? folder
|
58
|
-
FileUtils.mkdir_p folder
|
59
|
-
end
|
63
|
+
# Copy each source file (for the sake of mapping).
|
64
|
+
sources.each do |src_path|
|
60
65
|
FileUtils.cp(
|
61
|
-
File.join(Ichiban.project_root, 'assets
|
62
|
-
File.join(Ichiban.project_root, 'compiled',
|
66
|
+
File.join(Ichiban.project_root, 'assets/js', src_path),
|
67
|
+
File.join(Ichiban.project_root, 'compiled/js', src_path),
|
63
68
|
)
|
64
69
|
end
|
65
70
|
|
@@ -72,50 +77,6 @@ module Ichiban
|
|
72
77
|
def initialize(file)
|
73
78
|
@file = file
|
74
79
|
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
# Pass in absolute source_paths.
|
79
|
-
#def compile_paths(source_paths, source_root, js_filename, map_filename)
|
80
|
-
# # The Uglify gem, unlike UglifyJS2, doesn't support concatenation as of August 2015.
|
81
|
-
# # Thus, before we call Uglify, we have to concatenate ourselves. We also generate an
|
82
|
-
# # intermediate source map for the concatenated JS. Uglify will use the intermediate
|
83
|
-
# # source map when it creates its own source map.
|
84
|
-
# js, map = concat(
|
85
|
-
# source_paths.map { |p| [File.read(p), File.basename(p)] },
|
86
|
-
# source_root
|
87
|
-
# )
|
88
|
-
#
|
89
|
-
# js, map = uglify js, map, js_filename
|
90
|
-
#
|
91
|
-
# map_url = File.join Ichiban.config.relative_url_root, 'js', map_filename
|
92
|
-
# js << "\n//# sourceMappingURL=#{map_url}"
|
93
|
-
#
|
94
|
-
# [js, map]
|
95
|
-
#end
|
96
|
-
|
97
|
-
# Sources should be an array of form: [['alert("foo");', 'alert.js']] Returns a tuple. The
|
98
|
-
# first element is the concatenated JS. The second element is the map string.
|
99
|
-
#def concat(sources, source_root)
|
100
|
-
# js = StringIO.new
|
101
|
-
# map = SourceMap.new(
|
102
|
-
# generated_output: js,
|
103
|
-
# source_root: source_root
|
104
|
-
# )
|
105
|
-
# sources.each do |source_js, source_filename|
|
106
|
-
# map.add_generated source_js, source: File.join(source_filename)
|
107
|
-
# end
|
108
|
-
# js.rewind
|
109
|
-
# puts map.to_s
|
110
|
-
# [js.read, map.to_s]
|
111
|
-
#end
|
112
|
-
|
113
|
-
#def uglify(js, map, js_filename)
|
114
|
-
# Uglifier.new(
|
115
|
-
# input_source_map: map,
|
116
|
-
# output_filename: js_filename
|
117
|
-
# ).compile_with_map(js)
|
118
|
-
#end
|
119
80
|
end
|
120
81
|
|
121
82
|
class UglifyError < RuntimeError; end
|
data/lib/ichiban/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ichiban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrett Colby
|
@@ -76,47 +76,41 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: 3.1.5
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3'
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.1.5
|
90
90
|
- - "~>"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
92
|
+
version: '3'
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: activesupport
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 4.
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '4'
|
99
|
+
version: 4.2.8
|
103
100
|
type: :runtime
|
104
101
|
prerelease: false
|
105
102
|
version_requirements: !ruby/object:Gem::Requirement
|
106
103
|
requirements:
|
107
104
|
- - ">="
|
108
105
|
- !ruby/object:Gem::Version
|
109
|
-
version: 4.
|
110
|
-
- - "~>"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '4'
|
106
|
+
version: 4.2.8
|
113
107
|
- !ruby/object:Gem::Dependency
|
114
108
|
name: bundler
|
115
109
|
requirement: !ruby/object:Gem::Requirement
|
116
110
|
requirements:
|
117
111
|
- - ">="
|
118
112
|
- !ruby/object:Gem::Version
|
119
|
-
version: 1.
|
113
|
+
version: 1.13.6
|
120
114
|
- - "~>"
|
121
115
|
- !ruby/object:Gem::Version
|
122
116
|
version: '1'
|
@@ -126,7 +120,7 @@ dependencies:
|
|
126
120
|
requirements:
|
127
121
|
- - ">="
|
128
122
|
- !ruby/object:Gem::Version
|
129
|
-
version: 1.
|
123
|
+
version: 1.13.6
|
130
124
|
- - "~>"
|
131
125
|
- !ruby/object:Gem::Version
|
132
126
|
version: '1'
|
@@ -136,27 +130,27 @@ dependencies:
|
|
136
130
|
requirements:
|
137
131
|
- - ">="
|
138
132
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
133
|
+
version: 3.2.0
|
140
134
|
- - "~>"
|
141
135
|
- !ruby/object:Gem::Version
|
142
|
-
version: '
|
136
|
+
version: '3'
|
143
137
|
type: :runtime
|
144
138
|
prerelease: false
|
145
139
|
version_requirements: !ruby/object:Gem::Requirement
|
146
140
|
requirements:
|
147
141
|
- - ">="
|
148
142
|
- !ruby/object:Gem::Version
|
149
|
-
version: 2.
|
143
|
+
version: 3.2.0
|
150
144
|
- - "~>"
|
151
145
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
146
|
+
version: '3'
|
153
147
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
148
|
+
name: sourcemap
|
155
149
|
requirement: !ruby/object:Gem::Requirement
|
156
150
|
requirements:
|
157
151
|
- - ">="
|
158
152
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
153
|
+
version: 0.1.1
|
160
154
|
- - "~>"
|
161
155
|
- !ruby/object:Gem::Version
|
162
156
|
version: '0'
|
@@ -166,51 +160,57 @@ dependencies:
|
|
166
160
|
requirements:
|
167
161
|
- - ">="
|
168
162
|
- !ruby/object:Gem::Version
|
169
|
-
version: 0.
|
163
|
+
version: 0.1.1
|
170
164
|
- - "~>"
|
171
165
|
- !ruby/object:Gem::Version
|
172
166
|
version: '0'
|
173
167
|
- !ruby/object:Gem::Dependency
|
174
|
-
name:
|
168
|
+
name: therubyracer
|
175
169
|
requirement: !ruby/object:Gem::Requirement
|
176
170
|
requirements:
|
177
171
|
- - ">="
|
178
172
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
173
|
+
version: 0.12.2
|
174
|
+
- - "~>"
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
180
177
|
type: :runtime
|
181
178
|
prerelease: false
|
182
179
|
version_requirements: !ruby/object:Gem::Requirement
|
183
180
|
requirements:
|
184
181
|
- - ">="
|
185
182
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
183
|
+
version: 0.12.2
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
188
|
name: rake
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
191
|
- - ">="
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version:
|
193
|
+
version: 12.0.0
|
194
194
|
- - "~>"
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
version: '
|
196
|
+
version: '12'
|
197
197
|
type: :development
|
198
198
|
prerelease: false
|
199
199
|
version_requirements: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
201
|
- - ">="
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version:
|
203
|
+
version: 12.0.0
|
204
204
|
- - "~>"
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
version: '
|
206
|
+
version: '12'
|
207
207
|
- !ruby/object:Gem::Dependency
|
208
208
|
name: minitest
|
209
209
|
requirement: !ruby/object:Gem::Requirement
|
210
210
|
requirements:
|
211
211
|
- - ">="
|
212
212
|
- !ruby/object:Gem::Version
|
213
|
-
version: 5.
|
213
|
+
version: 5.10.2
|
214
214
|
- - "~>"
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '5'
|
@@ -220,7 +220,7 @@ dependencies:
|
|
220
220
|
requirements:
|
221
221
|
- - ">="
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version: 5.
|
223
|
+
version: 5.10.2
|
224
224
|
- - "~>"
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: '5'
|
@@ -230,7 +230,7 @@ dependencies:
|
|
230
230
|
requirements:
|
231
231
|
- - ">="
|
232
232
|
- !ruby/object:Gem::Version
|
233
|
-
version: 1.
|
233
|
+
version: 1.1.14
|
234
234
|
- - "~>"
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '1'
|
@@ -240,7 +240,7 @@ dependencies:
|
|
240
240
|
requirements:
|
241
241
|
- - ">="
|
242
242
|
- !ruby/object:Gem::Version
|
243
|
-
version: 1.
|
243
|
+
version: 1.1.14
|
244
244
|
- - "~>"
|
245
245
|
- !ruby/object:Gem::Version
|
246
246
|
version: '1'
|
@@ -250,7 +250,7 @@ dependencies:
|
|
250
250
|
requirements:
|
251
251
|
- - ">="
|
252
252
|
- !ruby/object:Gem::Version
|
253
|
-
version: 1.1
|
253
|
+
version: 1.2.1
|
254
254
|
- - "~>"
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '1'
|
@@ -260,7 +260,7 @@ dependencies:
|
|
260
260
|
requirements:
|
261
261
|
- - ">="
|
262
262
|
- !ruby/object:Gem::Version
|
263
|
-
version: 1.1
|
263
|
+
version: 1.2.1
|
264
264
|
- - "~>"
|
265
265
|
- !ruby/object:Gem::Version
|
266
266
|
version: '1'
|
@@ -290,7 +290,7 @@ dependencies:
|
|
290
290
|
requirements:
|
291
291
|
- - ">="
|
292
292
|
- !ruby/object:Gem::Version
|
293
|
-
version: 2.1.
|
293
|
+
version: 2.1.8
|
294
294
|
- - "~>"
|
295
295
|
- !ruby/object:Gem::Version
|
296
296
|
version: '2'
|
@@ -300,7 +300,7 @@ dependencies:
|
|
300
300
|
requirements:
|
301
301
|
- - ">="
|
302
302
|
- !ruby/object:Gem::Version
|
303
|
-
version: 2.1.
|
303
|
+
version: 2.1.8
|
304
304
|
- - "~>"
|
305
305
|
- !ruby/object:Gem::Version
|
306
306
|
version: '2'
|
@@ -397,7 +397,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
397
397
|
requirements:
|
398
398
|
- - ">="
|
399
399
|
- !ruby/object:Gem::Version
|
400
|
-
version:
|
400
|
+
version: 2.2.6
|
401
401
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
402
402
|
requirements:
|
403
403
|
- - ">="
|
@@ -405,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
405
|
version: '0'
|
406
406
|
requirements: []
|
407
407
|
rubyforge_project:
|
408
|
-
rubygems_version: 2.
|
408
|
+
rubygems_version: 2.6.12
|
409
409
|
signing_key:
|
410
410
|
specification_version: 4
|
411
411
|
summary: Ichiban
|