doctor_doug 0.1.2 → 0.1.3

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: 42cf84aa1d3cbf3284ca1f61cb7a3754f1efcc9a
4
- data.tar.gz: '002287f99d8c70417f2d64a96b4b68fb05a1b8b9'
3
+ metadata.gz: 0c765e1141a17da3c333f0af539d63648ca1461f
4
+ data.tar.gz: 071dd80dbc373a8f5e7e31720e574e1817cde3e7
5
5
  SHA512:
6
- metadata.gz: 948e853a0f0635426c4ac0cd7727963fa17558cbf8cf53df38e300950f7151d72eb10a08fa73fad0b62ba923ee99463f666b4d34ea8ba3288e242f9e3ceb704e
7
- data.tar.gz: c019d8343b714f4071f478ab63bf49a048267d4bb21d025655b709a7253a39cda7b1e21530dfe77d22d449f6a313508870632e49898010a80821e9565ed228e7
6
+ metadata.gz: 1b8210360c18e4cf62bf0d4227744baf469d2c5821927f82722f91d53ab58ca677298823d3e576f9fcf760b301e8f936db644bb2083b2651a325bf2895288008
7
+ data.tar.gz: f2fb96c05cf0500fe69ee32b502c649c8ef2aa8994bc3f33624a258b2a05853ab2be40289968047e932ee3ad3ced5f49fa9531e5d57742b32b0234f72149bfc8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doctor_doug (0.1.2)
4
+ doctor_doug (0.1.3)
5
5
  mail
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -42,7 +42,7 @@ end
42
42
  DoctorDoug.checkup "user name should not be blank" do
43
43
  users = User.where(updated_at: 1.hour.ago..Time.now)
44
44
  notify :if, any: users do |user|
45
- user.name.blank? # to make this work, the block must reutrn a boolean value
45
+ violate? user.name.blank?
46
46
  end
47
47
  end
48
48
 
@@ -13,16 +13,19 @@ class CheckupProxy # :nodoc:
13
13
  @checkup_name = checkup_name
14
14
  end
15
15
 
16
+ def violate?(condition)
17
+ return false unless [true, false].include?(condition)
18
+ condition
19
+ end
20
+
16
21
  def notify(condition, any:)
17
22
  raise NoneBlockGivenError unless block_given?
18
23
  collections = any
19
24
  violations = collections.map do |c|
20
25
  need_notify = false
21
26
  block_result = yield c
22
- if !!block_result == block_result
23
- need_notify = block_result if condition == :if
24
- need_notify = !block_result if condition == :unless
25
- end
27
+ need_notify = block_result if condition == :if
28
+ need_notify = !block_result if condition == :unless
26
29
  c if need_notify
27
30
  end
28
31
 
@@ -30,7 +30,7 @@ module DoctorDoug
30
30
  end
31
31
 
32
32
  def message
33
- "#{@violations.inspect}"
33
+ @violations.map(&:inspect).join(', ').to_s
34
34
  end
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module DoctorDoug
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doctor_doug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tongfei Gao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-26 00:00:00.000000000 Z
11
+ date: 2018-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail