summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-10-08 12:58:55 +0200
committerAzul <azul@leap.se>2012-10-08 12:58:55 +0200
commita00a0475515fc1576d88e2c9bcc99e844726d37d (patch)
tree6ce03eca67c18b3435cb7edd475d2cfca3cf221f /lib
parentd2e75cbf5540c0460be6c68e5d56511132ef52a9 (diff)
refactoring gem task
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/gems.rake45
-rw-r--r--lib/tasks/task_helper.rb19
2 files changed, 41 insertions, 23 deletions
diff --git a/lib/tasks/gems.rake b/lib/tasks/gems.rake
index cfeca1f..27eb04c 100644
--- a/lib/tasks/gems.rake
+++ b/lib/tasks/gems.rake
@@ -1,41 +1,40 @@
-require File.expand_path('../../../lib/leap_web/version', __FILE__)
+require File.expand_path('../task_helper', __FILE__)
+include TaskHelper
-namespace :gem do
- engines = %w(core users certs help)
+namespace :gem do
desc "run rake gem for all gems"
- task :build do
- engines.each do |gem_name|
- puts "########################### #{gem_name} #########################"
- cmd = "rm -rf #{gem_name}/pkg"; puts cmd; system cmd
- cmd = "cd #{gem_name} && bundle exec rake gem"; puts cmd; system cmd
+ task :build => :clear do
+ each_gem do |gem_name|
+ putsys "cd #{gem_name} && bundle exec rake gem"
+ end
+ putsys "bundle exec rake gem"
+ end
+
+ desc "run rake gem for all gems"
+ task :clear do
+ each_gem do |gem_name|
+ putsys "rm -rf #{gem_name}/pkg"
end
- cmd = "rm -rf pkg"; puts cmd; system cmd
- cmd = "bundle exec rake gem"; puts cmd; system cmd
+ putsys "rm -rf pkg"
end
desc "run gem install for all gems"
- task :install do
+ task :install => :build do
- engines.each do |gem_name|
- puts "########################### #{gem_name} #########################"
- cmd = "rm -rf #{gem_name}/pkg"; puts cmd; system cmd
- cmd = "cd #{gem_name} && bundle exec rake gem"; puts cmd; system cmd
- cmd = "cd #{gem_name}/pkg && gem install leap_web_#{gem_name}-#{LeapWeb::VERSION}.gem"; puts cmd; system cmd
+ each_gem do |gem_name|
+ putsys "cd #{gem_name}/pkg && gem install leap_web_#{gem_name}-#{LeapWeb::VERSION}.gem"
end
- cmd = "rm -rf pkg"; puts cmd; system cmd
- cmd = "bundle exec rake gem"; puts cmd; system cmd
- cmd = "gem install pkg/leap_web-#{LeapWeb::VERSION}.gem"; puts cmd; system cmd
+ putsys "gem install pkg/leap_web-#{LeapWeb::VERSION}.gem"
end
desc "Release all gems to gemcutter. Package leap web components, then push"
task :release do
- engines.each do |gem_name|
- puts "########################### #{gem_name} #########################"
- cmd = "cd #{gem_name}/pkg && gem push leap_web_#{gem_name}-#{LeapWeb::VERSION}.gem"; puts cmd; system cmd
+ each_gem do |gem_name|
+ putsys "cd #{gem_name}/pkg && gem push leap_web_#{gem_name}-#{LeapWeb::VERSION}.gem"
end
- cmd = "gem push pkg/leap_web-#{LeapWeb::VERSION}.gem"; puts cmd; system cmd
+ putsys "gem push pkg/leap_web-#{LeapWeb::VERSION}.gem"
end
end
diff --git a/lib/tasks/task_helper.rb b/lib/tasks/task_helper.rb
new file mode 100644
index 0000000..aa37698
--- /dev/null
+++ b/lib/tasks/task_helper.rb
@@ -0,0 +1,19 @@
+require File.expand_path('../../../lib/leap_web/version', __FILE__)
+
+module TaskHelper
+
+ ENGINES = %w(core users certs help)
+
+ def putsys(cmd)
+ puts cmd
+ system cmd
+ end
+
+ def each_gem
+ ENGINES.each do |gem_name|
+ puts "########################### #{gem_name} #########################"
+ yield gem_name
+ end
+ end
+end
+