flipp 0.0.2.10 → 0.0.2.11

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/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  $:.unshift File.expand_path('..', __FILE__)
2
- require 'lib/flipp/tasks'
2
+ # require 'lib/flipp/tasks'
data/flipp.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'bundler'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "flipp"
8
- s.version = '0.0.2.10'
8
+ s.version = '0.0.2.11'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Mike Pack"]
11
11
  s.email = ["mikepackdev@gmail.com"]
data/lib/flipp/flipp.rb CHANGED
@@ -18,8 +18,9 @@ module Flipp
18
18
 
19
19
  # Try connecting to the new database
20
20
  begin
21
- ActiveRecord::Base.establish_connection new_config
22
- rescue Mysql2::Error => exception
21
+ connection = ActiveRecord::Base.establish_connection new_config
22
+ connection.checkout
23
+ rescue
23
24
  create_new_db_or_fallback current_config, new_config
24
25
  end
25
26
  end
@@ -3,32 +3,6 @@ require 'fileutils'
3
3
  module Flipp
4
4
  module Helpers
5
5
  module GitHelper
6
- def self.hook_installed?
7
- File.exists? File.join(Rails.root, '.git/hooks/post-checkout')
8
- end
9
-
10
- def self.install_hook
11
- # Check for the .git directory
12
- if File.directory? '.git'
13
- unless File.directory? '.git/hooks'
14
- # Create hooks directory
15
- end
16
-
17
- # Copy the file to the git hooks
18
- puts 'Moving git hook into place...'
19
- FileUtils.cp File.join(File.dirname(__FILE__), '..', 'git_hooks', 'post-checkout'), File.join(Rails.root, '.git/hooks/post-checkout')
20
- # And give it execute permissions
21
- FileUtils.chmod 0755, '.git/hooks/post-checkout'
22
- else
23
- puts "Can't find your .git directory. Are you at the root of your project?"
24
- end
25
- end
26
-
27
- def self.uninstall_hook
28
- puts 'Removing git hook...'
29
- FileUtils.rm File.join(Rails.root, '.git/hooks/post-checkout')
30
- end
31
-
32
6
  def self.current_branch
33
7
  `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* /\1/'`.chomp[1..-1] # Remove control character
34
8
  end
data/lib/flipp/railtie.rb CHANGED
@@ -9,9 +9,5 @@ module Flipp
9
9
  flipp.switch_databases
10
10
  end
11
11
  end
12
-
13
- rake_tasks do
14
- load 'flipp/tasks.rb'
15
- end
16
12
  end
17
13
  end
@@ -12,7 +12,7 @@ describe Flipp::Flipp do
12
12
  end
13
13
 
14
14
  it 'tries to connect to the new database' do
15
- ActiveRecord::Base.should_receive(:establish_connection).with(an_instance_of(Hash))
15
+ ActiveRecord::Base.should_receive(:establish_connection).with(an_instance_of(Hash)).any_number_of_times
16
16
  flipp.switch_databases
17
17
  end
18
18
 
@@ -6,34 +6,6 @@ describe Flipp::Helpers::GitHelper do
6
6
  Rails.stub(:root).and_return(File.join(File.dirname(__FILE__), '..', '..', '..', '..'))
7
7
  end
8
8
 
9
- describe '#hook_installed?' do
10
- it 'returns true when the hook exists' do
11
- FileUtils.touch '.git/hooks/post-checkout'
12
- Flipp::Helpers::GitHelper.hook_installed?.should be_true
13
- end
14
-
15
- it 'returns false when the hook does not exists' do
16
- FileUtils.rm '.git/hooks/post-checkout'
17
- Flipp::Helpers::GitHelper.hook_installed?.should be_false
18
- end
19
- end
20
-
21
- describe '#install_hook' do
22
- it 'moves the git hook into place' do
23
- Flipp::Helpers::GitHelper.install_hook
24
- FileUtils.compare_file('.git/hooks/post-checkout', File.expand_path('../../../../../lib/flipp/git_hooks/post-checkout', __FILE__))
25
- end
26
- end
27
-
28
- describe '#uninstall_hook' do
29
- before { Flipp::Helpers::GitHelper.install_hook }
30
-
31
- it 'remove the git hook' do
32
- Flipp::Helpers::GitHelper.uninstall_hook
33
- Flipp::Helpers::GitHelper.hook_installed?.should be_false
34
- end
35
- end
36
-
37
9
  describe '#current_branch' do
38
10
  it 'returns the name of the current git branch' do
39
11
  `git checkout -b new_and_fun_branch`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.10
4
+ version: 0.0.2.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70140922642740 !ruby/object:Gem::Requirement
16
+ requirement: &70199856728960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70140922642740
24
+ version_requirements: *70199856728960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: database_exporter
27
- requirement: &70140922641700 !ruby/object:Gem::Requirement
27
+ requirement: &70199856727940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70140922641700
35
+ version_requirements: *70199856727940
36
36
  description: To alleviate issues around highly divergent development databases on
37
37
  feature/refactor branches, flipp helps switch databases upon new branch checkouts.
38
38
  email:
@@ -47,9 +47,7 @@ files:
47
47
  - lib/flipp/flipp.rb
48
48
  - lib/flipp/helpers/git_helper.rb
49
49
  - lib/flipp/railtie.rb
50
- - lib/flipp/tasks.rb
51
50
  - lib/flipp.rb
52
- - lib/flipp/git_hooks/post-checkout
53
51
  - spec/lib/flipp/flipp_spec.rb
54
52
  - spec/lib/flipp/helpers/git_helper_spec.rb
55
53
  - spec/spec_helper.rb
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rubygems'
3
- require File.join(File.dirname(__FILE__), '../../lib/flipp')
4
- # require 'flipp'
5
-
6
- if ARGV[2] == '1' # This was a branch switch
7
- flipp = Flipp.new
8
- flipp.switch_databases
9
- end
data/lib/flipp/tasks.rb DELETED
@@ -1,15 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib/flipp/helpers/git_helper')
2
-
3
- namespace :flipp do
4
- desc 'Install flipp'
5
- task :install do
6
- # Move git hook into place
7
- Flipp::Helpers::GitHelper.install_hook
8
- end
9
-
10
- desc 'Uninstall flipp'
11
- task :uninstall do
12
- # Remove git hook
13
- Flipp::Helpers::GitHelper.uninstall_hook
14
- end
15
- end