binflip 0.0.1 → 0.0.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.
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .DS_Store
3
+
4
+ *~
5
+ \#*
6
+ .\#*
7
+
8
+ *.swp
9
+
data/binflip.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "binflip"
5
- s.version = '0.0.1'
5
+ s.version = '0.0.2'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Brian Kaney"]
8
8
  s.email = ["brian@vermonster.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binflip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,6 +18,7 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - .gitignore
21
22
  - .rvmrc
22
23
  - .travis.yml
23
24
  - Gemfile
@@ -26,11 +27,6 @@ files:
26
27
  - Rakefile
27
28
  - binflip.gemspec
28
29
  - lib/binflip.rb
29
- - lib/binflip/cucumber.rb
30
- - lib/binflip/rails.rb
31
- - lib/binflip/rails/active_support.rb
32
- - lib/binflip/rails/tasks/db.rake
33
- - lib/core_ext/rake.rb
34
30
  - test/binflip_test.rb
35
31
  homepage: ''
36
32
  licenses: []
@@ -1,56 +0,0 @@
1
- require 'binflip'
2
-
3
- module Binflip
4
- module Cucumber
5
-
6
- def self.toggle_bin!(current_bin, scenario)
7
- # Toggle bin
8
- Binflip.module_eval <<-RUBY
9
- def self.current_bin
10
- return '#{current_bin}'
11
- end
12
- RUBY
13
-
14
- # Toggle RAILS_ENV
15
- ENV["RAILS_ENV"] = Rails.env = "cucumber_#{current_bin}"
16
- ActiveRecord::Base.configurations = Rails.application.config.database_configuration
17
- ActiveRecord::Base.establish_connection
18
-
19
-
20
- # Reload routes
21
- reload_routes_if_new_bin(scenario)
22
- end
23
-
24
- def self.current_tags(scenario)
25
- [ scenario.instance_variable_get(:@tags).tag_names +
26
- scenario.instance_variable_get(:@feature).instance_variable_get(:@tags).tag_names
27
- ].flatten
28
- end
29
-
30
- def self.rails_app
31
- raise NotImplementedError
32
- end
33
-
34
- def self.reload_routes_if_new_bin(scenario)
35
- if current_tags(scenario) != $tags
36
- rails_app.reload_routes!
37
- end
38
- end
39
-
40
- end
41
- end
42
-
43
- Before do |scenario|
44
- tags = Binflip::Cucumber.current_tags(scenario)
45
-
46
- if tags.size <= 1
47
- bin = tags.first.try(:gsub, '@', '')
48
- bin = bin.nil? ? Binflip::DEPLOYED_BIN : bin
49
- Binflip::Cucumber.toggle_bin!(bin, scenario)
50
- end
51
-
52
- end
53
-
54
- After do |scenario|
55
- $tags = Binflip::Cucumber.current_tags(scenario)
56
- end
@@ -1,53 +0,0 @@
1
- module ActiveRecord
2
- # This patch all adds a #skip? method on the migration classes. It is
3
- # mainly intended to be used with feature toggles.
4
- #
5
- # class FauxMigration < ActiveRecord::Migration
6
- #
7
- # def skip?
8
- # Feature.active?('178_feature_x')
9
- # end
10
- #
11
- # def up
12
- # add_column :patients, :foob, :string
13
- # end
14
- #
15
- # def down
16
- # remove_column :patients, :foob
17
- # end
18
- # end
19
- #
20
- class Migration
21
-
22
- def skip?
23
- false
24
- end
25
-
26
- def migrate_with_skip(direction)
27
- if skip?
28
- announce "Skipping Migration, skip? returned true."
29
- else
30
- migrate_without_skip(direction)
31
- end
32
- end
33
- alias_method :migrate_without_skip, :migrate
34
- alias_method :migrate, :migrate_with_skip
35
- end
36
-
37
- class MigrationProxy
38
- delegate :skip?, :to => :migration
39
- end
40
-
41
- class Migrator
42
- def record_version_state_after_migrating_with_skip(version)
43
- current = migrations.detect { |m| m.version == version } # This is actually the proxy for the migration
44
- unless current.skip?
45
- record_version_state_after_migrating_without_skip(version)
46
- end
47
- end
48
-
49
- alias_method :record_version_state_after_migrating_without_skip, :record_version_state_after_migrating
50
- alias_method :record_version_state_after_migrating, :record_version_state_after_migrating_with_skip
51
- end
52
-
53
- end
@@ -1,29 +0,0 @@
1
- require 'binflip'
2
-
3
- namespace :db do
4
- namespace :test do
5
- task :prepare_with_kanban do
6
- Binflip::BINS.each do |bin|
7
- # Toggle bin
8
-
9
- ENV['RAILS_ENV'] = Rails.env = "cucumber_#{bin}"
10
- puts "=== prepare for #{Rails.env}"
11
-
12
- Binflip.module_eval <<-RUBY
13
- def self.current_bin
14
- return '#{bin}'
15
- end
16
- RUBY
17
-
18
- Rake::Task['db:drop'].execute
19
- Rake::Task['db:create'].execute
20
- Rake::Task['db:migrate'].execute
21
- Rake::Task['db:schema:dump'].execute
22
- Rake::Task['db:test:prepare_without_kanban'].execute
23
- end
24
- end
25
- end
26
- end
27
-
28
- alias_task('db:test:prepare_without_kanban', 'db:test:prepare')
29
- alias_task('db:test:prepare', 'db:test:prepare_with_kanban')
data/lib/binflip/rails.rb DELETED
@@ -1 +0,0 @@
1
- require 'binflip/rails/active_support' #if defined?(ActiveSupport::Base)
data/lib/core_ext/rake.rb DELETED
@@ -1,14 +0,0 @@
1
- # This is an alias method, e.g.:
2
- #
3
- # alias_task(:alias_task, :original_task)
4
- #
5
- def alias_task(name, old_name)
6
- t = Rake::Task[old_name]
7
- desc t.full_comment if t.full_comment
8
- task name, *t.arg_names do |_, args|
9
- # values_at is broken on Rake::TaskArguments
10
- args = t.arg_names.map { |a| args[a] }
11
- t.invoke(args)
12
- end
13
- end
14
-