This file contains hidden or 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
| module Kernel | |
| alias_method :old_require, :require | |
| alias_method :old_load, :load | |
| alias_method :old_autoload, :autoload | |
| def require(path) | |
| p "require: #{path}" | |
| old_require(path) | |
| end |
This file contains hidden or 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
| #!/usr/bin/ruby | |
| require 'cgi' | |
| __DIR__ = File.dirname(__FILE__) | |
| HOME = 'HomePage' | |
| LINK = 'wiki.cgi?name=%s' | |
| query = CGI.new 'html4' |
This file contains hidden or 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
| class S < Module | |
| def initialize | |
| extend self | |
| end | |
| def __binding__ | |
| @binding ||= binding | |
| end |
This file contains hidden or 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
| class String | |
| # Returns short abstract of long strings; not exceeding +range+ | |
| # characters. If range is an integer then the minimum is 20% | |
| # of the maximum. The string is chopped at the nearest word | |
| # if possible, and appended by +ellipsis+, which defaults | |
| # to '...'. | |
| # | |
| # CREDIT: George Moschovitis, Trans |
This file contains hidden or 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
| # = Exception-based Event Hooks | |
| # | |
| # Provides an Event Hooks system designed | |
| # on top of Ruby's built-in Exception system. | |
| # | |
| # def dothis2 | |
| # puts 'pre' | |
| # hook :quitit | |
| # puts 'post' | |
| # end |
This file contains hidden or 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
| class VersionResolver | |
| attr :dependencies | |
| attr :versions | |
| attr :resolution | |
| # dependencies - Runtime dependencies in the form of a list of | |
| # [gemname, constraint1, constraint2, ...] | |
| def initialize(dependencies) | |
| @dependencies = dependencies |
This file contains hidden or 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
| # Function is an experiment in unifying Method, UnboundMethod and Proc. | |
| class Function | |
| # | |
| # MODES block Proc.new ? lambda | |
| # +---------------------------------- | |
| # @pcheck | false true false true | |
| # @rlocal | false false true true | |
| # |
This file contains hidden or 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
| # Simple hook/signal system. | |
| # | |
| # TODO: hooks should be an inheritor | |
| # | |
| module Hook | |
| def self.append_features(base) | |
| base.extend self | |
| end |
This file contains hidden or 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
| # Create temporary extensions. | |
| # Based on original code (c)2005 Nobuyoshi Nakada | |
| # = Beahvior | |
| # | |
| # Behavior class is used to encapsulates a behavior. | |
| # | |
| # nil.behaving(:to_nil) do | |
| # "1" | |
| # end |
This file contains hidden or 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
| # Include Open into a class and it automatically becomes proxied. | |
| require 'meta' | |
| module Open | |
| def self.included( base ) | |
| ( class << base ; self ; end ).class_eval { | |
| alias_method :create, :new | |
| define_method( :new ) { |*args| | |
| OpenProxy.new( base, *args ) |