medea 0.7.1 → 0.7.2

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.
@@ -38,8 +38,8 @@ module Medea
38
38
  'X-VERSION' => TEMPLATE_VERSION}
39
39
  curr_version = TEMPLATE_VERSION.split "."
40
40
  base_url = url ? url : JasonDB::db_auth_url
41
- Dir.glob(File.expand_path(File.join(template_dir, "*.template"))).select do |file|
42
- #for each template, we need to post it to ..#{filename}:html_template
41
+ Dir.glob(File.expand_path(File.join(template_dir, "*.*"))).select do |file|
42
+ #for each template, we need to post it to ..#{filenam e}:html_template
43
43
  file =~ name_pattern
44
44
  template_path = "#{base_url}..#{$1}:#{$2}"
45
45
 
@@ -92,8 +92,12 @@ module Medea
92
92
  #for each k/v in the hash, we want to add an entry to filter_array
93
93
  val.each do |field ,value|
94
94
  if value.is_a? Array
95
- value.each do |i|
96
- filter_array << URI.escape("#{name.to_s}=#{field}:#{i}", unsafe)
95
+ if field == :HTTP_X_PARENT
96
+ filter_array << URI.escape("#{name.to_s}={#{field}:[#{value.join ","}]}", unsafe)
97
+ else
98
+ value.each do |i|
99
+ filter_array << URI.escape("#{name.to_s}=#{field}:#{i}", unsafe)
100
+ end
97
101
  end
98
102
  else
99
103
  filter_array << URI.escape("#{name.to_s}=#{field.to_s}:#{value.to_s}", unsafe)
@@ -144,11 +148,10 @@ module Medea
144
148
  def execute_query content=true
145
149
  #hit the URL
146
150
  #fill self.contents with :ghost versions of JasonObjects
147
-
148
- begin
149
- response = RestClient.get to_url
151
+ self.contents = []
152
+ response = RestClient.get to_url
153
+ if response.code == 200 #OK
150
154
  result = JSON.parse(response)
151
- self.contents = []
152
155
  #results are in a hash, their keys are just numbers
153
156
  result.keys.each do |k|
154
157
  if k =~ /^[0-9]+$/
@@ -167,15 +170,14 @@ module Medea
167
170
  self.contents << item
168
171
  end
169
172
  end
170
-
171
173
  self.state = :postfetch
172
- rescue JSON::ParserError
173
- #we assume that a parser error means that there are no results, or a problem with the template
174
- #(currently a problem with the template is causing a parser error when there's no results)
175
- self.contents = []
174
+ self.contents
175
+ elsif response.code == 204 #No Content
176
176
  self.state = :postfetch
177
+ self.contents
178
+ else #response wasn't OK or empty!
179
+ self.state = :prefetch
177
180
  end
178
- result
179
181
  end
180
182
  end
181
183
  end
@@ -16,6 +16,10 @@ module Medea
16
16
  self.filters[:FILTER][:HTTP_X_CLASS] = list_class.name if list_type == :value
17
17
  @list_name = list_name
18
18
  @parent = parent
19
+ if @parent.is_a? JasonObject
20
+ self.filters[:FILTER][:HTTP_X_PARENT] = @parent.jason_key
21
+ end
22
+
19
23
  @state = :prefetch
20
24
  @contents = []
21
25
  @list_type = list_type
@@ -118,23 +122,18 @@ module Medea
118
122
 
119
123
 
120
124
  def to_url
121
- url = "#{JasonDB::db_auth_url}@#{@time_limit}.#{@result_format}?"
122
- params = ["VERSION0"]
123
- params << "FILTER=HTTP_X_LIST:#{@list_name.to_s}"
124
-
125
- if @parent.is_a? JasonObject
126
- params << "FILTER=HTTP_X_PARENT:#{@parent.jason_key}"
127
- else # @parent.is_a? JasonListProperty ##(or DeferredQuery?)
125
+ if not @parent.is_a? JasonObject
126
+ # @parent.is_a? JasonListProperty ##(or DeferredQuery?)
128
127
  #we can get the insecure url here, because it will be resolved and executed at JasonDB - on a secure subnet.
129
128
 
130
129
  #puts " = Fetching subquery stupidly. (#{@parent.to_url})"
131
130
  @parent.result_format = :keylist
132
131
  subquery = (RestClient.get @parent.to_url).strip
133
- #puts " = Result: #{subquery}"
134
- params << "FILTER={HTTP_X_PARENT:#{subquery}}"
132
+
133
+ self.filters[:FILTER][:HTTP_X_PARENT] = subquery.split ","
135
134
  end
136
135
 
137
- url << URI.escape(params.join("&"), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
136
+ super
138
137
  end
139
138
  end
140
139
  end
@@ -0,0 +1,3 @@
1
+ {
2
+ "MIME_TYPE":"json"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "MIME_TYPE":"json"
3
+ }
@@ -1 +1 @@
1
- [<!--%item% [%HTTP_X_KEY%][%COMMA%]%item%-->]
1
+ <!--%item% [%HTTP_X_KEY%][%COMMA%]%item%-->
@@ -0,0 +1,3 @@
1
+ {
2
+ "MIME_TYPE":"json"
3
+ }
@@ -5,11 +5,12 @@
5
5
  "SELF_LINK":"--%SELF_LINK%--",
6
6
  "AUTH_USER":"--%AUTH_USER%--",
7
7
  "RESTFULDB_VERSION":"--%RESTFULDB_VERSION%--",
8
+ "RESTFULDB_VER":"--%RESTFULDB_VER%--",
8
9
  "QUERY_URL":"--%QUERY_URL%--",
9
10
  "TOTAL_STATE_ERRORS":"--%TOTAL_STATE_ERRORS%--",
10
- "TOTAL_VALID_STATES_ERRORS":"--%TOTAL_VALID_STATES_ERRORS%--",
11
+ "TOTAL_VALID_STATES_ERRORS":"--%TOTAL_VALID_STATES_ERRORS%--"
11
12
  <!--%item%
12
- "[%ITEM_NUMBER%]":
13
+ ,"[%ITEM_NUMBER%]":
13
14
  {
14
15
  "POST_TO":"[%POST_TO%]",
15
16
  "RELATIVE_VERSION":"[%RELATIVE_VERSION%]",
@@ -24,6 +25,6 @@
24
25
  "HTTP_X_KEY":"[%HTTP_X_KEY%]",
25
26
  "HTTP_X_PARENT":"[%HTTP_X_PARENT%]",
26
27
  "CONTENT":[%CONTENT%]
27
- }[%COMMA%]
28
+ }
28
29
  %item%-->
29
30
  }
@@ -1,7 +1,7 @@
1
1
  module Medea
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
 
4
4
  #When the templates are changed, this version should be incremented
5
5
  #This version is used when uploading/updating the templates
6
- TEMPLATE_VERSION = "1.1.1"
6
+ TEMPLATE_VERSION = "1.1.3"
7
7
  end
@@ -6,6 +6,10 @@ require 'medea'
6
6
  class Message < Medea::JasonObject
7
7
  end
8
8
 
9
+ ENV["jason_user"] = "michael"
10
+ ENV["jason_topic"] = "medea-test"
11
+ ENV["jason_password"] = "password"
12
+
9
13
  class User < Medea::JasonObject
10
14
  has_location
11
15
  has_many :followees, User
@@ -21,7 +25,3 @@ class DummyResponse
21
25
  :timestamp => "12345678"}
22
26
  end
23
27
  end
24
-
25
- ENV["jason_user"] = "michael"
26
- ENV["jason_topic"] = "medea-test"
27
- ENV["jason_password"] = "password"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: medea
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.1
5
+ version: 0.7.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Jensen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-07 00:00:00 +11:00
13
+ date: 2011-03-29 00:00:00 +11:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -84,8 +84,11 @@ files:
84
84
  - lib/medea/jasonlistproperty.rb
85
85
  - lib/medea/jasonobject.rb
86
86
  - lib/medea/meta_properties.rb
87
+ - lib/medea/templates/content.metadata
87
88
  - lib/medea/templates/content.template
89
+ - lib/medea/templates/keylist.metadata
88
90
  - lib/medea/templates/keylist.template
91
+ - lib/medea/templates/search.metadata
89
92
  - lib/medea/templates/search.template
90
93
  - lib/medea/version.rb
91
94
  - medea.gemspec