jammit 0.5.4 → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jammit'
3
- s.version = '0.5.4' # Keep version in sync with jammit.rb
3
+ s.version = '0.6.0' # Keep version in sync with jammit.rb
4
4
  s.date = '2010-11-8'
5
5
 
6
6
  s.homepage = "http://documentcloud.github.com/jammit/"
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path(File.dirname(__FILE__))
4
4
  # to all of the configuration options.
5
5
  module Jammit
6
6
 
7
- VERSION = "0.5.4"
7
+ VERSION = "0.6.0"
8
8
 
9
9
  ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
10
10
 
@@ -50,7 +50,7 @@ module Jammit
50
50
  :embed_assets, :package_assets, :compress_assets, :gzip_assets,
51
51
  :package_path, :mhtml_enabled, :include_jst_script, :config_path,
52
52
  :javascript_compressor, :compressor_options, :css_compressor_options,
53
- :template_extension, :template_extension_matcher
53
+ :template_extension, :template_extension_matcher, :allow_debugging
54
54
  end
55
55
 
56
56
  # The minimal required configuration.
@@ -70,6 +70,7 @@ module Jammit
70
70
  @embed_assets = conf[:embed_assets] || conf[:embed_images]
71
71
  @compress_assets = !(conf[:compress_assets] == false)
72
72
  @gzip_assets = !(conf[:gzip_assets] == false)
73
+ @allow_debugging = !(conf[:allow_debugging] == false)
73
74
  @mhtml_enabled = @embed_assets && @embed_assets != "datauri"
74
75
  @compressor_options = symbolize_keys(conf[:compressor_options] || {})
75
76
  @css_compressor_options = symbolize_keys(conf[:css_compressor_options] || {})
@@ -22,7 +22,7 @@ module Jammit
22
22
 
23
23
  # Font extensions for which we allow embedding:
24
24
  EMBED_EXTS = EMBED_MIME_TYPES.keys
25
- EMBED_FONTS = ['.ttf', '.otf']
25
+ EMBED_FONTS = ['.ttf', '.otf', '.woff']
26
26
 
27
27
  # (32k - padding) maximum length for data-uri assets (an IE8 limitation).
28
28
  MAX_IMAGE_SIZE = 32700
@@ -128,7 +128,7 @@ module Jammit
128
128
  # the namespaced prefix. Otherwise, simply use the filename.
129
129
  def template_name(path, base_path)
130
130
  return File.basename(path, ".#{Jammit.template_extension}") unless base_path
131
- path.gsub(/\A#{base_path}\/(.*)\.#{Jammit.template_extension}\Z/, '\1')
131
+ path.gsub(/\A#{Regexp.escape(base_path)}\/(.*)\.#{Jammit.template_extension}\Z/, '\1')
132
132
  end
133
133
 
134
134
  # In order to support embedded assets from relative paths, we need to
@@ -244,7 +244,7 @@ module Jammit
244
244
 
245
245
  # `File.read`, but in "binary" mode.
246
246
  def read_binary_file(path)
247
- File.open(path, 'r:binary') {|f| f.read }
247
+ File.open(path, 'rb') {|f| f.read }
248
248
  end
249
249
  end
250
250
 
@@ -15,15 +15,16 @@ module Jammit
15
15
  # yet been cached. The package will be built, cached, and gzipped.
16
16
  def package
17
17
  parse_request
18
+ template_ext = Jammit.template_extension.to_sym
18
19
  case @extension
19
20
  when :js
20
21
  render :js => (@contents = Jammit.packager.pack_javascripts(@package))
21
- when Jammit.template_extension.to_sym
22
+ when template_ext
22
23
  render :js => (@contents = Jammit.packager.pack_templates(@package))
23
24
  when :css
24
25
  render :text => generate_stylesheets, :content_type => 'text/css'
25
26
  end
26
- cache_package if perform_caching
27
+ cache_package if perform_caching && (@extension != template_ext)
27
28
  rescue Jammit::PackageNotFound
28
29
  package_not_found
29
30
  end
@@ -87,7 +88,7 @@ end
87
88
  # Make the Jammit::Controller available to Rails as a top-level controller.
88
89
  ::JammitController = Jammit::Controller
89
90
 
90
- if defined?(Rails) && (Rails.env.development? || Rails.env.test?)
91
+ if defined?(Rails) && Rails.env.development?
91
92
  ActionController::Base.class_eval do
92
93
  append_before_filter { Jammit.reload! }
93
94
  end
@@ -16,7 +16,7 @@ module Jammit
16
16
  # compressed CSS, and in development the stylesheet URLs are passed verbatim.
17
17
  def include_stylesheets(*packages)
18
18
  options = packages.extract_options!
19
- return individual_stylesheets(packages, options) unless Jammit.package_assets
19
+ return individual_stylesheets(packages, options) unless should_package?
20
20
  disabled = (options.delete(:embed_assets) == false) || (options.delete(:embed_images) == false)
21
21
  return html_safe(packaged_stylesheets(packages, options)) if disabled || !Jammit.embed_assets
22
22
  return html_safe(embedded_image_stylesheets(packages, options))
@@ -26,7 +26,7 @@ module Jammit
26
26
  # except in development, where it references the individual scripts.
27
27
  def include_javascripts(*packages)
28
28
  tags = packages.map do |pack|
29
- Jammit.package_assets ? Jammit.asset_url(pack, :js) : Jammit.packager.individual_urls(pack.to_sym, :js)
29
+ should_package? ? Jammit.asset_url(pack, :js) : Jammit.packager.individual_urls(pack.to_sym, :js)
30
30
  end
31
31
  html_safe(javascript_include_tag(tags.flatten))
32
32
  end
@@ -40,6 +40,10 @@ module Jammit
40
40
 
41
41
  private
42
42
 
43
+ def should_package?
44
+ Jammit.package_assets && !(Jammit.allow_debugging && params[:debug_assets])
45
+ end
46
+
43
47
  def html_safe(string)
44
48
  string.respond_to?(:html_safe) ? string.html_safe : string
45
49
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jammit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease: false
4
+ hash: 7
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 4
10
- version: 0.5.4
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Ashkenas
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements: []
111
111
 
112
112
  rubyforge_project: jammit
113
- rubygems_version: 1.3.7
113
+ rubygems_version: 1.4.2
114
114
  signing_key:
115
115
  specification_version: 3
116
116
  summary: Industrial Strength Asset Packaging for Rails