lib/shelly/app.rb in shelly-0.0.21.pre5 vs lib/shelly/app.rb in shelly-0.0.21
- old
+ new
@@ -2,36 +2,45 @@
require 'launchy'
module Shelly
class App < Model
DATABASE_KINDS = %w(postgresql mongodb redis none)
+ attr_accessor :code_name, :databases, :ruby_version, :environment, :git_url, :domains
- attr_accessor :code_name, :databases, :ruby_version, :environment,
- :git_url, :domains
+ def initialize
+ @ruby_version = "MRI-1.9.2"
+ @environment = "production"
+ end
def add_git_remote
system("git remote rm production > /dev/null 2>&1")
system("git remote add production #{git_url}")
end
def generate_cloudfile
@email = current_user.email
+ @databases = databases
+ @domains = domains
template = File.read(cloudfile_template_path)
cloudfile = ERB.new(template, 0, "%<>-")
cloudfile.result(binding)
end
def cloudfile_template_path
File.join(File.dirname(__FILE__), "templates", "Cloudfile.erb")
end
def create
- attributes = {:name => code_name, :code_name => code_name, :domains => domains}
+ attributes = {
+ :name => code_name,
+ :code_name => code_name,
+ :environment => environment,
+ :ruby_version => ruby_version,
+ :domain_name => domains ? domains.join(" ") : nil
+ }
response = shelly.create_app(attributes)
self.git_url = response["git_url"]
- self.domains = response["domains"]
- self.ruby_version = response["ruby_version"]
- self.environment = response["environment"]
+ self.domains = response["domain_name"].split if domains.nil?
end
def create_cloudfile
content = generate_cloudfile
File.open(cloudfile_path, "a+") { |f| f << content }