Created
August 10, 2008 20:28
-
-
Save simonjefford/4763 to your computer and use it in GitHub Desktop.
A patch to merb-core and merb-freezer that adds functionality like rails config.gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib/merb-core/bootloader.rb | 6 +----- | |
lib/merb-core/config.rb | 7 +++++++ | |
lib/merb-core/core_ext/kernel.rb | 5 +++-- | |
spec/private/core_ext/kernel_spec.rb | 2 +- | |
4 files changed, 12 insertions(+), 8 deletions(-) | |
diff --git a/lib/merb-core/bootloader.rb b/lib/merb-core/bootloader.rb | |
index 5853c1a..585cfd0 100644 | |
--- a/lib/merb-core/bootloader.rb | |
+++ b/lib/merb-core/bootloader.rb | |
@@ -241,10 +241,6 @@ class Merb::BootLoader::BuildFramework < Merb::BootLoader | |
end | |
class Merb::BootLoader::Dependencies < Merb::BootLoader | |
- | |
- cattr_accessor :dependencies | |
- self.dependencies = [] | |
- | |
# Load the init_file specified in Merb::Config or if not specified, the | |
# init.rb file from the Merb configuration directory, and any environment | |
# files, which register the list of necessary dependencies and any | |
@@ -265,7 +261,7 @@ class Merb::BootLoader::Dependencies < Merb::BootLoader | |
end | |
def self.load_dependencies | |
- dependencies.each { |name, ver| Kernel.load_dependency(name, *ver) } | |
+ Merb::Config.dependencies.each { |name, ver| Kernel.load_dependency(name, *ver) } | |
end | |
def self.enable_json_gem | |
diff --git a/lib/merb-core/config.rb b/lib/merb-core/config.rb | |
index 41ef3f1..fb285ca 100644 | |
--- a/lib/merb-core/config.rb | |
+++ b/lib/merb-core/config.rb | |
@@ -5,6 +5,9 @@ module Merb | |
class Config | |
+ cattr_accessor :dependencies | |
+ self.dependencies = [] | |
+ | |
class << self | |
# ==== Returns | |
@@ -28,6 +31,10 @@ module Merb | |
} | |
end | |
+ def add_dependency(name, *ver) | |
+ dependencies << [name, ver] | |
+ end | |
+ | |
# Yields the configuration. | |
# | |
# ==== Block parameters | |
diff --git a/lib/merb-core/core_ext/kernel.rb b/lib/merb-core/core_ext/kernel.rb | |
index bfca2e3..e67d3c9 100644 | |
--- a/lib/merb-core/core_ext/kernel.rb | |
+++ b/lib/merb-core/core_ext/kernel.rb | |
@@ -17,9 +17,10 @@ module Kernel | |
def dependency(name, *ver) | |
if Merb::BootLoader.finished?(Merb::BootLoader::Dependencies) | |
load_dependency(name, *ver) | |
- else | |
- Merb::BootLoader::Dependencies.dependencies << [name, ver] | |
end | |
+ | |
+ Merb::Config.add_dependency(name, *ver) | |
+ | |
[name, ver] | |
end | |
diff --git a/spec/private/core_ext/kernel_spec.rb b/spec/private/core_ext/kernel_spec.rb | |
index 3df9834..ef1acde 100644 | |
--- a/spec/private/core_ext/kernel_spec.rb | |
+++ b/spec/private/core_ext/kernel_spec.rb | |
@@ -61,7 +61,7 @@ describe "Kernel#load_dependency" do | |
rescue LoadError => e | |
# some people may have no RSpec gem | |
end | |
- }.should_not change(Merb::BootLoader::Dependencies.dependencies, :size) | |
+ }.should_not change(Merb::Config.dependencies, :size) | |
end | |
it "DOES NOT defer load to boot loader run and requires it right away" do | |
-- | |
1.5.6.2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From cd91e10bb342095750ac5c75670c369c645068e8 Mon Sep 17 00:00:00 2001 | |
From: Simon Jefford <[email protected]> | |
Date: Sun, 10 Aug 2008 21:24:36 +0100 | |
Subject: [PATCH] Added task to freeze all the configured dependencies | |
--- | |
merb-freezer/lib/merb-freezer/merbtasks.rb | 6 ++++++ | |
1 files changed, 6 insertions(+), 0 deletions(-) | |
diff --git a/merb-freezer/lib/merb-freezer/merbtasks.rb b/merb-freezer/lib/merb-freezer/merbtasks.rb | |
index 413f04c..7e9b05d 100644 | |
--- a/merb-freezer/lib/merb-freezer/merbtasks.rb | |
+++ b/merb-freezer/lib/merb-freezer/merbtasks.rb | |
@@ -25,4 +25,10 @@ namespace :freeze do | |
end | |
end | |
+ desc "freeze all dependencies (as enumerated in your config/init.rb file)" | |
+ task :dependencies do | |
+ Merb::Config.dependencies.each do |name, vers| | |
+ Freezer.freeze(name, ENV["UPDATE"], "rubygems") | |
+ end | |
+ end | |
end | |
\ No newline at end of file | |
-- | |
1.5.6.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment