brancher 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5fd309a1776a81932593b18de4367bfb11a404d
4
- data.tar.gz: 093984983555acb5bbfdb75965f30764430721ab
3
+ metadata.gz: 338f02687959d178804d912e5b7055f2e764a644
4
+ data.tar.gz: 85e3e43519492a9614418763f0be94c890bdd524
5
5
  SHA512:
6
- metadata.gz: 1902a3cfcfe2aaf6581df862b116f59d93c1a30ef1b71f2a8d8a407c6ec3c95397078d9784730cdebe03715170c64e75ce9bd1cab46149e93541983343e8203a
7
- data.tar.gz: b98ddad42f34d988fee4f6748eee83bf0aab86d8f4ba098cdbbecf2f4888d8aeb70bed0f44e0aca90871ec5850d4e7b5757dc18cdb2bd8de324d4b358fd0c18e
6
+ metadata.gz: d241ee0923aca862c6ef840cdaced23daa31ac6c758cc0e9a2295901b4cae4c5d4947f5f019c98507f527c4119177a54a91c56cb319b891623bb56d5dba1e989
7
+ data.tar.gz: 49fc4fd0579356f4b7c844f617355104270949b26e1830cbe5284e5fd92d091a7b94dc4b108f5b8bc9586645747f8b98ce665344fe41ac29a06a7330a0c83c9a
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Brancher
2
2
 
3
- A rubygem to switch databases connected with ActiveRecord by Git branch
3
+ [![Build Status](https://travis-ci.org/naoty/brancher.svg)](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)
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "activerecord"
21
- spec.add_dependency "activesupport"
22
21
  spec.add_dependency "railties"
23
22
 
24
23
  spec.add_development_dependency "bundler", "~> 1.7"
@@ -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 += "_#{current_branch}"
11
+ database_name += suffix unless database_name =~ %r{#{suffix}$}
12
12
  configuration["database"] = database_name + database_extname
13
- configurations.merge!(env => configuration)
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
@@ -1,3 +1,3 @@
1
1
  module Brancher
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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 receive(:current_branch)
7
- .and_return(branch)
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
- configurations[env]["database"] = new_database_name
43
- configurations
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.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-18 00:00:00.000000000 Z
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