asset_hat 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +13 -14
- data/README.rdoc +171 -0
- data/Rakefile +24 -2
- data/VERSION.yml +3 -3
- data/app/helpers/asset_hat_helper.rb +67 -61
- data/asset_hat.gemspec +42 -8
- data/doc/classes/AssetHat/CSS/Engines.html +118 -0
- data/doc/classes/AssetHat/CSS.html +194 -0
- data/doc/classes/AssetHat/JS/Engines.html +122 -0
- data/doc/classes/AssetHat/JS/Vendors.html +110 -0
- data/doc/classes/AssetHat/JS.html +151 -0
- data/doc/classes/AssetHat.html +446 -0
- data/doc/classes/AssetHatHelper.html +161 -0
- data/doc/created.rid +1 -0
- data/doc/files/HISTORY.html +116 -0
- data/doc/files/LICENSE.html +76 -0
- data/doc/files/README_rdoc.html +234 -0
- data/doc/files/app/helpers/asset_hat_helper_rb.html +55 -0
- data/doc/files/lib/asset_hat/capistrano_rb.html +49 -0
- data/doc/files/lib/asset_hat/css_rb.html +57 -0
- data/doc/files/lib/asset_hat/js/vendors_rb.html +49 -0
- data/doc/files/lib/asset_hat/js_rb.html +57 -0
- data/doc/files/lib/asset_hat/tasks/css_rb.html +49 -0
- data/doc/files/lib/asset_hat/tasks/js_rb.html +49 -0
- data/doc/files/lib/asset_hat/tasks_rb.html +58 -0
- data/doc/files/lib/asset_hat/vcs_rb.html +49 -0
- data/doc/files/lib/asset_hat/version_rb.html +49 -0
- data/doc/files/lib/asset_hat_rb.html +49 -0
- data/doc/fr_class_index.html +23 -0
- data/doc/fr_file_index.html +33 -0
- data/doc/fr_method_index.html +4455 -0
- data/doc/index.html +15 -0
- data/doc/rdoc-style.css +328 -0
- data/lib/asset_hat/capistrano.rb +14 -0
- data/lib/asset_hat/css.rb +40 -10
- data/lib/asset_hat/js/vendors.rb +85 -0
- data/lib/asset_hat/js.rb +28 -29
- data/lib/asset_hat/tasks/css.rb +151 -0
- data/lib/asset_hat/tasks/js.rb +100 -0
- data/lib/asset_hat/tasks.rb +4 -272
- data/lib/asset_hat/vcs.rb +23 -20
- data/lib/asset_hat/version.rb +2 -0
- data/lib/asset_hat.rb +94 -19
- data/tasks/asset_hat.rake +1 -1
- data/test/asset_hat_helper_test.rb +63 -9
- data/test/test_helper.rb +5 -1
- metadata +94 -26
- data/README.markdown +0 -154
data/HISTORY
CHANGED
@@ -1,36 +1,35 @@
|
|
1
|
-
HISTORY
|
2
|
-
=======
|
1
|
+
= HISTORY
|
3
2
|
|
4
|
-
Version 0.
|
5
|
-
|
3
|
+
== Version 0.2.0 (2010-06-10)
|
4
|
+
* Added support for loading many more JS vendors from Google's CDN, including
|
5
|
+
Prototype, MooTools, and SWFObject.
|
6
|
+
* Cleaned up existing docs, and added complete RDoc documentation.
|
7
|
+
* Added example integration script for Capistrano deployments.
|
8
|
+
|
9
|
+
== Version 0.1.5 (2010-03-11)
|
6
10
|
* Fixed fetching asset commit IDs in some environments. The bug was possibly
|
7
11
|
caused by older versions of Git, which fail to read logs properly when given
|
8
12
|
absolute paths, rather than relative paths.
|
9
13
|
* Stopped app tests from running twice in some environments.
|
10
14
|
|
11
|
-
Version 0.1.4 (2010-03-03)
|
12
|
-
--------------------------
|
15
|
+
== Version 0.1.4 (2010-03-03)
|
13
16
|
* Fixed config filepaths in `asset_hat:config` task.
|
14
17
|
|
15
|
-
Version 0.1.3 (2010-03-03)
|
16
|
-
--------------------------
|
18
|
+
== Version 0.1.3 (2010-03-03)
|
17
19
|
* Allowed adding commit IDs and asset hosts to `url(/htc/...)` URLs (e.g.,
|
18
20
|
`/htc/iepngfix.htc`) in CSS, not just images.
|
19
21
|
* Changed `AssetHat.config` to memoize only if `cache?` is true. In
|
20
22
|
development environments, this means the config file will be reread with
|
21
23
|
every request.
|
22
24
|
|
23
|
-
Version 0.1.2 (2010-01-27)
|
24
|
-
--------------------------
|
25
|
+
== Version 0.1.2 (2010-01-27)
|
25
26
|
* Memoized HTML output from `include_css` and `include_js` when
|
26
27
|
`AssetHat.cache?` is true.
|
27
28
|
|
28
|
-
Version 0.1.1 (2010-01-20)
|
29
|
-
--------------------------
|
29
|
+
== Version 0.1.1 (2010-01-20)
|
30
30
|
* Rewrote `AssetHat::VERSION` to be based on `VERSION.yml`.
|
31
31
|
* Prefixed `AssetHat::CONFIG_FILEPATH` with `RAILS_ROOT`, which fixes ability
|
32
32
|
to run an app's individual test files.
|
33
33
|
|
34
|
-
Version 0.1.0 (2010-01-19)
|
35
|
-
--------------------------
|
34
|
+
== Version 0.1.0 (2010-01-19)
|
36
35
|
* Initial release.
|
data/README.rdoc
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
= AssetHat
|
2
|
+
|
3
|
+
Your assets are covered.
|
4
|
+
|
5
|
+
With Rails' default asset caching, CSS and JS are concatenated (not even
|
6
|
+
minified) the first time that bundle is requested. Not good enough. AssetHat
|
7
|
+
can automatically:
|
8
|
+
|
9
|
+
* Easily *minify* and *bundle* CSS and JS on deploy to reduce file sizes and
|
10
|
+
HTTP requests.
|
11
|
+
* Load popular <strong>third-party JS</strong> (like jQuery and Prototype)
|
12
|
+
from {<strong>Google's CDN</strong>}[http://code.google.com/apis/ajaxlibs/]
|
13
|
+
when in production, or from localhost in development.
|
14
|
+
* Force image URLs in your CSS to use <strong>CDN subdomains</strong>, not
|
15
|
+
just the current host.
|
16
|
+
* Add an image's last Git[http://git-scm.com/] commit ID to its CSS URLs to
|
17
|
+
<strong>bust browser caches</strong> (e.g.,
|
18
|
+
<code>/images/foo.png?ab12cd34e</code>).
|
19
|
+
|
20
|
+
After setup, you can use these in your layouts and views:
|
21
|
+
|
22
|
+
<%= include_css :bundle => 'application' %>
|
23
|
+
# => <link href="/stylesheets/bundles/application.min.css"
|
24
|
+
# media="screen,projection" rel="stylesheet" type="text/css" />
|
25
|
+
|
26
|
+
<%= include_js :bundles => ['plugins', 'common'] %>
|
27
|
+
# => <script src="/javascripts/bundles/plugins.min.js"
|
28
|
+
# type="text/javascript"></script>
|
29
|
+
# <script src="/javascripts/bundles/common.min.js"
|
30
|
+
# type="text/javascript"></script>
|
31
|
+
|
32
|
+
And this in your deploy script:
|
33
|
+
|
34
|
+
rake asset_hat:minify
|
35
|
+
|
36
|
+
Tested with Rails 2.3.x.
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
== Installation
|
41
|
+
|
42
|
+
1. Install the gem:
|
43
|
+
|
44
|
+
gem install asset_hat
|
45
|
+
|
46
|
+
2. Configure the gem:
|
47
|
+
|
48
|
+
* If you're using {Bundler 0.9+}[http://github.com/carlhuda/bundler]:
|
49
|
+
|
50
|
+
1. Add to your app's Gemfile: <code>gem 'asset_hat', '0.x.x'</code>
|
51
|
+
2. Command-line: <code>bundle install</code>
|
52
|
+
|
53
|
+
* If you're using Rails' <code>config.gem</code>, add to your app's
|
54
|
+
<code>config/environment.rb</code>:
|
55
|
+
|
56
|
+
config.gem 'asset_hat', :version => '0.x.x'
|
57
|
+
|
58
|
+
3. Add to your app's Rakefile:
|
59
|
+
|
60
|
+
require 'asset_hat/tasks'
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
== Configuration
|
65
|
+
|
66
|
+
1. Create the default config file:
|
67
|
+
|
68
|
+
rake asset_hat:config
|
69
|
+
|
70
|
+
2. In your app, open the new file at <code>config/assets.yml</code>, and set
|
71
|
+
up your CSS/JS bundles according to that file's example.
|
72
|
+
|
73
|
+
3. Minify your bundles:
|
74
|
+
|
75
|
+
rake asset_hat:minify
|
76
|
+
|
77
|
+
This minifies all of the CSS/JS files listed in
|
78
|
+
<code>config/assets.yml</code>, concatenates the minified code into bundle
|
79
|
+
files, and adds CDN asset hosts and cache-busting commit IDs to image URLs
|
80
|
+
in your CSS.
|
81
|
+
|
82
|
+
Bundles are created as new files in
|
83
|
+
<code>public/stylesheets/bundles/</code> and
|
84
|
+
<code>public/javascripts/bundles/</code>. Your original CSS/JS files
|
85
|
+
remain intact.
|
86
|
+
|
87
|
+
4. Set your deployment script to run <code>rake asset_hat:minify</code> after
|
88
|
+
deploying your latest CSS/JS. This overwrites previously minified bundles,
|
89
|
+
and leaves your original CSS/JS files intact.
|
90
|
+
|
91
|
+
=== Advanced configuration
|
92
|
+
|
93
|
+
If you manage deployments with Capistrano[http://www.capify.org/], see the
|
94
|
+
gem's packaged example at <code>lib/asset_hat/capistrano.rb</code>.
|
95
|
+
|
96
|
+
Additional settings are supported in <code>config/assets.yml</code>:
|
97
|
+
|
98
|
+
* <code>engine</code>: Indicates how CSS and JS are minified; omit this
|
99
|
+
setting to use the defaults. By default, CSS is minified with
|
100
|
+
rgrove/cssmin[http://github.com/rgrove/cssmin] (a Ruby port of Lecomte's
|
101
|
+
YUI Compressor and Schlueter's PHP cssmin), and JS is minified with
|
102
|
+
rgrove/jsmin[http://github.com/rgrove/jsmin] (a Ruby port of Crockford's
|
103
|
+
JSMin).
|
104
|
+
|
105
|
+
If the default engines cause problems by minifying too
|
106
|
+
strongly, try switching each to <code>weak</code>. The <code>weak</code>
|
107
|
+
engines are much safer, but don't save as many bytes.
|
108
|
+
|
109
|
+
* <code>vendors</code>: Currently only allows for setting the jQuery version
|
110
|
+
number:
|
111
|
+
|
112
|
+
js:
|
113
|
+
vendors:
|
114
|
+
jquery:
|
115
|
+
version: 1.4
|
116
|
+
|
117
|
+
In the future, this will be used for configuring the retrieval of other
|
118
|
+
third-party code.
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
== Usage
|
123
|
+
|
124
|
+
In your layouts and views, instead of these:
|
125
|
+
|
126
|
+
<%= stylesheet_link_tag 'reset', 'application', 'clearfix',
|
127
|
+
:media => 'screen,projection',
|
128
|
+
:cache => 'bundles/application' %>
|
129
|
+
<%= javascript_include_tag 'plugin-1', 'plugin-2', 'plugin-3',
|
130
|
+
:cache => 'bundles/application' %>
|
131
|
+
|
132
|
+
<strong>Use these:</strong>
|
133
|
+
|
134
|
+
<%= include_css :bundle => 'application' %>
|
135
|
+
<%= include_js :bundle => 'application' %>
|
136
|
+
|
137
|
+
These turn into:
|
138
|
+
|
139
|
+
<link href="/stylesheets/bundles/application.min.css"
|
140
|
+
media="screen,projection" rel="stylesheet" type="text/css" />
|
141
|
+
<script src="/javascripts/bundles/application.min.js"
|
142
|
+
type="text/javascript"></script>
|
143
|
+
|
144
|
+
Have an enormous app? You can integrate gradually, using AssetHat alongside
|
145
|
+
Rails' default asset caching.
|
146
|
+
|
147
|
+
If your environment has <code>config.action_controller.perform_caching</code>
|
148
|
+
set to <code>true</code> (e.g., in production), the layout/view will include
|
149
|
+
minified bundle files. Otherwise, the separate, unminified files will be
|
150
|
+
included, based on the bundle contents you define in
|
151
|
+
<code>config/assets.yml</code>.
|
152
|
+
|
153
|
+
=== Advanced usage
|
154
|
+
|
155
|
+
You can also include single files as expected:
|
156
|
+
|
157
|
+
<%= include_css 'reset', 'application' %>
|
158
|
+
<%= include_js 'plugin.min', 'application' %>
|
159
|
+
|
160
|
+
Or include multiple bundles at once:
|
161
|
+
|
162
|
+
<%= include_js :bundles => %w[plugins common] %>
|
163
|
+
|
164
|
+
When including multiple bundles at once, this yields one
|
165
|
+
<code><link></code> or <code><script></code> element per bundle.
|
166
|
+
|
167
|
+
You may want to use multiple bundles to separate plugins (rarely changed) from
|
168
|
+
application code (frequently changed). If all code is in one huge bundle, then
|
169
|
+
whenever there's a change, browsers have to re-download the whole bundle. By
|
170
|
+
using multiple bundles based on change frequency, browsers cache the rarely
|
171
|
+
changed code, and only re-download the frequently changed code.
|
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'rake/testtask'
|
2
|
+
# require 'rake/rdoctask'
|
3
|
+
require 'hanna/rdoctask'
|
2
4
|
|
3
5
|
begin
|
4
6
|
require 'jeweler'
|
@@ -11,8 +13,9 @@ begin
|
|
11
13
|
gemspec.authors = ['Ron DeVera', 'Mint Digital']
|
12
14
|
gemspec.email = %q{ronald.devera@gmail.com}
|
13
15
|
|
14
|
-
gemspec.add_development_dependency 'shoulda', '>= 2.10.2'
|
15
16
|
gemspec.add_development_dependency 'flexmock', '>= 0.8.6'
|
17
|
+
gemspec.add_development_dependency 'hanna', '>= 0.1.12'
|
18
|
+
gemspec.add_development_dependency 'shoulda', '>= 2.10.2'
|
16
19
|
gemspec.add_runtime_dependency 'cssmin', '>= 1.0.2'
|
17
20
|
gemspec.add_runtime_dependency 'jsmin', '>= 1.0.1'
|
18
21
|
end
|
@@ -20,3 +23,22 @@ begin
|
|
20
23
|
rescue LoadError
|
21
24
|
puts 'Jeweler is not available. Install it with: `gem install jeweler`'
|
22
25
|
end
|
26
|
+
|
27
|
+
Rake::TestTask.new(:test) do |t|
|
28
|
+
t.libs << 'lib' << 'test'
|
29
|
+
t.pattern = 'test/*_test.rb'
|
30
|
+
t.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
task :default => :test
|
34
|
+
|
35
|
+
desc 'Generate documentation'
|
36
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
37
|
+
rdoc.rdoc_dir = 'doc'
|
38
|
+
rdoc.title = 'AssetHat'
|
39
|
+
rdoc.main = 'README.rdoc'
|
40
|
+
rdoc.options += %w[--line-numbers --inline-source]
|
41
|
+
%w[README.rdoc HISTORY LICENSE app/* lib/*].each do |path|
|
42
|
+
rdoc.rdoc_files.include(path)
|
43
|
+
end
|
44
|
+
end
|
data/VERSION.yml
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# Helpers for use in layouts for global includes, and in views for
|
2
|
+
# view-specific includes.
|
1
3
|
module AssetHatHelper
|
2
4
|
unless defined?(RAILS_ROOT)
|
3
5
|
RAILS_ROOT = File.join(File.dirname(__FILE__), '..', '..')
|
4
6
|
end
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
# Includes CSS or JS files. <code>include_css</code> and
|
9
|
+
# <code>include_js</code> are recommended instead.
|
10
|
+
def include_assets(type, *args) #:nodoc:
|
9
11
|
type = type.to_sym
|
10
12
|
allowed_types = AssetHat::TYPES
|
11
13
|
unless allowed_types.include?(type)
|
@@ -65,7 +67,9 @@ module AssetHatHelper
|
|
65
67
|
# development environments), skip this, and instead default to Rails'
|
66
68
|
# mtime-based cache busting.
|
67
69
|
sources.map! do |src|
|
68
|
-
if src =~
|
70
|
+
if src =~ %r{^http(s?)://} || src =~ %r{^//}
|
71
|
+
# Absolute URL; do nothing
|
72
|
+
elsif src =~ /^bundles\//
|
69
73
|
# Get commit ID of bundle file with most recently committed update
|
70
74
|
bundle = src.match(/^bundles\/(.*)\.min\.#{type}$/)[1]
|
71
75
|
commit_id = AssetHat.last_bundle_commit_id(bundle, type)
|
@@ -91,30 +95,31 @@ module AssetHatHelper
|
|
91
95
|
else nil
|
92
96
|
end
|
93
97
|
end.join("\n")
|
94
|
-
end
|
95
|
-
|
98
|
+
end # def include_assets
|
99
|
+
|
100
|
+
# <code>include_css</code> is a smart wrapper for Rails'
|
101
|
+
# <code>stylesheet_link_tag</code>. The two can be used together while
|
102
|
+
# migrating to AssetHat.
|
103
|
+
#
|
104
|
+
# Include a single stylesheet:
|
105
|
+
# include_css 'diagnostics'
|
106
|
+
# => <link href="/stylesheets/diagnostics.min.css" media="screen,projection" rel="stylesheet" type="text/css" />
|
107
|
+
#
|
108
|
+
# Include a single unminified stylesheet:
|
109
|
+
# include_css 'diagnostics.css'
|
110
|
+
# => <link href="/stylesheets/diagnostics.css" media="screen,projection" rel="stylesheet" type="text/css" />
|
111
|
+
#
|
112
|
+
# Include a bundle of stylesheets (i.e., a concatenated set of
|
113
|
+
# stylesheets; configure in config/assets.yml):
|
114
|
+
# include_css :bundle => 'application'
|
115
|
+
# => <link href="/stylesheets/bundles/application.min.css" ... />
|
116
|
+
#
|
117
|
+
# Include multiple stylesheets separately (not as cool):
|
118
|
+
# include_css 'reset', 'application', 'clearfix'
|
119
|
+
# => <link href="/stylesheets/reset.min.css" ... />
|
120
|
+
# <link href="/stylesheets/application.min.css" ... />
|
121
|
+
# <link href="/stylesheets/clearfix.min.css" ... />
|
96
122
|
def include_css(*args)
|
97
|
-
# Usage:
|
98
|
-
#
|
99
|
-
# Include a single stylesheet:
|
100
|
-
# include_css 'diagnostics'
|
101
|
-
# => <link href="/stylesheets/diagnostics.min.css" media="screen,projection" rel="stylesheet" type="text/css" />
|
102
|
-
#
|
103
|
-
# Include a single unminified stylesheet:
|
104
|
-
# include_css 'diagnostics.css'
|
105
|
-
# => <link href="/stylesheets/diagnostics.css" media="screen,projection" rel="stylesheet" type="text/css" />
|
106
|
-
#
|
107
|
-
# Include a bundle of stylesheets (i.e., a concatenated set of
|
108
|
-
# stylesheets; configure in config/assets.yml):
|
109
|
-
# include_css :bundle => 'application'
|
110
|
-
# => <link href="/stylesheets/bundles/application.min.css" ... />
|
111
|
-
#
|
112
|
-
# Include multiple stylesheets separately (not as cool):
|
113
|
-
# include_css 'reset', 'application', 'clearfix'
|
114
|
-
# => <link href="/stylesheets/reset.min.css" ... />
|
115
|
-
# <link href="/stylesheets/application.min.css" ... />
|
116
|
-
# <link href="/stylesheets/clearfix.min.css" ... />
|
117
|
-
|
118
123
|
return if args.blank?
|
119
124
|
|
120
125
|
AssetHat.html_cache ||= {}
|
@@ -130,41 +135,42 @@ module AssetHatHelper
|
|
130
135
|
html
|
131
136
|
end
|
132
137
|
|
138
|
+
# <code>include_js</code> is a smart wrapper for Rails'
|
139
|
+
# <code>javascript_include_tag</code>. The two can be used together while
|
140
|
+
# migrating to AssetHat.
|
141
|
+
#
|
142
|
+
# Include a single JS file:
|
143
|
+
# include_js 'application'
|
144
|
+
# => <script src="/javascripts/application.min.js" type="text/javascript"></script>
|
145
|
+
#
|
146
|
+
# Include a single JS unminified file:
|
147
|
+
# include_js 'application.js'
|
148
|
+
# => <script src="/javascripts/application.js" type="text/javascript"></script>
|
149
|
+
#
|
150
|
+
# Include jQuery:
|
151
|
+
# include_js :jquery # Development/test environment
|
152
|
+
# => <script src="/javascripts/jquery-VERSION.min.js" ...></script>
|
153
|
+
# include_js :jquery # Staging/production environment
|
154
|
+
# => <script src="http://ajax.googleapis.com/.../jquery.min.js" ...></script>
|
155
|
+
# # Set jQuery versions either in `config/assets.yml`, or by using
|
156
|
+
# # `include_js :jquery, :version => '1.4'`.
|
157
|
+
#
|
158
|
+
# Include a bundle of JS files (i.e., a concatenated set of files;
|
159
|
+
# configure in config/assets.yml):
|
160
|
+
# include_js :bundle => 'application'
|
161
|
+
# => <script src="/javascripts/bundles/application.min.js" ...></script>
|
162
|
+
#
|
163
|
+
# Include multiple bundles of JS files:
|
164
|
+
# include_js :bundles => %w[plugins common]
|
165
|
+
# => <script src="/javascripts/bundles/plugins.min.js" ...></script>
|
166
|
+
# <script src="/javascripts/bundles/common.min.js" ...></script>
|
167
|
+
#
|
168
|
+
# Include multiple JS files separately (not as cool):
|
169
|
+
# include_js 'bloombox', 'jquery.cookie', 'jquery.json.min'
|
170
|
+
# => <script src="/javascripts/bloombox.min.js" ...></script>
|
171
|
+
# <script src="/javascripts/jquery.cookie.min.js" ...></script>
|
172
|
+
# <script src="/javascripts/jquery.json.min.js" ...></script>
|
133
173
|
def include_js(*args)
|
134
|
-
# Usage:
|
135
|
-
#
|
136
|
-
# Include a single JS file:
|
137
|
-
# include_js 'application'
|
138
|
-
# => <script src="/javascripts/application.min.js" type="text/javascript"></script>
|
139
|
-
#
|
140
|
-
# Include a single JS unminified file:
|
141
|
-
# include_js 'application.js'
|
142
|
-
# => <script src="/javascripts/application.js" type="text/javascript"></script>
|
143
|
-
#
|
144
|
-
# Include jQuery:
|
145
|
-
# include_js :jquery # Development/test environment
|
146
|
-
# => <script src="/javascripts/jquery-VERSION.min.js" ...></script>
|
147
|
-
# include_js :jquery # Staging/production environment
|
148
|
-
# => <script src="http://ajax.googleapis.com/.../jquery.min.js" ...></script>
|
149
|
-
# # Set jQuery versions either in `config/assets.yml`, or by using
|
150
|
-
# # `include_js :jquery, :version => '1.4'`.
|
151
|
-
#
|
152
|
-
# Include a bundle of JS files (i.e., a concatenated set of files;
|
153
|
-
# configure in config/assets.yml):
|
154
|
-
# include_js :bundle => 'application'
|
155
|
-
# => <script src="/javascripts/bundles/application.min.js" ...></script>
|
156
|
-
#
|
157
|
-
# Include multiple bundles of JS files:
|
158
|
-
# include_js :bundles => %w[plugins common]
|
159
|
-
# => <script src="/javascripts/bundles/plugins.min.js" ...></script>
|
160
|
-
# <script src="/javascripts/bundles/common.min.js" ...></script>
|
161
|
-
#
|
162
|
-
# Include multiple JS files separately (not as cool):
|
163
|
-
# include_js 'bloombox', 'jquery.cookie', 'jquery.json.min'
|
164
|
-
# => <script src="/javascripts/bloombox.min.js" ...></script>
|
165
|
-
# <script src="/javascripts/jquery.cookie.min.js" ...></script>
|
166
|
-
# <script src="/javascripts/jquery.json.min.js" ...></script>
|
167
|
-
|
168
174
|
return if args.blank?
|
169
175
|
|
170
176
|
AssetHat.html_cache ||= {}
|
data/asset_hat.gemspec
CHANGED
@@ -5,31 +5,62 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{asset_hat}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ron DeVera", "Mint Digital"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-10}
|
13
13
|
s.description = %q{Minify, bundle, and optimize CSS/JS assets.}
|
14
14
|
s.email = %q{ronald.devera@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
21
21
|
"HISTORY",
|
22
22
|
"LICENSE",
|
23
|
-
"README.
|
23
|
+
"README.rdoc",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION.yml",
|
26
26
|
"app/helpers/asset_hat_helper.rb",
|
27
27
|
"asset_hat.gemspec",
|
28
28
|
"config/assets.yml",
|
29
|
+
"doc/classes/AssetHat.html",
|
30
|
+
"doc/classes/AssetHat/CSS.html",
|
31
|
+
"doc/classes/AssetHat/CSS/Engines.html",
|
32
|
+
"doc/classes/AssetHat/JS.html",
|
33
|
+
"doc/classes/AssetHat/JS/Engines.html",
|
34
|
+
"doc/classes/AssetHat/JS/Vendors.html",
|
35
|
+
"doc/classes/AssetHatHelper.html",
|
36
|
+
"doc/created.rid",
|
37
|
+
"doc/files/HISTORY.html",
|
38
|
+
"doc/files/LICENSE.html",
|
39
|
+
"doc/files/README_rdoc.html",
|
40
|
+
"doc/files/app/helpers/asset_hat_helper_rb.html",
|
41
|
+
"doc/files/lib/asset_hat/capistrano_rb.html",
|
42
|
+
"doc/files/lib/asset_hat/css_rb.html",
|
43
|
+
"doc/files/lib/asset_hat/js/vendors_rb.html",
|
44
|
+
"doc/files/lib/asset_hat/js_rb.html",
|
45
|
+
"doc/files/lib/asset_hat/tasks/css_rb.html",
|
46
|
+
"doc/files/lib/asset_hat/tasks/js_rb.html",
|
47
|
+
"doc/files/lib/asset_hat/tasks_rb.html",
|
48
|
+
"doc/files/lib/asset_hat/vcs_rb.html",
|
49
|
+
"doc/files/lib/asset_hat/version_rb.html",
|
50
|
+
"doc/files/lib/asset_hat_rb.html",
|
51
|
+
"doc/fr_class_index.html",
|
52
|
+
"doc/fr_file_index.html",
|
53
|
+
"doc/fr_method_index.html",
|
54
|
+
"doc/index.html",
|
55
|
+
"doc/rdoc-style.css",
|
29
56
|
"lib/asset_hat.rb",
|
57
|
+
"lib/asset_hat/capistrano.rb",
|
30
58
|
"lib/asset_hat/css.rb",
|
31
59
|
"lib/asset_hat/js.rb",
|
60
|
+
"lib/asset_hat/js/vendors.rb",
|
32
61
|
"lib/asset_hat/tasks.rb",
|
62
|
+
"lib/asset_hat/tasks/css.rb",
|
63
|
+
"lib/asset_hat/tasks/js.rb",
|
33
64
|
"lib/asset_hat/vcs.rb",
|
34
65
|
"lib/asset_hat/version.rb",
|
35
66
|
"public/javascripts/bundles/js-bundle-1.min.js",
|
@@ -65,7 +96,7 @@ Gem::Specification.new do |s|
|
|
65
96
|
s.homepage = %q{http://github.com/mintdigital/asset_hat}
|
66
97
|
s.rdoc_options = ["--charset=UTF-8"]
|
67
98
|
s.require_paths = ["lib"]
|
68
|
-
s.rubygems_version = %q{1.3.
|
99
|
+
s.rubygems_version = %q{1.3.6}
|
69
100
|
s.summary = %q{Your assets are covered.}
|
70
101
|
s.test_files = [
|
71
102
|
"test/asset_hat_helper_test.rb",
|
@@ -78,19 +109,22 @@ Gem::Specification.new do |s|
|
|
78
109
|
s.specification_version = 3
|
79
110
|
|
80
111
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
81
|
-
s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
|
82
112
|
s.add_development_dependency(%q<flexmock>, [">= 0.8.6"])
|
113
|
+
s.add_development_dependency(%q<hanna>, [">= 0.1.12"])
|
114
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
|
83
115
|
s.add_runtime_dependency(%q<cssmin>, [">= 1.0.2"])
|
84
116
|
s.add_runtime_dependency(%q<jsmin>, [">= 1.0.1"])
|
85
117
|
else
|
86
|
-
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
87
118
|
s.add_dependency(%q<flexmock>, [">= 0.8.6"])
|
119
|
+
s.add_dependency(%q<hanna>, [">= 0.1.12"])
|
120
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
88
121
|
s.add_dependency(%q<cssmin>, [">= 1.0.2"])
|
89
122
|
s.add_dependency(%q<jsmin>, [">= 1.0.1"])
|
90
123
|
end
|
91
124
|
else
|
92
|
-
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
93
125
|
s.add_dependency(%q<flexmock>, [">= 0.8.6"])
|
126
|
+
s.add_dependency(%q<hanna>, [">= 0.1.12"])
|
127
|
+
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
94
128
|
s.add_dependency(%q<cssmin>, [">= 1.0.2"])
|
95
129
|
s.add_dependency(%q<jsmin>, [">= 1.0.1"])
|
96
130
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>: AssetHat::CSS::Engines [AssetHat]</title>
|
5
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../../../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='class' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>
|
29
|
+
<span class='type'>Module</span>
|
30
|
+
AssetHat::CSS::Engines
|
31
|
+
</h1>
|
32
|
+
<ol class='paths'>
|
33
|
+
<li>
|
34
|
+
<a href="../../../files/lib/asset_hat/css_rb.html">lib/asset_hat/css.rb</a>
|
35
|
+
</li>
|
36
|
+
</ol>
|
37
|
+
</div>
|
38
|
+
<div id='content'>
|
39
|
+
<div id='text'>
|
40
|
+
<div id='description'>
|
41
|
+
<p>
|
42
|
+
Swappable <a href="../CSS.html">CSS</a> minification engines.
|
43
|
+
</p>
|
44
|
+
</div>
|
45
|
+
<div id='method-list'>
|
46
|
+
<h2>Methods</h2>
|
47
|
+
<h3>public class</h3>
|
48
|
+
<ol>
|
49
|
+
<li><a href="#M000017">cssmin</a></li>
|
50
|
+
<li><a href="#M000016">weak</a></li>
|
51
|
+
</ol>
|
52
|
+
</div>
|
53
|
+
<div id='section'>
|
54
|
+
<div id='methods'>
|
55
|
+
<h2>Public class methods</h2>
|
56
|
+
<div class='method public-class' id='method-M000017'>
|
57
|
+
<a name='M000017'></a>
|
58
|
+
<div class='synopsis'>
|
59
|
+
<span class='name'>cssmin</span>
|
60
|
+
<span class='arguments'>(input_string)</span>
|
61
|
+
</div>
|
62
|
+
<div class='description'>
|
63
|
+
<p>
|
64
|
+
<a href="../CSS.html">CSS</a> minification engine that simply uses the
|
65
|
+
CSSMin gem, a Ruby port of Lecomte’s YUI Compressor and
|
66
|
+
Schlueter’s PHP cssmin.
|
67
|
+
</p>
|
68
|
+
<p>
|
69
|
+
Sources:
|
70
|
+
</p>
|
71
|
+
<ul>
|
72
|
+
<li><a href="http://github.com/rgrove/cssmin">github.com/rgrove/cssmin</a>
|
73
|
+
|
74
|
+
</li>
|
75
|
+
<li><a href="http://rubygems.org/gems/cssmin">rubygems.org/gems/cssmin</a>
|
76
|
+
|
77
|
+
</li>
|
78
|
+
</ul>
|
79
|
+
</div>
|
80
|
+
<div class='source'>
|
81
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
|
82
|
+
[show source]
|
83
|
+
</a>
|
84
|
+
<pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 105</span>
105: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cssmin</span>(<span class="ruby-identifier">input_string</span>)
106: <span class="ruby-constant">CSSMin</span>.<span class="ruby-identifier">minify</span>(<span class="ruby-identifier">input_string</span>)
107: <span class="ruby-keyword kw">end</span></pre>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
<div class='method public-class' id='method-M000016'>
|
88
|
+
<a name='M000016'></a>
|
89
|
+
<div class='synopsis'>
|
90
|
+
<span class='name'>weak</span>
|
91
|
+
<span class='arguments'>(input_string)</span>
|
92
|
+
</div>
|
93
|
+
<div class='description'>
|
94
|
+
<p>
|
95
|
+
Barebones <a href="../CSS.html">CSS</a> minification engine that only
|
96
|
+
strips whitespace from the start and end of every line, including
|
97
|
+
linebreaks. For safety, doesn’t attempt to parse the <a
|
98
|
+
href="../CSS.html">CSS</a> itself.
|
99
|
+
</p>
|
100
|
+
</div>
|
101
|
+
<div class='source'>
|
102
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000016-source'); return false">
|
103
|
+
[show source]
|
104
|
+
</a>
|
105
|
+
<pre id='M000016-source'> <span class="ruby-comment cmt"># File lib/asset_hat/css.rb, line 83</span>
83: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">weak</span>(<span class="ruby-identifier">input_string</span>)
84: <span class="ruby-identifier">input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">input_string</span>)
85: <span class="ruby-identifier">output</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
86: 
87: <span class="ruby-identifier">input</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
88: <span class="ruby-comment cmt"># Remove indentation and trailing whitespace (including line breaks)</span>
89: <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip!</span>
90: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">blank?</span>
91: 
92: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">line</span>
93: <span class="ruby-keyword kw">end</span>
94: 
95: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">rewind</span>
96: <span class="ruby-identifier">output</span>.<span class="ruby-identifier">read</span>
97: <span class="ruby-keyword kw">end</span></pre>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
<div id='footer-push'></div>
|
113
|
+
</div>
|
114
|
+
<div id='footer'>
|
115
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
116
|
+
</div>
|
117
|
+
</body>
|
118
|
+
</html>
|