Class: Kondate::RoleFile
- Inherits:
-
Object
- Object
- Kondate::RoleFile
- Defined in:
- lib/kondate/role_file.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Class Method Summary collapse
Instance Method Summary collapse
-
#explore ⇒ String
Returns readable role file exploring possible role files.
-
#initialize(dir, role, ext = nil) ⇒ RoleFile
constructor
A new instance of RoleFile.
Constructor Details
#initialize(dir, role, ext = nil) ⇒ RoleFile
Returns a new instance of RoleFile.
11 12 13 14 15 |
# File 'lib/kondate/role_file.rb', line 11 def initialize(dir, role, ext = nil) @dir = dir @role = role @ext = ext end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
5 6 7 |
# File 'lib/kondate/role_file.rb', line 5 def dir @dir end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
5 6 7 |
# File 'lib/kondate/role_file.rb', line 5 def ext @ext end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
5 6 7 |
# File 'lib/kondate/role_file.rb', line 5 def role @role end |
Class Method Details
.explore(dir, role, ext = nil) ⇒ Object
7 8 9 |
# File 'lib/kondate/role_file.rb', line 7 def self.explore(dir, role, ext = nil) self.new(dir, role, ext).explore end |
Instance Method Details
#explore ⇒ String
Returns readable role file exploring possible role files. For example, if ‘role` is `myapp-web-staging`, this method explores files as
-
myapp-web-staging.yml
-
myapp-web-base.yml
-
myapp-web.yml
-
myapp-base.yml
-
myapp.yml
-
base.yml
28 29 30 31 32 33 34 35 |
# File 'lib/kondate/role_file.rb', line 28 def explore paths = if Config.explore_role_files? possible_paths else [get_path] end paths.find {|path| File.readable?(path) } || paths.last end |