Class: Procodile::AppDetermination
- Inherits:
-
Object
- Object
- Procodile::AppDetermination
- Defined in:
- lib/procodile/app_determination.rb
Overview
This class is responsible for determining which application should be sued
Instance Method Summary collapse
- #ambiguous? ⇒ Boolean
-
#app_options ⇒ Object
Return an hash of possible options to settle the ambiguity.
-
#environment ⇒ Object
Return the environment.
-
#in_app_directory? ⇒ Boolean
Are we in an app’s directory?.
-
#initialize(pwd, given_root, given_procfile, given_environment, global_options = {}) ⇒ AppDetermination
constructor
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).
-
#procfile ⇒ Object
Return the procfile.
-
#reexec? ⇒ Boolean
Should this be reexeced.
-
#root ⇒ Object
Return the root directory.
-
#set_app(id) ⇒ Object
Choose which of the ambiguous options we want to choose.
-
#unambiguous? ⇒ Boolean
If we have a root and procfile, we’re all good.
-
#user ⇒ Object
Return the user that we must be executing as if not current user.
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, = {}) @pwd = pwd @given_root = given_root @given_procfile = given_procfile @given_environment = given_environment @global_options = calculate end |
Instance Method Details
#ambiguous? ⇒ Boolean
54 55 56 |
# File 'lib/procodile/app_determination.rb', line 54 def ambiguous? !unambiguous? end |
#app_options ⇒ Object
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 if ambiguous? hash = {} @global_options.each_with_index { |option, i| hash[i] = option['name'] || option['root'] } hash else {} end end |
#environment ⇒ Object
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?
45 46 47 |
# File 'lib/procodile/app_determination.rb', line 45 def in_app_directory? @in_app_directory == true end |
#procfile ⇒ Object
Return the procfile
30 31 32 |
# File 'lib/procodile/app_determination.rb', line 30 def procfile @procfile end |
#reexec? ⇒ Boolean
Should this be reexeced
40 41 42 |
# File 'lib/procodile/app_determination.rb', line 40 def reexec? @reexec == true end |
#root ⇒ Object
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 (@global_options) end |
#unambiguous? ⇒ Boolean
If we have a root and procfile, we’re all good
50 51 52 |
# File 'lib/procodile/app_determination.rb', line 50 def unambiguous? !!(@root && @procfile) end |
#user ⇒ Object
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 |