broken_record 0.0.2 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjdiYTkwNWYxYTIzNjE3OTczNzBhZDU2ZjRkY2VkNDZlNWFjYWY2Mg==
4
+ ZTEyNmRlZWM4NjUxZjdmNmE3ZWE0NjJlYzNmZDVjZDcyMTJkZGIwMw==
5
5
  data.tar.gz: !binary |-
6
- MGE1Mzc2M2Q5YzJjNzVkYzM5YmQ3OTM1Yzk2MjAzMWJlMmZiMGFkZQ==
6
+ NmYxZDNlZGI5NzJhZDRkODU1YmFkOTFlZWUyNTU0MGEyZDNmZTg4ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2M1MWE2Nzg5ODYzYjVjMzczODYzZjYxYzhmZTYwOTY4OTRmNzk0NThlZTEz
10
- YjdjMjIxZGMwZDA3OTMzZWYyMjkyYTIyYzMzNmFlODU3MjRkOGNjYTNhZDM1
11
- OGVmZGViM2Y3M2ExZTdmNDk4ODVhOTM1MjQ2MjUyN2ZjMjQ5MjQ=
9
+ ZDAyNDkxNDc2MzEyY2I1MGY3NTQ2MzVkZGI5NmM1ZWViNzE1YTc0OGJkMDkz
10
+ MjQxMWM3NmNkYjc0ZGYxZmJlN2NjMTZkNWY5MGJkZWVmYzJjY2Y1ODAyODQ4
11
+ MzkxZjRmZTQ1YjA3YTIxMzlhOTM2NThmNTE3NDllNDlhMDczOGQ=
12
12
  data.tar.gz: !binary |-
13
- NGMwNTEzMzVmYzcyZDJjMTNkODdmZDEyZDk1YWYzZmYzMzA0YWM4ZDBjZDZj
14
- ZmY3ODhkZTlmZTE4NDdlNmM0N2I2OGE4MzA5NzM3OWEyY2ZiN2EyZjFlYjI3
15
- OWE1ZjMzMGYwYjYxZjUyNTRhYzhjODE0Y2VhNTI0YmU4OTBkYWY=
13
+ MWU0ZWQxZWViZjM5ZWY2YzI4NmRjYWIwZmRiOWM4ZDEzZTE2MmJkYjYyYTc0
14
+ NjA5NDg5MWJlNzQxN2NjNDc1OTVkMjUyNTM0YTBjZmZjN2MxZTc5ZDM5YjI2
15
+ OTEyY2NiYzg2MzkyMDRmNjgyYzQzOWUxNDY0YjljNWZmNWNmMWM=
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  .bundle
4
+ /.idea
4
5
  .config
5
6
  .yardoc
6
7
  Gemfile.lock
@@ -5,4 +5,8 @@
5
5
  ## v0.0.2
6
6
 
7
7
  * Initialize BrokenRecord::Config.before_scan_callbacks
8
- * Add 'require' statements needed in lazy environments
8
+ * Add 'require' statements needed in lazy environments
9
+
10
+ ## v0.0.3
11
+
12
+ * Allow setting a per-model default scope
data/README.md CHANGED
@@ -34,6 +34,9 @@ BrokenRecord provides a configure method with two options. Here's an example:
34
34
  # Skip the Foo and Bar models when scanning.
35
35
  config.classes_to_skip = [Foo, Bar]
36
36
 
37
+ # Set a scope for which models should be validated
38
+ config.default_scopes = { Foo => proc { with_bars } }
39
+
37
40
  # BrokenRecord will call the block provided in before_scan before scanning
38
41
  # your records. This is useful for skipping validations you want to ignore.
39
42
  config.before_scan do
@@ -1,8 +1,9 @@
1
1
  module BrokenRecord
2
2
  module Config
3
3
  extend self
4
- attr_accessor :classes_to_skip, :before_scan_callbacks
4
+ attr_accessor :classes_to_skip, :before_scan_callbacks, :default_scopes
5
5
  self.before_scan_callbacks = []
6
+ self.default_scopes = {}
6
7
 
7
8
  def before_scan(&block)
8
9
  self.before_scan_callbacks << block
@@ -50,7 +50,13 @@ module BrokenRecord
50
50
  logger.log_message "Validating model #{model}... ".ljust(70)
51
51
 
52
52
  begin
53
- model.unscoped.all.each do |r|
53
+ if BrokenRecord::Config.default_scopes[model]
54
+ model_scope = model.instance_exec &BrokenRecord::Config.default_scopes[model]
55
+ else
56
+ model_scope = model.unscoped
57
+ end
58
+
59
+ model_scope.find_each do |r|
54
60
  begin
55
61
  if !r.valid?
56
62
  message = " Invalid record in #{model} id=#{r.id}."
@@ -1,3 +1,3 @@
1
1
  module BrokenRecord
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: broken_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Gervasi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.1.11
110
+ rubygems_version: 2.2.2
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Provides a rake task for scanning your ActiveRecord models and detecting