Next step in upgrading Tracks to Rails 2.2. Some highlights:

* Ran rake rails:update
* Added old actionwebservice framework
* Updated RSpec and RSpec-Rails
* Removed asset_packager plugin (not compatible, Scott no longer maintaining), and replaced with bundle_fu. See the bundle_fu README for more info.
* Hacks to UJS and ARTS plugins, which are no longer supported. Probably should move off both UJS and RJS.
* Hack to flashobject_helper plugin (upgrade to Rails 2.2-compatible version if/when it comes out.)
* Hack to skinny-spec plugin, for Rails 2.2 compatibility. Should check for official release.
* Hacks to resource_feeder plugin, for Rails 2.2 compatibility. Should check for official release (not likely) or move off it.
* Addressed some deprecation warnings. More to come.
* My mobile mime type hackery is no longer necessary with new Rails features. Yay!
* Updated environment.rb.tmpl with changes

TODO:
* Restore view specs marked pending
* Fix failing integration tests.
* Try selenium tests.
* Investigate OpenID support.
* Address deprecation warnings.
* Consider moving parts of environment.rb to initializers
* Address annoying config.gem warning about highline gem
This commit is contained in:
Luke Melia 2008-11-29 12:00:06 -05:00
parent 6d11ebd1b0
commit 35ae5fc431
394 changed files with 15184 additions and 9936 deletions

View file

@ -0,0 +1,42 @@
class BundleFu::CSSUrlRewriter
class << self
# rewrites a relative path to an absolute path, removing excess "../" and "./"
# rewrite_relative_path("stylesheets/default/global.css", "../image.gif") => "/stylesheets/image.gif"
def rewrite_relative_path(source_filename, relative_url)
relative_url = relative_url.to_s.strip.gsub(/["']/, "")
return relative_url if relative_url.first == "/" || relative_url.include?("://")
elements = File.join("/", File.dirname(source_filename)).gsub(/\/+/, '/').split("/")
elements += relative_url.gsub(/\/+/, '/').split("/")
index = 0
while(elements[index])
if (elements[index]==".")
elements.delete_at(index)
elsif (elements[index]=="..")
next if index==0
index-=1
2.times { elements.delete_at(index)}
else
index+=1
end
end
elements * "/"
end
# rewrite the URL reference paths
# url(../../../images/active_scaffold/default/add.gif);
# url(/stylesheets/active_scaffold/default/../../../images/active_scaffold/default/add.gif);
# url(/stylesheets/active_scaffold/../../images/active_scaffold/default/add.gif);
# url(/stylesheets/../images/active_scaffold/default/add.gif);
# url('/images/active_scaffold/default/add.gif');
def rewrite_urls(filename, content)
content.gsub!(/url *\(([^\)]+)\)/) { "url(#{rewrite_relative_path(filename, $1)})" }
content
end
end
end

View file

@ -0,0 +1,64 @@
require 'fileutils.rb'
class BundleFu::FileList
attr_accessor :filelist
def initialize(filenames=[])
self.filelist = []
self.add_files(filenames)
end
def initialize_copy(from)
self.filelist = from.filelist.collect{|entry| entry.clone}
end
def filenames
self.filelist.collect{ |entry| entry[0] }
end
def update_mtimes
old_filenames = self.filenames
self.filelist = []
# readding the files will effectively update the mtimes
self.add_files(old_filenames)
self
end
def self.open(filename)
return nil unless File.exists?(filename)
b = new
File.open(filename, "rb") {|f|
b.filelist = Marshal.load(f) # rescue [])
}
b
rescue
nil
end
# compares to see if one file list is exactly the same as another
def ==(compare)
return false if compare.nil?
throw "cant compare with #{compare.class}" unless self.class===compare
self.filelist == compare.filelist
end
def add_files(filenames=[])
filenames.each{|filename|
self.filelist << [ extract_filename_from_url(filename), (File.mtime(abs_location(filename)).to_i rescue 0) ]
}
end
def extract_filename_from_url(url)
url.gsub(/^https?:\/\/[^\/]+/i, '')
end
def save_as(filename)
File.open(filename, "wb") {|f| f.puts Marshal.dump(self.filelist)}
end
protected
def abs_location(filename)
File.join(RAILS_ROOT, "public", filename)
end
end

View file

@ -0,0 +1,217 @@
#!/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.
require 'stringio'
class BundleFu::JSMinimizer
attr_accessor :input
attr_accessor :output
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] > 126)
end
# get -- return the next character from input. 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
def self.minimize_content(content)
js_minimizer = new
js_minimizer.input = StringIO.new(content)
js_minimizer.output = StringIO.new
js_minimizer.jsmin
js_minimizer.output.string
end
end