diff --git a/CHANGELOG b/CHANGELOG
deleted file mode 100644
index 40f1f27..0000000
--- a/CHANGELOG
+++ /dev/null
@@ -1,122 +0,0 @@
-------------------------------------------------------------------------
-r52 | sbecker | 2007-11-04 01:38:21 -0400 (Sun, 04 Nov 2007) | 3 lines
-
-* Allow configuration of which environments the helpers should merge scripts with the Synthesis::AssetPackage.merge_environments variable.
-* Refactored tests so they can all run together, and not depend on what the RAILS_ENV constant is.
-* Only add file extension if it was explicitly passed in, fixes other helpers in rails.
-------------------------------------------------------------------------
-r51 | sbecker | 2007-10-26 16:24:48 -0400 (Fri, 26 Oct 2007) | 1 line
-
-* Updated jsmin.rb to latest version from 2007-07-20
-------------------------------------------------------------------------
-r50 | sbecker | 2007-10-23 23:16:07 -0400 (Tue, 23 Oct 2007) | 1 line
-
-Updated CHANGELOG
-
-------------------------------------------------------------------------
-r49 | sbecker | 2007-10-23 23:13:27 -0400 (Tue, 23 Oct 2007) | 1 line
-
-* Finally committed the subdirectory patch. (Thanks James Coglan!)
-------------------------------------------------------------------------
-r48 | sbecker | 2007-10-15 15:10:43 -0400 (Mon, 15 Oct 2007) | 1 line
-
-* Speed up rake tasks and remove rails environment dependencies
-------------------------------------------------------------------------
-r43 | sbecker | 2007-07-02 15:30:29 -0400 (Mon, 02 Jul 2007) | 1 line
-
-* Updated the docs regarding testing.
-------------------------------------------------------------------------
-r42 | sbecker | 2007-07-02 15:27:00 -0400 (Mon, 02 Jul 2007) | 1 line
-
-* For production helper test, build packages once - on first setup.
-------------------------------------------------------------------------
-r41 | sbecker | 2007-07-02 15:14:13 -0400 (Mon, 02 Jul 2007) | 1 line
-
-* Put build_all in test setup and delete_all in test teardown so all tests will pass the on first run of test suite.
-------------------------------------------------------------------------
-r40 | sbecker | 2007-07-02 14:55:28 -0400 (Mon, 02 Jul 2007) | 1 line
-
-* Fix quotes, add contact info
-------------------------------------------------------------------------
-r39 | sbecker | 2007-07-02 14:53:52 -0400 (Mon, 02 Jul 2007) | 1 line
-
-* Add note on how to run the tests for asset packager.
-------------------------------------------------------------------------
-r38 | sbecker | 2007-01-25 15:36:42 -0500 (Thu, 25 Jan 2007) | 1 line
-
-added CHANGELOG w/ subversion log entries
-------------------------------------------------------------------------
-r37 | sbecker | 2007-01-25 15:34:39 -0500 (Thu, 25 Jan 2007) | 1 line
-
-updated jsmin with new version from 2007-01-23
-------------------------------------------------------------------------
-r35 | sbecker | 2007-01-15 19:22:16 -0500 (Mon, 15 Jan 2007) | 1 line
-
-require synthesis/asset_package in rake tasks, as Rails 1.2 seems to necessitate
-------------------------------------------------------------------------
-r34 | sbecker | 2007-01-05 12:22:09 -0500 (Fri, 05 Jan 2007) | 1 line
-
-do a require before including in action view, because when running migrations, the plugin lib files don't automatically get required, causing the include to error out
-------------------------------------------------------------------------
-r33 | sbecker | 2006-12-23 02:03:41 -0500 (Sat, 23 Dec 2006) | 1 line
-
-updating readme with various tweaks
-------------------------------------------------------------------------
-r32 | sbecker | 2006-12-23 02:03:12 -0500 (Sat, 23 Dec 2006) | 1 line
-
-updating readme with various tweaks
-------------------------------------------------------------------------
-r31 | sbecker | 2006-12-23 01:52:25 -0500 (Sat, 23 Dec 2006) | 1 line
-
-updated readme to show how to use different media for stylesheets
-------------------------------------------------------------------------
-r28 | sbecker | 2006-11-27 21:02:14 -0500 (Mon, 27 Nov 2006) | 1 line
-
-updated compute_public_path, added check for images
-------------------------------------------------------------------------
-r27 | sbecker | 2006-11-10 18:28:29 -0500 (Fri, 10 Nov 2006) | 1 line
-
-tolerate extra periods in source asset names. fixed subversion revision checking to be file specific, instead of repository specific.
-------------------------------------------------------------------------
-r26 | sbecker | 2006-06-24 17:04:27 -0400 (Sat, 24 Jun 2006) | 1 line
-
-convert asset_packages_yml var to a class var
-------------------------------------------------------------------------
-r25 | sbecker | 2006-06-24 12:37:47 -0400 (Sat, 24 Jun 2006) | 1 line
-
-Added ability to include assets by package name. In development, include all uncompressed asset files. In production, include the single compressed asset.
-------------------------------------------------------------------------
-r24 | sbecker | 2006-06-19 21:57:23 -0400 (Mon, 19 Jun 2006) | 1 line
-
-Updates to README and about.yml
-------------------------------------------------------------------------
-r23 | sbecker | 2006-06-19 14:55:39 -0400 (Mon, 19 Jun 2006) | 2 lines
-
-Modifying about.yml and README
-
-------------------------------------------------------------------------
-r21 | sbecker | 2006-06-19 12:18:32 -0400 (Mon, 19 Jun 2006) | 2 lines
-
-added "formerly known as MergeJS"
-
-------------------------------------------------------------------------
-r20 | sbecker | 2006-06-19 12:14:46 -0400 (Mon, 19 Jun 2006) | 2 lines
-
-Updating docs
-
-------------------------------------------------------------------------
-r19 | sbecker | 2006-06-19 11:26:08 -0400 (Mon, 19 Jun 2006) | 2 lines
-
-removing compiled test assets from subversion
-
-------------------------------------------------------------------------
-r18 | sbecker | 2006-06-19 11:19:59 -0400 (Mon, 19 Jun 2006) | 2 lines
-
-Initial import.
-
-------------------------------------------------------------------------
-r17 | sbecker | 2006-06-19 11:18:56 -0400 (Mon, 19 Jun 2006) | 2 lines
-
-Creating directory.
-
-------------------------------------------------------------------------
diff --git a/README b/README.rdoc
similarity index 81%
rename from README
rename to README.rdoc
index ae94cf3..bf8e25c 100644
--- a/README
+++ b/README.rdoc
@@ -4,36 +4,39 @@ JavaScript and CSS Asset Compression for Production Rails Apps
== Description
-When it comes time to deploy your new web application, instead of
-sending down a dozen JavaScript and CSS files full of formatting
-and comments, this Rails plugin makes it simple to merge and
-compress JavaScript and CSS down into one or more files, increasing
+When it comes time to deploy your new web application, instead of
+sending down a dozen JavaScript and CSS files full of formatting
+and comments, this Rails plugin makes it simple to merge and
+compress JavaScript and CSS down into one or more files, increasing
speed and saving bandwidth.
-When in development, it allows you to use your original versions
+When in development, it allows you to use your original versions
and retain formatting and comments for readability and debugging.
-This code is released under the MIT license (like Ruby). You're free
-to rip it up, enhance it, etc. And if you make any enhancements,
+This code is released under the MIT license (like Ruby). You're free
+to rip it up, enhance it, etc. And if you make any enhancements,
I'd like to know so I can add them back in. Thanks!
* Formerly known as MergeJS.
== Credit
-This Rails Plugin was inspired by Cal Henderson's article
+This Rails Plugin was inspired by Cal Henderson's article
"Serving JavaScript Fast" on Vitamin:
http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
-It also uses the Ruby JavaScript Minifier created by
+It also uses the Ruby JavaScript Minifier created by
Douglas Crockford.
http://www.crockford.com/javascript/jsmin.html
+...and Google's Closure Compiler, which is now the default as it often leads to better compression than Crockford's JS Minifier.
+http://closure-compiler.appspot.com/
+
== Key Features
-* Merges and compresses JavaScript and CSS when running in production.
+* Merges and compresses JavaScript and CSS when running in production, using Google's Closure Compiler by default and falling back to Crockford's JS Minifier on failure (the Closure Compiler runs remotely on Google's servers).
* Uses uncompressed originals when running in development.
-* Generates packages on demand in production
+* Generates packages on demand in production.
== Components
@@ -44,7 +47,14 @@ http://www.crockford.com/javascript/jsmin.html
== Updates
-November '08:
+December 2010:
+* Rails 3.0.3 support.
+
+June 2010:
+* Works fine with Rails 3 beta 3.
+* Sets the built packages' modification times to the latest mtime of the source files, or order to be more compatible with Rails asset ID caching.
+
+November 2008:
* Rails 2.2 compatibility fixes
* No more mucking with internal Rails functions, which means:
* Return to use of query-string timestamps. Greatly simplifies things.
@@ -56,30 +66,33 @@ November '08:
== How to Use:
1. Download and install the plugin:
- ./script/plugin install git://github.com/sbecker/asset_packager.git
+ rails plugin install git://github.com/brady8/asset_packager.git
+
2. Run the rake task "asset:packager:create_yml" to generate the /config/asset_packages.yml
-file the first time. You will need to reorder files under 'base' so dependencies are loaded
+file the first time. You will need to reorder files under 'base' so dependencies are loaded
in correct order. Feel free to rename or create new file packages.
+ rake asset:packager:create_yml
+
IMPORTANT: JavaScript files can break once compressed if each statement doesn't end with a semi-colon.
-The minifier puts multiple statements on one line, so if the semi-colon is missing, the statement may no
+The minifier puts multiple statements on one line, so if the semi-colon is missing, the statement may no
longer makes sense and cause a syntax error.
== Examples of config/asset_packages.yml
-Example from a fresh rails app after running the rake task. (Stylesheets is blank because a
+Example from a fresh rails app after running the rake task. (The 'stylesheets' listing is blank because a
default rails app has no stylesheets yet.):
----
-javascripts:
-- base:
+---
+javascripts:
+- base:
- prototype
- effects
- dragdrop
- controls
- application
-stylesheets:
+stylesheets:
- base: []
Multiple packages:
@@ -104,33 +117,35 @@ stylesheets:
- bar
3. Run the rake task "asset:packager:build_all" to generate the compressed, merged versions
-for each package. Whenever you rearrange the yaml file, you'll need to run this task again.
+for each package. Whenever you rearrange the yaml file, you'll need to run this task again.
+
+ rake asset:packager:build_all
Merging and compressing is expensive, so this is something we want to do once, not every time
your app starts. Thats why its a rake task. You can run this task via Capistrano when deploying
-to avoid an initially slow request the first time a page is generated.
+to avoid an initially slow request the first time a page is generated.
-Note: The package will be generated on the fly if it doesn't yet exist, so you don't *need*
+Note: The package will be generated on the fly if it doesn't yet exist, so you don't *need*
to run the rake task when deploying, its just recommended for speeding up initial requests.
4. Use the helper functions whenever including these files in your application. See below for examples.
5. Potential warning: css compressor function currently removes CSS comments. This might blow
-away some CSS hackery. To disable comment removal, comment out /lib/synthesis/asset_package.rb line 176.
+away some CSS hackery. To disable comment removal, comment out /lib/synthesis/asset_package.rb line 206.
== JavaScript Examples
Example call (based on above /config/asset_packages.yml):
<%= javascript_include_merged :base %>
-In development, this generates:
+In development, this generates:
-In production, this generates:
+In production, this generates:
== Stylesheet Examples
@@ -139,11 +154,11 @@ Example call:
<%= stylesheet_link_merged :base %>
In development, this generates:
-
-
+
+
In production this generates:
-
+
== Different CSS Media
@@ -175,4 +190,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Rakefile b/Rakefile
index ca20585..f730d5a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,6 +1,7 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
+require File.join(File.dirname(__FILE__), 'lib', 'synthesis', 'version')
desc 'Default: run unit tests.'
task :default => :test
@@ -17,6 +18,25 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'AssetPackager'
rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('Readme.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "asset_packager"
+ gemspec.version = Synthesis::Version.dup
+ gemspec.summary = "JavaScript and CSS Asset Compression for Production Rails Apps"
+ gemspec.description = "This Rails plugin makes it simple to merge and compress JavaScript and CSS down into one or more files, increasing speed and saving bandwidth"
+ gemspec.email = "brady@ldawn.com"
+ gemspec.homepage = "http://synthesis.sbecker.net/pages/asset_packager"
+ gemspec.authors = ["Scott Becker", "Brady Bouchard", "Igor Galeta"]
+ gemspec.files = FileList["[A-Z]*", "lib/**/*"]
+ gemspec.rubyforge_project = "asset_packager"
+ end
+
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler not available. Install it with: gem install jeweler"
+end
diff --git a/about.yml b/about.yml
deleted file mode 100644
index 8860039..0000000
--- a/about.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-author: Scott Becker
-name: AssetPackager
-summary: JavaScript and CSS Asset Compression for Production Rails Apps
-homepage: http://synthesis.sbecker.net/pages/asset_packager
-plugin: http://sbecker.net/shared/plugins/asset_packager
-license: MIT
-version: 0.2
-rails_version: 1.1.2+
diff --git a/asset_packager.gemspec b/asset_packager.gemspec
new file mode 100644
index 0000000..0476a46
--- /dev/null
+++ b/asset_packager.gemspec
@@ -0,0 +1,52 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{asset_packager}
+ s.version = "0.3.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Scott Becker", "Brady Bouchard", "Igor Galeta"]
+ s.date = %q{2010-12-07}
+ s.description = %q{This Rails plugin makes it simple to merge and compress JavaScript and CSS down into one or more files, increasing speed and saving bandwidth}
+ s.email = %q{brady@ldawn.com}
+ s.extra_rdoc_files = [
+ "README.rdoc"
+ ]
+ s.files = [
+ "README.rdoc",
+ "Rakefile",
+ "lib/synthesis.rb",
+ "lib/synthesis/asset_package.rb",
+ "lib/synthesis/asset_package_helper.rb",
+ "lib/synthesis/jsmin.rb",
+ "lib/synthesis/railtie.rb",
+ "lib/synthesis/version.rb",
+ "lib/tasks/asset_packager_tasks.rake"
+ ]
+ s.homepage = %q{http://synthesis.sbecker.net/pages/asset_packager}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{asset_packager}
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{JavaScript and CSS Asset Compression for Production Rails Apps}
+ s.test_files = [
+ "test/asset_package_helper_development_test.rb",
+ "test/asset_packager_test.rb",
+ "test/asset_package_helper_production_test.rb",
+ "test/test_helper.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
diff --git a/init.rb b/init.rb
index c5713fb..13c2e7d 100644
--- a/init.rb
+++ b/init.rb
@@ -1,3 +1 @@
-require 'synthesis/asset_package'
-require 'synthesis/asset_package_helper'
-ActionView::Base.send :include, Synthesis::AssetPackageHelper
\ No newline at end of file
+require File.join(File.dirname(__FILE__), 'lib', 'synthesis')
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 0000000..496ee2c
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1 @@
+.DS_Store
\ No newline at end of file
diff --git a/lib/jsmin.rb b/lib/jsmin.rb
deleted file mode 100644
index 987747c..0000000
--- a/lib/jsmin.rb
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/usr/bin/ruby
-# jsmin.rb 2007-07-20
-# Author: Uladzislau Latynski
-# This work is a translation from C to Ruby of jsmin.c published by
-# Douglas Crockford. Permission is hereby granted to use the Ruby
-# version under the same conditions as the jsmin.c on which it is
-# based.
-#
-# /* jsmin.c
-# 2003-04-21
-#
-# Copyright (c) 2002 Douglas Crockford (www.crockford.com)
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the "Software"), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is furnished to do
-# so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# The Software shall be used for Good, not Evil.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-# Ruby 1.9 Compatibility Fix - the below isAlphanum uses Fixnum#ord to be compatible with Ruby 1.9 and 1.8.7
-# Fixnum#ord is not found by default in 1.8.6, so monkey patch it in:
-if RUBY_VERSION == '1.8.6'
- class Fixnum; def ord; return self; end; end
-end
-
-EOF = -1
-$theA = ""
-$theB = ""
-
-# isAlphanum -- return true if the character is a letter, digit, underscore,
-# dollar sign, or non-ASCII character
-def isAlphanum(c)
- return false if !c || c == EOF
- return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
- (c >= 'A' && c <= 'Z') || c == '_' || c == '$' ||
- c == '\\' || c[0].ord > 126)
-end
-
-# get -- return the next character from stdin. Watch out for lookahead. If
-# the character is a control character, translate it to a space or linefeed.
-def get()
- c = $stdin.getc
- return EOF if(!c)
- c = c.chr
- return c if (c >= " " || c == "\n" || c.unpack("c") == EOF)
- return "\n" if (c == "\r")
- return " "
-end
-
-# Get the next character without getting it.
-def peek()
- lookaheadChar = $stdin.getc
- $stdin.ungetc(lookaheadChar)
- return lookaheadChar.chr
-end
-
-# mynext -- get the next character, excluding comments.
-# peek() is used to see if a '/' is followed by a '/' or '*'.
-def mynext()
- c = get
- if (c == "/")
- if(peek == "/")
- while(true)
- c = get
- if (c <= "\n")
- return c
- end
- end
- end
- if(peek == "*")
- get
- while(true)
- case get
- when "*"
- if (peek == "/")
- get
- return " "
- end
- when EOF
- raise "Unterminated comment"
- end
- end
- end
- end
- return c
-end
-
-
-# action -- do something! What you do is determined by the argument: 1
-# Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B.
-# (Delete A). 3 Get the next B. (Delete B). action treats a string as a
-# single character. Wow! action recognizes a regular expression if it is
-# preceded by ( or , or =.
-def action(a)
- if(a==1)
- $stdout.write $theA
- end
- if(a==1 || a==2)
- $theA = $theB
- if ($theA == "\'" || $theA == "\"")
- while (true)
- $stdout.write $theA
- $theA = get
- break if ($theA == $theB)
- raise "Unterminated string literal" if ($theA <= "\n")
- if ($theA == "\\")
- $stdout.write $theA
- $theA = get
- end
- end
- end
- end
- if(a==1 || a==2 || a==3)
- $theB = mynext
- if ($theB == "/" && ($theA == "(" || $theA == "," || $theA == "=" ||
- $theA == ":" || $theA == "[" || $theA == "!" ||
- $theA == "&" || $theA == "|" || $theA == "?" ||
- $theA == "{" || $theA == "}" || $theA == ";" ||
- $theA == "\n"))
- $stdout.write $theA
- $stdout.write $theB
- while (true)
- $theA = get
- if ($theA == "/")
- break
- elsif ($theA == "\\")
- $stdout.write $theA
- $theA = get
- elsif ($theA <= "\n")
- raise "Unterminated RegExp Literal"
- end
- $stdout.write $theA
- end
- $theB = mynext
- end
- end
-end
-
-# jsmin -- Copy the input to the output, deleting the characters which are
-# insignificant to JavaScript. Comments will be removed. Tabs will be
-# replaced with spaces. Carriage returns will be replaced with linefeeds.
-# Most spaces and linefeeds will be removed.
-def jsmin
- $theA = "\n"
- action(3)
- while ($theA != EOF)
- case $theA
- when " "
- if (isAlphanum($theB))
- action(1)
- else
- action(2)
- end
- when "\n"
- case ($theB)
- when "{","[","(","+","-"
- action(1)
- when " "
- action(3)
- else
- if (isAlphanum($theB))
- action(1)
- else
- action(2)
- end
- end
- else
- case ($theB)
- when " "
- if (isAlphanum($theA))
- action(1)
- else
- action(3)
- end
- when "\n"
- case ($theA)
- when "}","]",")","+","-","\"","\\", "'", '"'
- action(1)
- else
- if (isAlphanum($theA))
- action(1)
- else
- action(3)
- end
- end
- else
- action(1)
- end
- end
- end
-end
-
-ARGV.each do |anArg|
- $stdout.write "// #{anArg}\n"
-end
-
-jsmin
diff --git a/lib/synthesis.rb b/lib/synthesis.rb
new file mode 100644
index 0000000..4caea9e
--- /dev/null
+++ b/lib/synthesis.rb
@@ -0,0 +1,7 @@
+module Synthesis
+ autoload :AssetPackage, 'synthesis/asset_package'
+ autoload :AssetPackageHelper, 'synthesis/asset_package_helper'
+ autoload :JSMin, 'synthesis/jsmin'
+end
+
+require 'synthesis/railtie'
diff --git a/lib/synthesis/asset_package.rb b/lib/synthesis/asset_package.rb
index 99c9f7a..a931d07 100644
--- a/lib/synthesis/asset_package.rb
+++ b/lib/synthesis/asset_package.rb
@@ -1,20 +1,21 @@
+require 'yaml'
+
module Synthesis
class AssetPackage
-
@asset_base_path = "#{Rails.root}/public"
@asset_packages_yml = File.exists?("#{Rails.root}/config/asset_packages.yml") ? YAML.load_file("#{Rails.root}/config/asset_packages.yml") : nil
-
+
# singleton methods
class << self
attr_accessor :asset_base_path,
:asset_packages_yml
attr_writer :merge_environments
-
+
def merge_environments
- @merge_environments ||= ["production"]
+ @merge_environments ||= ['production']
end
-
+
def parse_path(path)
/^(?:(.*)\/)?([^\/]+)$/.match(path).to_a
end
@@ -52,7 +53,7 @@ def sources_from_targets(asset_type, targets)
package = find_by_target(asset_type, target)
source_names += (package ? package.sources.collect do |src|
package.target_dir.gsub(/^(.+)$/, '\1/') + src
- end : target.to_a)
+ end : Array(target))
end
source_names.uniq
end
@@ -88,10 +89,10 @@ def create_yml
end
end
-
+
# instance methods
attr_accessor :asset_type, :target, :target_dir, :sources
-
+
def initialize(asset_type, package_hash)
target_parts = self.class.parse_path(package_hash.keys.first)
@target_dir = target_parts[1].to_s
@@ -102,8 +103,9 @@ def initialize(asset_type, package_hash)
@extension = get_extension
@file_name = "#{@target}_packaged.#{@extension}"
@full_path = File.join(@asset_path, @file_name)
+ @latest_mtime = get_latest_mtime
end
-
+
def package_exists?
File.exists?(@full_path)
end
@@ -131,48 +133,74 @@ def create_new_build
log "Latest version already exists: #{new_build_path}"
else
File.open(new_build_path, "w") {|f| f.write(compressed_file) }
+ File.utime(0, @latest_mtime, new_build_path)
log "Created #{new_build_path}"
end
end
def merged_file
merged_file = ""
- @sources.each {|s|
- File.open("#{@asset_path}/#{s}.#{@extension}", "r") { |f|
- merged_file += f.read + "\n"
+ @sources.each {|s|
+ File.open("#{@asset_path}/#{s}.#{@extension}", "r") { |f|
+ merged_file += f.read + "\n"
}
}
merged_file
end
-
+
+ # Store the latest mtime so that we can attach it to the merged archive.
+ # This allows the Rails asset IDs to work as intended for caching purposes -
+ # if none of the files in the archive have been modified since the last build,
+ # then the new build (typically done at deploy time) will keep the same mtime
+ # (and Rails asset ID).
+ #
+ def get_latest_mtime
+ return @sources.collect{ |s| File.mtime("#{@asset_path}/#{s}.#{@extension}") }.max
+ end
+
def compressed_file
case @asset_type
- when "javascripts" then compress_js(merged_file)
- when "stylesheets" then compress_css(merged_file)
+ when 'javascripts' then compress_js(merged_file)
+ when 'stylesheets' then compress_css(merged_file)
end
end
- def compress_js(source)
- jsmin_path = "#{Rails.root}/vendor/plugins/asset_packager/lib"
- tmp_path = "#{Rails.root}/tmp/#{@target}_packaged"
-
- # write out to a temp file
- File.open("#{tmp_path}_uncompressed.js", "w") {|f| f.write(source) }
-
- # compress file with JSMin library
- `ruby #{jsmin_path}/jsmin.rb <#{tmp_path}_uncompressed.js >#{tmp_path}_compressed.js \n`
-
- # read it back in and trim it
- result = ""
- File.open("#{tmp_path}_compressed.js", "r") { |f| result += f.read.strip }
-
- # delete temp files if they exist
- File.delete("#{tmp_path}_uncompressed.js") if File.exists?("#{tmp_path}_uncompressed.js")
- File.delete("#{tmp_path}_compressed.js") if File.exists?("#{tmp_path}_compressed.js")
+ def compress_js(source, minifier = 'google_closure')
+ case minifier
+ when 'google_closure' then result = compress_google_closure(source)
+ else result = compress_js_min(source)
+ end
+ result
+ end
+
+ def compress_js_min(source)
+ Synthesis::JSMin.compress(source)
+ end
+ def compress_google_closure(source)
+ require 'net/http'
+ require 'uri'
+
+ url = URI.parse('http://closure-compiler.appspot.com/compile')
+ req = Net::HTTP::Post.new(url.path)
+ req.set_form_data(
+ {
+ 'js_code'=> source,
+ 'compilation_level' => 'SIMPLE_OPTIMIZATIONS',
+ 'output_format' => 'text',
+ 'output_info' => 'compiled_code'
+ })
+ res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
+ case res
+ when Net::HTTPSuccess, Net::HTTPRedirection
+ result = res.body
+ else
+ log("Error compiling js with Google's Closure Compiler. Falling back on js_min...")
+ result = compress_js_jsmin(source)
+ end
result
end
-
+
def compress_css(source)
source.gsub!(/\s+/, " ") # collapse space
source.gsub!(/\/\*(.*?)\*\//, "") # remove comments - caution, might want to remove this if using css hacks
@@ -180,20 +208,37 @@ def compress_css(source)
source.gsub!(/\n$/, "") # remove last break
source.gsub!(/ \{ /, " {") # trim inside brackets
source.gsub!(/; \}/, "}") # trim inside brackets
+
+ # add timestamps to images in css
+ source.gsub!(/url\(['"]?([^'"\)]+?(?:gif|png|jpe?g))['"]?\)/i) do |match|
+
+ file = $1
+ path = File.join(Rails.root, 'public')
+
+ if file.starts_with?('/')
+ path = File.join(path, file)
+ else
+ path = File.join(path, 'stylesheets', file)
+ end
+
+
+ match.gsub(file, "#{file}?#{File.new(path).mtime.to_i}")
+ end
+
source
end
def get_extension
case @asset_type
- when "javascripts" then "js"
- when "stylesheets" then "css"
+ when 'javascripts' then 'js'
+ when 'stylesheets' then 'css'
end
end
-
+
def log(message)
self.class.log(message)
end
-
+
def self.log(message)
puts message
end
@@ -205,6 +250,6 @@ def self.build_file_list(path, extension)
file_list.reverse! if extension == "js"
file_list
end
-
+
end
end
diff --git a/lib/synthesis/asset_package_helper.rb b/lib/synthesis/asset_package_helper.rb
index 77674f4..785bebb 100644
--- a/lib/synthesis/asset_package_helper.rb
+++ b/lib/synthesis/asset_package_helper.rb
@@ -21,7 +21,7 @@ def javascript_include_merged(*sources)
AssetPackage.targets_from_sources("javascripts", sources) :
AssetPackage.sources_from_targets("javascripts", sources))
- sources.collect {|source| javascript_include_tag(source, options) }.join("\n")
+ sources.collect {|source| javascript_include_tag(source, options) }.join("\n").html_safe
end
def stylesheet_link_merged(*sources)
@@ -32,8 +32,8 @@ def stylesheet_link_merged(*sources)
AssetPackage.targets_from_sources("stylesheets", sources) :
AssetPackage.sources_from_targets("stylesheets", sources))
- sources.collect { |source| stylesheet_link_tag(source, options) }.join("\n")
+ sources.collect { |source| stylesheet_link_tag(source, options) }.join("\n").html_safe
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/synthesis/jsmin.rb b/lib/synthesis/jsmin.rb
new file mode 100644
index 0000000..e4635e8
--- /dev/null
+++ b/lib/synthesis/jsmin.rb
@@ -0,0 +1,234 @@
+# Updated to work as a module instead of a command line version
+
+# jsmin.rb 2007-07-20
+# Author: Uladzislau Latynski
+# This work is a translation from C to Ruby of jsmin.c published by
+# Douglas Crockford. Permission is hereby granted to use the Ruby
+# version under the same conditions as the jsmin.c on which it is
+# based.
+#
+# /* jsmin.c
+# 2003-04-21
+#
+# Copyright (c) 2002 Douglas Crockford (www.crockford.com)
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of
+# this software and associated documentation files (the "Software"), to deal in
+# the Software without restriction, including without limitation the rights to
+# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+# of the Software, and to permit persons to whom the Software is furnished to do
+# so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# The Software shall be used for Good, not Evil.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+require 'stringio'
+
+# Ruby 1.9 Compatibility Fix - the below isAlphanum uses Fixnum#ord to be compatible with Ruby 1.9 and 1.8.7
+# Fixnum#ord is not found by default in 1.8.6, so monkey patch it in:
+if RUBY_VERSION == '1.8.6'
+ class Fixnum; def ord; return self; end; end
+end
+
+module Synthesis
+ class JSMin
+ # class variables
+ @@EOF = -1
+ @@theA = ""
+ @@theB = ""
+ @@input = ""
+ @@output = ""
+
+ # singleton methods
+ class << self
+
+ def compress(incoming)
+ @@output = StringIO.new("","w")
+ if incoming.is_a? String
+ @@input = StringIO.new(incoming,"r")
+ elsif incoming.kind_of? IO
+ @@input = incoming
+ else
+ raise ArgumentError.new("JSMin can only compress strings or files")
+ end
+ jsmin
+ @@output.string
+ end
+
+
+ protected
+ # isAlphanum -- return true if the character is a letter, digit, underscore,
+ # dollar sign, or non-ASCII character
+ def isAlphanum(c)
+ return false if !c || c == @@EOF
+ return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
+ (c >= 'A' && c <= 'Z') || c == '_' || c == '$' ||
+ c == '\\' || c[0].ord > 126)
+ end
+
+ # get -- return the next character from stdin. Watch out for lookahead. If
+ # the character is a control character, translate it to a space or linefeed.
+ def get()
+ c = @@input.getc
+ return @@EOF if(!c)
+ c = c.chr
+ return c if (c >= " " || c == "\n" || c.unpack("c") == @@EOF)
+ return "\n" if (c == "\r")
+ return " "
+ end
+
+ # Get the next character without getting it.
+ def peek()
+ lookaheadChar = @@input.getc
+ @@input.ungetc(lookaheadChar)
+ return lookaheadChar.chr
+ end
+
+ # mynext -- get the next character, excluding comments.
+ # peek() is used to see if a '/' is followed by a '/' or '*'.
+ def mynext()
+ c = get
+ if (c == "/")
+ if(peek == "/")
+ while(true)
+ c = get
+ if (c <= "\n")
+ return c
+ end
+ end
+ end
+ if(peek == "*")
+ get
+ while(true)
+ case get
+ when "*"
+ if (peek == "/")
+ get
+ return " "
+ end
+ when @@EOF
+ raise "Unterminated comment"
+ end
+ end
+ end
+ end
+ return c
+ end
+
+
+ # action -- do something! What you do is determined by the argument: 1
+ # Output A. Copy B to A. Get the next B. 2 Copy B to A. Get the next B.
+ # (Delete A). 3 Get the next B. (Delete B). action treats a string as a
+ # single character. Wow! action recognizes a regular expression if it is
+ # preceded by ( or , or =.
+ def action(a)
+ if(a==1)
+ @@output.write $theA
+ end
+ if(a==1 || a==2)
+ $theA = $theB
+ if ($theA == "\'" || $theA == "\"")
+ while (true)
+ @@output.write $theA
+ $theA = get
+ break if ($theA == $theB)
+ raise "Unterminated string literal" if ($theA <= "\n")
+ if ($theA == "\\")
+ @@output.write $theA
+ $theA = get
+ end
+ end
+ end
+ end
+ if(a==1 || a==2 || a==3)
+ $theB = mynext
+ if ($theB == "/" && ($theA == "(" || $theA == "," || $theA == "=" ||
+ $theA == ":" || $theA == "[" || $theA == "!" ||
+ $theA == "&" || $theA == "|" || $theA == "?" ||
+ $theA == "{" || $theA == "}" || $theA == ";" ||
+ $theA == "\n"))
+ @@output.write $theA
+ @@output.write $theB
+ while (true)
+ $theA = get
+ if ($theA == "/")
+ break
+ elsif ($theA == "\\")
+ @@output.write $theA
+ $theA = get
+ elsif ($theA <= "\n")
+ raise "Unterminated RegExp Literal"
+ end
+ @@output.write $theA
+ end
+ $theB = mynext
+ end
+ end
+ end
+
+ # jsmin -- Copy the input to the output, deleting the characters which are
+ # insignificant to JavaScript. Comments will be removed. Tabs will be
+ # replaced with spaces. Carriage returns will be replaced with linefeeds.
+ # Most spaces and linefeeds will be removed.
+ def jsmin
+ $theA = "\n"
+ action(3)
+ while ($theA != @@EOF)
+ case $theA
+ when " "
+ if (isAlphanum($theB))
+ action(1)
+ else
+ action(2)
+ end
+ when "\n"
+ case ($theB)
+ when "{","[","(","+","-"
+ action(1)
+ when " "
+ action(3)
+ else
+ if (isAlphanum($theB))
+ action(1)
+ else
+ action(2)
+ end
+ end
+ else
+ case ($theB)
+ when " "
+ if (isAlphanum($theA))
+ action(1)
+ else
+ action(3)
+ end
+ when "\n"
+ case ($theA)
+ when "}","]",")","+","-","\"","\\", "'", '"'
+ action(1)
+ else
+ if (isAlphanum($theA))
+ action(1)
+ else
+ action(3)
+ end
+ end
+ else
+ action(1)
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/synthesis/railtie.rb b/lib/synthesis/railtie.rb
new file mode 100644
index 0000000..e62a855
--- /dev/null
+++ b/lib/synthesis/railtie.rb
@@ -0,0 +1,16 @@
+require 'rails'
+require 'synthesis'
+
+module Synthesis
+ class Railtie < ::Rails::Railtie
+ config.after_initialize do
+ ActiveSupport.on_load :action_view do
+ ActionView::Base.send :include, Synthesis::AssetPackageHelper
+ end
+ end
+
+ rake_tasks do
+ load "tasks/asset_packager_tasks.rake"
+ end
+ end
+end
diff --git a/lib/synthesis/version.rb b/lib/synthesis/version.rb
new file mode 100644
index 0000000..ca6ff52
--- /dev/null
+++ b/lib/synthesis/version.rb
@@ -0,0 +1,11 @@
+module Synthesis
+ module Version
+ MAJOR = 0
+ MINOR = 3
+ RELEASE = 0
+
+ def self.dup
+ "#{MAJOR}.#{MINOR}.#{RELEASE}"
+ end
+ end
+end
diff --git a/lib/tasks/asset_packager_tasks.rake b/lib/tasks/asset_packager_tasks.rake
index 67504f9..58b68fa 100644
--- a/lib/tasks/asset_packager_tasks.rake
+++ b/lib/tasks/asset_packager_tasks.rake
@@ -1,9 +1,8 @@
-require 'yaml'
-require File.dirname(__FILE__) + '/../../lib/synthesis/asset_package'
+require File.join(File.dirname(__FILE__), "..", "synthesis", "asset_package")
+require File.join(File.dirname(__FILE__), "..", "synthesis", "jsmin")
namespace :asset do
namespace :packager do
-
desc "Merge and compress assets"
task :build_all do
Synthesis::AssetPackage.build_all
@@ -18,6 +17,5 @@ namespace :asset do
task :create_yml do
Synthesis::AssetPackage.create_yml
end
-
end
end
diff --git a/test/asset_package_helper_development_test.rb b/test/asset_package_helper_development_test.rb
index 4e2b919..cb935ed 100644
--- a/test/asset_package_helper_development_test.rb
+++ b/test/asset_package_helper_development_test.rb
@@ -1,13 +1,6 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-
-ENV['RAILS_ENV'] = "development"
-require File.dirname(__FILE__) + '/../../../../config/environment'
-require 'test/unit'
-require 'rubygems'
-require 'mocha'
-
-require 'action_controller/test_process'
+require 'test/test_helper'
+Rails.env = 'development'
ActionController::Base.logger = nil
ActionController::Routing::Routes.reload rescue nil
@@ -19,8 +12,8 @@ class AssetPackageHelperDevelopmentTest < Test::Unit::TestCase
include Synthesis::AssetPackageHelper
def setup
- Synthesis::AssetPackage.asset_base_path = "#{Rails.root}/vendor/plugins/asset_packager/test/assets"
- Synthesis::AssetPackage.asset_packages_yml = YAML.load_file("#{Rails.root}/vendor/plugins/asset_packager/test/asset_packages.yml")
+ Synthesis::AssetPackage.asset_base_path = "test/assets"
+ Synthesis::AssetPackage.asset_packages_yml = YAML.load_file("test/asset_packages.yml")
Synthesis::AssetPackage.any_instance.stubs(:log)
diff --git a/test/asset_package_helper_production_test.rb b/test/asset_package_helper_production_test.rb
index 94e1362..85e5f1d 100644
--- a/test/asset_package_helper_production_test.rb
+++ b/test/asset_package_helper_production_test.rb
@@ -1,14 +1,5 @@
-$:.unshift(File.dirname(__FILE__) + '/../lib')
-
-require File.dirname(__FILE__) + '/../../../../config/environment'
-require 'test/unit'
-require 'rubygems'
-require 'mocha'
-
-require 'action_controller/test_process'
-
-ActionController::Base.logger = nil
-ActionController::Routing::Routes.reload rescue nil
+require 'test/test_helper'
+Rails.env = 'development'
class AssetPackageHelperProductionTest < Test::Unit::TestCase
include ActionController::Assertions::DomAssertions
@@ -20,8 +11,8 @@ class AssetPackageHelperProductionTest < Test::Unit::TestCase
cattr_accessor :packages_built
def setup
- Synthesis::AssetPackage.asset_base_path = "#{Rails.root}/vendor/plugins/asset_packager/test/assets"
- Synthesis::AssetPackage.asset_packages_yml = YAML.load_file("#{Rails.root}/vendor/plugins/asset_packager/test/asset_packages.yml")
+ Synthesis::AssetPackage.asset_base_path = "test/assets"
+ Synthesis::AssetPackage.asset_packages_yml = YAML.load_file("test/asset_packages.yml")
Synthesis::AssetPackage.any_instance.stubs(:log)
self.stubs(:should_merge?).returns(true)
diff --git a/test/asset_packager_test.rb b/test/asset_packager_test.rb
index dbeb52b..5645c97 100644
--- a/test/asset_packager_test.rb
+++ b/test/asset_packager_test.rb
@@ -1,13 +1,11 @@
-require File.dirname(__FILE__) + '/../../../../config/environment'
-require 'test/unit'
-require 'mocha'
+require 'test/test_helper'
class AssetPackagerTest < Test::Unit::TestCase
include Synthesis
def setup
- Synthesis::AssetPackage.asset_base_path = "#{Rails.root}/vendor/plugins/asset_packager/test/assets"
- Synthesis::AssetPackage.asset_packages_yml = YAML.load_file("#{Rails.root}/vendor/plugins/asset_packager/test/asset_packages.yml")
+ Synthesis::AssetPackage.asset_base_path = "test/assets"
+ Synthesis::AssetPackage.asset_packages_yml = YAML.load_file("test/asset_packages.yml")
Synthesis::AssetPackage.any_instance.stubs(:log)
Synthesis::AssetPackage.build_all
diff --git a/test/assets/javascripts/bar.js b/test/assets/javascripts/bar.js
index 3a65f10..ba2b734 100755
--- a/test/assets/javascripts/bar.js
+++ b/test/assets/javascripts/bar.js
@@ -1,4 +1,4 @@
-bar bar bar
-bar bar bar
-bar bar bar
-
+bar bar bar
+bar bar bar
+bar bar bar
+
diff --git a/test/assets/javascripts/foo.js b/test/assets/javascripts/foo.js
index 7e4cd9a..4a4dfba 100755
--- a/test/assets/javascripts/foo.js
+++ b/test/assets/javascripts/foo.js
@@ -1,4 +1,4 @@
-foo foo foo
-foo foo foo
-foo foo foo
-
+foo foo foo
+foo foo foo
+foo foo foo
+
diff --git a/test/assets/stylesheets/header.css b/test/assets/stylesheets/header.css
index 473902e..85b2dcc 100755
--- a/test/assets/stylesheets/header.css
+++ b/test/assets/stylesheets/header.css
@@ -1,16 +1,16 @@
-#header1 {
- background: #fff;
- color: #000;
- text-align: center;
-}
-#header2 {
- background: #fff;
- color: #000;
- text-align: center;
-}
-#header3 {
- background: #fff;
- color: #000;
- text-align: center;
-}
-
+#header1 {
+ background: #fff;
+ color: #000;
+ text-align: center;
+}
+#header2 {
+ background: #fff;
+ color: #000;
+ text-align: center;
+}
+#header3 {
+ background: #fff;
+ color: #000;
+ text-align: center;
+}
+
diff --git a/test/assets/stylesheets/screen.css b/test/assets/stylesheets/screen.css
index 0d66fd4..9564de1 100755
--- a/test/assets/stylesheets/screen.css
+++ b/test/assets/stylesheets/screen.css
@@ -1,16 +1,16 @@
-#screen1 {
- background: #fff;
- color: #000;
- text-align: center;
-}
-#screen2 {
- background: #fff;
- color: #000;
- text-align: center;
-}
-#screen3 {
- background: #fff;
- color: #000;
- text-align: center;
-}
-
+#screen1 {
+ background: #fff;
+ color: #000;
+ text-align: center;
+}
+#screen2 {
+ background: #fff;
+ color: #000;
+ text-align: center;
+}
+#screen3 {
+ background: #fff;
+ color: #000;
+ text-align: center;
+}
+
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..9ba73f8
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,37 @@
+require 'rubygems'
+
+`rm -rf test/fake_root`
+`mkdir -p test/fake_root/tmp`
+
+module Rails
+ def self.root
+ File.expand_path("test/fake_root")
+ end
+
+ def self.backtrace_cleaner
+ ActiveSupport::BacktraceCleaner.new
+ end
+
+ def self.env=(x)
+ @env = x
+ end
+
+ def self.env
+ @env
+ end
+end
+
+require 'rack'
+require 'action_view'
+require 'action_controller'
+require 'rails/backtrace_cleaner'
+
+$LOAD_PATH << 'lib'
+require 'init'
+
+require 'test/unit'
+require 'action_controller/test_process'
+require 'mocha'
+
+ActionController::Base.logger = nil
+ActionController::Routing::Routes.reload rescue nil
\ No newline at end of file