lib/shelly/app.rb in shelly-0.0.50 vs lib/shelly/app.rb in shelly-0.0.51.pre
- old
+ new
@@ -11,16 +11,20 @@
def initialize(code_name = nil)
self.code_name = code_name
end
def add_git_remote
- system("git remote rm production > /dev/null 2>&1")
- system("git remote add production #{git_url}")
+ system("git remote rm #{code_name} > /dev/null 2>&1")
+ system("git remote add #{code_name} #{git_url}")
end
+ def git_remote_exist?
+ IO.popen("git remote").read.include?(code_name)
+ end
+
def remove_git_remote
- system("git remote rm production > /dev/null 2>&1")
+ system("git remote rm #{code_name} > /dev/null 2>&1")
end
def generate_cloudfile
@email = current_user.email
template = File.read(cloudfile_template_path)
@@ -100,10 +104,22 @@
def cloudfile_path
File.join(Dir.pwd, "Cloudfile")
end
def self.guess_code_name
- File.basename(Dir.pwd)
+ guessed = nil
+ if Cloudfile.present?
+ clouds = Cloudfile.new.clouds
+ if clouds.grep(/staging/).present?
+ guessed = "production"
+ production_clouds = clouds.grep(/production/)
+ production_clouds.sort.each do |cloud|
+ cloud =~ /production(\d*)/
+ guessed = "production#{$1.to_i+1}"
+ end
+ end
+ end
+ "#{File.basename(Dir.pwd)}-#{guessed || 'staging'}"
end
def collaborations
@collaborations ||= Array(shelly.collaborations(code_name)).
sort_by { |c| c["email"] }