middleman-data_source 0.2.0 → 0.3.0

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: a1740b08c31a4760f0ab73077c0aa67c7e20bbb1
4
- data.tar.gz: b8d7771afa4af37eb51e11043c201bbb14dc4e5a
3
+ metadata.gz: f92c547722c3acc8279689d9f9b03f9bd22501fb
4
+ data.tar.gz: 7c597e7a910b1fa2226131e2791d52b2783b8512
5
5
  SHA512:
6
- metadata.gz: 459a8197ac39ed4bc0e38eccc64a7f7e0397381d2b65dc3ab9fabc07b2dd876d09725730ec275274ad1123662e99d0550b2e99df7d8bf50bb56efc56bb34ce95
7
- data.tar.gz: 678fd4d620a23691270fa5f780cf2eee58f99c853364519fbdcaf86ec8bb79e3a2844ace266d9adc5d2e503502164c3460997e70922bafffa727b340cefea0b4
6
+ metadata.gz: 1ad2e9d4c9ee45e674f37a784da7eb9b5f3082b3d15f59e81f4d9085a1e6819819f14eb4256c92ad85a76b3c8ad0a19c713fd0dedaf398f53a252cd6d3d9f384
7
+ data.tar.gz: 642a9856acd83198fd44920d3a71d3b627dda1f64884eac09960b988fba9743b7e4ab161cead01220fd612e98cbd1a5a54b0e8b02e3e009c777da7e834309ce9
data/changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.3.0
2
+ - add support for using remote data imediatly after activating the extension
3
+
1
4
  # 0.2.0
2
5
  - add support for specifying file resources as a hash so you can do
3
6
  ```ruby
@@ -12,11 +12,10 @@ module Middleman
12
12
  @_rack_app ||= ::Rack::Test::Session.new( ::Rack::MockSession.new( options.rack_app ) )
13
13
  end
14
14
 
15
- # files = [
16
- # '/url' => 'data/name'
17
- # ]
15
+ def initialize app, options_hash={}, &block
16
+ super app, options_hash, &block
18
17
 
19
- def after_configuration
18
+ app_inst = app.inst
20
19
  remote_datas = if options.files.respond_to? :keys
21
20
  options.files
22
21
  else
@@ -31,13 +30,13 @@ module Middleman
31
30
  basename = File.basename parts.pop, extension
32
31
 
33
32
  if parts.empty?
34
- original_callback = app.data.callbacks[basename]
35
- app.data.callbacks[basename] = Proc.new do
33
+ original_callback = app_inst.data.callbacks[basename]
34
+ app_inst.data.callbacks[basename] = Proc.new do
36
35
  attempt_merge_then_enhance decode_data(remote_file, extension), original_callback
37
36
  end
38
37
  else
39
- original_callback = app.data.callbacks[parts.first]
40
- app.data.callbacks[parts.first] = Proc.new do
38
+ original_callback = app_inst.data.callbacks[parts.first]
39
+ app_inst.data.callbacks[parts.first] = Proc.new do
41
40
  built_data = { basename => decode_data(remote_file, extension) }
42
41
  parts[1..-1].reverse.each do |part|
43
42
  built_data = { part => built_data }
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module DataSource
3
3
 
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
 
6
6
  end
7
7
  end
@@ -0,0 +1,14 @@
1
+ set :environment, :test
2
+ set :show_exceptions, false
3
+
4
+ activate :data_source do |c|
5
+
6
+ c.root = File.join( Dir.pwd, 'remote_data' )
7
+
8
+ c.files = [
9
+ 'remote.json'
10
+ ]
11
+
12
+ end
13
+
14
+ set :remote_data, data.remote
@@ -105,4 +105,11 @@ describe Middleman::DataSource::Extension do
105
105
  end
106
106
  end
107
107
 
108
+ it "allows for imediate use in config once defined" do
109
+ Given.fixture 'imediate_use'
110
+ @mm = Middleman::Fixture.app
111
+
112
+ expect( @mm.remote_data ).to match_array [{"item"=>"one"},{"item"=>"two"}]
113
+ end
114
+
108
115
  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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2014-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman
@@ -54,6 +54,7 @@ files:
54
54
  - spec/fixtures/base/config.rb
55
55
  - spec/fixtures/borrower/config.rb
56
56
  - spec/fixtures/files_as_hash/config.rb
57
+ - spec/fixtures/imediate_use/config.rb
57
58
  - spec/fixtures/multiple_instances/config.rb
58
59
  - spec/fixtures/unsupported_extension/config.rb
59
60
  - spec/lib/middleman-data_source_spec.rb
@@ -91,6 +92,7 @@ test_files:
91
92
  - spec/fixtures/base/config.rb
92
93
  - spec/fixtures/borrower/config.rb
93
94
  - spec/fixtures/files_as_hash/config.rb
95
+ - spec/fixtures/imediate_use/config.rb
94
96
  - spec/fixtures/multiple_instances/config.rb
95
97
  - spec/fixtures/unsupported_extension/config.rb
96
98
  - spec/lib/middleman/data_source/extension_spec.rb