flipper-active_record 0.10.2 → 0.11.0.beta1

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: b3f630ced8e147d7e7278e14d09ef3ea8cf43c7c
4
- data.tar.gz: 5686e445a68398169fc238d09446cdf87e0bd4ab
3
+ metadata.gz: ab2e2560bca689141f6f486224f97abe87ded3a2
4
+ data.tar.gz: a26ecd4f4a019af72b44c3aa38a93332c3d7b0e0
5
5
  SHA512:
6
- metadata.gz: 862d115e1492cb8a10c1351609ac05c01027400032bbc7845e7a9bf24adef731b9266c6efa35deb84447e0852714c21cd87b9db164c397d16345a8048d8b0980
7
- data.tar.gz: 4a7bb4aba98a72cbf907dae022d96b539d73f00d41bd6ae807cb504e215e599c435ffdbc21963f1e6b96c01b36a3c4de2e92cce99c8b42525e9050881e3222b1
6
+ metadata.gz: c829cb8be44d1881630fef42431519d547df19bd74fa19ef486d09b287161fc5e8d7fde69f93e0c2be2d9a0eb58300e8d772c4bc7b1f2a4f295453308a1d0779
7
+ data.tar.gz: 1675a0478c9313f3a7f6e4056cd11d1548e17f4583e8741d44908bd1ce2445f588c0eecda84e2bb106b2073444a2f9c51ef9bb837349c1997da2a7808cad873b
@@ -6,6 +6,7 @@ Supported Active Record versions:
6
6
 
7
7
  * 3.2.x
8
8
  * 4.2.x
9
+ * 5.0.x
9
10
 
10
11
  ## Installation
11
12
 
@@ -23,7 +24,7 @@ Or install it yourself with:
23
24
 
24
25
  ## Usage
25
26
 
26
- For your convenience a migration generator is provided to create the necessary migrations for using the active record adapter. By default this generates a migration that will create two database tables - flipper_features and flipper_gates.
27
+ For your convenience a migration generator is provided to create the necessary migrations for using the active record adapter. By default this generates a migration that will create two database tables - flipper_features and flipper_gates.
27
28
 
28
29
  $ rails g flipper:active_record
29
30
 
@@ -1,28 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require File.expand_path('../lib/flipper/version', __FILE__)
3
3
 
4
- flipper_active_record_files = lambda { |file|
4
+ flipper_active_record_files = lambda do |file|
5
5
  file =~ /active_record/
6
- }
6
+ end
7
7
 
8
8
  Gem::Specification.new do |gem|
9
- gem.authors = ["John Nunemaker"]
10
- gem.email = ["nunemaker@gmail.com"]
11
- gem.summary = "ActiveRecord adapter for Flipper"
12
- gem.description = "ActiveRecord adapter for Flipper"
13
- gem.license = "MIT"
14
- gem.homepage = "https://github.com/jnunemaker/flipper"
9
+ gem.authors = ['John Nunemaker']
10
+ gem.email = ['nunemaker@gmail.com']
11
+ gem.summary = 'ActiveRecord adapter for Flipper'
12
+ gem.description = 'ActiveRecord adapter for Flipper'
13
+ gem.license = 'MIT'
14
+ gem.homepage = 'https://github.com/jnunemaker/flipper'
15
15
 
16
16
  extra_files = [
17
- "lib/generators/flipper/templates/migration.rb",
18
- "lib/flipper/version.rb",
17
+ 'lib/generators/flipper/templates/migration.rb',
18
+ 'lib/flipper/version.rb',
19
19
  ]
20
20
  gem.files = `git ls-files`.split("\n").select(&flipper_active_record_files) + extra_files
21
21
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_active_record_files)
22
- gem.name = "flipper-active_record"
23
- gem.require_paths = ["lib"]
22
+ gem.name = 'flipper-active_record'
23
+ gem.require_paths = ['lib']
24
24
  gem.version = Flipper::VERSION
25
25
 
26
26
  gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
27
- gem.add_dependency 'activerecord', ">= 3.2", "< 6"
27
+ gem.add_dependency 'activerecord', '>= 3.2', '< 6'
28
28
  end
@@ -9,12 +9,12 @@ module Flipper
9
9
 
10
10
  # Private: Do not use outside of this adapter.
11
11
  class Feature < ::ActiveRecord::Base
12
- self.table_name = "flipper_features"
12
+ self.table_name = 'flipper_features'
13
13
  end
14
14
 
15
15
  # Private: Do not use outside of this adapter.
16
16
  class Gate < ::ActiveRecord::Base
17
- self.table_name = "flipper_gates"
17
+ self.table_name = 'flipper_gates'
18
18
  end
19
19
 
20
20
  # Public: The name of the adapter.
@@ -78,7 +78,7 @@ module Flipper
78
78
 
79
79
  def get_multi(features)
80
80
  db_gates = @gate_class.where(feature_key: features.map(&:key))
81
- grouped_db_gates = db_gates.group_by { |gate| gate.feature_key }
81
+ grouped_db_gates = db_gates.group_by(&:feature_key)
82
82
  result = {}
83
83
  features.each do |feature|
84
84
  result[feature.key] = result_for_feature(feature, grouped_db_gates[feature.key])
@@ -90,7 +90,7 @@ module Flipper
90
90
  #
91
91
  # feature - The Flipper::Feature for the gate.
92
92
  # gate - The Flipper::Gate to disable.
93
- # thing - The Flipper::Type being disabled for the gate.
93
+ # thing - The Flipper::Type being enabled for the gate.
94
94
  #
95
95
  # Returns true.
96
96
  def enable(feature, gate, thing)
@@ -165,20 +165,21 @@ module Flipper
165
165
  db_gates ||= []
166
166
  result = {}
167
167
  feature.gates.each do |gate|
168
- result[gate.key] = case gate.data_type
169
- when :boolean
170
- if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
171
- db_gate.value
172
- end
173
- when :integer
174
- if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
175
- db_gate.value
168
+ result[gate.key] =
169
+ case gate.data_type
170
+ when :boolean
171
+ if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
172
+ db_gate.value
173
+ end
174
+ when :integer
175
+ if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
176
+ db_gate.value
177
+ end
178
+ when :set
179
+ db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
180
+ else
181
+ unsupported_data_type gate.data_type
176
182
  end
177
- when :set
178
- db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
179
- else
180
- unsupported_data_type gate.data_type
181
- end
182
183
  end
183
184
  result
184
185
  end
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = "0.10.2".freeze
2
+ VERSION = '0.11.0.beta1'.freeze
3
3
  end
@@ -1,15 +1,15 @@
1
- require "rails/generators/active_record"
1
+ require 'rails/generators/active_record'
2
2
 
3
3
  module Flipper
4
4
  module Generators
5
5
  class ActiveRecordGenerator < ::Rails::Generators::Base
6
6
  include ::Rails::Generators::Migration
7
- desc "Generates migration for flipper tables"
7
+ desc 'Generates migration for flipper tables'
8
8
 
9
- source_paths << File.join(File.dirname(__FILE__), "templates")
9
+ source_paths << File.join(File.dirname(__FILE__), 'templates')
10
10
 
11
11
  def create_migration_file
12
- migration_template "migration.rb", "db/migrate/create_flipper_tables.rb"
12
+ migration_template 'migration.rb', 'db/migrate/create_flipper_tables.rb'
13
13
  end
14
14
 
15
15
  def self.next_migration_number(dirname)
@@ -11,10 +11,8 @@ RSpec.describe Flipper::Adapters::ActiveRecord do
11
11
  subject { described_class.new }
12
12
 
13
13
  before(:all) do
14
- ActiveRecord::Base.establish_connection({
15
- adapter: "sqlite3",
16
- database: ":memory:",
17
- })
14
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
15
+ database: ':memory:')
18
16
  end
19
17
 
20
18
  before(:each) do
@@ -8,10 +8,8 @@ ActiveRecord::Migration.verbose = false
8
8
  class ActiveRecordTest < MiniTest::Test
9
9
  prepend Flipper::Test::SharedAdapterTests
10
10
 
11
- ActiveRecord::Base.establish_connection({
12
- adapter: "sqlite3",
13
- database: ":memory:",
14
- })
11
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3',
12
+ database: ':memory:')
15
13
 
16
14
  def setup
17
15
  @adapter = Flipper::Adapters::ActiveRecord.new
@@ -5,12 +5,12 @@ require 'generators/flipper/active_record_generator'
5
5
 
6
6
  class FlipperActiveRecordGeneratorTest < Rails::Generators::TestCase
7
7
  tests Flipper::Generators::ActiveRecordGenerator
8
- destination File.expand_path("../../../../tmp", __FILE__)
8
+ destination File.expand_path('../../../../tmp', __FILE__)
9
9
  setup :prepare_destination
10
10
 
11
11
  def test_generates_migration
12
12
  run_generator
13
- assert_migration "db/migrate/create_flipper_tables.rb", <<-EOM
13
+ assert_migration 'db/migrate/create_flipper_tables.rb', <<-EOM
14
14
  class CreateFlipperTables < ActiveRecord::Migration
15
15
  def self.up
16
16
  create_table :flipper_features do |t|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flipper
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.2
19
+ version: 0.11.0.beta1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.2
26
+ version: 0.11.0.beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -78,12 +78,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - ">"
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: 1.3.1
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.4.5.1
86
+ rubygems_version: 2.5.2
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: ActiveRecord adapter for Flipper