common_project_tasks 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Licensing terms follow:
2
+
3
+ This software is placed under the Creative Commons Attribution-Share ALike 3.0 Unported License
4
+
5
+ http://creativecommons.org/licenses/by-sa/3.0/
6
+
7
+ MIT
data/README ADDED
@@ -0,0 +1,41 @@
1
+ CommonProjectTasks
2
+ ===============
3
+
4
+ Rails gem/plugin to load common project tasks.
5
+
6
+
7
+ Once the plugin is installed add the following to {RAILS_ROOT}/Rakefile
8
+
9
+ require 'common_project_tasks'
10
+
11
+
12
+
13
+ Each project will need a {RAILS_ROOT}/config/app_vars.yml file. Each environment list in the database.yml
14
+ file should also be listed in app_vars.yml. The supported attributes are:
15
+
16
+ * rebuild_database [true/false]
17
+ * load_fixtures [true/false]
18
+ * fixtures [fixture1,fixture2,fixture3] (specify in order you want them to load)
19
+
20
+
21
+ The app_vars.yml file should look something like.
22
+ Note: This example can be found in {COMMON_PROJECT_TASKS_PLUGIN}/examples/app_vars.yml.
23
+
24
+ ###############################################
25
+ app_vars: &app_vars
26
+ rebuild_database: true
27
+ load_fixtures: true
28
+ fixtures: 'states,users,permissions'
29
+
30
+ development:
31
+ <<: *app_vars
32
+
33
+ test:
34
+ <<: *app_vars
35
+
36
+ production:
37
+ rebuild_database: false
38
+ load_fixtures: false
39
+ <<: *app_vars
40
+
41
+ ###############################################
@@ -0,0 +1,21 @@
1
+ app_vars: &app_vars
2
+ rebuild_database: true
3
+ run_db_migrate: true
4
+ load_fixtures: true
5
+ fixtures: 'states,users,permissions'
6
+ # post_fixture_tasks: some_rake_task_to_run
7
+ # load_sql_file: 'db/sql/roar_production_data_only-2008-07-25.sql'
8
+ # update_git_submodules: false
9
+
10
+ development:
11
+ load_sql_file: '/db/sql/roar_production_data_only-2008-07-25.sql'
12
+ <<: *app_vars
13
+
14
+ test:
15
+ load_sql_file: '/db/sql/roar_production_data_only-2008-07-25.sql'
16
+ <<: *app_vars
17
+
18
+ production:
19
+ rebuild_database: false
20
+ load_fixtures: false
21
+ <<: *app_vars
@@ -0,0 +1,4 @@
1
+ require 'erb'
2
+ require 'rake'
3
+
4
+ load 'common_project_tasks/app.rake'
@@ -0,0 +1,86 @@
1
+ namespace :app do
2
+ desc 'Setup the application. Usage: rake app:setup. Set RAILS_ENV for other environments. The default is development'
3
+ task :setup do
4
+ ENV['RAILS_ENV'] = 'development' unless ENV.include?('RAILS_ENV')
5
+
6
+ file = "#{RAILS_ROOT}/config/app_vars.yml"
7
+ app_vars = YAML::load(ERB.new(IO.read(file)).result)
8
+
9
+ file = "#{RAILS_ROOT}/config/database.yml"
10
+ database = YAML::load(ERB.new(IO.read(file)).result)
11
+
12
+ # update git submodules in case new ones were added
13
+ if !app_vars[ENV['RAILS_ENV']]['update_git_submodules'].nil? and app_vars[ENV['RAILS_ENV']]['update_git_submodules'] == true
14
+ system('git submodule init')
15
+ system('git submodule update')
16
+ end
17
+
18
+ if !app_vars[ENV['RAILS_ENV']]['rebuild_database'].nil? and app_vars[ENV['RAILS_ENV']]['rebuild_database'] == true
19
+ Rake::Task['db:drop'].invoke
20
+ Rake::Task['db:create'].invoke
21
+ end
22
+
23
+ if !app_vars[ENV['RAILS_ENV']]['run_db_migrate'].nil? and app_vars[ENV['RAILS_ENV']]['run_db_migrate'] == true
24
+ Rake::Task['db:migrate'].invoke
25
+ end
26
+
27
+ if !app_vars[ENV['RAILS_ENV']]['load_fixtures'].nil? and app_vars[ENV['RAILS_ENV']]['load_fixtures'] == true
28
+ ENV['FIXTURES'] = app_vars[ENV['RAILS_ENV']]['fixtures']
29
+ Rake::Task['spec:db:fixtures:load'].invoke
30
+ end
31
+
32
+ unless app_vars[ENV['RAILS_ENV']]['post_fixture_tasks'].nil?
33
+ begin
34
+ Rake::Task[app_vars[ENV['RAILS_ENV']]['post_fixture_tasks']].invoke
35
+ rescue
36
+ puts 'There was an error invoking the post fixture task. Make sure it exists.'
37
+ end
38
+ end
39
+
40
+ unless app_vars[ENV['RAILS_ENV']]['load_sql_file'].nil?
41
+ begin
42
+ path_to_sql_file = app_vars[ENV['RAILS_ENV']]['load_sql_file']
43
+ db = database[ENV['RAILS_ENV']]['database']
44
+ username = database[ENV['RAILS_ENV']]['username']
45
+ password = database[ENV['RAILS_ENV']]['password']
46
+ ENV['PGUSER'] = username
47
+ ENV['PGPASSWORD'] = password
48
+ system("psql -d #{db} < #{path_to_sql_file}")
49
+ rescue
50
+ puts 'There was an error loading sql file'
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ ##############################################
57
+ # The tasks below will not work because the
58
+ # commandline argument RAILS_ENV has already
59
+ # been read by the Rails environment by the
60
+ # time this task is executed.
61
+ ##############################################
62
+
63
+ # desc 'Setup the application for production.'
64
+ # task :setup_production => :environment do
65
+ # ENV['RAILS_ENV'] = 'production'
66
+ # Rake::Task['app:setup'].invoke
67
+ # end
68
+ #
69
+ # desc 'Setup the application for development.'
70
+ # task :setup_development => :environment do
71
+ # ENV['RAILS_ENV'] = 'development'
72
+ # Rake::Task['app:setup'].invoke
73
+ # end
74
+ #
75
+ # desc 'Setup the application for testing.'
76
+ # task :setup_test => :environment do
77
+ # ENV['RAILS_ENV'] = 'test'
78
+ # Rake::Task['app:setup'].invoke
79
+ # end
80
+ #
81
+ # desc 'Setup the application for production, development and testing environments.'
82
+ # task :setup_all => [:setup_production, :setup_development, :setup_test]
83
+ end
84
+
85
+
86
+
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: common_project_tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ platform: ruby
6
+ authors:
7
+ - Wes Hays
8
+ - John Dell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-11-25 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rake
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.8.3
25
+ version:
26
+ description: Rails gem/plugin to load common project tasks.
27
+ email: gems@gbdev.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README
34
+ - LICENSE
35
+ files:
36
+ - LICENSE
37
+ - README
38
+ - lib/common_project_tasks.rb
39
+ - lib/common_project_tasks/app.rake
40
+ - examples/app_vars.yml
41
+ has_rdoc: true
42
+ homepage: http://github.com/gbdev/common_project_tasks
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --title
48
+ - Common Project Tasks Documentation
49
+ - --main
50
+ - README
51
+ - -q
52
+ require_paths:
53
+ - lib/
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: Project on www.github.com
69
+ rubygems_version: 1.3.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Rails gem/plugin to load common project tasks.
73
+ test_files: []
74
+