medea 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/medea/jasondeferredquery.rb +24 -17
- data/lib/medea/version.rb +1 -1
- metadata +4 -4
@@ -114,26 +114,33 @@ module Medea
|
|
114
114
|
#hit the URL
|
115
115
|
#fill self.contents with :ghost versions of JasonObjects
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
117
|
+
begin
|
118
|
+
response = RestClient.get to_url
|
119
|
+
result = JSON.parse(response)
|
120
|
+
self.contents = []
|
121
|
+
#results are in a hash, their keys are just numbers
|
122
|
+
result.keys.each do |k|
|
123
|
+
if k =~ /^[0-9]+$/
|
124
|
+
#this is a result! get the key
|
125
|
+
item = type.new(result[k]["HTTP_X_KEY"], :lazy)
|
126
|
+
if content && result[k].has_key?("CONTENT") && result[k]["CONTENT"] != ""
|
127
|
+
item.instance_variable_set(:@__jason_data, result[k]["CONTENT"])
|
128
|
+
item.instance_variable_set(:@__jason_state, :stale)
|
129
|
+
end
|
130
|
+
if result[k].has_key?("HTTP_X_PARENT") && result[k]["HTTP_X_PARENT"] != ""
|
131
|
+
item.jason_parent_key = result[k]["HTTP_X_PARENT"]
|
132
|
+
end
|
133
|
+
self.contents << item
|
131
134
|
end
|
132
|
-
self.contents << item
|
133
135
|
end
|
134
|
-
end
|
135
136
|
|
136
|
-
|
137
|
+
self.state = :postfetch
|
138
|
+
rescue JSON::ParserError
|
139
|
+
#we assume that a parser error means that there are no results, or a problem with the template
|
140
|
+
#(currently a problem with the template is causing a parser error when there's no results)
|
141
|
+
self.contents = []
|
142
|
+
self.state = :postfetch
|
143
|
+
end
|
137
144
|
result
|
138
145
|
end
|
139
146
|
end
|
data/lib/medea/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: medea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 7
|
10
|
+
version: 0.3.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Jensen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-10 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|