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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7a795f3654c7cc818de89ae7b305a490f35cf79
4
- data.tar.gz: bea3e8661b877fcc400d3827f7bc151e7c768883
3
+ metadata.gz: 96160b6adc9bfb778a9514674c56f7c123eebb84
4
+ data.tar.gz: 9423c6302a1cc61e14696c8b00ec4afc680ed35b
5
5
  SHA512:
6
- metadata.gz: cc0818834f813e104131b5227f5aa9e72c125954957b8d89b4aa0690e0259129472ac4b140668053d9e1296b1d19392e6dcb30e9548f9405ca62ba8427f0973d
7
- data.tar.gz: c0f4ef61d865266300ac2bd746dc1229b1fe2dd6a0e4dfca73fef78404bfd3fa5be5c093dd046396147210f5383c4246fbdc2e451990a96a80a58eadeac59ada
6
+ metadata.gz: 317dd8172ab0d69f28f57b6005c92727f50c1970db9a6992033120b95d56d9c488774389da6236589ee35cbb7b6f8d3f231b686eae18bf5cc2ff036c3871dcbc
7
+ data.tar.gz: 6faa50f42a43ee59a7ce58b06327f7b8e22913d547baf9ef8b330565bc3b5af0c78891db88b6f26f00a576382814d4962bc692552c62cb890c9949d19a06621c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.0.2
2
+ -----
3
+
4
+ * Adopted Hash#deep_merge from active support 4 to use blocks.
5
+
1
6
  1.0.0
2
7
  -----
3
8
 
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "middleman-core", :github => "middleman/middleman", :branch => 'v3-stable'
3
+ gem "middleman-core", '~> 3.2'
4
4
 
5
5
  # Specify your gem's dependencies in middleman-ogp.gemspec
6
6
  gemspec
@@ -25,11 +25,14 @@ module Middleman
25
25
  mattr_accessor :namespaces
26
26
 
27
27
  def self.ogp_tags(opts = {}, &block)
28
- options = namespaces.respond_to?(:to_h) ? namespaces.to_h : namespaces || {}
29
- options = options.deep_merge(opts || {}) {|k, old_value, new_value|
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.deep_merge new_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.to_sym) , v, prefix, &block)
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
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module OGP
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  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 is presented" do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-ogp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atsushi Nagase