Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated to reflect changes in heroku's app #4

Merged
merged 5 commits into from Jun 1, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 39 additions & 40 deletions lib/heroku_jammit.rb
Expand Up @@ -19,21 +19,20 @@

module Heroku::Command
class Jammit < BaseWithApp

def add
is_root?

display "===== Compiling assets...", false

run "jammit -f"
run "jammit -f"

display "===== Commiting assets...", false

run "git add '#{package_path}' && git commit -m 'assets at #{formatted_date(Time.now)}'"
run "git add '#{package_path}' && git commit -m 'assets at #{formatted_date(Time.now)}'"

display "===== Done..."
end

def delete
is_root?

Expand All @@ -42,11 +41,11 @@ def delete
else
display "===== Deleting compiled assets...", false

run "rm -rf #{package_path}"
run "rm -rf #{package_path}"

display "===== Commiting deleted assets...", false

run "git rm -rf #{package_path} && git commit -m 'delete assets at #{formatted_date(Time.now)}'"
run "git rm -rf #{package_path} && git commit -m 'delete assets at #{formatted_date(Time.now)}'"

display "===== Done..."
end
Expand All @@ -60,9 +59,9 @@ def deploy
unless branch.empty?
add

display "===== Deploying assets for #{@app} to heroku...", true
display "===== Deploying assets for #{app} to heroku...", true

run "git push git@heroku.com:#{@app}.git #{branch}:master"
run "git push git@heroku.com:#{app}.git #{branch}:master"

display "===== Done..."

Expand All @@ -76,47 +75,47 @@ def deploy

private

def package_path
file = open(config_file_path) {|f| YAML.load(f) }
dir = "public/" + (file["package_path"] || "assets")
end
def package_path
file = open(config_file_path) {|f| YAML.load(f) }
dir = "public/" + (file["package_path"] || "assets")
end

def config_file_path
File.join(Dir.getwd, 'config', 'assets.yml')
end
def config_file_path
File.join(Dir.getwd, 'config', 'assets.yml')
end

def missing_assets?
!File.exists? package_path
end
def missing_assets?
!File.exists? package_path
end

def missing_config_file?
!File.exists? config_file_path
end
def missing_config_file?
!File.exists? config_file_path
end

def is_root?
if missing_config_file?
display "app rails not found!, you need stay on the root of one rails app"
exit
end
def is_root?
if missing_config_file?
display "app rails not found!, you need stay on the root of one rails app"
exit
end
end

def set_branch
`git branch`.scan(/^\* (.*)\n/)
Regexp.last_match(1)
end
def set_branch
`git branch`.scan(/^\* (.*)\n/)
Regexp.last_match(1)
end

def run(cmd)
shell cmd
if $?.exitstatus == 0
display "[OK]"
else
display "[FAIL]"
end
def run(cmd)
shell cmd
if $?.exitstatus == 0
display "[OK]"
else
display "[FAIL]"
end
end

def formatted_date(date)
date.strftime("%A %d, %Y")
end
def formatted_date(date)
date.strftime("%A %d, %Y")
end

end
end
Expand Down