asset_hat 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/HISTORY +13 -14
  2. data/README.rdoc +171 -0
  3. data/Rakefile +24 -2
  4. data/VERSION.yml +3 -3
  5. data/app/helpers/asset_hat_helper.rb +67 -61
  6. data/asset_hat.gemspec +42 -8
  7. data/doc/classes/AssetHat/CSS/Engines.html +118 -0
  8. data/doc/classes/AssetHat/CSS.html +194 -0
  9. data/doc/classes/AssetHat/JS/Engines.html +122 -0
  10. data/doc/classes/AssetHat/JS/Vendors.html +110 -0
  11. data/doc/classes/AssetHat/JS.html +151 -0
  12. data/doc/classes/AssetHat.html +446 -0
  13. data/doc/classes/AssetHatHelper.html +161 -0
  14. data/doc/created.rid +1 -0
  15. data/doc/files/HISTORY.html +116 -0
  16. data/doc/files/LICENSE.html +76 -0
  17. data/doc/files/README_rdoc.html +234 -0
  18. data/doc/files/app/helpers/asset_hat_helper_rb.html +55 -0
  19. data/doc/files/lib/asset_hat/capistrano_rb.html +49 -0
  20. data/doc/files/lib/asset_hat/css_rb.html +57 -0
  21. data/doc/files/lib/asset_hat/js/vendors_rb.html +49 -0
  22. data/doc/files/lib/asset_hat/js_rb.html +57 -0
  23. data/doc/files/lib/asset_hat/tasks/css_rb.html +49 -0
  24. data/doc/files/lib/asset_hat/tasks/js_rb.html +49 -0
  25. data/doc/files/lib/asset_hat/tasks_rb.html +58 -0
  26. data/doc/files/lib/asset_hat/vcs_rb.html +49 -0
  27. data/doc/files/lib/asset_hat/version_rb.html +49 -0
  28. data/doc/files/lib/asset_hat_rb.html +49 -0
  29. data/doc/fr_class_index.html +23 -0
  30. data/doc/fr_file_index.html +33 -0
  31. data/doc/fr_method_index.html +4455 -0
  32. data/doc/index.html +15 -0
  33. data/doc/rdoc-style.css +328 -0
  34. data/lib/asset_hat/capistrano.rb +14 -0
  35. data/lib/asset_hat/css.rb +40 -10
  36. data/lib/asset_hat/js/vendors.rb +85 -0
  37. data/lib/asset_hat/js.rb +28 -29
  38. data/lib/asset_hat/tasks/css.rb +151 -0
  39. data/lib/asset_hat/tasks/js.rb +100 -0
  40. data/lib/asset_hat/tasks.rb +4 -272
  41. data/lib/asset_hat/vcs.rb +23 -20
  42. data/lib/asset_hat/version.rb +2 -0
  43. data/lib/asset_hat.rb +94 -19
  44. data/tasks/asset_hat.rake +1 -1
  45. data/test/asset_hat_helper_test.rb +63 -9
  46. data/test/test_helper.rb +5 -1
  47. metadata +94 -26
  48. data/README.markdown +0 -154
@@ -0,0 +1,151 @@
1
+ namespace :asset_hat do
2
+ namespace :css do
3
+
4
+ # desc 'Adds mtimes to asset URLs in CSS'
5
+ # task :add_asset_mtimes, :filename, :verbose do |t, args|
6
+ # if args.filename.blank?
7
+ # raise 'Usage: rake asset_hat:css:add_asset_mtimes[filename.css]' and return
8
+ # end
9
+ #
10
+ # args.with_defaults :verbose => true
11
+ #
12
+ # css = File.open(args.filename, 'r') { |f| f.read }
13
+ # css = AssetHat::CSS.add_asset_mtimes(css)
14
+ # File.open(args.filename, 'w') { |f| f.write css }
15
+ #
16
+ # puts "- Added asset mtimes to #{args.filename}" if args.verbose
17
+ # end
18
+
19
+ desc 'Adds commit IDs to asset URLs in CSS for cache busting'
20
+ task :add_asset_commit_ids, :filename, :verbose, :needs => :environment do |t, args|
21
+ if args.filename.blank?
22
+ raise 'Usage: rake asset_hat:css:add_asset_commit_ids[filename.css]' and return
23
+ end
24
+
25
+ args.with_defaults :verbose => true
26
+
27
+ css = File.open(args.filename, 'r') { |f| f.read }
28
+ css = AssetHat::CSS.add_asset_commit_ids(css)
29
+ File.open(args.filename, 'w') { |f| f.write css }
30
+
31
+ puts "- Added asset commit IDs to #{args.filename}" if args.verbose
32
+ end
33
+
34
+ desc 'Adds hosts to asset URLs in CSS'
35
+ task :add_asset_hosts, :filename, :verbose, :needs => :environment do |t, args|
36
+ if args.filename.blank?
37
+ raise 'Usage: rake asset_hat:css:add_asset_hosts[filename.css]' and return
38
+ end
39
+
40
+ args.with_defaults :verbose => true
41
+
42
+ asset_host = ActionController::Base.asset_host
43
+ if asset_host.blank?
44
+ raise "This environment (#{ENV['RAILS_ENV']}) doesn't have an `asset_host` configured."
45
+ return
46
+ end
47
+
48
+ css = File.open(args.filename, 'r') { |f| f.read }
49
+ css = AssetHat::CSS.add_asset_hosts(css, asset_host)
50
+ File.open(args.filename, 'w') { |f| f.write css }
51
+
52
+ puts "- Added asset hosts to #{args.filename}" if args.verbose
53
+ end
54
+
55
+ desc 'Minifies one CSS file'
56
+ task :minify_file, :filepath, :verbose, :needs => :environment do |t, args|
57
+ if args.filepath.blank?
58
+ raise 'Usage: rake asset_hat:css:minify_file[path/to/filename.css]' and return
59
+ end
60
+
61
+ args.with_defaults :verbose => false
62
+ min_options = {
63
+ :engine => AssetHat.config['css']['engine']
64
+ }.reject { |k,v| v.blank? }
65
+
66
+ input = File.open(args.filepath, 'r').read
67
+ output = AssetHat::CSS.minify(input, min_options)
68
+
69
+ # Write minified content to file
70
+ target_filepath = AssetHat::CSS.min_filepath(args.filepath)
71
+ File.open(target_filepath, 'w') { |f| f.write output }
72
+
73
+ # Print results
74
+ puts "- Minified to #{target_filepath}" if args.verbose
75
+ end
76
+
77
+ desc 'Minifies one CSS bundle'
78
+ task :minify_bundle, :bundle, :needs => :environment do |t, args|
79
+ if args.bundle.blank?
80
+ raise 'Usage: rake asset_hat:css:minify_bundle[application]' and return
81
+ end
82
+
83
+ config = AssetHat.config
84
+ old_bundle_size = 0.0
85
+ new_bundle_size = 0.0
86
+ min_options = {
87
+ :engine => config['css']['engine']
88
+ }.reject { |k,v| v.blank? }
89
+
90
+ # Get bundle filenames
91
+ filenames = config['css']['bundles'][args.bundle]
92
+ if filenames.empty?
93
+ raise "No CSS files are specified for the #{args.bundle} bundle in #{AssetHat::CONFIG_FILEPATH}."
94
+ return
95
+ end
96
+ filepaths = filenames.map do |filename|
97
+ File.join('public', 'stylesheets', "#{filename}.css")
98
+ end
99
+ bundle_filepath = AssetHat::CSS.min_filepath(File.join(
100
+ 'public', 'stylesheets', 'bundles', "#{args.bundle}.css"))
101
+
102
+ # Concatenate and process output
103
+ output = ''
104
+ asset_host = ActionController::Base.asset_host
105
+ filepaths.each do |filepath|
106
+ file_output = File.open(filepath, 'r').read
107
+ old_bundle_size += file_output.size
108
+
109
+ file_output = AssetHat::CSS.minify(file_output, min_options)
110
+ file_output = AssetHat::CSS.add_asset_commit_ids(file_output)
111
+ if asset_host.present?
112
+ file_output = AssetHat::CSS.add_asset_hosts(file_output, asset_host)
113
+ end
114
+
115
+ new_bundle_size += file_output.size
116
+ output << file_output + "\n"
117
+ end
118
+ FileUtils.makedirs(File.dirname(bundle_filepath))
119
+ File.open(bundle_filepath, 'w') { |f| f.write output }
120
+
121
+ # Print results
122
+ percent_saved = 1 - (new_bundle_size / old_bundle_size)
123
+ puts "\nWrote CSS bundle: #{bundle_filepath}"
124
+ filepaths.each do |filepath|
125
+ puts " contains: #{filepath}"
126
+ end
127
+ if old_bundle_size > 0
128
+ engine = "(Engine: #{min_options[:engine]})"
129
+ puts " MINIFIED: #{'%.1f' % (percent_saved * 100)}% #{engine}"
130
+ end
131
+ end
132
+
133
+ desc 'Concatenates and minifies all CSS bundles'
134
+ task :minify, :needs => :environment do
135
+ # Get input bundles
136
+ config = AssetHat.config
137
+ if config['css'].blank? || config['css']['bundles'].blank?
138
+ puts "You need to set up CSS bundles in #{AssetHat::CONFIG_FILEPATH}."
139
+ exit
140
+ end
141
+ bundles = config['css']['bundles'].keys
142
+
143
+ # Minify bundles
144
+ bundles.each do |bundle|
145
+ Rake::Task['asset_hat:css:minify_bundle'].reenable
146
+ Rake::Task['asset_hat:css:minify_bundle'].invoke(bundle)
147
+ end
148
+ end
149
+
150
+ end # namespace :css
151
+ end # namespace :asset_hat
@@ -0,0 +1,100 @@
1
+ namespace :asset_hat do
2
+ namespace :js do
3
+
4
+ desc 'Minifies one JS file'
5
+ task :minify_file, :filepath, :verbose, :needs => :environment do |t, args|
6
+ if args.filepath.blank?
7
+ raise 'Usage: rake asset_hat:js:minify_file[filepath.js]' and return
8
+ end
9
+
10
+ args.with_defaults :verbose => false
11
+ min_options = {
12
+ :engine => AssetHat.config['js']['engine']
13
+ }.reject { |k,v| v.blank? }
14
+
15
+ if args.verbose && args.filepath.match(/\.min\.js$/)
16
+ puts "#{args.filepath} is already minified."
17
+ exit 1
18
+ end
19
+
20
+ input = File.open(args.filepath, 'r').read
21
+ output = AssetHat::JS.minify(input, min_options)
22
+
23
+ # Write minified content to file
24
+ target_filepath = AssetHat::JS.min_filepath(args.filepath)
25
+ File.open(target_filepath, 'w') { |f| f.write output }
26
+
27
+ # Print results
28
+ puts "- Minified to #{target_filepath}" if args.verbose
29
+ end
30
+
31
+ desc 'Minifies one JS bundle'
32
+ task :minify_bundle, :bundle, :needs => :environment do |t, args|
33
+ if args.bundle.blank?
34
+ raise 'Usage: rake asset_hat:js:minify_bundle[application]' and return
35
+ end
36
+
37
+ config = AssetHat.config
38
+ old_bundle_size = 0.0
39
+ new_bundle_size = 0.0
40
+ min_options = {
41
+ :engine => config['js']['engine']
42
+ }.reject { |k,v| v.blank? }
43
+
44
+ # Get bundle filenames
45
+ filenames = config['js']['bundles'][args.bundle]
46
+ if filenames.empty?
47
+ raise "No JS files are specified for the #{args.bundle} bundle in #{AssetHat::CONFIG_FILEPATH}."
48
+ return
49
+ end
50
+ filepaths = filenames.map do |filename|
51
+ File.join('public', 'javascripts', "#{filename}.js")
52
+ end
53
+ bundle_filepath = AssetHat::JS.min_filepath(File.join(
54
+ 'public', 'javascripts', 'bundles', "#{args.bundle}.js"))
55
+
56
+ # Concatenate and process output
57
+ output = ''
58
+ filepaths.each do |filepath|
59
+ file_output = File.open(filepath, 'r').read
60
+ old_bundle_size += file_output.size
61
+ unless filepath =~ /\.min\.js$/ # Already minified
62
+ file_output = AssetHat::JS.minify(file_output, min_options)
63
+ end
64
+ new_bundle_size += file_output.size
65
+ output << file_output + "\n"
66
+ end
67
+ FileUtils.makedirs(File.dirname(bundle_filepath))
68
+ File.open(bundle_filepath, 'w') { |f| f.write output }
69
+
70
+ # Print results
71
+ percent_saved = 1 - (new_bundle_size / old_bundle_size)
72
+ puts "\n Wrote JS bundle: #{bundle_filepath}"
73
+ filepaths.each do |filepath|
74
+ puts " contains: #{filepath}"
75
+ end
76
+ if old_bundle_size > 0
77
+ engine = "(Engine: #{min_options[:engine]})"
78
+ puts " MINIFIED: #{'%.1f' % (percent_saved * 100)}% #{engine}"
79
+ end
80
+ end
81
+
82
+ desc 'Concatenates and minifies all JS bundles'
83
+ task :minify, :needs => :environment do
84
+ # Get input bundles
85
+ config = AssetHat.config
86
+ if config['js'].blank? || config['js']['bundles'].blank?
87
+ puts "You need to set up JS bundles in #{AssetHat::CONFIG_FILEPATH}."
88
+ exit
89
+ end
90
+ bundles = config['js']['bundles'].keys
91
+
92
+ # Minify bundles
93
+ bundles.each do |bundle|
94
+ Rake::Task['asset_hat:js:minify_bundle'].reenable
95
+ Rake::Task['asset_hat:js:minify_bundle'].invoke(bundle)
96
+ end
97
+ end
98
+
99
+ end # namespace :js
100
+ end # namespace :asset_hat
@@ -1,31 +1,10 @@
1
- require 'rake/testtask'
2
- require 'active_support'
3
- require 'action_controller'
4
- require 'action_view'
5
- require File.join(File.dirname(__FILE__), %w[.. asset_hat])
6
-
7
- unless defined?(RAILS_ROOT)
8
- RAILS_ROOT = File.join(File.dirname(__FILE__), '..', '..')
9
- end
10
-
11
-
12
-
13
- task :default => :test
14
-
15
- Rake::TestTask.new(:test) do |t|
16
- t.libs << 'lib' << 'test'
17
- t.pattern = 'test/*_test.rb'
18
- t.verbose = true
19
- end
20
-
21
-
1
+ require 'asset_hat/tasks/css'
2
+ require 'asset_hat/tasks/js'
22
3
 
23
4
  namespace :asset_hat do
5
+
24
6
  desc 'Minifies all CSS and JS bundles'
25
- task :minify do
26
- Rake::Task['asset_hat:css:minify'].invoke # Generate all CSS bundles
27
- Rake::Task['asset_hat:js:minify'].invoke # Generate all JS bundles
28
- end
7
+ task :minify => ['asset_hat:css:minify', 'asset_hat:js:minify']
29
8
 
30
9
  desc 'Prepare configuration file'
31
10
  task :config do
@@ -45,251 +24,4 @@ namespace :asset_hat do
45
24
  puts "Wrote to #{target_filepath}"
46
25
  end
47
26
 
48
- namespace :css do
49
- # desc 'Adds mtimes to asset URLs in CSS'
50
- # task :add_asset_mtimes, :filename, :verbose do |t, args|
51
- # if args.filename.blank?
52
- # raise 'Usage: rake asset_hat:css:add_asset_mtimes[filename.css]' and return
53
- # end
54
- #
55
- # args.with_defaults :verbose => true
56
- #
57
- # css = File.open(args.filename, 'r') { |f| f.read }
58
- # css = AssetHat::CSS.add_asset_mtimes(css)
59
- # File.open(args.filename, 'w') { |f| f.write css }
60
- #
61
- # puts "- Added asset mtimes to #{args.filename}" if args.verbose
62
- # end
63
-
64
- desc 'Adds commit IDs to asset URLs in CSS for cache busting'
65
- task :add_asset_commit_ids, :filename, :verbose do |t, args|
66
- if args.filename.blank?
67
- raise 'Usage: rake asset_hat:css:add_asset_commit_ids[filename.css]' and return
68
- end
69
-
70
- args.with_defaults :verbose => true
71
-
72
- css = File.open(args.filename, 'r') { |f| f.read }
73
- css = AssetHat::CSS.add_asset_commit_ids(css)
74
- File.open(args.filename, 'w') { |f| f.write css }
75
-
76
- puts "- Added asset commit IDs to #{args.filename}" if args.verbose
77
- end
78
-
79
- desc 'Adds hosts to asset URLs in CSS'
80
- task :add_asset_hosts, :filename, :verbose, :needs => :environment do |t, args|
81
- if args.filename.blank?
82
- raise 'Usage: rake asset_hat:css:add_asset_hosts[filename.css]' and return
83
- end
84
-
85
- args.with_defaults :verbose => true
86
-
87
- asset_host = ActionController::Base.asset_host
88
- if asset_host.blank?
89
- raise "This environment (#{ENV['RAILS_ENV']}) doesn't have an `asset_host` configured."
90
- return
91
- end
92
-
93
- css = File.open(args.filename, 'r') { |f| f.read }
94
- css = AssetHat::CSS.add_asset_hosts(css, asset_host)
95
- File.open(args.filename, 'w') { |f| f.write css }
96
-
97
- puts "- Added asset hosts to #{args.filename}" if args.verbose
98
- end
99
-
100
- desc 'Minifies one CSS file'
101
- task :minify_file, :filepath, :verbose do |t, args|
102
- if args.filepath.blank?
103
- raise 'Usage: rake asset_hat:css:minify_file[path/to/filename.css]' and return
104
- end
105
-
106
- args.with_defaults :verbose => false
107
- min_options = {
108
- :engine => AssetHat.config['css']['engine']
109
- }.reject { |k,v| v.blank? }
110
-
111
- input = File.open(args.filepath, 'r').read
112
- output = AssetHat::CSS.minify(input, min_options)
113
-
114
- # Write minified content to file
115
- target_filepath = AssetHat::CSS.min_filepath(args.filepath)
116
- File.open(target_filepath, 'w') { |f| f.write output }
117
-
118
- # Print results
119
- puts "- Minified to #{target_filepath}" if args.verbose
120
- end
121
-
122
- desc 'Minifies one CSS bundle'
123
- task :minify_bundle, :bundle, :needs => :environment do |t, args|
124
- if args.bundle.blank?
125
- raise 'Usage: rake asset_hat:css:minify_bundle[application]' and return
126
- end
127
-
128
- config = AssetHat.config
129
- old_bundle_size = 0.0
130
- new_bundle_size = 0.0
131
- min_options = {
132
- :engine => config['css']['engine']
133
- }.reject { |k,v| v.blank? }
134
-
135
- # Get bundle filenames
136
- filenames = config['css']['bundles'][args.bundle]
137
- if filenames.empty?
138
- raise "No CSS files are specified for the #{args.bundle} bundle in #{AssetHat::CONFIG_FILEPATH}."
139
- return
140
- end
141
- filepaths = filenames.map do |filename|
142
- File.join('public', 'stylesheets', "#{filename}.css")
143
- end
144
- bundle_filepath = AssetHat::CSS.min_filepath(File.join(
145
- 'public', 'stylesheets', 'bundles', "#{args.bundle}.css"))
146
-
147
- # Concatenate and process output
148
- output = ''
149
- asset_host = ActionController::Base.asset_host
150
- filepaths.each do |filepath|
151
- file_output = File.open(filepath, 'r').read
152
- old_bundle_size += file_output.size
153
-
154
- file_output = AssetHat::CSS.minify(file_output, min_options)
155
- file_output = AssetHat::CSS.add_asset_commit_ids(file_output)
156
- if asset_host.present?
157
- file_output = AssetHat::CSS.add_asset_hosts(file_output, asset_host)
158
- end
159
-
160
- new_bundle_size += file_output.size
161
- output << file_output + "\n"
162
- end
163
- FileUtils.makedirs(File.dirname(bundle_filepath))
164
- File.open(bundle_filepath, 'w') { |f| f.write output }
165
-
166
- # Print results
167
- percent_saved = 1 - (new_bundle_size / old_bundle_size)
168
- puts "\nWrote CSS bundle: #{bundle_filepath}"
169
- filepaths.each do |filepath|
170
- puts " contains: #{filepath}"
171
- end
172
- if old_bundle_size > 0
173
- engine = "(Engine: #{min_options[:engine]})"
174
- puts " MINIFIED: #{'%.1f' % (percent_saved * 100)}% #{engine}"
175
- end
176
- end
177
-
178
- desc 'Concatenates and minifies all CSS bundles'
179
- task :minify do
180
- # Get input bundles
181
- config = AssetHat.config
182
- if config['css'].blank? || config['css']['bundles'].blank?
183
- puts "You need to set up CSS bundles in #{AssetHat::CONFIG_FILEPATH}."
184
- exit
185
- end
186
- bundles = config['css']['bundles'].keys
187
-
188
- # Minify bundles
189
- bundles.each do |bundle|
190
- Rake::Task['asset_hat:css:minify_bundle'].reenable
191
- Rake::Task['asset_hat:css:minify_bundle'].invoke(bundle)
192
- end
193
- end
194
-
195
- end # namespace :css
196
-
197
- namespace :js do
198
- desc 'Minifies one JS file'
199
- task :minify_file, :filepath, :verbose do |t, args|
200
- if args.filepath.blank?
201
- raise 'Usage: rake asset_hat:js:minify_file[filepath.js]' and return
202
- end
203
-
204
- args.with_defaults :verbose => false
205
- min_options = {
206
- :engine => AssetHat.config['js']['engine']
207
- }.reject { |k,v| v.blank? }
208
-
209
- if args.verbose && args.filepath.match(/\.min\.js$/)
210
- puts "#{args.filepath} is already minified."
211
- exit 1
212
- end
213
-
214
- input = File.open(args.filepath, 'r').read
215
- output = AssetHat::JS.minify(input, min_options)
216
-
217
- # Write minified content to file
218
- target_filepath = AssetHat::JS.min_filepath(args.filepath)
219
- File.open(target_filepath, 'w') { |f| f.write output }
220
-
221
- # Print results
222
- puts "- Minified to #{target_filepath}" if args.verbose
223
- end
224
-
225
- desc 'Minifies one JS bundle'
226
- task :minify_bundle, :bundle do |t, args|
227
- if args.bundle.blank?
228
- raise 'Usage: rake asset_hat:js:minify_bundle[application]' and return
229
- end
230
-
231
- config = AssetHat.config
232
- old_bundle_size = 0.0
233
- new_bundle_size = 0.0
234
- min_options = {
235
- :engine => config['js']['engine']
236
- }.reject { |k,v| v.blank? }
237
-
238
- # Get bundle filenames
239
- filenames = config['js']['bundles'][args.bundle]
240
- if filenames.empty?
241
- raise "No JS files are specified for the #{args.bundle} bundle in #{AssetHat::CONFIG_FILEPATH}."
242
- return
243
- end
244
- filepaths = filenames.map do |filename|
245
- File.join('public', 'javascripts', "#{filename}.js")
246
- end
247
- bundle_filepath = AssetHat::JS.min_filepath(File.join(
248
- 'public', 'javascripts', 'bundles', "#{args.bundle}.js"))
249
-
250
- # Concatenate and process output
251
- output = ''
252
- filepaths.each do |filepath|
253
- file_output = File.open(filepath, 'r').read
254
- old_bundle_size += file_output.size
255
- unless filepath =~ /\.min\.js$/ # Already minified
256
- file_output = AssetHat::JS.minify(file_output, min_options)
257
- end
258
- new_bundle_size += file_output.size
259
- output << file_output + "\n"
260
- end
261
- FileUtils.makedirs(File.dirname(bundle_filepath))
262
- File.open(bundle_filepath, 'w') { |f| f.write output }
263
-
264
- # Print results
265
- percent_saved = 1 - (new_bundle_size / old_bundle_size)
266
- puts "\n Wrote JS bundle: #{bundle_filepath}"
267
- filepaths.each do |filepath|
268
- puts " contains: #{filepath}"
269
- end
270
- if old_bundle_size > 0
271
- engine = "(Engine: #{min_options[:engine]})"
272
- puts " MINIFIED: #{'%.1f' % (percent_saved * 100)}% #{engine}"
273
- end
274
- end
275
-
276
- desc 'Concatenates and minifies all JS bundles'
277
- task :minify do
278
- # Get input bundles
279
- config = AssetHat.config
280
- if config['js'].blank? || config['js']['bundles'].blank?
281
- puts "You need to set up JS bundles in #{AssetHat::CONFIG_FILEPATH}."
282
- exit
283
- end
284
- bundles = config['js']['bundles'].keys
285
-
286
- # Minify bundles
287
- bundles.each do |bundle|
288
- Rake::Task['asset_hat:js:minify_bundle'].reenable
289
- Rake::Task['asset_hat:js:minify_bundle'].invoke(bundle)
290
- end
291
- end
292
-
293
- end # namespace :js
294
-
295
27
  end # namespace :asset_hat
data/lib/asset_hat/vcs.rb CHANGED
@@ -1,19 +1,21 @@
1
1
  module AssetHat
2
2
  class << self
3
- attr_accessor :last_commit_ids, :last_bundle_commit_ids
3
+ attr_accessor :last_commit_ids, :last_bundle_commit_ids #:nodoc:
4
4
  end
5
5
 
6
+ # Usage:
7
+ #
8
+ # AssetHat.last_commit_id('public/stylesheets/application.css')
9
+ # AssetHat.last_commit_id('public/stylesheets/ie.css',
10
+ # 'public/stylesheets/ie7.css',
11
+ # 'public/stylesheets/ie6.css')
12
+ #
13
+ # Returns a string of the commit ID for the file with the most recent
14
+ # commit. If the file(s) cannot be found, `nil` is returned. Options:
15
+ #
16
+ # [vcs] Version control system. Currently, the only supported value is
17
+ # <code>:git</code>.
6
18
  def self.last_commit_id(*args)
7
- # Usage:
8
- #
9
- # AssetHat.last_commit_id('public/stylesheets/application.css')
10
- # AssetHat.last_commit_id('public/stylesheets/ie.css',
11
- # 'public/stylesheets/ie7.css',
12
- # 'public/stylesheets/ie6.css')
13
- #
14
- # Returns a string of the commit ID for the file with the most recent
15
- # commit. If the file(s) cannot be found, `nil` is returned.
16
-
17
19
  # Process arguments
18
20
  options = args.extract_options!
19
21
  options = options.symbolize_keys.reverse_merge(:vcs => :git)
@@ -33,15 +35,14 @@ module AssetHat
33
35
  @last_commit_ids[filepaths]
34
36
  end
35
37
 
38
+ # Usage:
39
+ #
40
+ # AssetHat.last_bundle_commit_id('application', :css)
41
+ #
42
+ # Returns a string of the latest commit ID for the given bundle, based
43
+ # on which of its files were most recently modified in the repository. If
44
+ # no ID can be found, `nil` is returned.
36
45
  def self.last_bundle_commit_id(bundle, type)
37
- # Usage:
38
- #
39
- # AssetHat.last_bundle_commit_id('application', :css)
40
- #
41
- # Returns a string of the latest commit ID for the given bundle, based
42
- # on which of its files were most recently modified in the repository. If
43
- # no ID can be found, `nil` is returned.
44
-
45
46
  # Process arguments
46
47
  type = type.to_sym
47
48
  unless TYPES.include?(type)
@@ -64,6 +65,8 @@ module AssetHat
64
65
  @last_bundle_commit_ids[type][bundle]
65
66
  end
66
67
 
67
- def self.last_commit_ids ; @last_commit_ids ; end
68
+ def self.last_commit_ids #:nodoc:
69
+ @last_commit_ids
70
+ end
68
71
 
69
72
  end
@@ -1,4 +1,5 @@
1
1
  module AssetHat
2
+ # Returns this gem's version number. See also VERSION.
2
3
  def self.version
3
4
  data_filepath = File.join(File.dirname(__FILE__), %w[.. .. VERSION.yml])
4
5
  data = YAML.load(File.open(data_filepath, 'r'))
@@ -6,6 +7,7 @@ module AssetHat
6
7
  map { |x| data[x] }.reject(&:blank?).join('.')
7
8
  end
8
9
 
10
+ # This gem's version number.
9
11
  VERSION = self.version
10
12
 
11
13
  end