metanol 0.0.6 → 0.0.8
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.
- checksums.yaml +5 -13
- data/.rspec +1 -0
- data/lib/metanol/engine_controller.rb +29 -20
- data/lib/metanol/helpers.rb +3 -2
- data/lib/metanol/version.rb +1 -1
- data/spec/controllers/home_controller_spec.rb +9 -2
- data/spec/support/application.rb +15 -4
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NzVmYmRhYTU5N2U3MGU5MjI3MTAwMDg0MmNhMjZmOTBkZWVmMTI4YQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 192b22e268ed2c08e3b83a989deba1c79035530b
|
4
|
+
data.tar.gz: 779557ee8a0cc78ac1ccabca931e741cc1a833ef
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NDVkM2NhMzM4N2Q2NGVhMzBmNzg0ODA4ZWJlNDk4NjVlMWQzNGI1OTg1NWI4
|
11
|
-
YTY2Y2E2YmE5NzZiNGI0ZTRiYzQ2Y2U4Y2JiZjM2NjAwOWMwMTQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YTI3NWU5YjdjZWQ0ZmU5OTFkZTFiZjE0NWY0MTI1MzFjN2IwODkwOGUyMTA2
|
14
|
-
MmQxMmM3NDgyMDg2NzBiMzhjZGZlZjQ5OWVhMTIwMzQyM2Y2NjY0ZDFlMTc3
|
15
|
-
NWRhOWQyZDZhNzEyNzM3ZTY4MGJmY2EwNTlhYmEzZDYyYTc3ZDA=
|
6
|
+
metadata.gz: b5a924dcf8196ae2a6d12c860b7aa792b547d54b38618688ad4ed215bb0854a7116534b21c14acef8fed6f4692c166fcb094dc5b512cef1bdfac2e2a00828c4c
|
7
|
+
data.tar.gz: 67cc4bab0f137f8dc6d99be1dedafbbd58fba91e8e64171ec09a0fe3caf341e287a6f95e0ef9339a81acca8188c44718123a5979c39c1e0a32caa664eb450162
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -6,75 +6,84 @@ module Metanol
|
|
6
6
|
module EngineController
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
+
included do
|
10
|
+
before_filter :clear_metanols
|
11
|
+
end
|
12
|
+
|
9
13
|
module ClassMethods
|
10
|
-
def
|
11
|
-
@@
|
14
|
+
def common_metanols
|
15
|
+
@@common_metanols ||= {}
|
12
16
|
end
|
13
17
|
|
14
18
|
SUPPORT_GROUPS.keys.each do |method|
|
15
19
|
method_name = "#{method == :main ? '' : "#{method}_"}meta"
|
16
20
|
define_method method_name do |*args|
|
17
|
-
add_meta_tag(method, *args)
|
21
|
+
add_meta_tag(common_metanols, method, *args)
|
18
22
|
end
|
19
23
|
|
20
24
|
get_method_name = "get_#{method_name}"
|
21
25
|
define_method get_method_name do |name|
|
22
|
-
|
26
|
+
get_meta_tag(common_metanols, method, name)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
30
|
private
|
27
31
|
|
28
|
-
def add_meta_tag(type, *args)
|
32
|
+
def add_meta_tag(repo, type, *args)
|
29
33
|
if args[0].is_a? Hash
|
30
34
|
filters = args[1..-1]
|
31
35
|
args[0].each do |name, value|
|
32
|
-
add_meta_by_type type, name, value, filters
|
36
|
+
add_meta_by_type repo, type, name, value, filters
|
33
37
|
end
|
34
38
|
else
|
35
39
|
name = args[0].to_sym
|
36
40
|
value = args[1]
|
37
41
|
filters = args[2..-1]
|
38
|
-
add_meta_by_type type, name, value, filters
|
42
|
+
add_meta_by_type repo, type, name, value, filters
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
|
-
def add_meta_by_type(type, name, value, filters=[])
|
46
|
+
def add_meta_by_type(repo, type, name, value, filters=[])
|
43
47
|
meta_class = SUPPORT_GROUPS[type]
|
44
48
|
key = get_meta_key(type, name)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
else
|
49
|
-
metanol_options[key] = meta_class.new(name, value, filters)
|
49
|
+
unless repo.key? key
|
50
|
+
repo[key] = meta_class.new(name, value, filters)
|
51
|
+
return
|
50
52
|
end
|
53
|
+
repo[key].value = value
|
54
|
+
repo[key].filters = filters
|
51
55
|
end
|
52
56
|
|
53
|
-
def
|
57
|
+
def get_meta_tag(repo, type, name)
|
54
58
|
key = get_meta_key(type, name)
|
55
|
-
|
59
|
+
repo.key?(key) ? repo[key].value : nil
|
56
60
|
end
|
57
61
|
|
58
62
|
def get_meta_key(type, name)
|
59
63
|
"#{type}:#{name}"
|
60
64
|
end
|
61
|
-
|
62
65
|
end
|
63
66
|
|
64
67
|
SUPPORT_GROUPS.keys.each do |method|
|
65
68
|
method_name = "#{method == :main ? '' : "#{method}_"}meta"
|
66
69
|
define_method method_name do |*args|
|
67
|
-
self.class.send
|
70
|
+
self.class.send 'add_meta_tag', action_metanols, method, *args
|
68
71
|
end
|
69
72
|
|
70
73
|
get_method_name = "get_#{method_name}"
|
71
74
|
define_method get_method_name do |name|
|
72
|
-
self.class.send
|
75
|
+
self.class.send 'get_meta_tag', action_metanols, method, name
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
76
|
-
def
|
77
|
-
|
79
|
+
def action_metanols
|
80
|
+
@action_metanols ||= {}
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def clear_metanols
|
86
|
+
@action_metanols = {}
|
78
87
|
end
|
79
88
|
|
80
89
|
end
|
data/lib/metanol/helpers.rb
CHANGED
@@ -39,8 +39,9 @@ module Metanol
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def metanol_render_tags(type)
|
42
|
-
result =
|
43
|
-
self.controller.
|
42
|
+
result = ''
|
43
|
+
metanols = self.controller.class.common_metanols.merge(self.controller.action_metanols)
|
44
|
+
metanols.each_value do |value|
|
44
45
|
next unless value.is_a? type
|
45
46
|
result << value.render
|
46
47
|
end
|
data/lib/metanol/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe HomeController do
|
4
|
-
context
|
4
|
+
context 'render meta tags with some global ones' do
|
5
5
|
|
6
|
-
context
|
6
|
+
context 'all meta tags' do
|
7
7
|
before { get :index }
|
8
8
|
|
9
9
|
it { response.should have_selector("meta[content=\"#{url_for(controller: :home, action: :index, host: 'test.host')}\"]", property: 'og:url') }
|
@@ -15,6 +15,7 @@ describe HomeController do
|
|
15
15
|
it { response.should have_selector('meta[content="alexa code"]', name: 'alexaVerifyID') }
|
16
16
|
it { response.should have_selector('meta[content="google code"]', name: 'google-site-verification') }
|
17
17
|
it { response.should have_selector('meta[content="yandex code"]', name: 'yandex-verification') }
|
18
|
+
it { response.body.should =~ /<title>Index Page<\/title>/ }
|
18
19
|
end
|
19
20
|
|
20
21
|
context "only WebMaster's meta tags" do
|
@@ -28,5 +29,11 @@ describe HomeController do
|
|
28
29
|
it { response.should have_selector('meta[content="yandex code"]', name: 'yandex-verification') }
|
29
30
|
end
|
30
31
|
|
32
|
+
context 'correct title tag' do
|
33
|
+
before { get :index }
|
34
|
+
before { get :get_title }
|
35
|
+
it { response.body.should_not =~ /<title>Index Page<\/title>/ }
|
36
|
+
end
|
37
|
+
|
31
38
|
end
|
32
39
|
end
|
data/spec/support/application.rb
CHANGED
@@ -6,8 +6,8 @@ ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database
|
|
6
6
|
ActiveRecord::Base.establish_connection('test')
|
7
7
|
|
8
8
|
app = Class.new(Rails::Application)
|
9
|
-
app.config.secret_token =
|
10
|
-
app.config.session_store :cookie_store, :key =>
|
9
|
+
app.config.secret_token = 'f974ebb750a8e200c85f7a749d589fa2'
|
10
|
+
app.config.session_store :cookie_store, :key => '_myapp_session'
|
11
11
|
app.config.active_support.deprecation = :log
|
12
12
|
app.config.eager_load = false
|
13
13
|
app.config.root = File.dirname(__FILE__)
|
@@ -16,7 +16,11 @@ app.initialize!
|
|
16
16
|
|
17
17
|
app.routes.draw do
|
18
18
|
resources :tests
|
19
|
-
resources :home
|
19
|
+
resources :home do
|
20
|
+
collection do
|
21
|
+
get :get_title
|
22
|
+
end
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
class ApplicationController < ActionController::Base; end
|
@@ -38,11 +42,18 @@ class HomeController < ParentController
|
|
38
42
|
end
|
39
43
|
|
40
44
|
def index
|
41
|
-
|
45
|
+
meta :title, 'Index Page'
|
46
|
+
og_meta title: 'OpenGraph Title', description: 'OpenGraph Description'
|
42
47
|
render :inline => <<-ERB
|
43
48
|
<%= metanol_tags %>
|
44
49
|
ERB
|
45
50
|
end
|
51
|
+
|
52
|
+
def get_title
|
53
|
+
render :inline => <<-ERB
|
54
|
+
<%= metanol_main_tags %>
|
55
|
+
ERB
|
56
|
+
end
|
46
57
|
end
|
47
58
|
|
48
59
|
Object.const_set(:ApplicationHelper, Module.new)
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugene Kondratyuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-21 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: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
description: This is a meta tags plugin which helps to manage meta tags in your Rails
|
@@ -35,6 +35,7 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- .gitignore
|
38
|
+
- .rspec
|
38
39
|
- Gemfile
|
39
40
|
- LICENSE.txt
|
40
41
|
- README.md
|
@@ -66,17 +67,17 @@ require_paths:
|
|
66
67
|
- lib
|
67
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
69
|
requirements:
|
69
|
-
- -
|
70
|
+
- - '>='
|
70
71
|
- !ruby/object:Gem::Version
|
71
72
|
version: '0'
|
72
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
74
|
requirements:
|
74
|
-
- -
|
75
|
+
- - '>='
|
75
76
|
- !ruby/object:Gem::Version
|
76
77
|
version: '0'
|
77
78
|
requirements: []
|
78
79
|
rubyforge_project: metanol
|
79
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.2.2
|
80
81
|
signing_key:
|
81
82
|
specification_version: 4
|
82
83
|
summary: A <META> tags engine plugin for Rails 3.2+ applications
|