Module: MelissaData

Includes:
Constants
Defined in:
lib/melissadata/errors.rb,
lib/melissadata/cli.rb,
lib/melissadata/env.rb,
lib/melissadata/client.rb,
lib/melissadata/server.rb,
lib/melissadata/command.rb,
lib/melissadata/version.rb,
lib/melissadata/constants.rb,
lib/melissadata/constants.rb,
lib/melissadata/melissadata.rb,
lib/melissadata/command/base.rb,
lib/melissadata/native_object.rb,
lib/melissadata/vagrant_plugin.rb,
lib/melissadata/command/compile.rb,
lib/melissadata/command/helpers.rb,
lib/melissadata/command/package.rb

Overview

This file contains all of the internal errors in MelissaData’s core commands, actions, etc.

Defined Under Namespace

Modules: Client, Command, Constants, Errors, NativeObject, Server, VagrantPlugin Classes: CLI, Env

Constant Summary collapse

VERSION =
'0.1.5'
ENVIRONMENTS =
[:development, :production, :test, :staging]

Constants included from Constants

Constants::DEFAULT_SOCKET_FILE, Constants::DEFAULT_TCP_ADDRESS, Constants::DEFAULT_TCP_PORT, Constants::DEFAULT_VAGRANT_TCP_PORT

Class Method Summary collapse

Class Method Details

.clientObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/melissadata/melissadata.rb', line 31

def client
  if MelissaData::Client::Unix.available?
    MelissaData::Client::Unix.new

  elsif MelissaData::Client::TCP.available?
    MelissaData::Client::TCP.new

  elsif MelissaData::Client::Vagrant.available?
    MelissaData::Client::Vagrant.new

  else
    raise 'No client connection available'
  end
end

.dev?Boolean

Determines if we are in the development environment

Returns:

  • (Boolean)

    true if current environment is development, false otherwise



82
83
84
# File 'lib/melissadata/melissadata.rb', line 82

def dev?
  env == :development
end

.envString

Retrieves the current melissadata environment

Returns:

  • (String)

    the current environment



51
52
53
# File 'lib/melissadata/melissadata.rb', line 51

def env
  @env or fail "environment has not been set"
end

.env=(e) ⇒ Object

Sets the current melissadata environment

Parameters:

  • env (String|Symbol)

    the environment symbol of [dev | development | prod | production | test]



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/melissadata/melissadata.rb', line 58

def env=(e)
  es = case(e.to_sym)
  when :dev  then :development
  when :prod then :production
  else e.to_sym
  end

  if ENVIRONMENTS.include?(es)
    @env = es
  else
    fail "did not recognize environment: #{e}, expected one of: #{ENVIRONMENTS.join(', ')}"
  end
end

.gem_rootObject



100
101
102
# File 'lib/melissadata/melissadata.rb', line 100

def gem_root
  @gem_root ||= Pathname.new(File.expand_path('../../../', __FILE__))
end

.prod?Boolean

Determines if we are in the production environment

Returns:

  • (Boolean)

    true if current environment is production, false otherwise



75
76
77
# File 'lib/melissadata/melissadata.rb', line 75

def prod?
  env == :production
end

.staging?Boolean

Determines if we are in the staging environment

Returns:

  • (Boolean)

    true if current environment is staging.



96
97
98
# File 'lib/melissadata/melissadata.rb', line 96

def staging?
  env == :staging
end

.test?Boolean

Determines if we are in the test environment

Returns:

  • (Boolean)

    true if current environment is test, false otherwise



89
90
91
# File 'lib/melissadata/melissadata.rb', line 89

def test?
  env == :test
end