brancher 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/brancher.gemspec +0 -1
- data/lib/brancher/database_rename_service.rb +6 -2
- data/lib/brancher/version.rb +1 -1
- data/spec/brancher/database_rename_service_spec.rb +20 -4
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338f02687959d178804d912e5b7055f2e764a644
|
4
|
+
data.tar.gz: 85e3e43519492a9614418763f0be94c890bdd524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d241ee0923aca862c6ef840cdaced23daa31ac6c758cc0e9a2295901b4cae4c5d4947f5f019c98507f527c4119177a54a91c56cb319b891623bb56d5dba1e989
|
7
|
+
data.tar.gz: 49fc4fd0579356f4b7c844f617355104270949b26e1830cbe5284e5fd92d091a7b94dc4b108f5b8bc9586645747f8b98ce665344fe41ac29a06a7330a0c83c9a
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Brancher
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/naoty/brancher)
|
4
|
+
|
5
|
+
Brancher is a rubygem to switch databases connected with ActiveRecord by Git branch.
|
6
|
+
|
7
|
+
For example, if the name of a database is `sample_app_dev`, Brancher will switch the database to `sample_app_dev_master` at `master` branch, and `sample_app_dev_some_feature` at `some_feature` branch.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -18,10 +22,6 @@ And then execute:
|
|
18
22
|
$ bundle
|
19
23
|
```
|
20
24
|
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
For example, if the name of a database is `sample_app_dev`, Brancher will switch the database to `sample_app_dev_master` at `master` branch, and `sample_app_dev_some_feature` at `some_feature` branch.
|
24
|
-
|
25
25
|
## Contributing
|
26
26
|
|
27
27
|
1. Fork it ( https://github.com/[my-github-username]/brancher/fork )
|
@@ -32,4 +32,4 @@ For example, if the name of a database is `sample_app_dev`, Brancher will switch
|
|
32
32
|
|
33
33
|
## Author
|
34
34
|
|
35
|
-
[naoty](https://github.com/naoty)
|
35
|
+
[naoty](https://github.com/naoty)
|
data/brancher.gemspec
CHANGED
@@ -8,9 +8,9 @@ module Brancher
|
|
8
8
|
configuration = configurations[env]
|
9
9
|
database_extname = File.extname(configuration["database"])
|
10
10
|
database_name = configuration["database"].gsub(%r{#{database_extname}$}) { "" }
|
11
|
-
database_name +=
|
11
|
+
database_name += suffix unless database_name =~ %r{#{suffix}$}
|
12
12
|
configuration["database"] = database_name + database_extname
|
13
|
-
configurations
|
13
|
+
configurations
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -19,6 +19,10 @@ module Brancher
|
|
19
19
|
Rails.env
|
20
20
|
end
|
21
21
|
|
22
|
+
def suffix
|
23
|
+
"_#{current_branch}"
|
24
|
+
end
|
25
|
+
|
22
26
|
def current_branch
|
23
27
|
@current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
|
24
28
|
end
|
data/lib/brancher/version.rb
CHANGED
@@ -3,8 +3,10 @@ require "spec_helper"
|
|
3
3
|
describe Brancher::DatabaseRenameService do
|
4
4
|
describe ".rename" do
|
5
5
|
before do
|
6
|
-
allow(Brancher::DatabaseRenameService).to
|
7
|
-
|
6
|
+
allow(Brancher::DatabaseRenameService).to receive_messages(
|
7
|
+
current_branch: branch,
|
8
|
+
env: env
|
9
|
+
)
|
8
10
|
end
|
9
11
|
|
10
12
|
let(:configurations) do
|
@@ -39,8 +41,14 @@ describe Brancher::DatabaseRenameService do
|
|
39
41
|
end
|
40
42
|
|
41
43
|
let(:new_configurations) do
|
42
|
-
|
43
|
-
|
44
|
+
{
|
45
|
+
env => {
|
46
|
+
"adapter" => adapter,
|
47
|
+
"pool" => 5,
|
48
|
+
"timeout" => 5000,
|
49
|
+
"database" => new_database_name
|
50
|
+
}
|
51
|
+
}
|
44
52
|
end
|
45
53
|
|
46
54
|
subject do
|
@@ -64,5 +72,13 @@ describe Brancher::DatabaseRenameService do
|
|
64
72
|
|
65
73
|
it { is_expected.to eq new_configurations }
|
66
74
|
end
|
75
|
+
|
76
|
+
context "when a database has already renamed" do
|
77
|
+
let(:database_name) do
|
78
|
+
"db/sample_app_development_#{branch}.sqlite3"
|
79
|
+
end
|
80
|
+
|
81
|
+
it { is_expected.to eq new_configurations }
|
82
|
+
end
|
67
83
|
end
|
68
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brancher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoto Kaneko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activesupport
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: railties
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|