Skip to content

Commit 2bcbdff

Browse files
committed
Jammit 0.6.5
1 parent c3cca5c commit 2bcbdff

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
</p>
9494

9595
<p>
96-
<b>Current Version:</b> <a href="http://rubygems.org/gems/jammit/">0.6.4</a>
96+
<b>Current Version:</b> <a href="http://rubygems.org/gems/jammit/">0.6.5</a>
9797
</p>
9898

9999
<p>
@@ -693,7 +693,7 @@ <h2 id="jst">JavaScript Templates</h2>
693693
<h2 id="changes">Change Log</h2>
694694

695695
<p>
696-
<b class="header">0.6.4</b> &mdash; <small><i>Nov 30, 2011</i></small><br />
696+
<b class="header">0.6.5</b> &mdash; <small><i>Nov 30, 2011</i></small><br />
697697
Added the ability to pass HTML tag options to <tt>include_javascripts</tt>.
698698
Fixed a bug that would always cause JS to be recompiled, regardless of mtimes.
699699
</p>

jammit.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'jammit'
3-
s.version = '0.6.4' # Keep version in sync with jammit.rb
3+
s.version = '0.6.5' # Keep version in sync with jammit.rb
44
s.date = '2011-11-30'
55

66
s.homepage = "http://documentcloud.github.com/jammit/"

lib/jammit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# to all of the configuration options.
55
module Jammit
66

7-
VERSION = "0.6.4"
7+
VERSION = "0.6.5"
88

99
ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
1010

lib/jammit/packager.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ module Jammit
66
# with the correct timestamps.
77
class Packager
88

9-
# In Rails, the difference between a path and an asset URL is "public".
10-
PATH_DIFF = PUBLIC_ROOT.sub(ASSET_ROOT, '')
11-
PATH_TO_URL = /\A#{Regexp.escape(ASSET_ROOT)}(\/?#{Regexp.escape(PATH_DIFF)})?/
12-
139
# Set force to false to allow packages to only be rebuilt when their source
1410
# files have changed since the last time their package was built.
1511
attr_accessor :force, :package_names
@@ -37,7 +33,7 @@ def initialize
3733
# Unless forced, will only rebuild assets whose source files have been
3834
# changed since their last package build.
3935
def precache_all(output_dir=nil, base_url=nil)
40-
output_dir ||= File.join(PUBLIC_ROOT, Jammit.package_path)
36+
output_dir ||= File.join(Jammit.public_root, Jammit.package_path)
4137
cacheable(:js, output_dir).each {|p| cache(p, 'js', pack_javascripts(p), output_dir) }
4238
cacheable(:css, output_dir).each do |p|
4339
cache(p, 'css', pack_stylesheets(p), output_dir)
@@ -89,6 +85,7 @@ def pack_javascripts(package)
8985
def pack_templates(package)
9086
@compressor.compile_jst(package_for(package, :js)[:paths])
9187
end
88+
9289

9390
private
9491

@@ -107,6 +104,11 @@ def glob_files(glob)
107104
Jammit.warn("No assets match '#{glob}'") if paths.empty?
108105
paths
109106
end
107+
108+
# In Rails, the difference between a path and an asset URL is "public".
109+
def path_to_url
110+
@path_to_url ||= /\A#{Regexp.escape(ASSET_ROOT)}(\/?#{Regexp.escape(Jammit.public_root.sub(ASSET_ROOT, ''))})?/
111+
end
110112

111113
# Get the latest mtime of a list of files (plus the config path).
112114
def latest_mtime(paths)
@@ -155,10 +157,10 @@ def create_packages(config)
155157
paths = globs.flatten.uniq.map {|glob| glob_files(glob) }.flatten.uniq
156158
packages[name][:paths] = paths
157159
if !paths.grep(Jammit.template_extension_matcher).empty?
158-
packages[name][:urls] = paths.grep(JS_EXTENSION).map {|path| path.sub(PATH_TO_URL, '') }
160+
packages[name][:urls] = paths.grep(JS_EXTENSION).map {|path| path.sub(path_to_url, '') }
159161
packages[name][:urls] += [Jammit.asset_url(name, Jammit.template_extension)]
160162
else
161-
packages[name][:urls] = paths.map {|path| path.sub(PATH_TO_URL, '') }
163+
packages[name][:urls] = paths.map {|path| path.sub(path_to_url, '') }
162164
end
163165
end
164166
packages

0 commit comments

Comments
 (0)