medea 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -114,26 +114,33 @@ module Medea
114
114
  #hit the URL
115
115
  #fill self.contents with :ghost versions of JasonObjects
116
116
 
117
- response = RestClient.get to_url
118
- result = JSON.parse(response)
119
- self.contents = []
120
- #results are in a hash, their keys are just numbers
121
- result.keys.each do |k|
122
- if k =~ /^[0-9]+$/
123
- #this is a result! get the key
124
- item = type.new(result[k]["HTTP_X_KEY"], :lazy)
125
- if content && result[k].has_key?("CONTENT") && result[k]["CONTENT"] != ""
126
- item.instance_variable_set(:@__jason_data, result[k]["CONTENT"])
127
- item.instance_variable_set(:@__jason_state, :stale)
128
- end
129
- if result[k].has_key?("HTTP_X_PARENT") && result[k]["HTTP_X_PARENT"] != ""
130
- item.jason_parent_key = result[k]["HTTP_X_PARENT"]
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
- self.state = :postfetch
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
@@ -1,3 +1,3 @@
1
1
  module Medea
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 6
10
- version: 0.3.6
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-07 00:00:00 +11:00
18
+ date: 2011-01-10 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency