Class: ORS::Config
- Inherits:
-
Object
- Object
- ORS::Config
- Defined in:
- lib/ors/config.rb
Constant Summary collapse
- CONFIG_FILENAME =
"config/deploy.yml"- @@args =
[]
- @@options =
{}
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #_options ⇒ Object
- #finalize! ⇒ Object
- #git ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #parse_config_file ⇒ Object
- #parse_options(options) ⇒ Object
- #set_default_options ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
9 10 11 12 |
# File 'lib/ors/config.rb', line 9 def initialize() () parse_config_file end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/ors/config.rb', line 18 def [](key) [key] end |
#[]=(key, value) ⇒ Object
22 23 24 |
# File 'lib/ors/config.rb', line 22 def []=(key, value) [key] = value end |
#_options ⇒ Object
14 15 16 |
# File 'lib/ors/config.rb', line 14 def end |
#finalize! ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ors/config.rb', line 72 def finalize! [:name] = name [:remote_url] = remote_url [:deploy_directory] = deploy_directory [:revision] = git.log(1).first.sha [:ruby_servers] = [[:app_servers], [:console_server], [:cron_server], [:migration_server]].flatten.compact.uniq [:all_servers] = [[:web_servers], [:ruby_servers]].flatten.compact.uniq end |
#git ⇒ Object
83 84 85 |
# File 'lib/ors/config.rb', line 83 def git @git ||= Git.open(Dir.pwd) end |
#parse_config_file ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/ors/config.rb', line 64 def parse_config_file if File.exists?(CONFIG_FILENAME) YAML.load(File.read(CONFIG_FILENAME)).each do |(name, value)| [name.to_sym] = value end end end |
#parse_options(options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ors/config.rb', line 26 def () [:pretending] = true if .delete("-p") || .delete("--pretend") if .delete("-ng") || .delete("--no-gateway") [:use_gateway] = false else [:use_gateway] = true end # grab environment index = .index("to") || .index("from") unless index.nil? [:environment] = .delete_at(index + 1) .delete_at(index) end [:args] = .dup end |
#set_default_options ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ors/config.rb', line 47 def [:environment] ||= "production" [:remote] ||= "origin" [:branch] ||= [:environment] [:pretending] ||= false [:log_lines] = 100 [:gateway] = "deploy-gateway" [:user] = "deployer" [:base_path] = "/var/www" [:web_servers] = %w(koala) [:app_servers] = %w(eel jellyfish squid) [:migration_server] = "tuna" [:console_server] = "tuna" [:cron_server] = "tuna" end |
#valid? ⇒ Boolean
87 88 89 |
# File 'lib/ors/config.rb', line 87 def valid? name.to_s.size > 0 end |