Module: Capistrano::Configuration::Loading

Included in:
Capistrano::Configuration
Defined in:
lib/capistrano/configuration/loading.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#load_pathsObject (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)
  options = args.last.is_a?(Hash) ? args.pop : {}

  if block
    raise ArgumentError, "loading a block requires 0 arguments" unless options.empty? && args.empty?
    load(:proc => block)

  elsif args.any?
    args.each { |arg| load options.merge(:file => arg) }

  elsif options[:file]
    load_from_file(options[:file], options[:name])

  elsif options[:string]
    instance_eval(options[:string], options[:name] || "<eval>")

  elsif options[:proc]
    instance_eval(&options[: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