h2ocube_rails_helper 0.2.0 → 0.2.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: 2029760de8193e513768ad738ce9a7f9cc23f528
4
- data.tar.gz: 4f18712410163c22368f63910a2bf5bfabfe10b6
3
+ metadata.gz: ff9367a1cb8d4cde894af108e9cd19ba08c89818
4
+ data.tar.gz: c9c426b5c1e2277406d7deff7ddda4a3f2f005c2
5
5
  SHA512:
6
- metadata.gz: bdb6d809f7fe6957fef394c0e1bce599e798a21fbdabf52011cac80b6c37e07078b3168dec5aa9a6d6f72bb30a77fa15cd3d197a6f27811439904bd89ca490a8
7
- data.tar.gz: 840e34bd8329639619d24d715192038db7584e23033cfd87290e9f972fee7388853656e6ca9d2b16bd5986d230a27db4b935d9d5b3c6cf25e1d176a5aa82c919
6
+ metadata.gz: e8743fcca0abc272473c166fdef87cc0a9ac63c89c11fa2b309dd5fc8c5ff84b288a9c021d914fe19eb0660626790cfb4f4095b8481414b10f52503ce2c24ab2
7
+ data.tar.gz: da876729a90386fe104118837170ed5310c1d0b28d534ee2c57e39748925945d43f9aaf860fbec22ce0a6125f5d95a4e7fb17cf0c4e7d32ae2cca27e3e94c7c8
data/README.md CHANGED
@@ -14,10 +14,11 @@ Add this line to your application's Gemfile:
14
14
  And then execute:
15
15
 
16
16
  $ bundle
17
- $ rails g h2ocube_rails_helper
18
17
 
19
18
  ## Usage
20
19
 
20
+ rails_secrets #=> Rails.application.secrets.deep_symbolize_keys
21
+
21
22
  escape #=> CGI.escapeHTML
22
23
  unescape #=> CGI.unescapeHTML
23
24
 
@@ -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.2.0'
7
+ gem.version = '0.2.1'
8
8
  gem.authors = ['Ben']
9
9
  gem.email = ['ben@h2ocube.com']
10
10
  gem.description = 'Just an helper collection'
@@ -53,6 +53,10 @@ module Browser
53
53
  end
54
54
  end
55
55
 
56
+ def rails_secrets
57
+ @_secrest ||= Rails.application.secrets.deep_symbolize_keys
58
+ end
59
+
56
60
  module H2ocubeRailsHelper
57
61
  module ActionView
58
62
  module Helpers
@@ -109,7 +113,7 @@ module H2ocubeRailsHelper
109
113
  if opts.key? :title
110
114
  title.push opts[:title]
111
115
  else
112
- title.push Rails.application.secrets[:title]
116
+ title.push rails_secrets[:title]
113
117
  end
114
118
  title.compact.map { |t| t = t.strip; t == '' ? nil : t }.compact
115
119
  end
@@ -128,7 +132,7 @@ module H2ocubeRailsHelper
128
132
  elsif defined?(@item) && @item.respond_to?(:keywords) && !@item.keywords.blank?
129
133
  keywords = @item.keywords.strip.split(/(,|,)/)
130
134
  else
131
- keywords = opts.key?(:keywords) ? opts[:keywords] : Rails.application.secrets[:keywords]
135
+ keywords = opts.key?(:keywords) ? opts[:keywords] : rails_secrets[:keywords]
132
136
  end
133
137
  [keywords].flatten.compact.map{ |k| k.to_s.strip.split(/(,|,)/) }.flatten.map { |k| k.gsub(/(,|,)/, '').blank? ? nil : k }.compact.uniq
134
138
  end
@@ -148,7 +152,7 @@ module H2ocubeRailsHelper
148
152
  elsif defined?(@item) && @item.respond_to?(:description) && !@item.description.blank?
149
153
  description = @item.description
150
154
  else
151
- description = opts.key?(:description) ? opts[:description] : Rails.application.secrets[:description]
155
+ description = opts.key?(:description) ? opts[:description] : rails_secrets[:description]
152
156
  end
153
157
  strip_tags description.to_s.strip
154
158
  end
@@ -168,8 +172,8 @@ module H2ocubeRailsHelper
168
172
 
169
173
  def render_ga(opts = {})
170
174
  return '' if Rails.env.development?
171
- ga = opts.key?(:ga) ? opts[:ga] : Rails.application.secrets[:ga]
172
- domain = opts.key?(:domain) ? opts[:domain] : Rails.application.secrets[:domain]
175
+ ga = opts.key?(:ga) ? opts[:ga] : rails_secrets[:ga]
176
+ domain = opts.key?(:domain) ? opts[:domain] : rails_secrets[:domain]
173
177
  return '' if ga.nil?
174
178
  "<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', '#{ga}', '#{domain}');ga('send', 'pageview');</script>".html_safe
175
179
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2ocube_rails_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-18 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: browser
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.6.8
169
+ rubygems_version: 2.6.11
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Just an helper collection