Class: Procodile::AppDetermination

Inherits:
Object
  • Object
show all
Defined in:
lib/procodile/app_determination.rb

Overview

 This class is responsible for determining which application should be sued

Instance Method Summary collapse

Constructor Details

#initialize(pwd, given_root, given_procfile, given_environment, global_options = {}) ⇒ AppDetermination

Start by creating an determination ased on the root and procfile that has been provided to us by the user (from –root and/or –procfile)



10
11
12
13
14
15
16
17
# File 'lib/procodile/app_determination.rb', line 10

def initialize(pwd, given_root, given_procfile, given_environment, global_options = {})
  @pwd = pwd
  @given_root = given_root
  @given_procfile = given_procfile
  @given_environment = given_environment
  @global_options = global_options
  calculate
end

Instance Method Details

#ambiguous?Boolean

Returns:

  • (Boolean)


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

def ambiguous?
  !unambiguous?
end

#app_optionsObject

Return an hash of possible options to settle the ambiguity



65
66
67
68
69
70
71
72
73
# File 'lib/procodile/app_determination.rb', line 65

def app_options
  if ambiguous?
    hash = {}
    @global_options.each_with_index { |option, i| hash[i] = option['name'] || option['root'] }
    hash
  else
    {}
  end
end

#environmentObject

Return the environment



20
21
22
# File 'lib/procodile/app_determination.rb', line 20

def environment
  @given_environment || @environment || 'production'
end

#in_app_directory?Boolean

Are we in an app’s directory?

Returns:

  • (Boolean)


45
46
47
# File 'lib/procodile/app_determination.rb', line 45

def in_app_directory?
  @in_app_directory == true
end

#procfileObject

Return the procfile



30
31
32
# File 'lib/procodile/app_determination.rb', line 30

def procfile
  @procfile
end

#reexec?Boolean

Should this be reexeced

Returns:

  • (Boolean)


40
41
42
# File 'lib/procodile/app_determination.rb', line 40

def reexec?
  @reexec == true
end

#rootObject

Return the root directory



25
26
27
# File 'lib/procodile/app_determination.rb', line 25

def root
  @root
end

#set_app(id) ⇒ Object

Choose which of the ambiguous options we want to choose



59
60
61
62
# File 'lib/procodile/app_determination.rb', line 59

def set_app(id)
  @app_id = id
  find_root_and_procfile_from_options(@global_options)
end

#unambiguous?Boolean

If we have a root and procfile, we’re all good

Returns:

  • (Boolean)


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

def unambiguous?
  !!(@root && @procfile)
end

#userObject

Return the user that we must be executing as if not current user



35
36
37
# File 'lib/procodile/app_determination.rb', line 35

def user
  @user
end