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) @@options[key] end |
#[]=(key, value) ⇒ Object
22 23 24 |
# File 'lib/ors/config.rb', line 22 def []=(key, value) @@options[key] = value end |
#_options ⇒ Object
14 15 16 |
# File 'lib/ors/config.rb', line 14 def @@options end |
#finalize! ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ors/config.rb', line 72 def finalize! @@options[:name] = name @@options[:remote_url] = remote_url @@options[:deploy_directory] = deploy_directory @@options[:revision] = git.log(1).first.sha @@options[:ruby_servers] = [@@options[:app_servers], @@options[:console_server], @@options[:cron_server], @@options[:migration_server]].flatten.compact.uniq @@options[:all_servers] = [@@options[:web_servers], @@options[: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)| @@options[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 () @@options[:pretending] = true if .delete("-p") || .delete("--pretend") if .delete("-ng") || .delete("--no-gateway") @@options[:use_gateway] = false else @@options[:use_gateway] = true end # grab environment index = .index("to") || .index("from") unless index.nil? @@options[:environment] = .delete_at(index + 1) .delete_at(index) end @@options[: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 @@options[:environment] ||= "production" @@options[:remote] ||= "origin" @@options[:branch] ||= @@options[:environment] @@options[:pretending] ||= false @@options[:log_lines] = 100 @@options[:gateway] = "deploy-gateway" @@options[:user] = "deployer" @@options[:base_path] = "/var/www" @@options[:web_servers] = %w(koala) @@options[:app_servers] = %w(eel jellyfish squid) @@options[:migration_server] = "tuna" @@options[:console_server] = "tuna" @@options[:cron_server] = "tuna" end |
#valid? ⇒ Boolean
87 88 89 |
# File 'lib/ors/config.rb', line 87 def valid? name.to_s.size > 0 end |