Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Clean up whitespace, uses this method: http://bcardarella.com/post/868203 #44

Merged
merged 1 commit into from

2 participants

@bcardarella

Clean up whitespace, uses this method: http://bcardarella.com/post/8682039114/clean-up-trailing-whitespace

I'm a whitespace nut, my Vim config highlights and errant whitespace so this commit will clean up the entire repo.

@cjohansen cjohansen merged commit f23047f into cjohansen:master
@cjohansen
Owner

Ah, lovely. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
20 lib/juicer/asset/path.rb
@@ -16,35 +16,35 @@ module Asset
#
# Dir.pwd
# #=> "/home/christian/projects/mysite/design/css"
- #
+ #
# asset = Juicer::Asset::Path.new "../images/logo.png"
# asset.path
# #=> "../images/logo.png"
- #
+ #
# asset.rebase("~/projects/mysite/design").path
# #=> "images/logo.png"
- #
+ #
# asset.filename
# #=> "/home/christian/projects/mysite/design/images/logo.png"
- #
+ #
# asset.path(:cache_buster_type => :soft)
# #=> "../images/logo.png?jcb=1234567890"
- #
+ #
# asset.path(:cache_buster_type => :soft, :cache_buster => nil)
# #=> "../images/logo.png?1234567890"
- #
+ #
# asset.path(:cache_buster => "bustIT")
# #=> "../images/logo.png?bustIT=1234567890"
- #
+ #
# asset = Juicer::Asset::Path.new "../images/logo.png", :document_root
# #=> "/home/christian/projects/mysite"
- #
+ #
# asset.absolute_path(:cache_buster_type => :hard)
# #=> "/images/logo-jcb1234567890.png"
- #
+ #
# asset.absolute_path(:host => "http://localhost")
# #=> "http://localhost/images/logo.png"
- #
+ #
# asset.absolute_path(:host => "http://localhost", :cache_buster_type => :hard)
# #=> "http://localhost/images/logo-jcb1234567890.png"
#
View
4 lib/juicer/asset/path_resolver.rb
@@ -16,10 +16,10 @@ module Asset
# asset = path_resolver.resolve("../images/logo.png")
# asset.document_root
# #=> "/var/www"
- #
+ #
# asset.absolute_path(path_resolver.cycle_hosts)
# #=> "http://assets1.mysite.com/images/logo.png"
- #
+ #
# asset = path_resolver.resolve("/favicon.ico")
# asset.absolute_path(path_resolver.cycle_hosts)
# #=> "http://assets2.mysite.com/favicon.ico"
View
2  lib/juicer/binary.rb
@@ -129,7 +129,7 @@ def command
#
def locate(bin_glob, env = nil)
path << ENV[env] if env && ENV.key?(env) && File.exist?(ENV[env])
-
+
(path << Dir.pwd).each do |path|
files = Dir.glob(File.expand_path(File.join(path, bin_glob)))
return files unless files.empty?
View
2  lib/juicer/cache_buster.rb
@@ -127,7 +127,7 @@ def self.soft(file, parameter = DEFAULT_PARAMETER)
def self.rails(file)
self.path(file, :rails)
end
-
+
#
# Remove cache buster from a URL for a given parameter name. Parameter name is
# "cb" by default.
View
14 lib/juicer/command/merge.rb
@@ -30,7 +30,7 @@ def initialize(log = nil)
@absolute_urls = false # Make the merger use absolute URLs
@local_hosts = [] # Host names that are served from :document_root
@verify = true # Verify js files with JsLint
- @image_embed_type = :none # Embed images in css files, options are :none, :data_uri
+ @image_embed_type = :none # Embed images in css files, options are :none, :data_uri
@force_image_embed = false
@log = log || Logger.new(STDOUT)
@@ -76,7 +76,7 @@ def initialize(log = nil)
(" " * 37) + "Works with cycled asset hosts. Only valid for CSS files") { |t| @absolute_urls = true }
opt.on("-d", "--document-root dir", "Path to resolve absolute URLs relative to") { |path| @document_root = path }
opt.on("-c", "--cache-buster type", "none, soft, rails, or hard. Default is soft, which adds timestamps to\n" +
- (" " * 37) + "reference URLs as query parameters. None leaves URLs untouched, rails adds\n" +
+ (" " * 37) + "reference URLs as query parameters. None leaves URLs untouched, rails adds\n" +
(" " * 37) + "timestamps in the same format as Rails' image_tag helper, and hard alters\n" +
(" " * 37) + "file names") do |type|
@cache_buster = [:soft, :hard, :rails].include?(type.to_sym) ? type.to_sym : nil
@@ -190,13 +190,13 @@ def cache_buster(file)
Juicer::CssCacheBuster.new(:document_root => @document_root, :type => @cache_buster, :hosts => @local_hosts)
end
- #
- # Load image embed, only available for CSS files
- #
- def image_embed(file)
+ #
+ # Load image embed, only available for CSS files
+ #
+ def image_embed(file)
return nil if !file || file !~ /\.css$/ || @image_embed_type.nil?
Juicer::ImageEmbed.new(:document_root => @document_root, :type => @image_embed_type, :force => @force_image_embed )
- end
+ end
#
# Generate output file name. Optional argument is a filename to base the new
View
4 lib/juicer/datafy/datafy.rb
@@ -16,5 +16,5 @@ def Datafy::make_data_uri(content, content_type)
end
outuri += ",#{content}"
end
-
-end
+
+end
View
58 lib/juicer/dependency_resolver/css_dependency_resolver.rb
@@ -1,29 +1,29 @@
-require "juicer/dependency_resolver/dependency_resolver"
-
-module Juicer
-
- # Resolves @import statements in CSS files and builds a list of all
- # files, in order.
- #
- class CssDependencyResolver < DependencyResolver
- # Regexp borrowed from similar project:
- # http://github.com/cgriego/front-end-blender/tree/master/lib/front_end_architect/blender.rb
- @@import_pattern = /^\s*@import(?:\surl\(|\s)(['"]?)([^\?'"\)\s]+)(\?(?:[^'"\)]*))?\1\)?(?:[^?;]*);?/im
-
- private
- def parse(line, imported_file = nil)
- return $2 if line =~ @@import_pattern
-
- # At first sight of actual CSS rules we abort (TODO: This does not take
- # into account the fact that rules may be commented out and that more
- # imports may follow)
- throw :done if imported_file && line =~ %r{/*}
- throw :done if line =~ /^[\.\#a-zA-Z\:]/
- end
-
- def extension
- ".css"
- end
- end
-
-end
+require "juicer/dependency_resolver/dependency_resolver"
+
+module Juicer
+
+ # Resolves @import statements in CSS files and builds a list of all
+ # files, in order.
+ #
+ class CssDependencyResolver < DependencyResolver
+ # Regexp borrowed from similar project:
+ # http://github.com/cgriego/front-end-blender/tree/master/lib/front_end_architect/blender.rb
+ @@import_pattern = /^\s*@import(?:\surl\(|\s)(['"]?)([^\?'"\)\s]+)(\?(?:[^'"\)]*))?\1\)?(?:[^?;]*);?/im
+
+ private
+ def parse(line, imported_file = nil)
+ return $2 if line =~ @@import_pattern
+
+ # At first sight of actual CSS rules we abort (TODO: This does not take
+ # into account the fact that rules may be commented out and that more
+ # imports may follow)
+ throw :done if imported_file && line =~ %r{/*}
+ throw :done if line =~ /^[\.\#a-zA-Z\:]/
+ end
+
+ def extension
+ ".css"
+ end
+ end
+
+end
View
46 lib/juicer/dependency_resolver/javascript_dependency_resolver.rb
@@ -1,23 +1,23 @@
-require "juicer/dependency_resolver/dependency_resolver"
-
-module Juicer
- # Resolves @depends and @depend statements in comments in JavaScript files.
- # Only the first comment in a JavaScript file is parsed
- #
- class JavaScriptDependencyResolver < DependencyResolver
- @@depends_pattern = /\@depends?\s+([^\s\'\"\;]+)/
-
- private
- def parse(line, imported_file = nil)
- return $1 if line =~ @@depends_pattern
-
- # If we have already skimmed through some @depend/@depends or a
- # closing comment we're done.
- throw :done unless imported_file.nil? || !(line =~ /\*\//)
- end
-
- def extension
- ".js"
- end
- end
-end
+require "juicer/dependency_resolver/dependency_resolver"
+
+module Juicer
+ # Resolves @depends and @depend statements in comments in JavaScript files.
+ # Only the first comment in a JavaScript file is parsed
+ #
+ class JavaScriptDependencyResolver < DependencyResolver
+ @@depends_pattern = /\@depends?\s+([^\s\'\"\;]+)/
+
+ private
+ def parse(line, imported_file = nil)
+ return $1 if line =~ @@depends_pattern
+
+ # If we have already skimmed through some @depend/@depends or a
+ # closing comment we're done.
+ throw :done unless imported_file.nil? || !(line =~ /\*\//)
+ end
+
+ def extension
+ ".js"
+ end
+ end
+end
View
32 lib/juicer/image_embed.rb
@@ -6,18 +6,18 @@ module Juicer
#
# The ImageEmbed is a tool that can parse a CSS file and substitute all
# referenced URLs by a data uri
- #
+ #
# - data uri (http://en.wikipedia.org/wiki/Data_URI_scheme)
- #
+ #
# Only local resources will be processed this way, external resources referenced
# by absolute urls will be left alone
- #
+ #
class ImageEmbed
include Juicer::Chainable
# The maximum supported limit for modern browsers, See the Readme.rdoc for details
SIZE_LIMIT = 32768
-
+
#
# Returns the size limit
#
@@ -56,14 +56,14 @@ def save(file, output = nil)
duplicates = duplicate_urls(assets)
if duplicates.length > 0
- Juicer::LOGGER.warn("Duplicate image urls detected, these images will not be embedded: #{duplicates.collect { |v| v.gsub('?embed=true', '') }.inspect}")
+ Juicer::LOGGER.warn("Duplicate image urls detected, these images will not be embedded: #{duplicates.collect { |v| v.gsub('?embed=true', '') }.inspect}")
end
assets.each do |asset|
begin
next if used.include?(asset) || duplicates.include?(asset.path)
used << asset
-
+
# make sure we do not exceed SIZE_LIMIT
new_path = embed_data_uri(asset.filename)
@@ -71,7 +71,7 @@ def save(file, output = nil)
# replace the url in the css file with the data uri
@contents.gsub!(asset.path, embed_data_uri(asset.filename)) if @force || asset.filename.match( /\?embed=true$/ )
else
- Juicer::LOGGER.warn("The final data uri for the image located at #{asset.path.gsub('?embed=true', '')} exceeds #{SIZE_LIMIT} and will not be embedded to maintain compatability.")
+ Juicer::LOGGER.warn("The final data uri for the image located at #{asset.path.gsub('?embed=true', '')} exceeds #{SIZE_LIMIT} and will not be embedded to maintain compatability.")
end
rescue Errno::ENOENT
puts "Unable to locate file #{asset.path}, skipping image embedding"
@@ -83,10 +83,10 @@ def save(file, output = nil)
end
chain_method :save
-
+
def embed_data_uri( path )
new_path = path
-
+
if @force
supported_file_matches = path.match( /(?:\.)(png|gif|jpg|jpeg)$/i )
else
@@ -94,17 +94,17 @@ def embed_data_uri( path )
end
filetype = supported_file_matches[1] if supported_file_matches
-
- if ( filetype )
- filename = path.gsub('?embed=true','')
-
+
+ if ( filetype )
+ filename = path.gsub('?embed=true','')
+
# check if file exists, throw an error if it doesn't exist
if File.exist?( filename )
-
- # read contents of file into memory
+
+ # read contents of file into memory
content = File.read( filename )
content_type = "image/#{filetype}"
-
+
# encode the url
new_path = Datafy::make_data_uri( content, content_type )
else
View
58 lib/juicer/merger/javascript_merger.rb
@@ -1,29 +1,29 @@
-#!/usr/bin/env ruby
-require "juicer/merger/base"
-require "juicer/dependency_resolver/javascript_dependency_resolver"
-
-module Juicer
- module Merger
- # Merge several files into one single output file. Resolves and adds in files from @depend comments
- class JavaScriptMerger < Base
-
- # Constructor
- def initialize(files = [], options = {})
- @dependency_resolver = JavaScriptDependencyResolver.new(options)
- super(files, options)
- end
- end
- end
-end
-
-# Run file from command line
-# TODO: Refactor to testable Juicer::Merger::JavaScript::FileMerger.cli method
-# or similar.
-#
-if $0 == __FILE__
- puts("Usage: javascript_merger.rb file[...] output") and exit if $*.length < 2
-
- fm = JavaScriptMerger.new()
- fm << $*[0..-2]
- fm.save($*[-1])
-end
+#!/usr/bin/env ruby
+require "juicer/merger/base"
+require "juicer/dependency_resolver/javascript_dependency_resolver"
+
+module Juicer
+ module Merger
+ # Merge several files into one single output file. Resolves and adds in files from @depend comments
+ class JavaScriptMerger < Base
+
+ # Constructor
+ def initialize(files = [], options = {})
+ @dependency_resolver = JavaScriptDependencyResolver.new(options)
+ super(files, options)
+ end
+ end
+ end
+end
+
+# Run file from command line
+# TODO: Refactor to testable Juicer::Merger::JavaScript::FileMerger.cli method
+# or similar.
+#
+if $0 == __FILE__
+ puts("Usage: javascript_merger.rb file[...] output") and exit if $*.length < 2
+
+ fm = JavaScriptMerger.new()
+ fm << $*[0..-2]
+ fm.save($*[-1])
+end
View
222 lib/juicer/merger/stylesheet_merger.rb
@@ -1,111 +1,111 @@
-#!/usr/bin/env ruby
-require "juicer/merger/base"
-require "juicer/dependency_resolver/css_dependency_resolver"
-require 'pathname'
-
-module Juicer
- module Merger
- # Merge several files into one single output file. Resolves and adds in files
- # from @import statements
- #
- class StylesheetMerger < Base
-
- # Constructor
- #
- # Options:
- # * <tt>:document_root</tt> - Path to web root if there is any @import statements
- # using absolute URLs
- #
- def initialize(files = [], options = {})
- @dependency_resolver = CssDependencyResolver.new(options)
- super(files || [], options)
- @hosts = options[:hosts] || []
- @host_num = 0
- @use_absolute = options.key?(:absolute_urls) ? options[:absolute_urls] : false
- @use_relative = options.key?(:relative_urls) ? options[:relative_urls] : false
- @document_root = options[:document_root]
- @document_root = File.expand_path(@document_root).sub(/\/?$/, "") if @document_root # Make sure path doesn't end in a /
- end
-
- private
- #
- # Takes care of removing any import statements. This avoids importing the
- # file that was just merged into the current file.
- #
- # +merge+ also recalculates any referenced URLs. Relative URLs are adjusted
- # to be relative to the resulting merged file. Absolute URLs are left alone
- # by default. If the :hosts option is set, the absolute URLs will cycle
- # through these. This may help in concurrent downloads.
- #
- # The options hash decides how Juicer recalculates referenced URLs:
- #
- # options[:absolute_urls] When true, all paths are converted to absolute
- # URLs. Requires options[:document_root] to define
- # root directory to resolve absolute URLs from.
- # options[:relative_urls] When true, all paths are converted to relative
- # paths. Requires options[:document_root] to define
- # root directory to resolve absolute URLs from.
- #
- # If none if these are set then relative URLs are recalculated to match
- # location of merged target while absolute URLs are left absolute.
- #
- # If options[:hosts] is set to an array of hosts, then they will be cycled
- # for all absolute URLs regardless of absolute/relative URL strategy.
- #
- def merge(file)
- content = super.gsub(/^\s*@import(?:\surl\(|\s)(['"]?)([^\?'"\)\s]+)(\?(?:[^'"\)]*))?\1\)?(?:[^?;]*);?/i, "")
- dir = File.expand_path(File.dirname(file))
-
- content.scan(/url\([\s"']*([^\)"'\s]*)[\s"']*\)/m).uniq.collect do |url|
- url = url.first
- path = resolve_path(url, dir)
- content.gsub!(/\([\s"']*#{url}[\s"']*\)/m, "(#{path})") unless path == url
- end
-
- content
- end
-
- #
- # Resolves a path relative to a directory
- #
- def resolve_path(url, dir)
- return url if url =~ /^data:/
- path = url
-
- # Absolute URLs
- if url =~ %r{^/} && @use_relative
- raise ArgumentError.new("Unable to handle absolute URLs without :document_root option") if !@document_root
- path = Pathname.new(File.join(@document_root, url)).relative_path_from(@root).to_s
- end
-
- # All URLs that don't start with a protocol
- if url !~ %r{^/} && url !~ %r{^[a-z]+://}
- if @use_absolute || @hosts.length > 0
- raise ArgumentError.new("Unable to handle absolute URLs without :document_root option") if !@document_root
- path = File.expand_path(File.join(dir, url)).sub(@document_root, "") # Make absolute
- else
- path = Pathname.new(File.join(dir, url)).relative_path_from(@root).to_s # ...or redefine relative ref
- end
- end
-
- # Cycle hosts, if any
- if path =~ %r{^/} && @hosts.length > 0
- path = File.join(@hosts[@host_num % @hosts.length], path)
- @host_num += 1
- end
-
- path
- end
- end
- end
-end
-
-# Run file from command line
-#
-if $0 == __FILE__
- puts("Usage: stylesheet_merger.rb file[...] output") and exit if $*.length < 2
-
- fm = Juicer::Merger::StylesheetMerger.new()
- fm << $*[0..-2]
- fm.save($*[-1])
-end
+#!/usr/bin/env ruby
+require "juicer/merger/base"
+require "juicer/dependency_resolver/css_dependency_resolver"
+require 'pathname'
+
+module Juicer
+ module Merger
+ # Merge several files into one single output file. Resolves and adds in files
+ # from @import statements
+ #
+ class StylesheetMerger < Base
+
+ # Constructor
+ #
+ # Options:
+ # * <tt>:document_root</tt> - Path to web root if there is any @import statements
+ # using absolute URLs
+ #
+ def initialize(files = [], options = {})
+ @dependency_resolver = CssDependencyResolver.new(options)
+ super(files || [], options)
+ @hosts = options[:hosts] || []
+ @host_num = 0
+ @use_absolute = options.key?(:absolute_urls) ? options[:absolute_urls] : false
+ @use_relative = options.key?(:relative_urls) ? options[:relative_urls] : false
+ @document_root = options[:document_root]
+ @document_root = File.expand_path(@document_root).sub(/\/?$/, "") if @document_root # Make sure path doesn't end in a /
+ end
+
+ private
+ #
+ # Takes care of removing any import statements. This avoids importing the
+ # file that was just merged into the current file.
+ #
+ # +merge+ also recalculates any referenced URLs. Relative URLs are adjusted
+ # to be relative to the resulting merged file. Absolute URLs are left alone
+ # by default. If the :hosts option is set, the absolute URLs will cycle
+ # through these. This may help in concurrent downloads.
+ #
+ # The options hash decides how Juicer recalculates referenced URLs:
+ #
+ # options[:absolute_urls] When true, all paths are converted to absolute
+ # URLs. Requires options[:document_root] to define
+ # root directory to resolve absolute URLs from.
+ # options[:relative_urls] When true, all paths are converted to relative
+ # paths. Requires options[:document_root] to define
+ # root directory to resolve absolute URLs from.
+ #
+ # If none if these are set then relative URLs are recalculated to match
+ # location of merged target while absolute URLs are left absolute.
+ #
+ # If options[:hosts] is set to an array of hosts, then they will be cycled
+ # for all absolute URLs regardless of absolute/relative URL strategy.
+ #
+ def merge(file)
+ content = super.gsub(/^\s*@import(?:\surl\(|\s)(['"]?)([^\?'"\)\s]+)(\?(?:[^'"\)]*))?\1\)?(?:[^?;]*);?/i, "")
+ dir = File.expand_path(File.dirname(file))
+
+ content.scan(/url\([\s"']*([^\)"'\s]*)[\s"']*\)/m).uniq.collect do |url|
+ url = url.first
+ path = resolve_path(url, dir)
+ content.gsub!(/\([\s"']*#{url}[\s"']*\)/m, "(#{path})") unless path == url
+ end
+
+ content
+ end
+
+ #
+ # Resolves a path relative to a directory
+ #
+ def resolve_path(url, dir)
+ return url if url =~ /^data:/
+ path = url
+
+ # Absolute URLs
+ if url =~ %r{^/} && @use_relative
+ raise ArgumentError.new("Unable to handle absolute URLs without :document_root option") if !@document_root
+ path = Pathname.new(File.join(@document_root, url)).relative_path_from(@root).to_s
+ end
+
+ # All URLs that don't start with a protocol
+ if url !~ %r{^/} && url !~ %r{^[a-z]+://}
+ if @use_absolute || @hosts.length > 0
+ raise ArgumentError.new("Unable to handle absolute URLs without :document_root option") if !@document_root
+ path = File.expand_path(File.join(dir, url)).sub(@document_root, "") # Make absolute
+ else
+ path = Pathname.new(File.join(dir, url)).relative_path_from(@root).to_s # ...or redefine relative ref
+ end
+ end
+
+ # Cycle hosts, if any
+ if path =~ %r{^/} && @hosts.length > 0
+ path = File.join(@hosts[@host_num % @hosts.length], path)
+ @host_num += 1
+ end
+
+ path
+ end
+ end
+ end
+end
+
+# Run file from command line
+#
+if $0 == __FILE__
+ puts("Usage: stylesheet_merger.rb file[...] output") and exit if $*.length < 2
+
+ fm = Juicer::Merger::StylesheetMerger.new()
+ fm << $*[0..-2]
+ fm.save($*[-1])
+end
View
2  test/unit/juicer/cache_buster_test.rb
@@ -36,7 +36,7 @@ def teardown
should "remove cache buster query parameters with custom name" do
assert_equal @filename, Juicer::CacheBuster.clean("#@filename?cb=1234567890", :cb)
end
-
+
should "remove hard cache buster" do
assert_equal @filename, Juicer::CacheBuster.clean(@filename.sub(/(\.txt)/, '-jcb1234567890\1'))
end
View
4 test/unit/juicer/command/install_test.rb
@@ -31,7 +31,7 @@ def setup
@command.instance_eval { @path = path(".juicer") }
@command.execute("jslint")
-
+
assert installer.installed?
end
@@ -51,7 +51,7 @@ def setup
@command.instance_eval { @path = path(".juicer") }
@command.instance_eval { @version = "0.9" }
@command.execute("jslint")
-
+
assert installer.installed?("0.9")
end
end
View
4 test/unit/juicer/command/verify_test.rb
@@ -38,9 +38,9 @@ def teardown
Juicer::JsLint.any_instance.expects(:check).with(files[0]).returns(Juicer::JsLint::Report.new)
Juicer::JsLint.any_instance.expects(:check).with(files[1]).returns(Juicer::JsLint::Report.new(["Oops"]))
Juicer::JsLint.any_instance.expects(:check).with(files[2]).returns(Juicer::JsLint::Report.new)
-
+
@command.execute(files)
-
+
assert_match(/OK!/, @io.string)
assert_match(/Problems detected/, @io.string)
end
View
4 test/unit/juicer/css_cache_buster_test.rb
@@ -95,7 +95,7 @@ def teardown
buster.urls(output).each { |asset| assert_match /\?\d+$/, asset.path }
end
end
-
+
context "hard cache busters" do
should "should alter file name" do
File.open(path("a2.css"), "w") { |f| f.puts "" }
@@ -115,7 +115,7 @@ def teardown
buster = Juicer::CssCacheBuster.new :document_root => path("")
assert_nothing_raised do
- buster.save file
+ buster.save file
end
end
end
View
2  test/unit/juicer/datafy_test.rb
@@ -34,4 +34,4 @@ def test_make_data_uri_octet_stream
LONG_TEXT_PLAIN_URI = "data:#{TEXT_PLAIN},#{LONG_URLENCODED}"
-end
+end
View
8 test/unit/juicer/image_embed_test.rb
@@ -80,11 +80,11 @@ class TestImageEmbed < Test::Unit::TestCase
@files = [{ :path => "#{@document_root}/images/custom-file.png", :filename => '/images/custom-file.png', :content => "hello png!" }]
create_files(@files)
end
-
+
should "embed urls with embedder" do
stylesheets = [{ :path => "#{@document_root}/stylesheets/test_absolute_path.css", :content => "body: { background: url(#{@files.first[:filename]}?embed=true); }" }]
create_files(stylesheets)
-
+
@another_embedder.save stylesheets.first[:path]
css_contents = File.read(stylesheets.first[:path])
@@ -95,11 +95,11 @@ class TestImageEmbed < Test::Unit::TestCase
# make sure the encoded data_uri is present in the stylesheet
assert css_contents.include?(data_uri)
end
-
+
should "not embed urls with embedder" do
stylesheets = [{ :path => "#{@document_root}/stylesheets/test_absolute_path.css", :content => "body: { background: url(#{@files.first[:filename]}?embed=false); }" }]
create_files(stylesheets)
-
+
@another_embedder.save stylesheets.first[:path]
css_contents = File.read(stylesheets.first[:path])
View
6 test/unit/juicer/jslint_test.rb
@@ -6,7 +6,7 @@ def initialize(*args)
@file = path("jsltest.js")
super
end
-
+
def setup
FileUtils.mkdir(path("")) unless File.exists?(path(""))
File.open(@file, "w") { |f| f.puts "" }
@@ -20,7 +20,7 @@ def teardown
should "shell out to rhino/jslint" do
jslint = Juicer::JsLint.new(:bin_path => @path)
jslint.expects(:execute).with("-jar \"#{@path}/rhino1_7R3.jar\" \"#{@path}/jslint-1.0.js\" \"#{@file}\"").returns("jslint: No problems")
-
+
assert jslint.check(@file).ok?
end
end
@@ -36,7 +36,7 @@ def teardown
should "be a report object for invalid files" do
jslint = Juicer::JsLint.new(:bin_path => @path)
jslint.expects(:execute).returns("Wrong use of semicolon\nWrong blabla")
-
+
assert_equal Juicer::JsLint::Report, jslint.check(path("not-ok.js")).class
end
end
View
2  test/unit/juicer/merger/stylesheet_merger_test.rb
@@ -216,7 +216,7 @@ def teardown
assert_equal "../images/1.png", merger.resolve_path("/images/1.png", nil)
end
end
-
+
should "leave data URLs untouched" do
merger = Juicer::Merger::StylesheetMerger.new([],
:document_root => "test/data",
View
8 test/unit/juicer/minifyer/closure_compressor_test.rb
@@ -44,7 +44,7 @@ def setup
File.delete('compiler.jar') if File.exists?('compiler.jar')
FileUtils.rm_rf("another") if File.exists?("another")
end
-
+
should "not find jar when no jars on path" do
Juicer::Minifyer::ClosureCompiler.publicize_methods do
closure = Juicer::Minifyer::ClosureCompiler.new
@@ -69,7 +69,7 @@ def setup
File.open('compiler-2.3.5.jar', 'w') { |f| f.puts '' }
closure = Juicer::Minifyer::ClosureCompiler.new
-
+
# Test
assert_equal File.expand_path('compiler-2.3.5.jar'), closure.locate_jar
end
@@ -83,7 +83,7 @@ def setup
File.open('compiler.jar', 'w') { |f| f.puts '' }
closure = Juicer::Minifyer::ClosureCompiler.new
-
+
# Test
assert_equal File.expand_path('compiler.jar'), closure.locate_jar
end
@@ -96,7 +96,7 @@ def setup
File.open('another/compiler-2.3.4.jar', 'w') { |f| f.puts "" }
closure = Juicer::Minifyer::ClosureCompiler.new
-
+
# Test
assert_nil closure.locate_jar
closure = Juicer::Minifyer::ClosureCompiler.new({ :bin_path => 'another' })
View
8 test/unit/juicer/minifyer/yui_compressor_test.rb
@@ -53,7 +53,7 @@ def setup
File.delete('yuicompressor.jar') if File.exists?('yuicompressor.jar')
FileUtils.rm_rf("another") if File.exists?("another")
end
-
+
should "not find jar when no jars on path" do
Juicer::Minifyer::YuiCompressor.publicize_methods do
yui_compressor = Juicer::Minifyer::YuiCompressor.new
@@ -78,7 +78,7 @@ def setup
File.open('yuicompressor-2.3.5.jar', 'w') { |f| f.puts '' }
yui_compressor = Juicer::Minifyer::YuiCompressor.new
-
+
# Test
assert_equal File.expand_path('yuicompressor-2.3.5.jar'), yui_compressor.locate_jar
end
@@ -92,7 +92,7 @@ def setup
File.open('yuicompressor.jar', 'w') { |f| f.puts '' }
yui_compressor = Juicer::Minifyer::YuiCompressor.new
-
+
# Test
assert_equal File.expand_path('yuicompressor.jar'), yui_compressor.locate_jar
end
@@ -105,7 +105,7 @@ def setup
File.open('another/yuicompressor-2.3.4.jar', 'w') { |f| f.puts "" }
yui_compressor = Juicer::Minifyer::YuiCompressor.new
-
+
# Test
assert_nil yui_compressor.locate_jar
yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => 'another' })
View
2  test/unit/juicer_test.rb
@@ -1 +1 @@
-require "test_helper"
+require "test_helper"
Something went wrong with that request. Please try again.