silent_fail_check 0.0.5 → 0.1.0

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
- MThmNzhmNDE1MjEyYjgwNmQ3MGVhYWFlNWU5NGRhYTlmYzBlZTIwYQ==
4
+ NWI5ZjdjNGU0MTFhOWM1OThjNTAzMGE2N2U1MWZkYjA3NjA0MzE5Zg==
5
5
  data.tar.gz: !binary |-
6
- MmQ4NjE3NGI4OThkMjkxOTJkYzZjNzVkMTc5YTIyMWE4ZTY3Y2Y3Mg==
6
+ MGFjNTgyOGMxNTk1MzlmYmVmYWVmNmEyNTA5MjcxNWQ2NDk4NGE5OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWUyZTQxOWIwZjkzNGFmODE2MDUyNDhkYjhiNzliMmJiZGIwMTUyMDg1OTU1
10
- M2JlNDg1M2QzMDU4YWZlYTY3YWNhYWMzMzJmOTA5M2E2ZTQ3ZGJjY2VjZGJi
11
- NTlhMWM0ZmExZmQyMzYyN2U1OGI3NGQyNzE5YzJiMzQ2ZjY5Nzg=
9
+ OWNmNjBhNDVkODc3YTRmYjc5ZjZjZTA4YTI5OGZjOWUwZDI0YmU0OGJhYWNm
10
+ OTY3NTg5NDBiMGIxOGNkZTA5ZTEzODVlOTU2ZjdjYjYxMTc4NjZiOTVkZDdj
11
+ NzFiOTVmNTMwNzBhOWQ3NTNmYmM1OWJiMDY3ZjFlYWU0ZGNiYzM=
12
12
  data.tar.gz: !binary |-
13
- MTIxM2E2OTEyNDYzZjc2ZWEyY2FlZmE3ZjRkNzdmYjhjMjY5OTJiMWZkYzFl
14
- NDUyY2QwM2ZmNDQ0ZTYyNTE4MTQ5OWQ5MDE1NmY1NjU4ZjI5NmViZWU4OTUw
15
- MDkzM2M5MGZiNGFlN2RmNGU5NjE0NTE2NDU0OWQyYmVlZGExMzM=
13
+ OGQ2MjU4YThkMGQzNTQyZjE5MTIwYzc2N2UwODIxNjMxYWU4ZGJmODgwNDM3
14
+ NTFhYTlmNWY2NTg0MDRlOGNiMGZlMDI5N2JkYTkwYmUzNmEwZDNiNGQxMjA3
15
+ MmQzZTFlMDkzOWQzMDQ2NDUwYzcxMmYyYzczMDg2ZTg3ZmFhOGE=
@@ -5,22 +5,19 @@ module SilentFailCheck
5
5
  module Models
6
6
  CheckParameters = Struct.new(:sym, :args, :block)
7
7
 
8
- def silent_fail_check sym, *args, &block
9
- extend ClassMethods
8
+ def silent_fail_check(sym, *args, &block)
9
+ extend ClassMethods
10
10
  include InstanceMethods
11
11
 
12
12
  @check_parameters = CheckParameters.new(sym, args, block)
13
13
  method_name = "add_#{sym}_fail_check"
14
- send(method_name) if respond_to?(method_name, true)
14
+ send(method_name) if respond_to?(method_name, include_all: true)
15
15
  end
16
16
 
17
17
  module ClassMethods
18
-
19
18
  private
20
19
 
21
- def check_parameters
22
- @check_parameters
23
- end
20
+ attr_reader :check_parameters
24
21
 
25
22
  def add_validation_fail_check
26
23
  after_validation "#{check_parameters.sym}_fail_check"
@@ -28,7 +25,6 @@ module SilentFailCheck
28
25
  end
29
26
 
30
27
  module InstanceMethods
31
-
32
28
  private
33
29
 
34
30
  def validation_fail_check
@@ -36,14 +32,13 @@ module SilentFailCheck
36
32
 
37
33
  if p.block.nil?
38
34
  p.args.each do |a|
39
- Logger.add("#{self.class} : #{a} #{self.errors[a]}") if self.errors[a].present?
35
+ Logger.add("#{self.class} : #{a} #{errors[a]}") if errors[a].present?
40
36
  end
41
37
  else
42
- p.args.collect &p.block
38
+ p.args.map(&p.block)
43
39
  end
44
40
  end
45
41
  end
46
42
  end
47
-
48
43
  ActiveRecord::Base.extend Models
49
44
  end
@@ -1,17 +1,19 @@
1
1
  module SilentFailCheck
2
- class Logger
3
- @@options = {}
4
- @@is_configured = false
2
+ module Logger
3
+ extend self
5
4
 
6
- def self.configure opts={}
7
- @@options[:model] = opts[:model] || SilentFailLog
8
- @@options[:message] = opts[:message] || 'message'
9
- @@is_configured = true
5
+ @options = {}
6
+ @is_configured = false
7
+
8
+ def configure(opts = {})
9
+ @options[:model] = opts[:model] || SilentFailLog
10
+ @options[:message] = opts[:message] || 'message'
11
+ @is_configured = true
10
12
  end
11
13
 
12
- def self.add message
13
- self.configure if !@is_configured
14
- @@options[:model].send(:create, @@options[:message].to_sym => message)
14
+ def add(message)
15
+ configure unless @is_configured
16
+ @options[:model].send(:create, @options[:message].to_sym => message)
15
17
  end
16
18
  end
17
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silent_fail_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Folie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-06 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,30 +42,82 @@ dependencies:
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
45
48
  - - ! '>='
46
49
  - !ruby/object:Gem::Version
47
- version: '0'
50
+ version: 1.3.9
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: '1.3'
52
58
  - - ! '>='
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
60
+ version: 1.3.9
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: pry
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '0.10'
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: 0.10.0
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.10'
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: 0.10.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: coveralls
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.7'
59
88
  - - ! '>='
60
89
  - !ruby/object:Gem::Version
61
- version: '0'
90
+ version: 0.7.0
62
91
  type: :development
63
92
  prerelease: false
64
93
  version_requirements: !ruby/object:Gem::Requirement
65
94
  requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '0.7'
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: 0.7.0
101
+ - !ruby/object:Gem::Dependency
102
+ name: rake
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ~>
106
+ - !ruby/object:Gem::Version
107
+ version: '10.3'
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 10.3.2
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '10.3'
66
118
  - - ! '>='
67
119
  - !ruby/object:Gem::Version
68
- version: '0'
120
+ version: 10.3.2
69
121
  - !ruby/object:Gem::Dependency
70
122
  name: activerecord
71
123
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +132,7 @@ dependencies:
80
132
  - - ~>
81
133
  - !ruby/object:Gem::Version
82
134
  version: '4.0'
83
- description: Handle silent failure on ActiveRecord::Base
135
+ description: Handle silent failure on ActiveRecord models
84
136
  email: folie.adrien@gmail.com
85
137
  executables: []
86
138
  extensions: []