middleman-ogp 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/lib/middleman-ogp/extension.rb +28 -4
- data/lib/middleman-ogp/version.rb +1 -1
- data/spec/helper_spec.rb +20 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96160b6adc9bfb778a9514674c56f7c123eebb84
|
4
|
+
data.tar.gz: 9423c6302a1cc61e14696c8b00ec4afc680ed35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317dd8172ab0d69f28f57b6005c92727f50c1970db9a6992033120b95d56d9c488774389da6236589ee35cbb7b6f8d3f231b686eae18bf5cc2ff036c3871dcbc
|
7
|
+
data.tar.gz: 6faa50f42a43ee59a7ce58b06327f7b8e22913d547baf9ef8b330565bc3b5af0c78891db88b6f26f00a576382814d4962bc692552c62cb890c9949d19a06621c
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -25,11 +25,14 @@ module Middleman
|
|
25
25
|
mattr_accessor :namespaces
|
26
26
|
|
27
27
|
def self.ogp_tags(opts = {}, &block)
|
28
|
-
|
29
|
-
options =
|
28
|
+
opts ||= {}
|
29
|
+
options = (namespaces.respond_to?(:to_h) ? namespaces.to_h : namespaces || {}).dup
|
30
|
+
opts.stringify_keys!
|
31
|
+
options.stringify_keys!
|
32
|
+
options = options.deep_merge4(opts) {|k, old_value, new_value|
|
30
33
|
if old_value.is_a?(Hash)
|
31
34
|
if new_value.is_a? Hash
|
32
|
-
old_value.
|
35
|
+
old_value.deep_merge4 new_value
|
33
36
|
else
|
34
37
|
old_value[''] = new_value
|
35
38
|
old_value
|
@@ -55,7 +58,7 @@ module Middleman
|
|
55
58
|
case obj
|
56
59
|
when Hash
|
57
60
|
obj.map{|k, v|
|
58
|
-
og_tag(k.to_s.empty? ? key.dup : (key.dup << k.
|
61
|
+
og_tag(k.to_s.empty? ? key.dup : (key.dup << k.to_s) , v, prefix, &block)
|
59
62
|
}.join("\n")
|
60
63
|
when Array
|
61
64
|
obj.map{|v|
|
@@ -69,3 +72,24 @@ module Middleman
|
|
69
72
|
end
|
70
73
|
end
|
71
74
|
end
|
75
|
+
|
76
|
+
|
77
|
+
class Hash
|
78
|
+
|
79
|
+
def deep_merge4(other_hash, &block)
|
80
|
+
dup.deep_merge4!(other_hash, &block)
|
81
|
+
end
|
82
|
+
|
83
|
+
def deep_merge4!(other_hash, &block)
|
84
|
+
other_hash.each_pair do |k,v|
|
85
|
+
tv = self[k]
|
86
|
+
if tv.is_a?(Hash) && v.is_a?(Hash)
|
87
|
+
self[k] = tv.deep_merge4(v, &block)
|
88
|
+
else
|
89
|
+
self[k] = block && tv ? block.call(k, tv, v) : v
|
90
|
+
end
|
91
|
+
end
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/spec/helper_spec.rb
CHANGED
@@ -40,7 +40,7 @@ describe "Middleman::OGP::Helper" do
|
|
40
40
|
EOF
|
41
41
|
}
|
42
42
|
end
|
43
|
-
describe "options
|
43
|
+
describe "options are presented" do
|
44
44
|
let(:options) {
|
45
45
|
{
|
46
46
|
og: {
|
@@ -65,5 +65,24 @@ describe "Middleman::OGP::Helper" do
|
|
65
65
|
EOF
|
66
66
|
}
|
67
67
|
end
|
68
|
+
describe "only additional option is presented" do
|
69
|
+
let(:options) {
|
70
|
+
{
|
71
|
+
og: {
|
72
|
+
type: 'article'
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
it {
|
77
|
+
subject.should eq <<-EOF.unindent
|
78
|
+
<meta property="og:image" content="http://mydomain.tld/mysite.png" />
|
79
|
+
<meta property="og:image:type" content="image/png" />
|
80
|
+
<meta property="og:image:width" content="300" />
|
81
|
+
<meta property="og:image:height" content="400" />
|
82
|
+
<meta property="og:type" content="article" />
|
83
|
+
<meta property="fb:description" content="foo" />
|
84
|
+
EOF
|
85
|
+
}
|
86
|
+
end
|
68
87
|
end
|
69
88
|
end
|