pg_shrink 0.0.6 → 0.0.7

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: 1f5d381b33119abf32ee3e51c3d9efe5997194ff
4
- data.tar.gz: 255bcaed0c21c079370b483ac5941a5c7a320c1f
3
+ metadata.gz: 117e596cf13247f02367b4a68c567e992af5be2a
4
+ data.tar.gz: 923fdb14ee56b247545369797a6bdca7408d8953
5
5
  SHA512:
6
- metadata.gz: 8c6a6fc900c387196c7dfb973337123867b010bb6e7e9ea85e543e69ff23c0d69a1cfab472133b406d4ee421f8a9caf2e650671ca7cc9fee45b35016dffb8783
7
- data.tar.gz: 477d58878e5e00c8bf2f73d2818e4e672d5172eff9533c44d97025fdf1013637a380bda218d0e970575c846606471845538efdd8d62734b343738d8a22115ea2
6
+ metadata.gz: 8e4d119d4f47a29027e52b7311b04e2232b87510245ef09f727dbfc9d9b32472f6f07bb6dd2fd4287994147078a61b9ca3e06389a8d0fb084965ff642618a05c
7
+ data.tar.gz: 279662e61bb4fdfef90de4ed31f01ea2cad82f5c52460f27fff5223028ad979a309cb843863f042beaf9e9c825b3f6003c3bdc50ba0a94bfeab5c08d0b3c2913
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ tmp
22
22
  mkmf.log
23
23
  *.swp
24
24
  spec/pg_config.yml
25
+ .idea/*
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ #
2
+ language: ruby
3
+ rvm: 2.1.2
4
+ cache:
5
+ - bundler
6
+ - apt
7
+ before_script:
8
+ - cp spec/pg_config.travis.yml spec/pg_config.yml
9
+ - createdb test_pg_shrink
10
+ addons:
11
+ postgresql: '9.3'
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/apartmentlist/pg-shrink.svg?branch=master)](https://travis-ci.org/apartmentlist/pg-shrink)
2
+
1
3
  # PgShrink
2
4
 
3
5
  The pg_shrink tool makes it easy to shrink and sanitize a postgres database,
@@ -19,9 +21,8 @@ or sanitization is to be propagated.
19
21
 
20
22
  ```ruby
21
23
  filter_table :users do |f|
22
- f.filter_by do |u|
23
- u[:name].match(/save me/)
24
- end
24
+ f.filter_by 'id % 1000 = 0'
25
+
25
26
  f.sanitize do |u|
26
27
  u[:email] = "sanitized_email#{u[:id]}@fake.com"
27
28
  u
@@ -37,6 +38,7 @@ those users, and then filter the user_preferences table to contain only
37
38
  preferences associated with those users.
38
39
 
39
40
  ### Full DSL
41
+
40
42
  See the Shrinkfile.example file in this directory for a complete list of the
41
43
  available DSL.
42
44
 
data/Shrinkfile.example CHANGED
@@ -1,23 +1,9 @@
1
+
1
2
  filter_table :users do |f|
2
3
 
3
4
  # filter_by takes a sql condition for the records you would like to keep.
4
5
  # This condition can be as a hash or string
5
6
  f.filter_by("id % 1000 == 0")
6
-
7
- # NOTE: It can also take a block that expects the fields of each record (as
8
- # a hash) the block should return true to keep the record, false if not.
9
- # However, this approach is substantially slower than the conditions hash
10
- # based approach.
11
- #f.filter_by do |u|
12
- # u[:id] % 1000 == 0
13
- #end
14
-
15
- # lock takes a block and yields the fields of each record (as a hash of
16
- # fieldname => value) If the block returns true this record is immune to all
17
- # further filtering.
18
- f.lock do |u|
19
- u[:email].split('@').last == 'apartmentlist.com'
20
- end
21
7
 
22
8
  # sanitize takes a block, yields the fields of each record as a hash of
23
9
  # fieldname => value and should return a new set of fields that has been
@@ -44,7 +30,7 @@ filter_table :users do |f|
44
30
  :type => 'User')
45
31
 
46
32
  # If it feels more natural, you can define additional filters
47
- # or locks within a filter_subtable definitition
33
+ # within a filter_subtable definitition
48
34
  f.filter_subtable(:lockable_table, :foreign_key => :user_id) do |sub|
49
35
  sub.lock do |u|
50
36
  u[:locked] == true
data/bin/pg_shrink CHANGED
@@ -37,9 +37,9 @@ Please make sure you have a Shrinkfile or specify one using -c
37
37
  options[:force] = true
38
38
  end
39
39
 
40
- verbose_desc = 'run in verbose mode'
41
- opts.on('-v', '--verbose', verbose_desc) do
42
- options[:log] = true
40
+ quiet_desc = 'run in quiet mode, nothing will be printed'
41
+ opts.on('-q', '--quiet', quiet_desc) do
42
+ options[:log] = false
43
43
  end
44
44
 
45
45
  opts.on('-h', '--help', 'Show this message and exit') do |h|
@@ -162,6 +162,7 @@ module PgShrink
162
162
  filter!
163
163
  vacuum_and_reindex_all!
164
164
  sanitize!
165
+ self.log("Shrinking Done!")
165
166
  end
166
167
  end
167
168
  end
@@ -14,8 +14,7 @@ module PgShrink
14
14
  :child_table => self.table.table_name,
15
15
  :parent_key => primary_key,
16
16
  :child_key => foreign_key,
17
- :conditions => additional_conditions,
18
- :exclude => self.table.lock_opts)
17
+ :conditions => additional_conditions)
19
18
 
20
19
  self.database.log("Done with subtable propagation from " +
21
20
  "#{self.parent.table_name} to #{self.table.table_name}")
@@ -3,7 +3,7 @@ module PgShrink
3
3
  attr_accessor :table_name
4
4
  attr_accessor :database
5
5
  attr_accessor :opts
6
- attr_reader :filters, :sanitizers, :subtable_filters, :subtable_sanitizers, :lock_opts
6
+ attr_reader :filters, :sanitizers, :subtable_filters, :subtable_sanitizers
7
7
  # TODO: Figure out, do we need to be able to support tables with no
8
8
  # keys? If so, how should we handle that?
9
9
  def initialize(database, table_name, opts = {})
@@ -16,12 +16,8 @@ module PgShrink
16
16
  @subtable_sanitizers = []
17
17
  end
18
18
 
19
- def update_options(opts)
20
- @opts = @opts.merge(opts)
21
- end
22
-
23
- def filter_by(opts = {}, &block)
24
- self.filters << TableFilter.new(self, opts, &block)
19
+ def filter_by(opts)
20
+ self.filters << TableFilter.new(self, opts)
25
21
  end
26
22
 
27
23
  def filter_subtable(table_name, opts = {})
@@ -30,31 +26,6 @@ module PgShrink
30
26
  yield filter.table if block_given?
31
27
  end
32
28
 
33
- def lock(opts = {}, &block)
34
- @lock_opts = opts
35
- if block_given?
36
- puts "WARNING: Block-based lock on #{self.table_name} will make things SLOW"
37
- @lock_block = block
38
- end
39
- end
40
-
41
- def has_lock?
42
- (@lock_opts && @lock_opts.any?) || @lock_block
43
- end
44
-
45
- def lock_condition_ok?
46
- !@lock_block
47
- end
48
-
49
- def locked?(record)
50
- if @lock_block
51
- @lock_block.call(record)
52
- elsif @lock_opts && @lock_opts.any?
53
- raise "Unimplemented: Condition-based locks with block-based " +
54
- "filter on table #{self.table_name}"
55
- end
56
- end
57
-
58
29
  def sanitize(opts = {}, &block)
59
30
  self.sanitizers << TableSanitizer.new(self, opts, &block)
60
31
  end
@@ -65,6 +36,14 @@ module PgShrink
65
36
  yield sanitizer.table if block_given?
66
37
  end
67
38
 
39
+
40
+ #
41
+ # internal methods not intended to be used from Shrinkfile below this point
42
+
43
+ def update_options(opts)
44
+ @opts = @opts.merge(opts)
45
+ end
46
+
68
47
  def update_records(original_records, new_records)
69
48
  if self.database
70
49
  database.update_records(self.table_name, original_records, new_records)
@@ -118,7 +97,7 @@ module PgShrink
118
97
 
119
98
  def condition_filter(filter)
120
99
  self.database.log("Beginning filter on #{table_name}")
121
- self.database.delete_records(self.table_name, {}, [filter.opts, lock_opts].compact)
100
+ self.database.delete_records(self.table_name, {}, filter.opts)
122
101
  self.database.log("Done filtering on #{table_name}")
123
102
  # If there aren't any subtables, there isn't much benefit to vacuuming in
124
103
  # the middle, and we'll wait until we're done with all filters
@@ -127,14 +106,6 @@ module PgShrink
127
106
  end
128
107
  end
129
108
 
130
- def filter_batch(batch, &filter_block)
131
- new_set = batch.select do |record|
132
- locked?(record) || filter_block.call(record.dup)
133
- end
134
- delete_records(batch, new_set)
135
- filter_subtables(batch, new_set)
136
- end
137
-
138
109
  def sanitize_batch(batch, &sanitize_block)
139
110
  new_set = batch.map do |record|
140
111
  sanitize_block.call(record.dup)
@@ -148,16 +119,8 @@ module PgShrink
148
119
  remove!
149
120
  else
150
121
  self.filters.each do |filter|
151
- if filter.conditions? && self.lock_condition_ok?
152
- self.condition_filter(filter)
153
- self.subtable_filters.each(&:propagate_table!)
154
- else
155
- self.records_in_batches do |batch|
156
- self.filter_batch(batch) do |record|
157
- filter.apply(record)
158
- end
159
- end
160
- end
122
+ self.condition_filter(filter)
123
+ self.subtable_filters.each(&:propagate_table!)
161
124
  end
162
125
  end
163
126
  end
@@ -173,7 +136,7 @@ module PgShrink
173
136
  end
174
137
 
175
138
  def can_just_remove?
176
- self.subtable_filters.empty? && self.subtable_sanitizers.empty? && !has_lock?
139
+ self.subtable_filters.empty? && self.subtable_sanitizers.empty?
177
140
  end
178
141
 
179
142
  # Mark @remove and add filter so that if we're in the simple case we can
@@ -181,7 +144,7 @@ module PgShrink
181
144
  # dependencies will be handled
182
145
  def mark_for_removal!
183
146
  @remove = true
184
- self.filter_by { false }
147
+ self.filter_by 'false'
185
148
  end
186
149
 
187
150
  def remove?
@@ -6,31 +6,5 @@ module PgShrink
6
6
  @opts = opts
7
7
  @block = block if block_given?
8
8
  end
9
-
10
- def conditions?
11
- # use !empty instead of any? because we accept string conditions
12
- !@block
13
- end
14
-
15
- def apply(hash)
16
- if @block
17
- @block.call(hash)
18
- # if we have a straightforwards conditions hash can just do in place comparisons
19
- elsif @opts.is_a?(Hash)
20
- @opts.each do |k, v|
21
- if [Array, Range].include?(v.class)
22
- return false unless v.include?(hash[k])
23
- elsif [String, Integer, Float].include?(v.class)
24
- return false unless hash[k] == v
25
- else
26
- raise "Unsupported condition type for mixing with block locks: #{v.class}"
27
- end
28
- end
29
- return true
30
- #TODO: Figure out if this case matters and we want to support it.
31
- elsif @opts.is_a?(String)
32
- raise "Unsupported: Mixing string conditions with block locks"
33
- end
34
- end
35
9
  end
36
10
  end
@@ -1,3 +1,3 @@
1
1
  module PgShrink
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/pg_shrink.rb CHANGED
@@ -12,6 +12,7 @@ require "pg_shrink/sub_table_operator"
12
12
  require "pg_shrink/sub_table_filter"
13
13
  require "pg_shrink/sub_table_sanitizer"
14
14
  require "pg_shrink/table"
15
+
15
16
  module PgShrink
16
17
 
17
18
  def self.blank_options
@@ -20,7 +21,7 @@ module PgShrink
20
21
  config: 'Shrinkfile',
21
22
  force: false,
22
23
  batch_size: 10000,
23
- log: false,
24
+ log: true,
24
25
  }
25
26
  end
26
27
 
@@ -30,7 +31,7 @@ module PgShrink
30
31
  "Please specify postgres url using -u <postgres_url>")
31
32
  end
32
33
  uri = URI.parse(url)
33
- if uri.scheme == 'postgres' && !uri.user.blank? && uri.path != '/'
34
+ if uri.scheme == 'postgres' && uri.path != '/'
34
35
  return true
35
36
  else
36
37
  abort("Error loading postgres: " +
@@ -60,9 +61,9 @@ module PgShrink
60
61
  abort("Batch size must be at least 1. #{options[:batch_size]} is invalid!")
61
62
  end
62
63
 
63
- database = Database::Postgres.new(:postgres_url => options[:url],
64
- :batch_size => batch_size,
65
- :log => options[:log])
64
+ database = PgShrink::Database::Postgres.new(postgres_url: options[:url],
65
+ batch_size: batch_size,
66
+ log: options[:log])
66
67
 
67
68
  database.instance_eval(File.read(options[:config]), options[:config], 1)
68
69
 
data/pg_shrink.gemspec CHANGED
@@ -4,31 +4,34 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'pg_shrink/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "pg_shrink"
7
+ spec.name = 'pg_shrink'
8
8
  spec.version = PgShrink::VERSION
9
- spec.authors = ["Kevin Ball"]
10
- spec.email = ["kmball11@gmail.com"]
11
- spec.description = "pg_shrink makes it simple to shrink and sanitize a psql database"
12
- spec.summary = ""
13
- spec.homepage = "https://github.com/apartmentlist/pg-shrink"
14
- spec.license = "MIT"
9
+ spec.authors = ['Kevin Ball']
10
+ spec.email = ['kmball11@gmail.com']
11
+ spec.description = 'pg_shrink makes it simple to shrink and sanitize a PosrgreSQL database'
12
+ spec.summary = 'pg_shrink'
13
+ spec.homepage = 'https://github.com/apartmentlist/pg-shrink'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = '>= 1.9.2'
22
+
21
23
  spec.add_runtime_dependency 'pg'
22
- spec.add_runtime_dependency 'activesupport'
23
- spec.add_runtime_dependency 'sequel'
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "rspec-nc"
28
- spec.add_development_dependency "rspec-mocks"
29
- spec.add_development_dependency "guard"
30
- spec.add_development_dependency "guard-rspec"
31
- spec.add_development_dependency "pry"
32
- spec.add_development_dependency "pry-remote"
33
- spec.add_development_dependency "pry-nav"
24
+ spec.add_runtime_dependency 'activesupport', '~> 4.0'
25
+ spec.add_runtime_dependency 'sequel', '~> 4.0'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.6'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec', '~> 2.0'
30
+ spec.add_development_dependency 'rspec-nc'
31
+ spec.add_development_dependency 'rspec-mocks'
32
+ spec.add_development_dependency 'guard'
33
+ spec.add_development_dependency 'guard-rspec'
34
+ spec.add_development_dependency 'pry'
35
+ spec.add_development_dependency 'pry-remote'
36
+ spec.add_development_dependency 'pry-nav'
34
37
  end
@@ -1,6 +1,4 @@
1
1
  filter_table :users do |f|
2
- f.filter_by do |u|
3
- u[:name] == "test 1"
4
- end
2
+ f.filter_by "name = 'test 1'"
5
3
  f.filter_subtable(:user_preferences, :foreign_key => :user_id)
6
4
  end
@@ -0,0 +1,3 @@
1
+ test:
2
+ database: test_pg_shrink
3
+ host: localhost
@@ -6,53 +6,12 @@ describe PgShrink::Table do
6
6
  let(:table) { PgShrink::Table.new(database, :test_table) }
7
7
 
8
8
  before(:each) do
9
- table.filter_by {|test| test[:u] == 1 }
9
+ table.filter_by 'u = 1'
10
10
  end
11
11
 
12
12
  it "should add filter to filters array" do
13
13
  expect(table.filters.size).to eq(1)
14
14
  end
15
-
16
- it "should accept values that match the block" do
17
- expect(table.filters.first.apply({:u => 1})).to eq(true)
18
- end
19
-
20
- it "should reject values that don't match the block" do
21
- expect(table.filters.first.apply({:u => 2})).to eq(false)
22
- end
23
-
24
- context "when running filters" do
25
- it "should return matching subset" do
26
- test_data = [{:u => 1}, {:u => 2}]
27
- expect(table).to receive(:records_in_batches).and_yield(test_data)
28
- expect(table).to receive(:delete_records) do |old_batch, new_batch|
29
- expect(old_batch.size).to eq(2)
30
- expect(new_batch.size).to eq(1)
31
- expect(new_batch.first).to eq({:u => 1})
32
- end
33
- table.filter!
34
- end
35
- end
36
-
37
- context "when locked" do
38
- before(:each) do
39
- table.lock { |test| !!test[:lock] }
40
- end
41
-
42
- it "should not filter locked records" do
43
- test_data = [{:u => 1, :lock => false},
44
- {:u => 2, :lock => false},
45
- {:u => 2, :lock => true}]
46
- allow(table).to receive(:records_in_batches).and_yield(test_data)
47
- allow(table).to receive(:delete_records) do |old_batch, new_batch|
48
- expect(old_batch.size).to eq(3)
49
- expect(new_batch.size).to eq(2)
50
- expect(new_batch).
51
- to eq([{:u => 1, :lock => false}, {:u => 2, :lock => true}])
52
- end
53
- table.filter!
54
- end
55
- end
56
15
  end
57
16
 
58
17
  context "when a sanitizer is specified" do
@@ -104,26 +63,8 @@ describe PgShrink::Table do
104
63
  it "adds subtable_filter to subtable_filters array" do
105
64
  expect(table.subtable_filters.size).to eq(1)
106
65
  end
107
-
108
- describe "when running filters" do
109
- before(:each) do
110
- table.filter_by do |test|
111
- !!test[:u]
112
- end
113
- end
114
-
115
- it "runs subtable filters with old and new batches" do
116
- test_data = [{:u => true}, {:u => false}]
117
- expect(table).to receive(:records_in_batches).and_yield(test_data)
118
- expect(database).to receive(:delete_records)
119
- expect(table).to receive(:filter_subtables) do |old_batch, new_batch|
120
- expect(old_batch).to eq(test_data)
121
- expect(new_batch).to eq([{:u => true}])
122
- end
123
- table.filter!
124
- end
125
- end
126
66
  end
67
+
127
68
  context "when a remove is specified" do
128
69
  let(:database) {PgShrink::Database.new}
129
70
  let(:table) { PgShrink::Table.new(database, :test_table) }
@@ -138,17 +79,5 @@ describe PgShrink::Table do
138
79
  table.shrink!
139
80
  end
140
81
 
141
- it "should allow locking of records" do
142
- table.lock do |u|
143
- u[:u] == 1
144
- end
145
- expect(table).to receive(:records_in_batches).and_yield(test_data)
146
- expect(table).to receive(:delete_records) do |old_batch, new_batch|
147
- expect(old_batch).to eq(test_data)
148
- expect(new_batch).to eq([{:u => 1}])
149
- end
150
- table.shrink!
151
- end
152
-
153
82
  end
154
83
  end
@@ -104,70 +104,6 @@ describe PgShrink do
104
104
  expect(remaining_users.size).to eq(10)
105
105
  end
106
106
 
107
- describe "and a condition hash lock" do
108
- before(:each) do
109
- database.filter_table(:users) do |f|
110
- f.lock(name: "test 11")
111
- end
112
- end
113
- it "Should not call records in batches" do
114
- expect(database).not_to receive(:records_in_batches)
115
- database.shrink!
116
- end
117
-
118
- it "Should call delete_records once" do
119
- expect(database).to receive(:delete_records).once
120
- database.shrink!
121
- end
122
- it "Still results in the appropriate records being deleted" do
123
- database.shrink!
124
- remaining_users = database.connection.from(:users).all
125
- expect(remaining_users.size).to eq(11)
126
- end
127
- end
128
-
129
- describe "and a condition string lock" do
130
- before(:each) do
131
- database.filter_table(:users) do |f|
132
- f.lock("name = 'test 11'")
133
- end
134
- end
135
- it "Should not call records in batches" do
136
- expect(database).not_to receive(:records_in_batches)
137
- database.shrink!
138
- end
139
-
140
- it "Should call delete_records once" do
141
- expect(database).to receive(:delete_records).once
142
- database.shrink!
143
- end
144
- it "Still results in the appropriate records being deleted" do
145
- database.shrink!
146
- remaining_users = database.connection.from(:users).all
147
- expect(remaining_users.size).to eq(11)
148
- end
149
- end
150
-
151
- describe "and a block-based lock" do
152
- before(:each) do
153
- database.filter_table(:users) do |f|
154
- f.lock do |u|
155
- u[:name] == "test 11"
156
- end
157
- end
158
- end
159
- it "falls back to results in batches" do
160
- expect(database).to receive(:records_in_batches)
161
- database.shrink!
162
- end
163
- it "Still results in the appropriate records being deleted" do
164
- database.shrink!
165
- remaining_users = database.connection.from(:users).all
166
- expect(remaining_users.size).to eq(11)
167
- end
168
-
169
- end
170
-
171
107
  describe "with a subtable_filter" do
172
108
  before(:each) do
173
109
  database.filter_table(:users) do |f|
@@ -183,14 +119,6 @@ describe PgShrink do
183
119
  end
184
120
  end
185
121
 
186
- it "Should not run delete if there is nothing filtered" do
187
- database.filter_table(:users) do |f|
188
- f.filter_by {true}
189
- end
190
- expect(database).not_to receive(:delete_records)
191
- database.shrink!
192
- end
193
-
194
122
  describe "with a test shrinkfile" do
195
123
  let(:shrinkfile) {"spec/Shrinkfile.basic"}
196
124
  let(:url) {database.connection_string}
@@ -207,9 +135,7 @@ describe PgShrink do
207
135
  describe "a simple filter and subtable" do
208
136
  before(:each) do
209
137
  database.filter_table(:users) do |f|
210
- f.filter_by do |u|
211
- u[:name] == "test 1"
212
- end
138
+ f.filter_by "name = 'test 1'"
213
139
  f.filter_subtable(:user_preferences, :foreign_key => :user_id)
214
140
  end
215
141
  database.filter!
@@ -234,9 +160,7 @@ describe PgShrink do
234
160
 
235
161
  before(:each) do
236
162
  database.filter_table(:users) do |f|
237
- f.filter_by do |u|
238
- u[:name] == "test 1"
239
- end
163
+ f.filter_by "name = 'test 1'"
240
164
  f.sanitize do |u|
241
165
  u[:name] = "sanitized #{u[:name]}"
242
166
  u[:email] = "blank_email#{u[:id]}@foo.bar"
@@ -269,7 +193,7 @@ describe PgShrink do
269
193
  expect(remaining_preferences.size).to eq(3)
270
194
  expect(remaining_preferences.all? do |p|
271
195
  p[:value] =~ /sanitized/
272
- end).to be_true
196
+ end).to be true
273
197
  end
274
198
  end
275
199
  end
@@ -367,9 +291,7 @@ describe PgShrink do
367
291
  describe "a simple filter and chained subtables" do
368
292
  before(:each) do
369
293
  database.filter_table(:users) do |f|
370
- f.filter_by do |u|
371
- u[:name] == "test 1"
372
- end
294
+ f.filter_by "name = 'test 1'"
373
295
  f.filter_subtable(:user_preferences, :foreign_key => :user_id)
374
296
  end
375
297
  database.filter_table(:user_preferences) do |f|
@@ -528,9 +450,7 @@ describe PgShrink do
528
450
  describe "simple two table filtering" do
529
451
  before(:each) do
530
452
  database.filter_table(:users) do |f|
531
- f.filter_by do |u|
532
- u[:name] == "test 1"
533
- end
453
+ f.filter_by "name = 'test 1'"
534
454
  f.filter_subtable(:preferences, :foreign_key => :context_id,
535
455
  :type_key => :context_type, :type => 'User')
536
456
  end
@@ -580,9 +500,7 @@ describe PgShrink do
580
500
  end
581
501
 
582
502
  database.filter_table(:users) do |f|
583
- f.filter_by do |u|
584
- u[:name] == "test 1"
585
- end
503
+ f.filter_by "name = 'test 1'"
586
504
  f.filter_subtable(:preferences, :foreign_key => :context_id,
587
505
  :type_key => :context_type, :type => 'User')
588
506
  end
@@ -657,9 +575,7 @@ describe PgShrink do
657
575
  describe "With a simple cascading filter" do
658
576
  before(:each) do
659
577
  database.filter_table(:users) do |f|
660
- f.filter_by do |u|
661
- u[:name] == "test 1"
662
- end
578
+ f.filter_by "name = 'test 1'"
663
579
  f.filter_subtable(:apartments_users,
664
580
  :foreign_key => :user_id) do |t|
665
581
  t.filter_subtable(:apartments, :foreign_key => :id,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_shrink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ball
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '4.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '4.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '2.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '2.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-nc
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
- description: pg_shrink makes it simple to shrink and sanitize a psql database
195
+ description: pg_shrink makes it simple to shrink and sanitize a PosrgreSQL database
196
196
  email:
197
197
  - kmball11@gmail.com
198
198
  executables:
@@ -202,6 +202,7 @@ extra_rdoc_files: []
202
202
  files:
203
203
  - ".gitignore"
204
204
  - ".rspec"
205
+ - ".travis.yml"
205
206
  - Gemfile
206
207
  - Guardfile
207
208
  - README.md
@@ -221,6 +222,7 @@ files:
221
222
  - pg_shrink.gemspec
222
223
  - spec/Shrinkfile.basic
223
224
  - spec/pg_config.example.yml
225
+ - spec/pg_config.travis.yml
224
226
  - spec/pg_shrink/database/postgres_spec.rb
225
227
  - spec/pg_shrink/database_spec.rb
226
228
  - spec/pg_shrink/table_spec.rb
@@ -239,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
241
  requirements:
240
242
  - - ">="
241
243
  - !ruby/object:Gem::Version
242
- version: '0'
244
+ version: 1.9.2
243
245
  required_rubygems_version: !ruby/object:Gem::Requirement
244
246
  requirements:
245
247
  - - ">="
@@ -250,10 +252,11 @@ rubyforge_project:
250
252
  rubygems_version: 2.2.2
251
253
  signing_key:
252
254
  specification_version: 4
253
- summary: ''
255
+ summary: pg_shrink
254
256
  test_files:
255
257
  - spec/Shrinkfile.basic
256
258
  - spec/pg_config.example.yml
259
+ - spec/pg_config.travis.yml
257
260
  - spec/pg_shrink/database/postgres_spec.rb
258
261
  - spec/pg_shrink/database_spec.rb
259
262
  - spec/pg_shrink/table_spec.rb