Class: Teleport::Config
- Inherits:
-
Object
- Object
- Teleport::Config
- Includes:
- Constants
- Defined in:
- lib/teleport/config.rb
Overview
This class parses Telfile, and includes DSL and the models.
Defined Under Namespace
Classes: Apt, DSL, Role, Server
Constant Summary collapse
- RUBIES =
["2.0.0", "1.9.3", "1.9.2", "REE", "1.8.7"]
Constants included from Constants
Constants::DATA, Constants::DIR, Constants::FILES, Constants::GEM, Constants::PUBKEY, Constants::RUBYGEMS
Instance Attribute Summary collapse
-
#apt ⇒ Object
Returns the value of attribute apt.
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
-
#dsl ⇒ Object
Returns the value of attribute dsl.
-
#packages ⇒ Object
Returns the value of attribute packages.
-
#recipes ⇒ Object
Returns the value of attribute recipes.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#ruby ⇒ Object
Returns the value of attribute ruby.
-
#servers ⇒ Object
Returns the value of attribute servers.
-
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
-
#ssh_options ⇒ Object
Returns the value of attribute ssh_options.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(file = "Telfile") ⇒ Config
constructor
A new instance of Config.
- #role(n) ⇒ Object
- #sanity_check_gemfiles ⇒ Object
- #server(n) ⇒ Object
Constructor Details
#initialize(file = "Telfile") ⇒ Config
Returns a new instance of Config.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/teleport/config.rb', line 10 def initialize(file = "Telfile") @roles = [] @servers = [] @apt = [] @packages = [] @recipes = [] @callbacks = { } @dsl = DSL.new(self) @dsl.instance_eval(File.read(file), file) @user ||= Util.whoami @ruby ||= RUBIES.first sanity_check_gemfiles end |
Instance Attribute Details
#apt ⇒ Object
Returns the value of attribute apt.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def apt @apt end |
#callbacks ⇒ Object
Returns the value of attribute callbacks.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def callbacks @callbacks end |
#dsl ⇒ Object
Returns the value of attribute dsl.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def dsl @dsl end |
#packages ⇒ Object
Returns the value of attribute packages.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def packages @packages end |
#recipes ⇒ Object
Returns the value of attribute recipes.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def recipes @recipes end |
#roles ⇒ Object
Returns the value of attribute roles.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def roles @roles end |
#ruby ⇒ Object
Returns the value of attribute ruby.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def ruby @ruby end |
#servers ⇒ Object
Returns the value of attribute servers.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def servers @servers end |
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def ssh_key @ssh_key end |
#ssh_options ⇒ Object
Returns the value of attribute ssh_options.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def @ssh_options end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'lib/teleport/config.rb', line 8 def user @user end |
Instance Method Details
#role(n) ⇒ Object
27 28 29 |
# File 'lib/teleport/config.rb', line 27 def role(n) @roles.find { |i| i.name == n.to_sym } end |
#sanity_check_gemfiles ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/teleport/config.rb', line 35 def sanity_check_gemfiles files = ["files"] + @roles.map { |i| "files_#{i.name}" } files.each do |i| gemfile = "#{i}/Gemfile" lock = "#{gemfile}.lock" if File.exists?(gemfile) && !File.exists?(lock) Util.fatal "Hm. I found #{gemfile}, but you forgot to create #{lock}." end end end |
#server(n) ⇒ Object
31 32 33 |
# File 'lib/teleport/config.rb', line 31 def server(n) @servers.find { |i| i.name == n.to_s } end |