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.
-
#in_app_directory? ⇒ Boolean
Are we in an app’s directory?.
-
#initialize(pwd, given_root, given_procfile, 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.
-
#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.
Constructor Details
#initialize(pwd, given_root, given_procfile, 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 |
# File 'lib/procodile/app_determination.rb', line 10 def initialize(pwd, given_root, given_procfile, = {}) @pwd = pwd @given_root = given_root ? File.(given_root, pwd) : nil @given_procfile = given_procfile @global_options = calculate end |
Instance Method Details
#ambiguous? ⇒ Boolean
38 39 40 |
# File 'lib/procodile/app_determination.rb', line 38 def ambiguous? !unambiguous? end |
#app_options ⇒ Object
Return an hash of possible options to settle the ambiguity
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/procodile/app_determination.rb', line 49 def if ambiguous? hash = {} @global_options.each_with_index do |option, i| hash[i] = option['name'] || option['root'] end hash else {} end end |
#in_app_directory? ⇒ Boolean
Are we in an app’s directory?
29 30 31 |
# File 'lib/procodile/app_determination.rb', line 29 def in_app_directory? @in_app_directory == true end |
#procfile ⇒ Object
Return the procfile
24 25 26 |
# File 'lib/procodile/app_determination.rb', line 24 def procfile @procfile end |
#root ⇒ Object
Return the root directory
19 20 21 |
# File 'lib/procodile/app_determination.rb', line 19 def root @root end |
#set_app(id) ⇒ Object
Choose which of the ambiguous options we want to choose
43 44 45 46 |
# File 'lib/procodile/app_determination.rb', line 43 def set_app(id) @app_id = id (@global_options) end |
#unambiguous? ⇒ Boolean
If we have a root and procfile, we’re all good
34 35 36 |
# File 'lib/procodile/app_determination.rb', line 34 def unambiguous? !!(@root && @procfile) end |