1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Data API test

This commit is contained in:
Thomas Reynolds 2011-07-06 10:29:07 -07:00
parent c9e4d41533
commit 6a3de0768c
5 changed files with 17 additions and 4 deletions

7
features/data.feature Normal file
View file

@ -0,0 +1,7 @@
Feature: Local Data API
In order to abstract content from structure
Scenario: Rendering html with the feature enabled
Given the Server is running
When I go to "/data.html"
Then I should see "One:Two"

View file

@ -3,6 +3,7 @@ with_layout false do
page "/inline-js.html"
page "/inline-coffeescript.html"
page "/slim.html"
page "/data.html"
end
get "/page-class.html" do

View file

@ -0,0 +1,4 @@
-
title: "One"
-
title: "Two"

View file

@ -0,0 +1 @@
<%= data.test.map { |r| r.title }.join(":") %>

View file

@ -13,7 +13,7 @@ module Middleman::CoreExtensions::Data
module Helpers
def data
@@data ||= Middleman::CoreExtensions::Data::DataObject.new(self)
@@data ||= DataObject.new(self)
end
end
@ -33,7 +33,7 @@ module Middleman::CoreExtensions::Data
elsif @@remote_sources.has_key?(path.to_s)
response = HTTParty.get(@@remote_sources[path.to_s]).parsed_response
else
file_path = File.join(@app.class.root, "data", "#{path}.yml")
file_path = File.join(@app.class.root, "data", "#{path}.yml")
if File.exists? file_path
response = YAML.load_file(file_path)
end
@ -82,11 +82,11 @@ module Middleman::CoreExtensions::Data
#
# data.my_json
def data_source(name, url)
Middleman::CoreExtensions::Data::DataObject.add_source(name, url)
DataObject.add_source(name, url)
end
def data_content(name, content)
Middleman::CoreExtensions::Data::DataObject.data_content(name, content)
DataObject.data_content(name, content)
end
end
end