Module: Rubber

Extended by:
MonitorMixin
Defined in:
lib/rubber.rb,
lib/rubber.rb,
lib/rubber/cli.rb,
lib/rubber/dns.rb,
lib/rubber/tag.rb,
lib/rubber/util.rb,
lib/rubber/cloud.rb,
lib/rubber/dns/aws.rb,
lib/rubber/railtie.rb,
lib/rubber/version.rb,
lib/rubber/dns/base.rb,
lib/rubber/instance.rb,
lib/rubber/cloud/aws.rb,
lib/rubber/cloud/fog.rb,
lib/rubber/generator.rb,
lib/rubber/platforms.rb,
lib/rubber/cloud/base.rb,
lib/rubber/dns/dyndns.rb,
lib/rubber/dns/zerigo.rb,
lib/rubber/encryption.rb,
lib/rubber/dns/nettica.rb,
lib/rubber/environment.rb,
lib/rubber/cloud/aws/vpc.rb,
lib/rubber/cloud/generic.rb,
lib/rubber/cloud/vagrant.rb,
lib/rubber/cloud/vsphere.rb,
lib/rubber/commands/cron.rb,
lib/rubber/commands/util.rb,
lib/rubber/configuration.rb,
lib/rubber/cloud/aws/base.rb,
lib/rubber/commands/config.rb,
lib/rubber/cloud/aws/classic.rb,
lib/rubber/cloud/fog_storage.rb,
lib/rubber/thread_safe_proxy.rb,
lib/rubber/commands/vulcanize.rb,
lib/rubber/cloud/digital_ocean.rb,
lib/rubber/cloud/aws/table_store.rb

Defined Under Namespace

Modules: Cloud, Commands, Configuration, Dns, Encryption, Platforms, Tag, Util Classes: CLI, Railtie, ThreadSafeProxy

Constant Summary collapse

VERSION =
'3.2.2'.freeze

Class Method Summary collapse

Class Method Details

.cloud(capistrano = nil) ⇒ Object



78
79
80
81
82
# File 'lib/rubber.rb', line 78

def self.cloud(capistrano = nil)
  # sharing a Net::HTTP instance across threads doesn't work, so
  # create a new instance per thread
  Rubber::ThreadSafeProxy.new { Rubber::Cloud::get_provider(self.config.cloud_provider || "aws", self.config, capistrano) }
end

.configObject



58
59
60
61
62
63
64
65
66
# File 'lib/rubber.rb', line 58

def self.config
  unless @config
    synchronize do
      @config ||= Rubber::Configuration.rubber_env
    end
  end

  @config
end

.envObject



46
47
48
# File 'lib/rubber.rb', line 46

def self.env
  @@env
end

.initialize(project_root, project_env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rubber.rb', line 8

def self.initialize(project_root, project_env)
  return if defined?(RUBBER_ROOT) && defined?(RUBBER_ENV)

  @config = nil
  @instances = nil

  @@root = project_root
  @@env = project_env
  Object.const_set(:RUBBER_ENV, project_env)
  Object.const_set(:RUBBER_ROOT, File.expand_path(project_root))

  if ! defined?(Rails) && ! Rubber::Util::is_bundler?
    # pull in basic rails env.  rubber only needs RAILS_ROOT and RAILS_ENV.
    # We actually do NOT want the entire rails environment because it
    # complicates bootstrap (i.e. can't run config to create db because full
    # rails env needs db to exist as some plugin accesses model or something)
    rails_boot_file = File.join(Rubber.root, 'config', 'boot.rb')
    require(rails_boot_file) if File.exists? rails_boot_file
  end

  if defined?(Rails.logger) && Rails.logger
    @@logger = Rails.logger
  else
    @@logger = Logger.new($stdout)
    @@logger.level = Logger::INFO
    @@logger.formatter = lambda {|severity, time, progname, msg| "Rubber[%s]: %s\n" % [severity, msg.to_s.lstrip]}
  end

  # conveniences for backwards compatibility with old names
  Object.const_set(:RUBBER_CONFIG, self.config)
  Object.const_set(:RUBBER_INSTANCES, self.instances)

end

.instancesObject



68
69
70
71
72
73
74
75
76
# File 'lib/rubber.rb', line 68

def self.instances
  unless @instances
    synchronize do
      @instances ||= Rubber::Configuration.rubber_instances
    end
  end

  @instances
end

.loggerObject



54
55
56
# File 'lib/rubber.rb', line 54

def self.logger
  @@logger
end

.resetObject



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rubber.rb', line 84

def self.reset
  [:RUBBER_ENV, :RUBBER_ROOT, :RUBBER_CONFIG, :RUBBER_INSTANCES].each do |const|
    Object.send(:remove_const, const) if Object.constants.include?(const)
  end

  Rubber::Configuration.reset

  synchronize do
    @config = nil
  end
end

.rootObject



42
43
44
# File 'lib/rubber.rb', line 42

def self.root
  @@root
end

.versionObject



50
51
52
# File 'lib/rubber.rb', line 50

def self.version
  Rubber::VERSION
end