Permalink
Browse files

Updating plugins.rb format, adding remove tasks to each rake group

  • Loading branch information...
Winton Welsh
Winton Welsh committed Aug 24, 2008
1 parent 4038f27 commit aa08bc2cbba21a173cd268d96f0c77b7d216fb6c
Showing with 89 additions and 42 deletions.
  1. +1 −1 README.markdown
  2. +1 −1 resources/git/ignore
  3. +12 −9 resources/git/plugins.rb
  4. +14 −0 tasks/app_helpers.rake
  5. +8 −2 tasks/db.rake
  6. +43 −25 tasks/git.rake
  7. +5 −0 tasks/views.rake
  8. +5 −4 tasks/widgets.rake
View
@@ -30,4 +30,4 @@ What does it do?
This is constantly being expanded, so [check out the wiki](http://github.com/winton/app_helpers/wikis) for more details.
-##### Copyright (c) 2008 [Winton Welsh](mailto:mail@wintoni.us), released under the MIT license
+##### Copyright © 2008 [Winton Welsh](mailto:mail@wintoni.us), released under the MIT license
View
@@ -10,4 +10,4 @@ log/*
public/cache/**/*
public/media/**/*
tmp/**/*
-vendor/plugins
+vendor
View
@@ -1,12 +1,15 @@
-%w(
- git@github.com:winton/acts_as_relationable.git
- git@github.com:winton/admin.git
- git@github.com:winton/authentication.git
- git@github.com:winton/captcha.git
- git@github.com:winton/rails_widget.git
-
- git://github.com/mislav/will_paginate.git
-)
+[
+ { :repo => 'git@github.com:winton/acts_as_relationable.git' },
+ { :repo => 'git@github.com:winton/authentication.git' },
+ { :repo => 'git@github.com:winton/cookbook.git' },
+ { :repo => 'git@github.com:winton/rails_widget.git' },
+ { :repo => 'git@github.com:winton/widgets.git', :to => 'app/widgets/widgets' },
+ { :repo => 'git://github.com/mislav/will_paginate.git', :depth => 1, :tag => '2.3.2' },
+ { :repo => 'git://github.com/rails/rails.git', :to => 'vendor/rails', :depth => 1 },
+ 'haml'
+]
+#git@github.com:winton/captcha.git
+#git@github.com:winton/admin.git
#git://github.com/technoweenie/attachment_fu.git
#git://github.com/jcnetdev/active_record_without_table.git
#git://github.com/freelancing-god/thinking-sphinx.git
View
@@ -1,7 +1,21 @@
desc 'Copy database config, git assets, views, widget assets'
task :app_helpers => [ 'app_helpers:db', 'app_helpers:git', 'app_helpers:views', 'app_helpers:widgets' ]
+namespace :plugins do
+ desc 'Adds plugins defined in config/plugins.rb'
+ task :install => 'app_helpers:git:plugins:install'
+
+ desc 'Updates plugins defined in config/plugins.rb'
+ task :update => 'app_helpers:git:plugins:update'
+
+ desc 'Removes plugins defined in config/plugins.rb'
+ task :remove => 'app_helpers:git:plugins:remove'
+end
+
namespace :app_helpers do
+
+ desc 'Removes files created by rake app_helpers'
+ task :remove => [ 'app_helpers:db:remove', 'app_helpers:git:remove', 'app_helpers:views:remove', 'app_helpers:widgets:remove' ]
def app_helper_resource(type, to, reverse=false)
from = "#{File.dirname(__FILE__)}/../resources/#{type}"
View
@@ -10,11 +10,12 @@ namespace :app_helpers do
namespace :db do
desc 'Creates a generic database.yml file'
task :config do
- puts('Database name?') unless ENV["DB"]
+ return if ENV['db'] == 'false'
+ puts('Database name?') unless ENV['db']
File.open 'config/database.yml', 'w' do |file|
file.write "development: &defaults
adapter: mysql
- database: #{ENV["DB"] || STDIN.gets.strip}
+ database: #{ENV['db'] || STDIN.gets.strip}
username: root
password:
host: localhost
@@ -27,5 +28,10 @@ production:
"
end
end
+
+ desc 'Removes database.yml'
+ task :remove do
+ `rm config/database.yml`
+ end
end
end
View
@@ -1,21 +1,9 @@
-namespace :plugins do
- task :update => 'app_helpers:git:plugins:update'
-end
-
namespace :app_helpers do
desc 'Copies git assets to app'
task :git => [ 'app_helpers:git:ignore', 'app_helpers:git:plugins' ]
namespace :git do
-
- desc 'Initiates git pull on all git repositories'
- task :pull do
- Dir["**/*/.git"].collect do |f|
- puts f
- `cd #{File.dirname(f)}; git checkout master; git pull`
- end
- end
desc 'Copies .gitignore to app'
task :ignore do
@@ -27,25 +15,55 @@ namespace :app_helpers do
app_helper_resource 'git/plugins.rb', 'config/plugins.rb'
end
+ desc 'Removes files from rake app_helpers:git'
+ task :remove do
+ `rm .gitignore`
+ `rm config/plugins.rb`
+ end
+
namespace :plugins do
- desc 'Clones git repositories to vendor/plugins'
+ desc 'Adds plugins defined in config/plugins.rb'
+ task :install do
+ eval(File.read('config/plugins.rb')).each do |plugin|
+ if plugin == 'haml'
+ puts plugin
+ `haml --rails .`
+ next
+ end
+ puts plugin[:repo]
+ install_path = mkdir_p(plugin[:to] || "vendor/plugins/#{File.basename(plugin[:repo], '.git')}")
+ Dir.chdir install_path do
+ `git init`
+ `git remote add origin #{plugin[:repo]}`
+ `git pull #{plugin[:depth] ? "--depth #{plugin[:depth]} " : ''}origin #{git_head(plugin)}`
+ end
+ end
+ end
+
+ desc 'Updates plugins defined in config/plugins.rb'
task :update do
- eval(File.read('config/plugins.rb')).each do |url|
- puts url
- if url.include?('@')
- dir = "vendor/plugins/#{File.basename(url, '.git')}"
- unless File.exists?(dir)
- `git clone #{url} #{dir}`
- end
- else
- `ruby script/plugin install #{url}`
+ eval(File.read('config/plugins.rb')).each do |plugin|
+ puts plugin[:repo]
+ Dir.chdir install_path do
+ `git pull origin #{git_head(plugin)}`
+ `git checkout #{git_head(plugin)}`
end
end
- Dir["#{RAILS_ROOT}/**/*/.git"].each do |dir|
- puts dir
- `cd #{dir}/../; git checkout master; git pull origin master`
+ end
+
+ desc 'Removes plugins defined in config/plugins.rb'
+ task :remove do
+ eval(File.read('config/plugins.rb')).each do |plugin|
+ puts plugin[:repo]
+ rm_rf(plugin[:to] || "vendor/plugins/#{File.basename(plugin[:repo], '.git')}")
end
end
+
+ def git_head(plugin)
+ return "tags/#{plugin[:tag]}" if plugin[:tag]
+ return "tags/#{plugin[:branch]}" if plugin[:branch]
+ return 'master'
+ end
end
end
end
View
@@ -13,6 +13,11 @@ namespace :app_helpers do
task :to_plugin do
app_helper_resource :views, 'app/views/app_helpers', true
end
+
+ desc 'Removes plugin resources from app'
+ task :remove do
+ rm_rf 'app/views/app_helpers'
+ end
end
end
View
@@ -1,11 +1,12 @@
namespace :app_helpers do
desc 'Updates app/widgets assets'
- task :widgets => [ 'app_helpers:widgets:javascripts:to_app', 'app_helpers:widgets:stylesheets:to_app', 'app_helpers:widgets:clone' ]
+ task :widgets => [ 'app_helpers:widgets:javascripts:to_app', 'app_helpers:widgets:stylesheets:to_app' ]
namespace :widgets do
- desc 'Updates app/widgets/widgets'
- task :clone do
- `git clone git@github.com:winton/widgets.git app/widgets/widgets`
+ desc 'Removes app/widgets assets'
+ task :remove do
+ rm_rf 'app/widgets/javascripts'
+ rm_rf 'app/widgets/stylesheets'
end
namespace :javascripts do

0 comments on commit aa08bc2

Please sign in to comment.