simple_messages 1.0.0 → 1.0.1

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: 83d41874ead77c11ec3bbef3c22a0fa3f86cabb8
4
- data.tar.gz: 468cb9500317cd2763c90d4d4cfe32bc8d94a997
3
+ metadata.gz: 992e209ceb2ca1754e23c03b3e7269f9db3530a4
4
+ data.tar.gz: 7e0707e15dda322f7c1f54ee38aed17313337ebf
5
5
  SHA512:
6
- metadata.gz: 5ba07a6d9deba03c3b90981bcbef2bdac17844d959a0adb05d338ac2d752de0f3452c0ce3f1d49c2faa47e620f3e955f4e6931efa05275cd580d02e1668e50a5
7
- data.tar.gz: 5d93ec3b49b3bc631c09845c0798386604100fbeca9ae5be54c0bbd9b540f30c9a6a7508cfc9477d1a4280ebb61f4cba2e39629f15fd79982b4720d9f1f35efa
6
+ metadata.gz: 22af4e290c59a247123b2f7309fc1cc1ace62d952ccde78fc12901306b5919f42483c0bf129a0ff10f20340753b6c0919b590e9deac44db6072200969fb3abbc
7
+ data.tar.gz: 9541c78a7e8cd5d4864dfcf316f7f1783ffa56f1eeac9a728ec630204afe53cf30ad79e85918db3186831f0c49614a78d4c2744f574e6c207131c297f1a0da69
@@ -17,6 +17,8 @@ module SimpleMessages
17
17
  end
18
18
 
19
19
  def simple_messages_models
20
+ return [] if @simple_messages_models.nil? or @dont_simple_messages_models.nil?
21
+
20
22
  (@simple_messages_models.collect(&:to_sym) - @dont_simple_messages_models.collect(&:to_sym)).compact.uniq
21
23
  end
22
24
 
@@ -16,7 +16,7 @@ module SimpleMessages
16
16
 
17
17
  def simple_messages_flash(options = {})
18
18
  html = flash.collect do |kind, content|
19
- builder = Builder.new({ kind: kind, body: content }.reverse_merge(options))
19
+ builder = Builder.new options.reverse_merge(kind: kind, body: content)
20
20
 
21
21
  builder.to_html
22
22
  end
@@ -30,15 +30,15 @@ module SimpleMessages
30
30
  simple_messages_models.collect do |model_name|
31
31
  object = instance_variable_get("@#{model_name}")
32
32
 
33
- object if object.present? and object.errors.any?
33
+ object if simple_messages_object_has_errors? object
34
34
  end.compact
35
35
  end
36
36
 
37
37
  def simple_messages_validation(options = {})
38
38
  simple_messages_objects.collect do |object|
39
- title = I18n.t('errors.template.header', count: object.errors.count, model: object.class.model_name.human)
39
+ title = I18n.t('errors.template.header', count: object.errors.full_messages.count, model: object.class.model_name.human)
40
40
 
41
- builder = Builder.new({ kind: :error, body: object.errors.full_messages, header: title }.reverse_merge(options))
41
+ builder = Builder.new options.reverse_merge(kind: :error, body: object.errors.full_messages, header: title)
42
42
 
43
43
  builder.to_html
44
44
  end.join.html_safe
@@ -52,6 +52,13 @@ module SimpleMessages
52
52
  "SimpleMessages.alert(#{messages.to_json});".html_safe
53
53
  end
54
54
 
55
+ private
56
+ def simple_messages_object_has_errors?(object)
57
+ object.present? and (
58
+ (object.errors.respond_to? :any? and object.errors.any?) or
59
+ (object.errors.respond_to? :empty? and !object.errors.empty?)
60
+ )
61
+ end
62
+
55
63
  end
56
64
  end
57
-
@@ -1,3 +1,3 @@
1
1
  module SimpleMessages
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "rails", "~> 4.0.8"
21
+ spec.add_dependency "rails", ">= 4.0.8", "< 5"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.6"
24
24
  spec.add_development_dependency "coveralls"
25
- spec.add_development_dependency "fuubar", '2.0.0.rc1'
25
+ spec.add_development_dependency "fuubar", '~> 2.0'
26
26
  spec.add_development_dependency "guard"
27
27
  spec.add_development_dependency "guard-rspec"
28
28
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_messages
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 29sul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.8
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 4.0.8
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +62,16 @@ dependencies:
56
62
  name: fuubar
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '='
65
+ - - ~>
60
66
  - !ruby/object:Gem::Version
61
- version: 2.0.0.rc1
67
+ version: '2.0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '='
72
+ - - ~>
67
73
  - !ruby/object:Gem::Version
68
- version: 2.0.0.rc1
74
+ version: '2.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: guard
71
77
  requirement: !ruby/object:Gem::Requirement