Module: Capistrano::Configuration::Loading
- Included in:
- Capistrano::Configuration
- Defined in:
- lib/capistrano/configuration/loading.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#load_paths ⇒ Object
readonly
The load paths used for locating recipe files.
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#load(*args, &block) ⇒ Object
Load a configuration file or string into this configuration.
-
#require(*args) ⇒ Object
Require another file.
Instance Attribute Details
#load_paths ⇒ Object (readonly)
The load paths used for locating recipe files.
31 32 33 |
# File 'lib/capistrano/configuration/loading.rb', line 31 def load_paths @load_paths end |
Class Method Details
.included(base) ⇒ Object
:nodoc:
4 5 6 7 8 |
# File 'lib/capistrano/configuration/loading.rb', line 4 def self.included(base) #:nodoc: base.send :alias_method, :initialize_without_loading, :initialize base.send :alias_method, :initialize, :initialize_with_loading base.extend ClassMethods end |
Instance Method Details
#load(*args, &block) ⇒ Object
Load a configuration file or string into this configuration.
Usage:
load("recipe"):
Look for and load the contents of 'recipe.rb' into this
configuration.
load(:file => "recipe"):
same as above
load(:string => "set :scm, :subversion"):
Load the given string as a configuration specification.
load { ... }
Load the block in the context of the configuration.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/capistrano/configuration/loading.rb', line 55 def load(*args, &block) = args.last.is_a?(Hash) ? args.pop : {} if block raise ArgumentError, "loading a block requires 0 arguments" unless .empty? && args.empty? load(:proc => block) elsif args.any? args.each { |arg| load .merge(:file => arg) } elsif [:file] load_from_file([:file], [:name]) elsif [:string] instance_eval([:string], [:name] || "<eval>") elsif [:proc] instance_eval(&[:proc]) else raise ArgumentError, "don't know how to load #{options.inspect}" end end |
#require(*args) ⇒ Object
Require another file. This is identical to the standard require method, with the exception that it sets the receiver as the “current” configuration so that third-party task bundles can include themselves relative to that configuration.
83 84 85 86 87 88 89 |
# File 'lib/capistrano/configuration/loading.rb', line 83 def require(*args) #:nodoc: original, self.class.instance = self.class.instance, self super ensure # restore the original, so that require's can be nested self.class.instance = original end |