voomify_tasks 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1 @@
1
+ This is a gem that defines common rake tasks the are used in multiple voomify projects.
@@ -0,0 +1,17 @@
1
+ # OverrideRakeTask
2
+ Rake::TaskManager.class_eval do
3
+ def alias_task(old_name, new_name)
4
+ @tasks[new_name] = @tasks.delete(old_name)
5
+ end
6
+ end
7
+
8
+ def alias_task(old_name, new_name)
9
+ Rake.application.alias_task(old_name, new_name)
10
+ end
11
+
12
+ def override_task(*args, &block)
13
+ name, params, deps = Rake.application.resolve_args(args.dup)
14
+ task = "#{Rake.application.current_scope.join(':')}:#{name.to_s}"
15
+ alias_task task.to_s, "#{task}:original"
16
+ Rake::Task.define_task(*args, &block)
17
+ end
@@ -0,0 +1,41 @@
1
+ require 'replace_rake_tasks'
2
+
3
+ # we override these tasks to use ddl file instead of ruby
4
+
5
+ namespace :db do
6
+ namespace :schema do
7
+ override_task :load => :environment do
8
+ run_psql_file(ActiveRecord::Base.configurations[Rails.env], "schema.sql")
9
+ end
10
+
11
+ override_task :dump => :environment do
12
+ puts 'This is a NOOP. The schema is defined in /db/sql/schema.sql.'
13
+ end
14
+ end
15
+
16
+ override_task :seed => :environment do
17
+ run_psql_file(ActiveRecord::Base.configurations[Rails.env], "seed.sql")
18
+ end
19
+
20
+ namespace :test do
21
+
22
+ override_task :purge do
23
+ end
24
+
25
+ override_task :load => :environment do
26
+ run_psql_file(ActiveRecord::Base.configurations["test"], "schema.sql")
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def run_psql_file(config, filename)
33
+ file_with_path = "#{Rails.root}/db/sql/#{filename}"
34
+ puts "Executing sql file: #{file_with_path}"
35
+ database = config["database"]
36
+ username = config["username"]
37
+ `psql -f #{file_with_path} #{database} -U #{username}`
38
+ end
39
+
40
+
41
+ end
@@ -0,0 +1,50 @@
1
+ def call_dependent_project_tasks(projects, commands, calls_task=nil)
2
+ commands.each do |tasks|
3
+ call_recursive_dependent_project_tasks(projects, tasks.split(':'), calls_task)
4
+ end
5
+ end
6
+
7
+
8
+ def noop_project_tasks(commands)
9
+ commands.each do |tasks|
10
+ noop_recursive_project_tasks(tasks.split(':'))
11
+ end
12
+ end
13
+
14
+ def sub_directories
15
+ FileList.new('./**') do |f|
16
+ f.to_a.each do |item|
17
+ f.exclude(item) unless (File.directory?(item) || item == '.' || item == '..')
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def call_recursive_dependent_project_tasks(projects, commands, calls_task, index=0)
25
+ if(index<commands.size-1)
26
+ namespace commands[index].to_sym do
27
+ call_recursive_dependent_project_tasks(projects, commands, calls_task, index+1)
28
+ end
29
+ else
30
+ task commands[index].to_sym do
31
+ errors = []
32
+ projects.each do |project|
33
+ system(%(cd #{project} && #{$0} #{calls_task!=nil && calls_task || commands.join(':')})) || errors << project
34
+ end
35
+ fail("Errors in #{errors.join(', ')}") unless errors.empty?
36
+ end
37
+ end
38
+ end
39
+
40
+ def noop_recursive_project_tasks(commands, index=0)
41
+ if(index<commands.size-1)
42
+ namespace commands[index].to_sym do
43
+ noop_recursive_project_tasks(commands, index+1)
44
+ end
45
+ else
46
+ task commands[index].to_sym do
47
+ # This is a no-op
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,29 @@
1
+ %w[development production integration].each do |env|
2
+
3
+ desc "Runs the following task in the #{env} environment"
4
+
5
+ task env do
6
+
7
+ RAILS_ENV = ENV['RAILS_ENV'] = env
8
+
9
+ end
10
+
11
+ end
12
+
13
+ task :testing do
14
+
15
+ RAILS_ENV = ENV['RAILS_ENV'] = 'test'
16
+
17
+ end
18
+
19
+ task :dev do
20
+
21
+ Rake::Task["development"].invoke
22
+
23
+ end
24
+
25
+ task :prod do
26
+
27
+ Rake::Task["production"].invoke
28
+
29
+ end
@@ -0,0 +1,5 @@
1
+ module Voomify
2
+ module Tasks
3
+ require 'voomify_tasks/railtie' if defined?(Rails)
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'voomify_tasks'
2
+ require 'rails'
3
+ module Voomify
4
+ module Tasks
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load "tasks/enviornments.rake"
8
+ load "tasks/databases.rake"
9
+ end
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voomify_tasks
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Russell Edens
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-01 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: This gem contains common tasks for the voomify rails projects
23
+ email: russell@voomify.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ files:
31
+ - lib/replace_rake_tasks.rb
32
+ - lib/tasks/databases.rake
33
+ - lib/tasks/dependent_projects.rake
34
+ - lib/tasks/enviornments.rake
35
+ - lib/voomify_tasks.rb
36
+ - lib/voomify_tasks/railtie.rb
37
+ - README
38
+ has_rdoc: true
39
+ homepage: http://www.github.com/voomify/voomify/gems/tasks
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --charset=UTF-8
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ hash: 3
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.7
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Common Voomify tasks.
72
+ test_files: []
73
+