crystalmeta 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.9.4 2013-02-28
2
+
3
+ * Fix bugs with displaying tags: a tag key name should be `property` for OpenGraph & `name` for anything else, value should be called `content`
4
+ * Remove default value for `twitter:url` — it has an OpenGraph fallback to `og:url`
5
+
1
6
  ### 0.9.3 2013-02-03
2
7
 
3
8
  * Fix interpolation bug
@@ -27,8 +27,7 @@ module Crystal
27
27
 
28
28
  def default_options
29
29
  HashWithStringifyKeys.new(
30
- :'og:url' => url,
31
- :'twitter:url' => url
30
+ :'og:url' => url
32
31
  )
33
32
  end
34
33
 
data/lib/crystal/tag.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  module Crystal
2
2
  class Tag < Struct.new(:name, :value)
3
+ def name_key
4
+ name.starts_with?('og:') ? :property : :name
5
+ end
6
+
3
7
  def value_for_context(context)
4
8
  case
5
9
  when asset?
@@ -1,3 +1,3 @@
1
1
  module Crystal
2
- VERSION = '0.9.3'
2
+ VERSION = '0.9.4'
3
3
  end
@@ -6,7 +6,7 @@ module Crystal
6
6
 
7
7
  def meta_tags(pattern = //)
8
8
  meta.tags_by_pattern(pattern).map{|t|
9
- tag(:meta, :property => t.name, :value => t.value_for_context(self))
9
+ tag(:meta, t.name_key => t.name, :content => t.value_for_context(self))
10
10
  }.join("\n").html_safe
11
11
  end
12
12
  end
@@ -7,6 +7,7 @@ en:
7
7
  og:image: imdb.jpg
8
8
  og:type: article
9
9
  fb:app_id: 115109575169727
10
+ twitter:card: summary
10
11
 
11
12
  movies:
12
13
  _defaults:
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe 'meta tags' do
4
4
  def meta_tags(pattern = //)
5
- all('meta').select{|meta| pattern === meta[:property]}
5
+ all('meta').select{|meta| pattern === meta[:property] || pattern === meta[:name] }
6
6
  end
7
7
 
8
8
  def value_for(pattern = //)
9
- meta_tags(pattern).first[:value]
9
+ meta_tags(pattern).first[:content]
10
10
  end
11
11
 
12
12
  def title
@@ -26,6 +26,10 @@ describe 'meta tags' do
26
26
  value_for('og:image').should == '/images/rock.jpg'
27
27
  end
28
28
 
29
+ it 'include og:image from locale' do
30
+ value_for('twitter:card').should == 'summary'
31
+ end
32
+
29
33
  it 'include og:type from controller defaults' do
30
34
  value_for('og:type').should == 'video.movie'
31
35
  end
@@ -4,8 +4,14 @@ describe Crystal::Tag do
4
4
  subject { Crystal::Tag.new('og:title', 'Caesar must die') }
5
5
  its(:name) {should == 'og:title'}
6
6
  its(:value) {should == 'Caesar must die'}
7
+ its(:name_key) { should == :property }
7
8
 
8
- context '#value_for_context' do
9
+ context 'for twitter' do
10
+ subject { Crystal::Tag.new('twitter:title', 'Caesar must die') }
11
+ its(:name_key) { should == :name }
12
+ end
13
+
14
+ describe '#value_for_context' do
9
15
  let(:context) { double }
10
16
 
11
17
  it 'returns asset path if asset' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crystalmeta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails