h2ocube_rails_helper 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'h2ocube_rails_helper'
7
- gem.version = '0.0.8'
7
+ gem.version = '0.0.9'
8
8
  gem.authors = ['Ben']
9
9
  gem.email = ['ben@h2ocube.com']
10
10
  gem.description = %q{Just an helper collection}
@@ -62,36 +62,36 @@ def render_title opts = {}
62
62
  "<title>#{_title(opts).join(' - ')}</title>".html_safe
63
63
  end
64
64
 
65
- def _keywords
65
+ def _keywords opts = {}
66
66
  if defined? @keywords
67
- keywords = (@keywords.class.to_s == 'Array' ? @keywords : @keywords.to_s.strip.split(/(,|,)/))
67
+ keywords = @keywords
68
68
  elsif defined?(@item) && @item.respond_to?(:keywords) && !@item.keywords.blank?
69
69
  keywords = @item.keywords.strip.split(/(,|,)/)
70
70
  else
71
- keywords = HelperSettings.keywords.strip.split(/(,|,)/)
71
+ keywords = opts.has_key?(:keywords) ? opts[:keywords] : HelperSettings.keywords.strip.split(/(,|,)/)
72
72
  end
73
- keywords.compact.map{ |k| k = k.gsub(/(,|,)/, '').strip; k.blank? ? nil : k }.compact.uniq
73
+ [keywords].flatten.compact.map{ |k| k = k.gsub(/(,|,)/, '').strip; k.blank? ? nil : k }.compact.uniq
74
74
  end
75
75
 
76
76
  def render_keywords opts = {}
77
77
  return '' if _keywords.length == 0
78
- "<meta name=\"keywords\" content=\"#{_keywords.join(',')}\" />".html_safe
78
+ "<meta name=\"keywords\" content=\"#{_keywords(opts).join(',')}\" />".html_safe
79
79
  end
80
80
 
81
- def _description
81
+ def _description opts = {}
82
82
  if defined? @description
83
83
  description = @description
84
84
  elsif defined?(@item) && @item.respond_to?(:description) && !@item.description.blank?
85
85
  description = @item.description
86
86
  else
87
- description = HelperSettings.description
87
+ description = opts.has_key?(:description) ? opts[:description] : HelperSettings.description
88
88
  end
89
89
  description.to_s.strip
90
90
  end
91
91
 
92
92
  def render_description opts = {}
93
93
  return '' if _description == ''
94
- "<meta name=\"description\" content=\"#{_description}\" />".html_safe
94
+ "<meta name=\"description\" content=\"#{_description(opts)}\" />".html_safe
95
95
  end
96
96
 
97
97
  def render_canonical opts = {}
@@ -18,6 +18,10 @@ class RenderDescriptionClass < ActionView::TestCase
18
18
  @item = Item.new
19
19
  assert_equal render_description, '<meta name="description" content="item_description" />'
20
20
  end
21
+
22
+ test 'opts' do
23
+ assert_equal render_description(description: 'opts'), '<meta name="description" content="opts" />'
24
+ end
21
25
  end
22
26
 
23
27
  class HelperSettings
@@ -20,6 +20,10 @@ class RenderKeywordsClass < ActionView::TestCase
20
20
  @item = Item.new
21
21
  assert_equal render_keywords, '<meta name="keywords" content="item_keywords" />'
22
22
  end
23
+
24
+ test 'opts' do
25
+ assert_equal render_keywords(keywords: 'opts'), '<meta name="keywords" content="opts" />'
26
+ end
23
27
  end
24
28
 
25
29
  class HelperSettings
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2ocube_rails_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: