hyper-resource 1.0.0.lap79 → 1.0.0.lap80
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.yardopts +1 -0
- data/API.md +62 -0
- data/Gemfile +2 -0
- data/JSON_format.md +62 -0
- data/PubSub.md +20 -0
- data/README.md +2 -0
- data/Security.md +0 -0
- data/docs/HyperRecord/ClassMethods.html +2969 -0
- data/docs/HyperRecord/ClientInstanceMethods.html +1833 -0
- data/docs/HyperRecord/Collection.html +564 -0
- data/docs/HyperRecord/DummyValue.html +384 -0
- data/docs/HyperRecord/PubSub/ClassMethods.html +2047 -0
- data/docs/HyperRecord/PubSub.html +1679 -0
- data/docs/HyperRecord/ServerClassMethods.html +697 -0
- data/docs/HyperRecord.html +119 -0
- data/docs/Hyperloop/Resource/ClientDrivers.html +352 -0
- data/docs/Hyperloop/Resource/HTTP.html +1795 -0
- data/docs/Hyperloop/Resource/MethodsController.html +479 -0
- data/docs/Hyperloop/Resource/PropertiesController.html +225 -0
- data/docs/Hyperloop/Resource/PubSub/ClassMethods.html +105 -0
- data/docs/Hyperloop/Resource/PubSub.html +1210 -0
- data/docs/Hyperloop/Resource/RelationsController.html +529 -0
- data/docs/Hyperloop/Resource/ScopesController.html +380 -0
- data/docs/Hyperloop/Resource/SecurityError.html +124 -0
- data/docs/Hyperloop/Resource/SecurityGuards/ClassMethods.html +226 -0
- data/docs/Hyperloop/Resource/SecurityGuards.html +299 -0
- data/docs/Hyperloop/Resource.html +135 -0
- data/docs/Hyperloop.html +186 -0
- data/docs/_index.html +302 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.API.html +138 -0
- data/docs/file.JSON_format.html +134 -0
- data/docs/file.PubSub.html +86 -0
- data/docs/file.README.html +192 -0
- data/docs/file_list.html +71 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +192 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1115 -0
- data/docs/top-level-namespace.html +110 -0
- data/hyper-resource.gemspec +19 -18
- data/lib/hyper_record/class_methods.rb +186 -3
- data/lib/hyper_record/client_instance_methods.rb +68 -3
- data/lib/hyper_record/collection.rb +19 -4
- data/lib/hyper_record/pub_sub.rb +92 -12
- data/lib/hyper_record/server_class_methods.rb +15 -0
- data/lib/hyperloop/resource/client_drivers.rb +2 -0
- data/lib/hyperloop/resource/http.rb +33 -22
- data/lib/hyperloop/resource/pub_sub.rb +2 -0
- data/lib/hyperloop/resource/version.rb +1 -1
- metadata +61 -2
@@ -1,11 +1,11 @@
|
|
1
1
|
module Hyperloop
|
2
2
|
module Resource
|
3
|
-
#
|
3
|
+
# HTTP is used to perform a `XMLHttpRequest` in ruby. It is a simple wrapper
|
4
4
|
# around `XMLHttpRequest`
|
5
5
|
#
|
6
6
|
# # Making requests
|
7
7
|
#
|
8
|
-
# To create a simple request,
|
8
|
+
# To create a simple request, HTTP exposes class level methods to specify
|
9
9
|
# the HTTP action you wish to perform. Each action accepts the url for the
|
10
10
|
# request, as well as optional arguments passed as a hash:
|
11
11
|
#
|
@@ -14,17 +14,17 @@ module Hyperloop
|
|
14
14
|
#
|
15
15
|
# The supported `HTTP` actions are:
|
16
16
|
#
|
17
|
-
# *
|
18
|
-
# *
|
19
|
-
# *
|
20
|
-
# *
|
21
|
-
# *
|
22
|
-
# *
|
17
|
+
# * HTTP.get
|
18
|
+
# * HTTP.post
|
19
|
+
# * HTTP.put
|
20
|
+
# * HTTP.delete
|
21
|
+
# * HTTP.patch
|
22
|
+
# * HTTP.head
|
23
23
|
#
|
24
24
|
# # Handling responses
|
25
25
|
#
|
26
26
|
# Responses can be handled using either a simple block callback, or using a
|
27
|
-
#
|
27
|
+
# Promise returned by the request.
|
28
28
|
#
|
29
29
|
# ## Using a block
|
30
30
|
#
|
@@ -36,8 +36,8 @@ module Hyperloop
|
|
36
36
|
# puts "the request has completed!"
|
37
37
|
# end
|
38
38
|
#
|
39
|
-
# This `request` object will simply be the instance of the
|
40
|
-
# wraps the native `XMLHttpRequest`.
|
39
|
+
# This `request` object will simply be the instance of the HTTP class which
|
40
|
+
# wraps the native `XMLHttpRequest`. HTTP#ok? can be used to quickly determine
|
41
41
|
# if the request was successful.
|
42
42
|
#
|
43
43
|
# HTTP.get("/users/1") do |request|
|
@@ -48,11 +48,11 @@ module Hyperloop
|
|
48
48
|
# end
|
49
49
|
# end
|
50
50
|
#
|
51
|
-
# The
|
51
|
+
# The HTTP instance will always be the only object passed to the block.
|
52
52
|
#
|
53
53
|
# ## Using a Promise
|
54
54
|
#
|
55
|
-
# If no block is given to one of the action methods, then a
|
55
|
+
# If no block is given to one of the action methods, then a Promise is
|
56
56
|
# returned instead. See the standard library for more information on Promises.
|
57
57
|
#
|
58
58
|
# HTTP.get("/users/1").then do |req|
|
@@ -61,20 +61,20 @@ module Hyperloop
|
|
61
61
|
# puts "response was not ok"
|
62
62
|
# end
|
63
63
|
#
|
64
|
-
# When using a
|
65
|
-
#
|
64
|
+
# When using a Promise, both success and failure handlers will be passed the
|
65
|
+
# HTTP instance.
|
66
66
|
#
|
67
67
|
# # Accessing Response Data
|
68
68
|
#
|
69
|
-
# All data returned from an HTTP request can be accessed via the
|
69
|
+
# All data returned from an HTTP request can be accessed via the HTTP object
|
70
70
|
# passed into the block or promise handlers.
|
71
71
|
#
|
72
|
-
# -
|
73
|
-
# -
|
74
|
-
# -
|
75
|
-
# -
|
72
|
+
# - #ok? - returns `true` or `false`, if request was a success (or not).
|
73
|
+
# - #body - returns the raw text response of the request
|
74
|
+
# - #status_code - returns the raw {HTTP} status code as integer
|
75
|
+
# - #json - tries to convert the body response into a JSON object
|
76
76
|
class HTTP
|
77
|
-
# All valid
|
77
|
+
# All valid HTTP action methods this class accepts.
|
78
78
|
#
|
79
79
|
# @see HTTP.get
|
80
80
|
# @see HTTP.post
|
@@ -112,7 +112,7 @@ module Hyperloop
|
|
112
112
|
# @param url [String] url for request
|
113
113
|
# @param options [Hash] optional request options
|
114
114
|
# @yield [self] optional block to yield for response
|
115
|
-
# @return [Promise, nil] returns a
|
115
|
+
# @return [Promise, nil] returns a Promise unless block given
|
116
116
|
|
117
117
|
# @!method self.put(url, options = {}, &block)
|
118
118
|
|
@@ -138,6 +138,8 @@ module Hyperloop
|
|
138
138
|
@ok = true
|
139
139
|
end
|
140
140
|
|
141
|
+
# check if requests are still active
|
142
|
+
# return [Boolean]
|
141
143
|
def self.active?
|
142
144
|
jquery_active_requests = 0
|
143
145
|
%x{
|
@@ -148,16 +150,19 @@ module Hyperloop
|
|
148
150
|
(jquery_active_requests + @active_requests) > 0
|
149
151
|
end
|
150
152
|
|
153
|
+
# @private
|
151
154
|
def self.active_requests
|
152
155
|
@active_requests ||= 0
|
153
156
|
@active_requests
|
154
157
|
end
|
155
158
|
|
159
|
+
# @private
|
156
160
|
def self.incr_active_requests
|
157
161
|
@active_requests ||= 0
|
158
162
|
@active_requests += 1
|
159
163
|
end
|
160
164
|
|
165
|
+
# @private
|
161
166
|
def self.decr_active_requests
|
162
167
|
@active_requests ||= 0
|
163
168
|
@active_requests -= 1
|
@@ -167,6 +172,7 @@ module Hyperloop
|
|
167
172
|
end
|
168
173
|
end
|
169
174
|
|
175
|
+
# @private
|
170
176
|
def send(method, url, options, block)
|
171
177
|
@method = method
|
172
178
|
@url = url
|
@@ -266,12 +272,15 @@ module Hyperloop
|
|
266
272
|
}
|
267
273
|
end
|
268
274
|
|
275
|
+
# inspect on request
|
276
|
+
# @return [String]
|
269
277
|
def inspect
|
270
278
|
"#<HTTP @url=#{@url} @method=#{@method}>"
|
271
279
|
end
|
272
280
|
|
273
281
|
private
|
274
282
|
|
283
|
+
# @private
|
275
284
|
def promise
|
276
285
|
return @promise if @promise
|
277
286
|
|
@@ -286,6 +295,7 @@ module Hyperloop
|
|
286
295
|
}
|
287
296
|
end
|
288
297
|
|
298
|
+
# @private
|
289
299
|
def succeed(data, status, xhr)
|
290
300
|
%x{
|
291
301
|
#@body = data;
|
@@ -300,6 +310,7 @@ module Hyperloop
|
|
300
310
|
@handler.call self if @handler
|
301
311
|
end
|
302
312
|
|
313
|
+
# @private
|
303
314
|
def fail(xhr, status, error)
|
304
315
|
%x{
|
305
316
|
#@body = xhr.responseText;
|
@@ -6,6 +6,7 @@ module Hyperloop
|
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
+
# @private
|
9
10
|
def _pusher_client
|
10
11
|
Hyperloop.pusher_instance ||= Pusher::Client.new(
|
11
12
|
app_id: Hyperloop.pusher[:app_id],
|
@@ -16,6 +17,7 @@ module Hyperloop
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
20
|
+
# (see HyperRecord::ClassMethods#publish_record)
|
19
21
|
def publish_record(record)
|
20
22
|
subscribers = Hyperloop.redis_instance.hgetall("HRPS__#{record.class}__#{record.id}")
|
21
23
|
time_now = Time.now.to_f
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.lap80
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: yard
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 0.9.13
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 0.9.13
|
195
209
|
description: Write Browser Apps that transparently access server side resources like
|
196
210
|
'MyModel.first_name', with ease
|
197
211
|
email: jan@kursator.de
|
@@ -199,8 +213,53 @@ executables: []
|
|
199
213
|
extensions: []
|
200
214
|
extra_rdoc_files: []
|
201
215
|
files:
|
216
|
+
- ".gitignore"
|
217
|
+
- ".yardopts"
|
218
|
+
- API.md
|
219
|
+
- Gemfile
|
220
|
+
- JSON_format.md
|
202
221
|
- LICENSE
|
222
|
+
- PubSub.md
|
203
223
|
- README.md
|
224
|
+
- Security.md
|
225
|
+
- docs/HyperRecord.html
|
226
|
+
- docs/HyperRecord/ClassMethods.html
|
227
|
+
- docs/HyperRecord/ClientInstanceMethods.html
|
228
|
+
- docs/HyperRecord/Collection.html
|
229
|
+
- docs/HyperRecord/DummyValue.html
|
230
|
+
- docs/HyperRecord/PubSub.html
|
231
|
+
- docs/HyperRecord/PubSub/ClassMethods.html
|
232
|
+
- docs/HyperRecord/ServerClassMethods.html
|
233
|
+
- docs/Hyperloop.html
|
234
|
+
- docs/Hyperloop/Resource.html
|
235
|
+
- docs/Hyperloop/Resource/ClientDrivers.html
|
236
|
+
- docs/Hyperloop/Resource/HTTP.html
|
237
|
+
- docs/Hyperloop/Resource/MethodsController.html
|
238
|
+
- docs/Hyperloop/Resource/PropertiesController.html
|
239
|
+
- docs/Hyperloop/Resource/PubSub.html
|
240
|
+
- docs/Hyperloop/Resource/PubSub/ClassMethods.html
|
241
|
+
- docs/Hyperloop/Resource/RelationsController.html
|
242
|
+
- docs/Hyperloop/Resource/ScopesController.html
|
243
|
+
- docs/Hyperloop/Resource/SecurityError.html
|
244
|
+
- docs/Hyperloop/Resource/SecurityGuards.html
|
245
|
+
- docs/Hyperloop/Resource/SecurityGuards/ClassMethods.html
|
246
|
+
- docs/_index.html
|
247
|
+
- docs/class_list.html
|
248
|
+
- docs/css/common.css
|
249
|
+
- docs/css/full_list.css
|
250
|
+
- docs/css/style.css
|
251
|
+
- docs/file.API.html
|
252
|
+
- docs/file.JSON_format.html
|
253
|
+
- docs/file.PubSub.html
|
254
|
+
- docs/file.README.html
|
255
|
+
- docs/file_list.html
|
256
|
+
- docs/frames.html
|
257
|
+
- docs/index.html
|
258
|
+
- docs/js/app.js
|
259
|
+
- docs/js/full_list.js
|
260
|
+
- docs/js/jquery.js
|
261
|
+
- docs/method_list.html
|
262
|
+
- docs/top-level-namespace.html
|
204
263
|
- hyper-resource.gemspec
|
205
264
|
- lib/hyper-resource.rb
|
206
265
|
- lib/hyper_record.rb
|