Sprocketize Prototype
This commit is contained in:
parent
d5be195340
commit
a519c02b2e
34
Rakefile
34
Rakefile
|
@ -12,17 +12,32 @@ PROTOTYPE_TMP_DIR = File.join(PROTOTYPE_TEST_UNIT_DIR, 'tmp')
|
|||
PROTOTYPE_VERSION = '1.6.0.3'
|
||||
|
||||
$:.unshift File.join(PROTOTYPE_ROOT, 'lib')
|
||||
$:.unshift File.join(PROTOTYPE_ROOT, 'vendor', 'sprockets', 'lib')
|
||||
|
||||
task :default => [:dist, :dist_helper, :package, :clean_package_source]
|
||||
|
||||
def sprocketize(path, source, destination = source)
|
||||
begin
|
||||
require "sprockets"
|
||||
rescue LoadError => e
|
||||
puts "\nYou'll need Sprockets to build Prototype. Just run:\n\n"
|
||||
puts " $ git submodule init"
|
||||
puts " $ git submodule update"
|
||||
puts "\nand you should be all set.\n\n"
|
||||
end
|
||||
|
||||
environment = Sprockets::Environment.new(File.join(PROTOTYPE_ROOT, path), [File.join(PROTOTYPE_ROOT, "src")])
|
||||
preprocessor = Sprockets::Preprocessor.new(environment)
|
||||
preprocessor.require(environment.find(source).source_file)
|
||||
|
||||
File.open(File.join(PROTOTYPE_DIST_DIR, destination), 'w+') do |dist|
|
||||
dist.write(preprocessor.output_file)
|
||||
end
|
||||
end
|
||||
|
||||
desc "Builds the distribution."
|
||||
task :dist do
|
||||
require 'protodoc'
|
||||
|
||||
File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype.js'), 'w+') do |dist|
|
||||
source = File.join(PROTOTYPE_SRC_DIR, 'prototype.js')
|
||||
dist << Protodoc::Preprocessor.new(source, :strip_documentation => true)
|
||||
end
|
||||
sprocketize("src", "prototype.js")
|
||||
end
|
||||
|
||||
namespace :doc do
|
||||
|
@ -56,12 +71,7 @@ task :doc => ['doc:build']
|
|||
|
||||
desc "Builds the updating helper."
|
||||
task :dist_helper do
|
||||
require 'protodoc'
|
||||
|
||||
File.open(File.join(PROTOTYPE_DIST_DIR, 'prototype_update_helper.js'), 'w+') do |dist|
|
||||
source = File.join(PROTOTYPE_ROOT, 'ext', 'update_helper', 'prototype_update_helper.js')
|
||||
dist << Protodoc::Preprocessor.new(source)
|
||||
end
|
||||
sprocketize("ext/update_helper", "prototype_update_helper.js")
|
||||
end
|
||||
|
||||
Rake::PackageTask.new('prototype', PROTOTYPE_VERSION) do |package|
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<%= include "update_helper.js" %>
|
||||
//= require "update_helper"
|
||||
|
||||
/* UpdateHelper for Prototype <%= PROTOTYPE_VERSION %> (c) 2008 Tobie Langel
|
||||
*
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
require 'erb'
|
||||
|
||||
class String
|
||||
def lines
|
||||
split $/
|
||||
end
|
||||
|
||||
def strip_whitespace_at_line_ends
|
||||
lines.map {|line| line.gsub(/\s+$/, '')} * $/
|
||||
end
|
||||
|
||||
def strip_pdoc_comments
|
||||
gsub %r{\s*/\*\*.*?\*\*/}m, "\n"
|
||||
end
|
||||
end
|
||||
|
||||
module Protodoc
|
||||
module Environment
|
||||
def include(*filenames)
|
||||
filenames.map do |filename|
|
||||
Preprocessor.new(expand_path(filename), @options).result
|
||||
end.join("\n")
|
||||
end
|
||||
end
|
||||
|
||||
class Preprocessor
|
||||
include Environment
|
||||
|
||||
def initialize(filename, options = { })
|
||||
filename = File.join(filename.split('/'))
|
||||
@filename = File.expand_path(filename)
|
||||
@template = ERB.new(IO.read(@filename), nil, '%')
|
||||
@options = options
|
||||
end
|
||||
|
||||
def expand_path(filename)
|
||||
File.join(File.dirname(@filename), filename)
|
||||
end
|
||||
|
||||
def result
|
||||
result = @template.result(binding)
|
||||
result = result.strip_whitespace_at_line_ends
|
||||
result = result.strip_pdoc_comments if @options[:strip_documentation]
|
||||
result
|
||||
end
|
||||
|
||||
alias_method :to_s, :result
|
||||
end
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
print Protodoc::Preprocessor.new(ARGV.first)
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
/* Prototype JavaScript framework, version <%= PROTOTYPE_VERSION %>
|
||||
* (c) 2005-2008 Sam Stephenson
|
||||
*
|
||||
* Prototype is freely distributable under the terms of an MIT-style license.
|
||||
* For details, see the Prototype web site: http://www.prototypejs.org/
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
|
@ -0,0 +1,7 @@
|
|||
//= require "ajax/ajax"
|
||||
//= require "ajax/responders"
|
||||
//= require "ajax/base"
|
||||
//= require "ajax/request"
|
||||
//= require "ajax/response"
|
||||
//= require "ajax/updater"
|
||||
//= require "ajax/periodical_updater"
|
|
@ -0,0 +1 @@
|
|||
PROTOTYPE_VERSION: 1.6.0.3
|
|
@ -0,0 +1,6 @@
|
|||
//= require "dom/dom"
|
||||
//= require "dom/selector"
|
||||
//= require "dom/form"
|
||||
//= require "dom/event"
|
||||
|
||||
Element.addMethods();
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* == lang ==
|
||||
* Language extensions.
|
||||
**/
|
||||
|
||||
var Abstract = { };
|
||||
|
||||
/** section: lang
|
||||
* Try
|
||||
**/
|
||||
|
||||
/**
|
||||
* Try.these(function...) -> ?
|
||||
* - function (Function): A function that may throw an exception.
|
||||
* Accepts an arbitrary number of functions and returns the result of the
|
||||
* first one that doesn't throw an error.
|
||||
**/
|
||||
var Try = {
|
||||
these: function() {
|
||||
var returnValue;
|
||||
|
||||
for (var i = 0, length = arguments.length; i < length; i++) {
|
||||
var lambda = arguments[i];
|
||||
try {
|
||||
returnValue = lambda();
|
||||
break;
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
};
|
||||
|
||||
//= require "lang/class"
|
||||
//= require "lang/object"
|
||||
//= require "lang/function"
|
||||
//= require "lang/date"
|
||||
//= require "lang/regexp"
|
||||
//= require "lang/periodical_executer"
|
||||
//= require "lang/string"
|
||||
//= require "lang/template"
|
||||
//= require "lang/enumerable"
|
||||
//= require "lang/array"
|
||||
//= require "lang/hash"
|
||||
//= require "lang/number"
|
||||
//= require "lang/range"
|
|
@ -1,5 +1,11 @@
|
|||
<%= include 'HEADER' %>
|
||||
|
||||
/* Prototype JavaScript framework, version <%= PROTOTYPE_VERSION %>
|
||||
* (c) 2005-2009 Sam Stephenson
|
||||
*
|
||||
* Prototype is freely distributable under the terms of an MIT-style license.
|
||||
* For details, see the Prototype web site: http://www.prototypejs.org/
|
||||
*
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
var Prototype = {
|
||||
Version: '<%= PROTOTYPE_VERSION %>',
|
||||
|
||||
|
@ -47,55 +53,8 @@ var Prototype = {
|
|||
if (Prototype.Browser.MobileSafari)
|
||||
Prototype.BrowserFeatures.SpecificElementExtensions = false;
|
||||
|
||||
var Abstract = { };
|
||||
//= require "lang"
|
||||
//= require "ajax"
|
||||
//= require "dom"
|
||||
|
||||
/**
|
||||
* == lang ==
|
||||
* Language extensions.
|
||||
**/
|
||||
|
||||
/** section: lang
|
||||
* Try
|
||||
**/
|
||||
|
||||
/**
|
||||
* Try.these(function...) -> ?
|
||||
* - function (Function): A function that may throw an exception.
|
||||
* Accepts an arbitrary number of functions and returns the result of the
|
||||
* first one that doesn't throw an error.
|
||||
**/
|
||||
var Try = {
|
||||
these: function() {
|
||||
var returnValue;
|
||||
|
||||
for (var i = 0, length = arguments.length; i < length; i++) {
|
||||
var lambda = arguments[i];
|
||||
try {
|
||||
returnValue = lambda();
|
||||
break;
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
};
|
||||
|
||||
<%= include 'lang/class.js', 'lang/object.js', 'lang/function.js' %>
|
||||
|
||||
<%= include 'lang/date.js', 'lang/regexp.js', 'lang/periodical_executer.js' %>
|
||||
|
||||
<%= include 'lang/string.js', 'lang/template.js' %>
|
||||
|
||||
<%= include 'lang/enumerable.js', 'lang/array.js', 'lang/hash.js' %>
|
||||
|
||||
<%= include 'lang/number.js', 'lang/range.js' %>
|
||||
|
||||
<%= include 'ajax/ajax.js', 'ajax/responders.js', 'ajax/base.js', 'ajax/request.js', 'ajax/response.js' %>
|
||||
|
||||
<%= include 'ajax/updater.js', 'ajax/periodical_updater.js' %>
|
||||
|
||||
<%= include 'dom/dom.js', 'dom/selector.js', 'dom/form.js', 'dom/event.js' %>
|
||||
|
||||
<%= include 'deprecated.js' %>
|
||||
|
||||
Element.addMethods();
|
||||
//= require "deprecated"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit bf472927407df4318705259ef1790718fc96eddc
|
||||
Subproject commit 05108e6ca76352b8954b066cf041865415fd6bf9
|
Loading…
Reference in New Issue