Module: VagrantPlugins::StartCloud

Defined in:
lib/vagrant-startcloud.rb,
lib/vagrant-startcloud/action.rb,
lib/vagrant-startcloud/config.rb,
lib/vagrant-startcloud/errors.rb,
lib/vagrant-startcloud/plugin.rb,
lib/vagrant-startcloud/command.rb,
lib/vagrant-startcloud/version.rb,
lib/vagrant-startcloud/provisioner.rb,
lib/vagrant-startcloud/config_builder.rb,
lib/vagrant-startcloud/action/is_created.rb,
lib/vagrant-startcloud/action/load_config.rb,
lib/vagrant-startcloud/action/is_virtualbox.rb,
lib/vagrant-startcloud/action/configure_disks.rb,
lib/vagrant-startcloud/action/configure_networks.rb,
lib/vagrant-startcloud/action/configure_providers.rb,
lib/vagrant-startcloud/action/configure_provisioners.rb,
lib/vagrant-startcloud/action/configure_shared_folders.rb

Defined Under Namespace

Modules: Action, Errors Classes: Command, Config, ConfigBuilder, Plugin, Provisioner

Constant Summary collapse

VERSION =
'0.1.3'

Class Method Summary collapse

Class Method Details

.init!Object

This initializes the plugin.



134
135
136
137
138
# File 'lib/vagrant-startcloud.rb', line 134

def self.init!
  init_i18n
  init_logging
  setup_logging
end

.init_i18nObject

This initializes the internationalization strings.



78
79
80
81
82
83
84
85
86
# File 'lib/vagrant-startcloud.rb', line 78

def self.init_i18n
  I18n.load_path << File.expand_path('locales/en.yml', source_root)
  I18n.reload!
rescue Errno::ENOENT
  # During testing, the locale file might not be in the expected location
  return if ENV['VAGRANT_ENV'] == 'test'

  raise
end

.init_loggingObject

This initializes the logging system.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/vagrant-startcloud.rb', line 89

def self.init_logging
  require 'log4r'

  level = nil
  begin
    level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
  rescue NameError
    level = Log4r::INFO
  end

  logger = Log4r::Logger.new('vagrant_startcloud')
  logger.outputters = Log4r::Outputter.stderr
  logger.level = level

  logger
end

.setup_loggingObject

This sets up our log level to be whatever VAGRANT_LOG is.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/vagrant-startcloud.rb', line 107

def self.setup_logging
  level = nil
  begin
    level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
  rescue NameError
    # This means that the logging constant wasn't found,
    # which is fine, we just keep `level` as `nil`. But
    # we tell the user.
    level = nil
  end

  # Some constants, such as "true" resolve to booleans, so the
  # above error checking doesn't catch it. This will check to make
  # sure that the log level is an integer, as Log4r requires.
  level = nil unless level.is_a?(Integer)

  # Set the logging level on all "vagrant" namespaced
  # logs as long as we have a valid level.
  return unless level

  logger = Log4r::Logger.new('vagrant_startcloud')
  logger.outputters = Log4r::Outputter.stderr
  logger.level = level
  logger
end

.source_rootObject

This returns the path to the source of this plugin.



73
74
75
# File 'lib/vagrant-startcloud.rb', line 73

def self.source_root
  @source_root ||= Pathname.new(File.expand_path('..', __dir__))
end