banana 0.0.1 → 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.md +70 -2
- data/banana.gemspec +3 -3
- data/lib/banana/version.rb +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Banana
|
2
2
|
|
3
|
-
|
3
|
+
A simple plugin for multiple databases in rails app.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,75 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
1. add multiple database settings to `config/database.yml`
|
22
|
+
2. add connection setting to model
|
23
|
+
3. add database name to migration
|
24
|
+
4. as always run `rake db:create`, `rake db:migrate`, `rake db:drop`
|
25
|
+
|
26
|
+
## Exsamples
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
# config/database.yml
|
30
|
+
default: &default
|
31
|
+
adapter: mysql2
|
32
|
+
encoding: utf8
|
33
|
+
reconnect: false
|
34
|
+
pool: 5
|
35
|
+
username: root
|
36
|
+
password:
|
37
|
+
socket: /var/run/mysqld/mysqld.sock
|
38
|
+
|
39
|
+
development:
|
40
|
+
<<: *default
|
41
|
+
database: fruit_development
|
42
|
+
|
43
|
+
test:
|
44
|
+
<<: *default
|
45
|
+
database: fruit_test
|
46
|
+
|
47
|
+
production:
|
48
|
+
<<: *default
|
49
|
+
database: fruit_production
|
50
|
+
|
51
|
+
vegetable_development:
|
52
|
+
<<: *default
|
53
|
+
database: vegetable_development
|
54
|
+
|
55
|
+
vegetable_test:
|
56
|
+
<<: *default
|
57
|
+
database: vegetable_test
|
58
|
+
|
59
|
+
vegetable_production:
|
60
|
+
<<: *default
|
61
|
+
database: vegetable_production
|
62
|
+
```
|
63
|
+
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
# app/models/vegetable.rb
|
67
|
+
class Vegetable < ActiveRecord::Base
|
68
|
+
establish_connection "vegetable_#{Rails.env}"
|
69
|
+
end
|
70
|
+
```
|
71
|
+
```ruby
|
72
|
+
# app/models/onion.rb
|
73
|
+
class Onion < Vegetable
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
# db/migrate/20120728121720_create_onions.rb
|
79
|
+
class CreateOnions < ActiveRecord::Migration
|
80
|
+
DATABASE_NAME = "vegetable_#{Rails.env}"
|
81
|
+
|
82
|
+
def change
|
83
|
+
create_table :onions do |t|
|
84
|
+
|
85
|
+
t.timestamps
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
```
|
22
90
|
|
23
91
|
## Contributing
|
24
92
|
|
data/banana.gemspec
CHANGED
@@ -4,9 +4,9 @@ require File.expand_path('../lib/banana/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["sinsoku"]
|
6
6
|
gem.email = ["sinsoku.listy@gmail.com"]
|
7
|
-
gem.description = %q{}
|
8
|
-
gem.summary = %q{}
|
9
|
-
gem.homepage = ""
|
7
|
+
gem.description = %q{A simple plugin for multiple databases in rails app.}
|
8
|
+
gem.summary = %q{A simple plugin for multiple databases in rails app.}
|
9
|
+
gem.homepage = "https://github.com/sinsoku/banana"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/banana/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-07-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description:
|
14
|
+
description: A simple plugin for multiple databases in rails app.
|
15
15
|
email:
|
16
16
|
- sinsoku.listy@gmail.com
|
17
17
|
executables: []
|
@@ -29,7 +29,7 @@ files:
|
|
29
29
|
- lib/banana/multidb_schema_dumper.rb
|
30
30
|
- lib/banana/tasks/database.rake
|
31
31
|
- lib/banana/version.rb
|
32
|
-
homepage:
|
32
|
+
homepage: https://github.com/sinsoku/banana
|
33
33
|
licenses: []
|
34
34
|
post_install_message:
|
35
35
|
rdoc_options: []
|
@@ -43,7 +43,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
43
|
version: '0'
|
44
44
|
segments:
|
45
45
|
- 0
|
46
|
-
hash:
|
46
|
+
hash: 457216682735190219
|
47
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
48
|
none: false
|
49
49
|
requirements:
|
@@ -52,11 +52,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
segments:
|
54
54
|
- 0
|
55
|
-
hash:
|
55
|
+
hash: 457216682735190219
|
56
56
|
requirements: []
|
57
57
|
rubyforge_project:
|
58
58
|
rubygems_version: 1.8.24
|
59
59
|
signing_key:
|
60
60
|
specification_version: 3
|
61
|
-
summary:
|
61
|
+
summary: A simple plugin for multiple databases in rails app.
|
62
62
|
test_files: []
|