rails_meta_tags 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +25 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/rails/meta_tags.rb +50 -0
- data/lib/rails/meta_tags/builder.rb +82 -0
- data/lib/rails/meta_tags/config.rb +31 -0
- data/lib/rails/meta_tags/controller_methods.rb +15 -0
- data/lib/rails/meta_tags/model_support.rb +45 -0
- data/lib/rails/meta_tags/model_support/data.rb +35 -0
- data/lib/rails/meta_tags/model_support/data_config.rb +11 -0
- data/lib/rails_meta_tags.rb +7 -0
- data/rails_meta_tags.gemspec +74 -0
- data/spec/builder_spec.rb +25 -0
- data/spec/metatags_spec.rb +9 -0
- data/spec/model_support_spec.rb +49 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/models.rb +36 -0
- data/spec/support/request.rb +31 -0
- metadata +153 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
gem "activesupport", "~> 3.2"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.12.0"
|
10
|
+
gem "bundler", "~> 1.2.2"
|
11
|
+
gem "jeweler", "~> 1.8.4"
|
12
|
+
gem "simplecov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.9)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
diff-lcs (1.1.3)
|
8
|
+
git (1.2.5)
|
9
|
+
i18n (0.6.1)
|
10
|
+
jeweler (1.8.4)
|
11
|
+
bundler (~> 1.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rake
|
14
|
+
rdoc
|
15
|
+
json (1.7.5)
|
16
|
+
multi_json (1.3.7)
|
17
|
+
rake (10.0.2)
|
18
|
+
rdoc (3.12)
|
19
|
+
json (~> 1.4)
|
20
|
+
rspec (2.12.0)
|
21
|
+
rspec-core (~> 2.12.0)
|
22
|
+
rspec-expectations (~> 2.12.0)
|
23
|
+
rspec-mocks (~> 2.12.0)
|
24
|
+
rspec-core (2.12.0)
|
25
|
+
rspec-expectations (2.12.0)
|
26
|
+
diff-lcs (~> 1.1.3)
|
27
|
+
rspec-mocks (2.12.0)
|
28
|
+
simplecov (0.7.1)
|
29
|
+
multi_json (~> 1.0)
|
30
|
+
simplecov-html (~> 0.7.1)
|
31
|
+
simplecov-html (0.7.1)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
activesupport (~> 3.2)
|
38
|
+
bundler (~> 1.2.2)
|
39
|
+
jeweler (~> 1.8.4)
|
40
|
+
rspec (~> 2.12.0)
|
41
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Mateo Murphy
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= rails_meta_tags
|
2
|
+
|
3
|
+
{<img src="https://gemnasium.com/mateomurphy/rails_meta_tags.png" alt="Dependency Status" />}[https://gemnasium.com/mateomurphy/rails_meta_tags]
|
4
|
+
|
5
|
+
Easy meta tag generation for rails apps
|
6
|
+
|
7
|
+
== Inspiration
|
8
|
+
|
9
|
+
https://github.com/kpumuk/meta-tags
|
10
|
+
|
11
|
+
== Contributing to rails_meta_tags
|
12
|
+
|
13
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
14
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
15
|
+
* Fork the project
|
16
|
+
* Start a feature/bugfix branch
|
17
|
+
* Commit and push until you are happy with your contribution
|
18
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
19
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
20
|
+
|
21
|
+
== Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2011 Mateo Murphy. See LICENSE.txt for
|
24
|
+
further details.
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "rails_meta_tags"
|
18
|
+
gem.homepage = "http://github.com/mateomurphy/rails_meta_tags"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Metatag library for rails}
|
21
|
+
gem.description = %Q{Easily manage your meta tags in rails projects}
|
22
|
+
gem.email = "mateo.murphy@gmail.com"
|
23
|
+
gem.authors = ["Mateo Murphy"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
RDoc::Task.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "rails_meta_tags #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.8
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Rails
|
2
|
+
module MetaTags
|
3
|
+
autoload :ControllerMethods, 'rails/meta_tags/controller_methods'
|
4
|
+
autoload :Builder, 'rails/meta_tags/builder'
|
5
|
+
autoload :Config, 'rails/meta_tags/config'
|
6
|
+
autoload :ModelSupport, 'rails/meta_tags/model_support'
|
7
|
+
|
8
|
+
PROPERTIES = [
|
9
|
+
:title,
|
10
|
+
:type,
|
11
|
+
:image,
|
12
|
+
:url,
|
13
|
+
:description,
|
14
|
+
:audio,
|
15
|
+
:determiner,
|
16
|
+
:locale,
|
17
|
+
:site_name,
|
18
|
+
:video,
|
19
|
+
:keywords,
|
20
|
+
:robots,
|
21
|
+
:creator,
|
22
|
+
:subject,
|
23
|
+
:publisher,
|
24
|
+
:created,
|
25
|
+
:identifier,
|
26
|
+
:language,
|
27
|
+
:content_type
|
28
|
+
]
|
29
|
+
|
30
|
+
mattr_accessor :seperator
|
31
|
+
@@seperator = " | "
|
32
|
+
|
33
|
+
def self.config
|
34
|
+
yield self
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.defaults
|
38
|
+
@defaults ||= Config.new
|
39
|
+
end
|
40
|
+
|
41
|
+
# default config
|
42
|
+
defaults.site_name "SITE"
|
43
|
+
defaults.type "website"
|
44
|
+
defaults.content_type "text/html; charset=utf-8"
|
45
|
+
defaults.created { |c| Time.new.strftime('%Y-%m-%d') }
|
46
|
+
defaults.language { |c| I18n.locale.to_s }
|
47
|
+
defaults.identifier { |c| c.request.url }
|
48
|
+
defaults.url { |c| c.request.url }
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Information on tags http://www.webreference.com/xml/column24/2.html
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module MetaTags
|
5
|
+
class Builder
|
6
|
+
delegate :request, :tag, :content_tag, :to => :@view_context
|
7
|
+
|
8
|
+
attr_accessor :resource
|
9
|
+
|
10
|
+
DC_TERMS = %w(creator subject created language identifier publisher)
|
11
|
+
OG_PROPERTIES= %w(type image url audio description locale site_name video)
|
12
|
+
|
13
|
+
def initialize(view_context)
|
14
|
+
@view_context = view_context
|
15
|
+
@data = MetaTags.defaults.to_hash
|
16
|
+
end
|
17
|
+
|
18
|
+
PROPERTIES.each do |t|
|
19
|
+
class_eval "def #{t}=(val); self[:#{t}] = val; end"
|
20
|
+
class_eval "def #{t}; self[:#{t}]; end"
|
21
|
+
end
|
22
|
+
|
23
|
+
def [](tag)
|
24
|
+
tag = tag.to_sym
|
25
|
+
|
26
|
+
return resource.meta[tag] if resource && resource.meta[tag].present?
|
27
|
+
|
28
|
+
if @data[tag].is_a?(Symbol)
|
29
|
+
@view_context.send(@data[tag])
|
30
|
+
elsif @data[tag].respond_to?(:call)
|
31
|
+
@data[tag].call(@view_context)
|
32
|
+
else
|
33
|
+
@data[tag]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def []=(tag, value)
|
38
|
+
@data[tag.to_sym] = value
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_title
|
42
|
+
if value_present?(:title)
|
43
|
+
[self[:title], MetaTags.defaults[:site_name]].flatten.join(MetaTags.seperator).html_safe
|
44
|
+
else
|
45
|
+
MetaTags.defaults[:site_name]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def title_or_site_name
|
50
|
+
if value_present?(:title)
|
51
|
+
self[:title]
|
52
|
+
else
|
53
|
+
MetaTags.defaults[:site_name]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def value_present?(term)
|
58
|
+
self[term].present?
|
59
|
+
end
|
60
|
+
|
61
|
+
def render_tags
|
62
|
+
tags = []
|
63
|
+
tags << tag(:meta, :'http-equiv' => "Content-Type", :content => content_type)
|
64
|
+
tags << content_tag(:title, full_title)
|
65
|
+
tags << tag(:meta, :name => 'description', :content => description)
|
66
|
+
|
67
|
+
|
68
|
+
tags << tag(:meta, :name => "dcterms.title", :content => title_or_site_name)
|
69
|
+
DC_TERMS.each do |term|
|
70
|
+
tags << tag(:meta, :name => "dcterms.#{term}", :content => self[term]) if value_present?(term)
|
71
|
+
end
|
72
|
+
|
73
|
+
tags << tag(:meta, :property => "og:title", :content => title_or_site_name)
|
74
|
+
OG_PROPERTIES.each do |property|
|
75
|
+
tags << tag(:meta, :property => "og:#{property}", :content => self[property]) if value_present?(property)
|
76
|
+
end
|
77
|
+
|
78
|
+
tags.join("\n").html_safe
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Rails
|
2
|
+
module MetaTags
|
3
|
+
class Config
|
4
|
+
PROPERTIES.each do |t|
|
5
|
+
class_eval "def #{t}(val = nil, &block); self[:#{t}] = val || block; end"
|
6
|
+
class_eval "def #{t}=(val); self[:#{t}] = val; end"
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(data = nil)
|
10
|
+
@data = data || {}
|
11
|
+
@instances = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure_via_block(block)
|
15
|
+
instance_eval(&block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def [](tag)
|
19
|
+
@data[tag.to_sym]
|
20
|
+
end
|
21
|
+
|
22
|
+
def []=(tag, value)
|
23
|
+
@data[tag.to_sym] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_hash
|
27
|
+
@data.dup
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# TODO support structured properties
|
2
|
+
module Rails
|
3
|
+
module MetaTags
|
4
|
+
module ModelSupport
|
5
|
+
autoload :Data, 'rails/meta_tags/model_support/data'
|
6
|
+
autoload :DataConfig, 'rails/meta_tags/model_support/data_config'
|
7
|
+
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
# defaults specific to model support
|
11
|
+
DEFAULTS = { :title => :to_s, :created => lambda { |r| r.updated_at.strftime('%Y-%m-%d') } }.freeze
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def meta(&block)
|
15
|
+
raise "no block given" unless block
|
16
|
+
|
17
|
+
if ancestor = meta_ancestor
|
18
|
+
@data = DataConfig.new(ancestor.to_hash)
|
19
|
+
else
|
20
|
+
@data = DataConfig.new(DEFAULTS.dup)
|
21
|
+
end
|
22
|
+
|
23
|
+
@data.configure_via_block(block)
|
24
|
+
@data
|
25
|
+
end
|
26
|
+
|
27
|
+
def meta_ancestor
|
28
|
+
ancestors.each do |ancestor|
|
29
|
+
next if ancestor == ModelSupport || ancestor == self
|
30
|
+
return ancestor.meta_config if ancestor.respond_to?(:meta_config)
|
31
|
+
end
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def meta_config
|
36
|
+
@data || meta_ancestor
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def meta
|
41
|
+
self.class.meta_config.instance(self)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Rails
|
2
|
+
module MetaTags
|
3
|
+
module ModelSupport
|
4
|
+
class Data
|
5
|
+
attr_reader :config, :model
|
6
|
+
|
7
|
+
def initialize(config, model)
|
8
|
+
@config, @model = config, model
|
9
|
+
end
|
10
|
+
|
11
|
+
PROPERTIES.each do |t|
|
12
|
+
class_eval "def #{t}; self[:#{t}]; end"
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](tag)
|
16
|
+
if config[tag].is_a?(Symbol)
|
17
|
+
model.send(config[tag])
|
18
|
+
elsif config[tag].respond_to?(:call)
|
19
|
+
config[tag].call(model)
|
20
|
+
else
|
21
|
+
config[tag]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_hash
|
26
|
+
result = {}
|
27
|
+
config.to_hash.keys.each do |k|
|
28
|
+
result[k] = self[k] if self[k].present?
|
29
|
+
end
|
30
|
+
result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'active_support/deprecation'
|
2
|
+
require 'active_support/concern'
|
3
|
+
require 'active_support/core_ext/module'
|
4
|
+
require 'rails/meta_tags'
|
5
|
+
|
6
|
+
ActionController::Base.send :include, Rails::MetaTags::ControllerMethods if defined?(ActionController)
|
7
|
+
ActiveRecord::Base.send :include, Rails::MetaTags::ModelSupport if defined?(ActiveRecord)
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rails_meta_tags"
|
8
|
+
s.version = "0.2.8"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Mateo Murphy"]
|
12
|
+
s.date = "2012-11-26"
|
13
|
+
s.description = "Easily manage your meta tags in rails projects"
|
14
|
+
s.email = "mateo.murphy@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/rails/meta_tags.rb",
|
29
|
+
"lib/rails/meta_tags/builder.rb",
|
30
|
+
"lib/rails/meta_tags/config.rb",
|
31
|
+
"lib/rails/meta_tags/controller_methods.rb",
|
32
|
+
"lib/rails/meta_tags/model_support.rb",
|
33
|
+
"lib/rails/meta_tags/model_support/data.rb",
|
34
|
+
"lib/rails/meta_tags/model_support/data_config.rb",
|
35
|
+
"lib/rails_meta_tags.rb",
|
36
|
+
"rails_meta_tags.gemspec",
|
37
|
+
"spec/builder_spec.rb",
|
38
|
+
"spec/metatags_spec.rb",
|
39
|
+
"spec/model_support_spec.rb",
|
40
|
+
"spec/spec_helper.rb",
|
41
|
+
"spec/support/models.rb",
|
42
|
+
"spec/support/request.rb"
|
43
|
+
]
|
44
|
+
s.homepage = "http://github.com/mateomurphy/rails_meta_tags"
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = "1.8.24"
|
48
|
+
s.summary = "Metatag library for rails"
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 3.2"])
|
55
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.12.0"])
|
56
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.2.2"])
|
57
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
58
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<activesupport>, ["~> 3.2"])
|
61
|
+
s.add_dependency(%q<rspec>, ["~> 2.12.0"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.2"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
64
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<activesupport>, ["~> 3.2"])
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 2.12.0"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.2"])
|
70
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
71
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module Rails::MetaTags
|
4
|
+
describe Builder do
|
5
|
+
describe '#render_tags' do
|
6
|
+
subject { Builder.new(MockViewContext.new) }
|
7
|
+
specify { subject.render_tags.should_not be_nil }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'using a resource' do
|
11
|
+
subject {
|
12
|
+
b = Builder.new(MockViewContext.new)
|
13
|
+
b.resource = TestObject.new
|
14
|
+
b
|
15
|
+
}
|
16
|
+
it 'returns the title of the resource' do
|
17
|
+
subject.title.should == 'new article'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns the title of the resource' do
|
21
|
+
subject.full_title.should == 'new article | SITE'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Rails::MetaTags
|
4
|
+
describe TestObject do
|
5
|
+
describe ".meta_config" do
|
6
|
+
specify { TestObject.meta_config.should be_a(ModelSupport::DataConfig) }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#meta' do
|
10
|
+
subject { TestObject.new}
|
11
|
+
specify { subject.meta.type.should == 'website' }
|
12
|
+
specify { subject.meta.title.should == 'new article' }
|
13
|
+
specify { subject.meta.description.should == 'new hotness' }
|
14
|
+
specify { subject.meta.url.should be_nil }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe TestObjectChildNoMeta do
|
19
|
+
describe ".meta_ancestor" do
|
20
|
+
specify { TestObjectChildNoMeta.meta_ancestor.should be_a(ModelSupport::DataConfig) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".meta_config" do
|
24
|
+
specify { TestObjectChildNoMeta.meta_config.should be_a(ModelSupport::DataConfig) }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#meta' do
|
28
|
+
subject { TestObjectChildNoMeta.new}
|
29
|
+
specify { subject.meta.type.should == 'website' }
|
30
|
+
specify { subject.meta.title.should == 'new article' }
|
31
|
+
specify { subject.meta.description.should == 'new hotness' }
|
32
|
+
specify { subject.meta.url.should be_nil }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe TestObjectChildOwnMeta do
|
37
|
+
describe ".meta_config" do
|
38
|
+
specify { TestObjectChildOwnMeta.meta_config.should be_a(ModelSupport::DataConfig) }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#meta' do
|
42
|
+
subject { TestObjectChildOwnMeta.new}
|
43
|
+
specify { subject.meta.type.should == 'website' }
|
44
|
+
specify { subject.meta.title.should == 'new sub article' }
|
45
|
+
specify { subject.meta.description.should == 'new hotness' }
|
46
|
+
specify { subject.meta.url.should == 'http://test.com' }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'rails_meta_tags'
|
5
|
+
|
6
|
+
require 'active_support/core_ext/string'
|
7
|
+
|
8
|
+
# Requires supporting files with custom matchers and macros, etc,
|
9
|
+
# in ./support/ and its subdirectories.
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Rails::MetaTags
|
2
|
+
class TestObject
|
3
|
+
include ModelSupport
|
4
|
+
|
5
|
+
meta do
|
6
|
+
type 'website'
|
7
|
+
title :title
|
8
|
+
description do |o|
|
9
|
+
o.subtitle
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def title
|
14
|
+
'new article'
|
15
|
+
end
|
16
|
+
|
17
|
+
def subtitle
|
18
|
+
'new hotness'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class TestObjectChildNoMeta < TestObject
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class TestObjectChildOwnMeta < TestObject
|
28
|
+
meta do
|
29
|
+
url 'http://test.com'
|
30
|
+
end
|
31
|
+
|
32
|
+
def title
|
33
|
+
'new sub article'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Rails::MetaTags
|
2
|
+
class MockRequest
|
3
|
+
def url
|
4
|
+
"url"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class MockViewContext
|
9
|
+
def request
|
10
|
+
MockRequest.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag(*args)
|
14
|
+
args.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
def content_tag(*args)
|
18
|
+
args.inspect
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class MockController
|
24
|
+
def self.helper_method(*args)
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
include ControllerMethods
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_meta_tags
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.8
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mateo Murphy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.12.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.12.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.2.2
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.2
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.4
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: simplecov
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Easily manage your meta tags in rails projects
|
95
|
+
email: mateo.murphy@gmail.com
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files:
|
99
|
+
- LICENSE.txt
|
100
|
+
- README.rdoc
|
101
|
+
files:
|
102
|
+
- .document
|
103
|
+
- .rspec
|
104
|
+
- Gemfile
|
105
|
+
- Gemfile.lock
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.rdoc
|
108
|
+
- Rakefile
|
109
|
+
- VERSION
|
110
|
+
- lib/rails/meta_tags.rb
|
111
|
+
- lib/rails/meta_tags/builder.rb
|
112
|
+
- lib/rails/meta_tags/config.rb
|
113
|
+
- lib/rails/meta_tags/controller_methods.rb
|
114
|
+
- lib/rails/meta_tags/model_support.rb
|
115
|
+
- lib/rails/meta_tags/model_support/data.rb
|
116
|
+
- lib/rails/meta_tags/model_support/data_config.rb
|
117
|
+
- lib/rails_meta_tags.rb
|
118
|
+
- rails_meta_tags.gemspec
|
119
|
+
- spec/builder_spec.rb
|
120
|
+
- spec/metatags_spec.rb
|
121
|
+
- spec/model_support_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/support/models.rb
|
124
|
+
- spec/support/request.rb
|
125
|
+
homepage: http://github.com/mateomurphy/rails_meta_tags
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
hash: 2890970730908774467
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 1.8.24
|
150
|
+
signing_key:
|
151
|
+
specification_version: 3
|
152
|
+
summary: Metatag library for rails
|
153
|
+
test_files: []
|