helper_methods 0.0.10 → 0.0.11

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.
@@ -1,3 +1,3 @@
1
1
  module HelperMethods
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -4,33 +4,63 @@ require "helper_methods/version"
4
4
 
5
5
  module HelperMethods
6
6
 
7
- def error_messages_for(resource, css_class = "alert alert-error")
7
+ def error_messages_for(resource, style = :bootstrap)
8
8
  if resource.errors.any?
9
- content = %(<button type="button" class="close" data-dismiss="alert">×</button>)
10
- content += %(<ul>)
11
- resource.errors.collect do |key, value|
12
- content += content_tag :li, value
13
- end.join
14
- content += %(</ul>)
9
+
10
+ if style == :bootstrap
11
+ css_class = "alert alert-error"
12
+ content = %(<button type="button" class="close" data-dismiss="alert">×</button>)
13
+ content += %(<ul>)
14
+ resource.errors.collect do |key, value|
15
+ content += content_tag :li, value
16
+ end.join
17
+ content += %(</ul>)
18
+
19
+ elsif style == :foundation
20
+ css_class = "alert-box alert"
21
+
22
+ content = %(<a href="" class="close">&times;</a>)
23
+ content += %(<ul>)
24
+ resource.errors.collect do |key, value|
25
+ content += content_tag :li, value
26
+ end.join
27
+ content += %(</ul>)
28
+ end
29
+
15
30
  content_tag :div, content.html_safe, class: css_class
16
31
  end
17
32
  end
18
33
 
19
- def flash_messages
34
+
35
+ def flash_messages(style = :bootstrap)
20
36
  if flash.any?
21
- content = %(<button type="button" class="close" data-dismiss="alert">×</button>)
22
37
 
23
- flash.collect do |key, value|
24
- unless [true, false, nil].include?(value)
25
- key = :success if key == :notice
26
- content += value
27
- content_tag(:div, content.html_safe, class: "alert alert-#{key}")
28
- end
29
- end.join.html_safe
30
- #content_tag :div, content.html_safe
38
+ if style == :bootstrap
39
+
40
+ content = %(<button type="button" class="close" data-dismiss="alert">×</button>)
41
+ flash.collect do |key, value|
42
+ unless [true, false, nil].include?(value)
43
+ key = :success if key == :notice
44
+ content += value
45
+ content_tag(:div, content.html_safe, class: "alert alert-#{key}")
46
+ end
47
+ end.join.html_safe
48
+
49
+ elsif style == :foundation
50
+ content = %(<a href="" class="close">&times;</a>)
51
+ flash.collect do |key, value|
52
+ unless [true, false, nil].include?(value)
53
+ key = :success if key == :notice
54
+ content += value
55
+ content_tag(:div, content.html_safe, class: "alert-box #{key}")
56
+ end
57
+ end.join.html_safe
58
+ end
59
+
31
60
  end
32
61
  end
33
62
 
63
+
34
64
  def mobile_device?
35
65
  request.user_agent =~ /Mobile|webOS/
36
66
  end
@@ -114,6 +144,11 @@ module HelperMethods
114
144
  false
115
145
  end
116
146
  end
147
+
148
+ def gravatar(email, html_options = {})
149
+ email = Digest::MD5.hexdigest(email)
150
+ image_tag "http://www.gravatar.com/avatar/#{email}?size=48", html_options
151
+ end
117
152
 
118
153
  end
119
154
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helper_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-27 00:00:00.000000000 Z
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: There are a small collection of simple methods
15
15
  email: