branchinator 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0cf45cc27acc050d49ebd0664f226c6c173d071
4
- data.tar.gz: 9bb2f0d872cdb384a209a7211214669ee19ba7e5
3
+ metadata.gz: d7648ccf5809f8cdbf1c17e37b65677302e67ad5
4
+ data.tar.gz: 6131d88c0aa0492cbb2be7e1e5374fcb0b5788b7
5
5
  SHA512:
6
- metadata.gz: 68d4bea6aeef2e4fa2add8bc657e005f96e2aec5bee3bd157baa93b154a0edbfbaf7911db31071f6fbb78cc71b39ce127717bbd27a1f6fe40eb32bc2bffc0790
7
- data.tar.gz: 78b99b7bdf77abb06020234762d0268e3d775983ecc412bb890a88eaa3753dc6c973f0c25c96318d1c5a11e4616a3aba82f5d64e7846991f1a9656fe7022d4e5
6
+ metadata.gz: fc4fa837ff16507789ca59ec06dee92331bdf845f2722f8ad7c5e2b0bc0115926b5515944daeec9fa495f01f61bbfb0d6779c0807182a04e2a00afe2d926b990
7
+ data.tar.gz: 76402967595dae0cfb1de69ab7fb82258eb523a896e414ed796d0ab04842ca45f191dafe7e3e9342ed7b6ed3f8fd8cac22b9b0c2cabc10b44908afdc79cc4d66
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  Branchinator
2
2
  ============
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/branchinator.svg)](https://badge.fury.io/rb/branchinator)
5
+
4
6
  Database per branch so you can easily switch between database models.
5
7
 
8
+ Works with Rails 4.x and 5.x
9
+
6
10
  # How to use
7
11
 
8
12
  `bin/rails db:branch`
@@ -23,7 +27,7 @@ Put it into:
23
27
 
24
28
  ```ruby
25
29
  group :development, :test do
26
- gem 'branchinator', github: 'pawelniewie/branchinator'
30
+ gem 'branchinator'
27
31
  end
28
32
  ```
29
33
 
@@ -39,3 +43,22 @@ test:
39
43
  database: <%= Branchinator.database %>
40
44
  ```
41
45
 
46
+ Update your `.gitingore` as well:
47
+
48
+ ```echo .branchinator >> .gitignore```
49
+
50
+ # Additional configuration
51
+
52
+ By default database name is taken from application name and looks something like:
53
+
54
+ `awesomeproject_branch_environment`
55
+
56
+ If you want you can change the first part and the separator.
57
+
58
+ In your `database.yml` put:
59
+
60
+ ```yaml
61
+ branchinator:
62
+ prefix: awesome-project
63
+ separator: _
64
+ ```
@@ -11,7 +11,7 @@ module Branchinator
11
11
  end
12
12
 
13
13
  def current_branch
14
- `git branch | grep "*"`.chomp.split.last.parameterize
14
+ `git branch | grep "*"`.chomp.split.last.gsub(/.*\//, '').parameterize
15
15
  end
16
16
 
17
17
  def branch_database
@@ -1,3 +1,3 @@
1
1
  module Branchinator
2
- VERSION = '0.1.0'
3
- end
2
+ VERSION = '0.2.0'
3
+ end
data/lib/tasks/db.rb CHANGED
@@ -2,8 +2,11 @@ require 'branchinator/branched_database'
2
2
  require 'branchinator/constants'
3
3
 
4
4
  def create_database(env)
5
+ branchinator = ActiveRecord::Base.configurations.values_at('branchinator').first || {}
6
+ branchinator.deep_symbolize_keys!
7
+
5
8
  config = ActiveRecord::Base.configurations.values_at(env.to_s).first
6
- config['database'] = Branchinator::BranchedDatabase.name(env: env)
9
+ config['database'] = Branchinator::BranchedDatabase.name(branchinator.merge(env: env))
7
10
 
8
11
  ActiveRecord::Tasks::DatabaseTasks.create(config)
9
12
  ActiveRecord::Base.establish_connection(env)
@@ -11,7 +14,13 @@ def create_database(env)
11
14
  if env == :test
12
15
  ActiveRecord::Schema.verbose = false
13
16
  end
14
- ActiveRecord::Tasks::DatabaseTasks.load_schema(config)
17
+
18
+ if Rails.version.start_with? '4'
19
+ ActiveRecord::Tasks::DatabaseTasks.load_schema_for(config)
20
+ else
21
+ ActiveRecord::Tasks::DatabaseTasks.load_schema(config)
22
+ end
23
+
15
24
  ActiveRecord::Tasks::DatabaseTasks.load_seed
16
25
 
17
26
  config['database']
@@ -38,4 +47,4 @@ namespace :db do
38
47
  desc 'Remove then Create the branch specific database'
39
48
  task :reset => [:remove, :branch]
40
49
  end
41
- end
50
+ end
metadata CHANGED
@@ -1,27 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branchinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pawel Niewiadomski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-29 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - ">="
31
+ - - '>='
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - '>='
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  description: Rails helper that simplifies database per branch development.
@@ -31,13 +45,13 @@ extensions: []
31
45
  extra_rdoc_files: []
32
46
  files:
33
47
  - README.md
34
- - lib/branchinator.rb
35
48
  - lib/branchinator/branched_database.rb
36
49
  - lib/branchinator/constants.rb
37
50
  - lib/branchinator/railtie.rb
38
51
  - lib/branchinator/version.rb
52
+ - lib/branchinator.rb
39
53
  - lib/tasks/db.rb
40
- homepage: https://pawelniewiadomski.com
54
+ homepage: https://github.com/pawelniewie/branchinator
41
55
  licenses:
42
56
  - MIT
43
57
  metadata: {}
@@ -47,17 +61,17 @@ require_paths:
47
61
  - lib
48
62
  required_ruby_version: !ruby/object:Gem::Requirement
49
63
  requirements:
50
- - - ">="
64
+ - - '>='
51
65
  - !ruby/object:Gem::Version
52
66
  version: '2'
53
67
  required_rubygems_version: !ruby/object:Gem::Requirement
54
68
  requirements:
55
- - - ">="
69
+ - - '>='
56
70
  - !ruby/object:Gem::Version
57
71
  version: '0'
58
72
  requirements: []
59
73
  rubyforge_project:
60
- rubygems_version: 2.5.1
74
+ rubygems_version: 2.0.14.1
61
75
  signing_key:
62
76
  specification_version: 4
63
77
  summary: Helps you manage database per branch