diff --git a/.gitmodules b/.gitmodules index 51c3adf..ee65a40 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,9 +11,10 @@ path = vendor/sprockets url = git://github.com/sstephenson/sprockets.git -[submodule "vendor/sizzle/sizzle"] - path = vendor/sizzle/sizzle - url = git://github.com/jeresig/sizzle.git -[submodule "vendor/nwmatcher/nwmatcher"] - path = vendor/nwmatcher/nwmatcher + +[submodule "vendor/nwmatcher/repository"] + path = vendor/nwmatcher/repository url = git://github.com/dperini/nwmatcher.git +[submodule "vendor/sizzle/repository"] + path = vendor/sizzle/repository + url = git://github.com/jeresig/sizzle.git diff --git a/Rakefile b/Rakefile index 3aa2c18..31e772e 100755 --- a/Rakefile +++ b/Rakefile @@ -9,13 +9,13 @@ module PrototypeHelper DOC_DIR = File.join(ROOT_DIR, 'doc') TEMPLATES_DIR = File.join(ROOT_DIR, 'templates') PKG_DIR = File.join(ROOT_DIR, 'pkg') - SIZZLE_DIR = File.join(ROOT_DIR, 'vendor', 'sizzle') TEST_DIR = File.join(ROOT_DIR, 'test') TEST_UNIT_DIR = File.join(TEST_DIR, 'unit') TMP_DIR = File.join(TEST_UNIT_DIR, 'tmp') VERSION = YAML.load(IO.read(File.join(SRC_DIR, 'constants.yml')))['PROTOTYPE_VERSION'] - - %w[sprockets pdoc unittest_js caja_builder sizzle].each do |name| + DEFAULT_SELECTOR_ENGINE = 'sizzle' + + %w[sprockets pdoc unittest_js caja_builder].each do |name| $:.unshift File.join(PrototypeHelper::ROOT_DIR, 'vendor', name, 'lib') end @@ -39,11 +39,10 @@ module PrototypeHelper def self.sprocketize(path, source, destination = nil, strip_comments = true) require_sprockets - require_sizzle - require_nwmatcher + get_selector_engine(selector) secretary = Sprockets::Secretary.new( :root => File.join(ROOT_DIR, path), - :load_path => self.load_path, + :load_path => [SRC_DIR, selector_path], :source_files => [source], :strip_comments => strip_comments ) @@ -52,16 +51,12 @@ module PrototypeHelper secretary.concatenation.save_to(destination) end - def self.load_path - selector = ENV['SELECTOR_ENGINE'] || 'sizzle' - selector_path = File.join(ROOT_DIR, 'vendor', selector) - if File.exists?(selector_path) - [SRC_DIR, selector_path] - else - puts "\nYou seem to be missing vendor/#{selector}." - puts "Built Prototype using Sizzle instead.\n\n" - [SRC_DIR, SIZZLE_DIR] - end + def self.selector + ENV['SELECTOR_ENGINE'] || DEFAULT_SELECTOR_ENGINE + end + + def self.selector_path + File.join(ROOT_DIR, 'vendor', selector) end def self.build_doc_for(file) @@ -95,15 +90,14 @@ module PrototypeHelper require_submodule('CajaBuilder', 'caja_builder') end - def self.require_sizzle - if !File.exists?(File.join(SIZZLE_DIR, 'sizzle', 'sizzle.js')) - exit unless get_submodule("Sizzle", "sizzle/sizzle") - end - end - - def self.require_nwmatcher - if !File.exists?(File.join(ROOT_DIR, 'vendor', 'nwmatcher', 'nwmatcher', 'src', 'nwmatcher.js')) - exit unless get_submodule("NWMmatcher", "nwmatcher/nwmatcher") + def self.get_selector_engine(name) + file = File.join(ROOT_DIR, 'vendor', name, 'repository') + unless File.exists?(file) + get_submodule('the required selector engine', "#{name}/repository") + unless File.exists?(file) + puts "The selector engine you required isn't available at vendor/#{name}.\n\n" + exit + end end end @@ -113,7 +107,6 @@ module PrototypeHelper Kernel.system("git submodule init") return true if Kernel.system("git submodule update vendor/#{path}") - # If we got this far, something went wrong. puts "\nLooks like it didn't work. Try it manually:\n\n" puts " $ git submodule init" diff --git a/vendor/legacy/legacy.js b/vendor/legacy/repository/legacy.js similarity index 100% rename from vendor/legacy/legacy.js rename to vendor/legacy/repository/legacy.js diff --git a/vendor/legacy/selector_engine.js b/vendor/legacy/selector_engine.js index 0ad6a86..cff9dab 100644 --- a/vendor/legacy/selector_engine.js +++ b/vendor/legacy/selector_engine.js @@ -1,4 +1,4 @@ -//= require "legacy" +//= require "repository/legacy" Prototype.Selector = (function(Legacy) { function select(selector, scope) { diff --git a/vendor/nwmatcher/nwmatcher b/vendor/nwmatcher/repository similarity index 100% rename from vendor/nwmatcher/nwmatcher rename to vendor/nwmatcher/repository diff --git a/vendor/nwmatcher/selector_engine.js b/vendor/nwmatcher/selector_engine.js index fea4a02..9639ae6 100644 --- a/vendor/nwmatcher/selector_engine.js +++ b/vendor/nwmatcher/selector_engine.js @@ -1,5 +1,5 @@ Prototype._original_nw = window.NW; -//= require "nwmatcher/src/nwmatcher" +//= require "repository/src/nwmatcher" Prototype.NW = window.NW; // Restore globals. diff --git a/vendor/sizzle/sizzle b/vendor/sizzle/repository similarity index 100% rename from vendor/sizzle/sizzle rename to vendor/sizzle/repository diff --git a/vendor/sizzle/selector_engine.js b/vendor/sizzle/selector_engine.js index d7aeeda..bed246f 100644 --- a/vendor/sizzle/selector_engine.js +++ b/vendor/sizzle/selector_engine.js @@ -1,5 +1,5 @@ Prototype._original_sizzle = window.Sizzle; -//= require "sizzle/sizzle" +//= require "repository/sizzle" Prototype.Sizzle = window.Sizzle; // Restore globals.