h2ocube_rails_helper 0.1.3 → 0.2.0

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: bc635fefe9cbf7c3f383a3a85ccb2ed9d3b766bd
4
- data.tar.gz: ec232863a0795eb085bbea78eefd7de8b055b18b
3
+ metadata.gz: 2029760de8193e513768ad738ce9a7f9cc23f528
4
+ data.tar.gz: 4f18712410163c22368f63910a2bf5bfabfe10b6
5
5
  SHA512:
6
- metadata.gz: e601689a6498cca8bc2fbd96f0023d11db4bb78a46723b3e678ff400fb51d86d4ae5086f0aa858cff30d88c3602e055da045cc1bb4af250bd9335a192465b7d9
7
- data.tar.gz: 2d23b0f1be80336ef49e55f5a52ae52be965014840d56e7f2bb151ce06f4034814a0fede5dc42a393021399c9c474983fee0c2fc093a73e477af277d8e15af2a
6
+ metadata.gz: bdb6d809f7fe6957fef394c0e1bce599e798a21fbdabf52011cac80b6c37e07078b3168dec5aa9a6d6f72bb30a77fa15cd3d197a6f27811439904bd89ca490a8
7
+ data.tar.gz: 840e34bd8329639619d24d715192038db7584e23033cfd87290e9f972fee7388853656e6ca9d2b16bd5986d230a27db4b935d9d5b3c6cf25e1d176a5aa82c919
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.0
3
+ - 2.4.1
5
4
  script: "bundle exec rspec"
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
+ # source 'https://gems.ruby-china.org'
2
3
 
3
4
  # Specify your gem's dependencies in h2ocube_rails_helper.gemspec
4
5
  gemspec
data/README.md CHANGED
@@ -30,13 +30,12 @@ And then execute:
30
30
  render_keywords
31
31
  render_description
32
32
 
33
- render_ga #=> show Google Analytics code at production (if require Garelic, will show Garelic code)
33
+ render_ga #=> show Google Analytics code at production
34
34
 
35
35
  render_seo #=> render_title << render_canonical << render_keywords << render_description << render_ga << csrf_meta_tags
36
36
 
37
37
  ## Include
38
38
 
39
- * settingslogic https://github.com/binarylogic/settingslogic
40
39
  * browser https://github.com/fnando/browser
41
40
 
42
41
  ## Contributing
@@ -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.1.3'
7
+ gem.version = '0.2.0'
8
8
  gem.authors = ['Ben']
9
9
  gem.email = ['ben@h2ocube.com']
10
10
  gem.description = 'Just an helper collection'
@@ -17,7 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
- gem.add_dependency 'settingslogic'
21
20
  gem.add_dependency 'browser'
22
21
 
23
22
  gem.add_development_dependency 'tzinfo'
@@ -1,4 +1,3 @@
1
- require 'settingslogic'
2
1
  require 'browser'
3
2
 
4
3
  module Browser
@@ -110,7 +109,7 @@ module H2ocubeRailsHelper
110
109
  if opts.key? :title
111
110
  title.push opts[:title]
112
111
  else
113
- title.push HelperSettings.title
112
+ title.push Rails.application.secrets[:title]
114
113
  end
115
114
  title.compact.map { |t| t = t.strip; t == '' ? nil : t }.compact
116
115
  end
@@ -129,7 +128,7 @@ module H2ocubeRailsHelper
129
128
  elsif defined?(@item) && @item.respond_to?(:keywords) && !@item.keywords.blank?
130
129
  keywords = @item.keywords.strip.split(/(,|,)/)
131
130
  else
132
- keywords = opts.key?(:keywords) ? opts[:keywords] : HelperSettings.keywords
131
+ keywords = opts.key?(:keywords) ? opts[:keywords] : Rails.application.secrets[:keywords]
133
132
  end
134
133
  [keywords].flatten.compact.map{ |k| k.to_s.strip.split(/(,|,)/) }.flatten.map { |k| k.gsub(/(,|,)/, '').blank? ? nil : k }.compact.uniq
135
134
  end
@@ -149,7 +148,7 @@ module H2ocubeRailsHelper
149
148
  elsif defined?(@item) && @item.respond_to?(:description) && !@item.description.blank?
150
149
  description = @item.description
151
150
  else
152
- description = opts.key?(:description) ? opts[:description] : HelperSettings.description
151
+ description = opts.key?(:description) ? opts[:description] : Rails.application.secrets[:description]
153
152
  end
154
153
  strip_tags description.to_s.strip
155
154
  end
@@ -169,8 +168,8 @@ module H2ocubeRailsHelper
169
168
 
170
169
  def render_ga(opts = {})
171
170
  return '' if Rails.env.development?
172
- ga = opts.key?(:ga) ? opts[:ga] : HelperSettings.ga
173
- domain = opts.key?(:domain) ? opts[:domain] : HelperSettings.domain
171
+ ga = opts.key?(:ga) ? opts[:ga] : Rails.application.secrets[:ga]
172
+ domain = opts.key?(:domain) ? opts[:domain] : Rails.application.secrets[:domain]
174
173
  return '' if ga.nil?
175
174
  "<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
176
175
  end
@@ -3,13 +3,12 @@ require 'action_controller/railtie'
3
3
  require 'action_view/railtie'
4
4
  require 'active_record'
5
5
 
6
- ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
7
- ActiveRecord::Base.establish_connection('test')
6
+ ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
8
7
 
9
8
  # config
10
9
  app = Class.new(Rails::Application)
11
10
  app.config.secret_token = '3b7cd727ee24e8444053437c36cc66c4'
12
- app.config.session_store :cookie_store, :key => '_myapp_session'
11
+ app.config.session_store :cookie_store, key: '_myapp_session'
13
12
  app.config.active_support.deprecation = :log
14
13
  app.config.eager_load = false
15
14
  # Rais.root
@@ -22,7 +21,7 @@ app.routes.draw do
22
21
  resources :users
23
22
  end
24
23
 
25
- #models
24
+ # models
26
25
  require 'fake_app/models'
27
26
 
28
27
  # controllers
@@ -1,11 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- class HelperSettings
4
- def self.description
5
- 'description'
6
- end
7
- end
8
-
9
3
  class Item
10
4
  def description
11
5
  'item_description'
@@ -13,6 +7,10 @@ class Item
13
7
  end
14
8
 
15
9
  describe 'render_description' do
10
+ before do
11
+ Rails.application.secrets[:description] = 'description'
12
+ end
13
+
16
14
  it 'simple' do
17
15
  expect(render_description).to eq('<meta name="description" content="description" />')
18
16
  end
@@ -1,28 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
- class HelperSettings
4
- def self.title
5
- 'title'
6
- end
7
-
8
- def self.keywords
9
- 'keywords'
10
- end
11
-
12
- def self.description
13
- 'description'
14
- end
15
-
16
- def self.ga
17
- 'ga_code'
3
+ describe 'render_ga' do
4
+ before do
5
+ Rails.application.secrets[:title] = 'title'
6
+ Rails.application.secrets[:keywords] = 'keywords'
7
+ Rails.application.secrets[:description] = 'description'
8
+ Rails.application.secrets[:ga] = 'ga_code'
9
+ Rails.application.secrets[:domain] = 'domain'
18
10
  end
19
11
 
20
- def self.domain
21
- 'domain'
22
- end
23
- end
24
-
25
- describe 'render_ga' do
26
12
  it 'default' do
27
13
  expect(render_ga).to include('ga_code')
28
14
  end
@@ -1,11 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- class HelperSettings
4
- def self.keywords
5
- 'keywords'
6
- end
7
- end
8
-
9
3
  class Item
10
4
  def keywords
11
5
  'item,item_keywords'
@@ -13,6 +7,10 @@ class Item
13
7
  end
14
8
 
15
9
  describe 'render_keywords' do
10
+ before do
11
+ Rails.application.secrets[:keywords] = 'keywords'
12
+ end
13
+
16
14
  it 'simple' do
17
15
  expect(render_keywords).to eq('<meta name="keywords" content="keywords" />')
18
16
  end
@@ -1,11 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- class HelperSettings
4
- def self.title
5
- 'title'
6
- end
7
- end
8
-
9
3
  class ResourceModelName
10
4
  def human
11
5
  'Class Name'
@@ -23,6 +17,10 @@ class Resource
23
17
  end
24
18
 
25
19
  describe 'render_title' do
20
+ before do
21
+ Rails.application.secrets[:title] = 'title'
22
+ end
23
+
26
24
  it 'simple' do
27
25
  expect(render_title).to eq('<title>title</title>')
28
26
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2ocube_rails_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: settingslogic
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: browser
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -150,9 +136,6 @@ files:
150
136
  - README.md
151
137
  - Rakefile
152
138
  - h2ocube_rails_helper.gemspec
153
- - lib/generators/h2ocube_rails_helper_generator.rb
154
- - lib/generators/source/helper.yml.erb
155
- - lib/generators/source/helper_settings.rb.erb
156
139
  - lib/h2ocube_rails_helper.rb
157
140
  - spec/fake_app/models.rb
158
141
  - spec/fake_app/rails_app.rb
@@ -183,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
166
  version: '0'
184
167
  requirements: []
185
168
  rubyforge_project:
186
- rubygems_version: 2.6.4
169
+ rubygems_version: 2.6.8
187
170
  signing_key:
188
171
  specification_version: 4
189
172
  summary: Just an helper collection
@@ -1,19 +0,0 @@
1
- class H2ocubeRailsHelperGenerator < Rails::Generators::Base
2
- source_root File.expand_path('../source', __FILE__)
3
-
4
- desc 'Creates a helper.yml to your config/.'
5
-
6
- def copy_helper_yml
7
- template 'helper.yml.erb', 'config/helper.yml'
8
- end
9
-
10
- def copy_helper_rb
11
- template 'helper_settings.rb.erb', 'app/models/helper_settings.rb'
12
- end
13
-
14
- private
15
-
16
- def app_name
17
- Rails.application.class.to_s.split('::').first
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- defaults: &defaults
2
- ga: Google Analytics Profile Id
3
- domain: h2ocube.com
4
- title: <%= app_name %>
5
- keywords: <%= app_name %>
6
- description: <%= app_name %>
7
-
8
- development:
9
- <<: *defaults
10
-
11
- test:
12
- <<: *defaults
13
-
14
- production:
15
- <<: *defaults
@@ -1,4 +0,0 @@
1
- class HelperSettings < Settingslogic
2
- source "#{Rails.root}/config/helper.yml"
3
- namespace Rails.env
4
- end