Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chebyte committed Aug 11, 2010
1 parent e4e2ed6 commit f9c2cd6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions init.rb
Expand Up @@ -6,4 +6,5 @@
require File.dirname(__FILE__) + '/lib/heroku_jammit_command'
require File.dirname(__FILE__) + '/lib/help'
require 'yaml'
require 'heroku'

39 changes: 31 additions & 8 deletions lib/heroku_jammit_command.rb
Expand Up @@ -2,23 +2,25 @@ module Heroku::Command
class Jammit < BaseWithApp

def index
display "===== Compiling assets..."
is_root?

%x{ jammit -f }
display "===== Compiling assets...", false

display "===== Commiting assets..."
run "jammit -f"

commite_assets
#%x{ git commit -am 'assets' }
display "===== Commiting assets...", false

commit_assets

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

private

def commite_assets
def commit_assets
file = open(config_file_path) {|f| YAML.load(f) }
package_dir = "public/" + (file["package_path"] || "assets")
git add package_dir
git commit -m "assets #{Time.now}"
run "git add '#{package_dir}' && git commit -m 'assets #{formatted_date(Time.now)}'"
end

def config_file_path
Expand All @@ -28,6 +30,27 @@ def config_file_path
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
end

def run(cmd)
begin
shell(cmd)
display "[OK]"
rescue
display "[FAIL]"
end
end

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

end
end

0 comments on commit f9c2cd6

Please sign in to comment.