Permalink
Browse files

some changes

  • Loading branch information...
1 parent f9c2cd6 commit e09bc471b1fe89bf5dc52695a7258a15820f0493 @chebyte chebyte committed Aug 12, 2010
Showing with 851 additions and 13 deletions.
  1. +675 −0 LICENSE
  2. +23 −0 README.rdoc
  3. +21 −3 init.rb
  4. +22 −1 lib/help.rb
  5. +88 −0 lib/heroku_jammit.rb
  6. +22 −9 lib/heroku_jammit_command.rb
View
675 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,23 @@
+= Heroku Jammit Plugin
+
+Plugin that provides support for jammit on heroku. This allows you
+to automate the process of compiling and commit your assets to heroku.
+
+== Installation
+
+ $ heroku plugins:install git@github.com:kylejginavan/heroku_jammit.git
+
+will get you up and running.
+
+== Usage
+
+From your project's root directory:
+
+ $ heroku jammit:add
+
+That'll make the assets and commit it.
+
+ $ heroku jammit:delete
+
+That'll delete the assets and commit it.
+
View
24 init.rb
@@ -1,10 +1,28 @@
+=begin
+ Copyright (c) 2010 Kyle J. Ginavan & Mauro Torres.
+
+ This file is part of Heroku Jammit Plugin.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+=end
+
begin
require 'jammit'
rescue LoadError
raise "jammit gem is missing. Please install jammit: sudo gem install jammit"
end
-require File.dirname(__FILE__) + '/lib/heroku_jammit_command'
-require File.dirname(__FILE__) + '/lib/help'
require 'yaml'
-require 'heroku'
+require File.dirname(__FILE__) + '/lib/heroku_jammit'
+require File.dirname(__FILE__) + '/lib/help'
View
@@ -1,4 +1,25 @@
+=begin
+ Copyright (c) 2010 Kyle J. Ginavan & Mauro Torres.
+
+ This file is part of Heroku Jammit Plugin.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+=end
+
+
Heroku::Command::Help.group('Jammit Command') do |group|
- group.command('jammit', 'compile assets and commit it')
+ group.command('jammit:add', 'compile assets and commited it')
+ group.command('jammit:delete', 'delete assets and commited it')
end
View
@@ -0,0 +1,88 @@
+=begin
+ Copyright (c) 2010 Kyle J. Ginavan & Mauro Torres.
+
+ This file is part of Heroku Jammit Plugin.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+=end
+
+module Heroku::Command
+ class Jammit < BaseWithApp
+
+ def add
+ is_root?
+
+ display "===== Compiling assets...", false
+
+ run "jammit -f"
+
+ display "===== Commiting assets...", false
+
+ run "git add '#{package_path}' && git commit -m 'assets at #{formatted_date(Time.now)}'"
+
+ display "===== Done..."
+ end
+
+ def delete
+ is_root?
+
+ display "===== Deleting compiled assets...", false
+
+ 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)}'"
+
+ display "===== Done..."
+ end
+
+ private
+
+ 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 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)
+ shell cmd
+ if $?.exitstatus == 0
+ display "[OK]"
+ else
+ display "[FAIL]"
+ end
+ end
+
+ def formatted_date(date)
+ date.strftime("%A %d, %Y")
+ end
+
+ end
+end
+
@@ -1,26 +1,39 @@
module Heroku::Command
class Jammit < BaseWithApp
- def index
+ def add
is_root?
display "===== Compiling assets...", false
- run "jammit -f"
+ run "jammit -f"
display "===== Commiting assets...", false
- commit_assets
+ run "git add '#{package_path}' && git commit -m 'assets at #{formatted_date(Time.now)}'"
+
+ display "===== Done..."
+ end
+
+ def delete
+ is_root?
+
+ display "===== Deleting compiled assets...", false
+
+ 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)}'"
display "===== Done..."
end
private
- def commit_assets
+ def package_path
file = open(config_file_path) {|f| YAML.load(f) }
- package_dir = "public/" + (file["package_path"] || "assets")
- run "git add '#{package_dir}' && git commit -m 'assets #{formatted_date(Time.now)}'"
+ dir = "public/" + (file["package_path"] || "assets")
end
def config_file_path
@@ -39,10 +52,10 @@ def is_root?
end
def run(cmd)
- begin
- shell(cmd)
+ shell cmd
+ if $?.exitstatus == 0
display "[OK]"
- rescue
+ else
display "[FAIL]"
end
end

0 comments on commit e09bc47

Please sign in to comment.