middleman-data_source 0.6.0 → 0.6.1

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: 8149a40f5de297992c3027d32d35a35592781065
4
- data.tar.gz: 14b91bba9a92160b4c2d696df4698eefc48266ec
3
+ metadata.gz: 8644a9a460f377c8c69f395ad49f85e08c600fcc
4
+ data.tar.gz: 2dc0d7139e818f655f7ad6a3bbd7eb8612d38693
5
5
  SHA512:
6
- metadata.gz: 218bd22fd6a2875f9015641d9f87ccaaa865a24e4022304a1ed2a89b0094276e3197b0bf651b4a1cfff6300d097918e726e764087671dc1149ee7ee230ea52ea
7
- data.tar.gz: 6589a1e6dd03534bf4121ff797058f91776ca6b90ce34b141b1bdb3171c4203a3e51b144a5184b75147b66f133f3e68d77f7b9f9563b475719bd5832b4bd54ce
6
+ metadata.gz: 031b02e3c88069f6232345bf159f007b9d0b14fa22e87e74c461beaf5abef13d47e7a85bff1d4cf210247ed695c1b37fba8128964c7e286d78af391d748fda0e
7
+ data.tar.gz: 1699caaa0cdfad8f4ba4cf5d311ca0ff0fe44ea101cfe2bd0d2f7a9e68027763a9e5e0b647e8480dd655126e08ec217afa61f68d4ca16ea5ef38aaa9775a7edf
data/changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.6.1
2
+ - fixes for newer versions of middleman 4 compatability
3
+
1
4
  # 0.6.0
2
5
  - add definable decoders & allow override of default json & yaml decoders
3
6
  - allow for defining sources with arbitrary data types
@@ -73,8 +73,10 @@ module Middleman
73
73
  def attempt_merge_then_enhance new_data, original_callback
74
74
  if original_callback
75
75
  original_data = original_callback.call
76
- if original_data.respond_to? :merge
76
+ if original_data.respond_to? :deep_merge
77
77
  return ::Middleman::Util.recursively_enhance original_data.deep_merge(new_data)
78
+ elsif original_data.respond_to? :merge
79
+ return ::Middleman::Util.recursively_enhance deep_merge(original_data, new_data)
78
80
  end
79
81
  end
80
82
 
@@ -105,6 +107,19 @@ module Middleman
105
107
  end
106
108
  end
107
109
 
110
+ def deep_merge base, extension
111
+ base.merge extension do |key, old_val, new_val|
112
+ old_val = old_val.to_hash if old_val.respond_to?(:to_hash)
113
+ new_val = new_val.to_hash if new_val.respond_to?(:to_hash)
114
+
115
+ if old_val.respond_to?(:merge) && new_val.respond_to?(:merge)
116
+ deep_merge old_val, new_val
117
+ else
118
+ new_val
119
+ end
120
+ end
121
+ end
122
+
108
123
  class UnsupportedDataExtension < ArgumentError
109
124
  end
110
125
 
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module DataSource
3
3
 
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
 
6
6
  end
7
7
  end
@@ -8,25 +8,25 @@ describe Middleman::DataSource::Extension do
8
8
 
9
9
  shared_examples "data import" do
10
10
  it "adds data to application" do
11
- expect( @mm.data.remote ).to eq [{"item" => "one"}, {"item" => "two"}]
11
+ expect( @mm.data.remote.map(&:to_h) ).to match_array [{"item" => "one"}, {"item" => "two"}]
12
12
  end
13
13
 
14
14
  it "supports nested routes" do
15
- expect( @mm.data.deeply.nested.routes ).to eq [{"item" => "one"}, {"item" => "two"}]
15
+ expect( @mm.data.deeply.nested.routes.map(&:to_h) ).to match_array [{"item" => "one"}, {"item" => "two"}]
16
16
  end
17
17
 
18
18
  it "supports query params" do
19
- expect( @mm.data.query_param ).to eq [{"foo" => "bar"}]
19
+ expect( @mm.data.query_param.map(&:to_h) ).to match_array [{"foo" => "bar"}]
20
20
  end
21
21
 
22
22
  it "attempts to not clobber data of overlapping nested routes (if it's hashes)" do
23
- expect( @mm.data.deeply.nested.has_key? "nestable" ).to eq true
23
+ expect( @mm.data.deeply.nested.to_h.has_key? "nestable" ).to eq true
24
24
  expect( @mm.data.deeply.nested["nestable"] ).to eq "data"
25
25
  end
26
26
 
27
27
  it "support yaml or json" do
28
- expect( @mm.data.in_yaml ).to eq ["data","in","yaml"]
29
- expect( @mm.data.in_json ).to eq ["data","in","json"]
28
+ expect( @mm.data.in_yaml ).to match_array ["data","in","yaml"]
29
+ expect( @mm.data.in_json ).to match_array ["data","in","json"]
30
30
  end
31
31
  end
32
32
 
@@ -98,8 +98,8 @@ describe Middleman::DataSource::Extension do
98
98
  end
99
99
 
100
100
  it "returns data from both instances" do
101
- expect( @mm.data.remote ).to eq [{"item" => "one"}, {"item" => "two"}]
102
- expect( @mm.data.in_yaml ).to eq ["data","in","yaml"]
101
+ expect( @mm.data.remote ).to match_array [{"item" => "one"}, {"item" => "two"}]
102
+ expect( @mm.data.in_yaml ).to match_array ["data","in","yaml"]
103
103
  end
104
104
  end
105
105
 
@@ -116,8 +116,8 @@ describe Middleman::DataSource::Extension do
116
116
 
117
117
  it "maps correctly between route & data name" do
118
118
  expect( @mm.data.mapped_nested["nestable"] ).to eq "data"
119
- expect( @mm.data.mapped_in_yaml ).to eq ["data","in","yaml"]
120
- expect( @mm.data.mapped_in_json ).to eq ["data","in","json"]
119
+ expect( @mm.data.mapped_in_yaml ).to match_array ["data","in","yaml"]
120
+ expect( @mm.data.mapped_in_json ).to match_array ["data","in","json"]
121
121
  end
122
122
  end
123
123
 
@@ -125,8 +125,9 @@ describe Middleman::DataSource::Extension do
125
125
  Given.fixture 'imediate_use'
126
126
  @mm = Middleman::Fixture.app
127
127
 
128
- data = (@mm.respond_to?(:config) && @mm.config.respond_to?(:setting)) ? @mm.config.setting(:remote_data).value : @mm.remote_data
129
- expect( data ).to match_array [{"item"=>"one"},{"item"=>"two"}]
128
+ remote_data = (@mm.config.setting(:remote_data).value.respond_to?(:value)) ? @mm.config.setting(:remote_data).value.value : @mm.config.setting(:remote_data).value
129
+
130
+ expect( remote_data ).to match_array [{"item"=>"one"},{"item"=>"two"}]
130
131
  end
131
132
 
132
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-data_source
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.4.5
101
+ rubygems_version: 2.4.6
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Allow for loading data in middleman from remote sources