rails-rake-pg 0.0.4

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.
@@ -0,0 +1,23 @@
1
+ # rails-rake-pg #
2
+
3
+ This little gem will build a local postgresql database for you from your Rails
4
+ database config.
5
+
6
+ ## Installation ##
7
+
8
+ In your `Gemfile`:
9
+
10
+ gem 'rails-rake-pg', group: ['development', 'test']
11
+
12
+ ## Use ##
13
+
14
+ To build a local postgresql cluster:
15
+
16
+ rake db:cluster:create
17
+
18
+ Username and password will be taken `config/database.yml` for the current Rails
19
+ environment.
20
+
21
+ To run your cluster:
22
+
23
+ rake db:cluster:run
@@ -0,0 +1,3 @@
1
+ module RailsRakePg
2
+ class Engine < Rails::Engine ; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module RailsRakePg
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,32 @@
1
+ namespace "db:cluster" do
2
+ desc "Create a new postgresql database cluster in RAILS_ROOT/db/postgresql directory."
3
+ task :create => "db:load_config" do
4
+ db_dir = File.join(Rails.root, 'db', 'postgresql')
5
+
6
+ config = ActiveRecord::Base.configurations[Rails.env]
7
+
8
+ unless config['username']
9
+ raise "Please specify a username in database.yml"
10
+ end
11
+
12
+ pass_config = if config["password"]
13
+ password_file = Tempfile.new('pword')
14
+ password_file.write config["password"]
15
+ password_file.flush
16
+
17
+ "--pwfile=#{password_file.path}"
18
+ end
19
+
20
+ command = %{initdb -D #{db_dir} -U #{config["username"]} #{pass_config}}
21
+ sh command do |ok, result|
22
+ ok or fail "Command failed with status (#{result.exitstatus}): [#{command}]"
23
+ end
24
+ end
25
+
26
+ desc "Run the local postgresql database cluster"
27
+ task :run => "db:load_config" do
28
+ config = ActiveRecord::Base.configurations[Rails.env]
29
+ port = config['port'] ? "-p #{config['port']}" : ""
30
+ exec "postgres #{port} -D ./db/postgresql"
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-rake-pg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - bpo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Postgres tasks for Rails.
31
+ email:
32
+ - bpo@somnambulance.net
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/rails-rake-pg/version.rb
38
+ - lib/rails-rake-pg.rb
39
+ - lib/tasks/postgresql.rake
40
+ - README.markdown
41
+ homepage: http://github.com/bpo/rails-rake-pg
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
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
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.23
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Postgres tasks for Rails
65
+ test_files: []