lws 9.0.2 → 10.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +581 -0
- data/README.md +170 -0
- data/lib/lws/apps/generic.rb +11 -7
- data/lib/lws/middleware/caching.rb +158 -0
- data/lib/lws/middleware/http_logger.rb +3 -2
- data/lib/lws/middleware/json_logger.rb +3 -1
- data/lib/lws/middleware/json_parser.rb +3 -1
- data/lib/lws/middleware.rb +29 -0
- data/lib/lws/version.rb +1 -1
- data/lib/lws.rb +17 -7
- metadata +49 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b95bfeece7dd86ad3600b16dcb9144c705c4229d470812260af4d1d0970ce8d4
|
4
|
+
data.tar.gz: 59ce679a1c5343c37be5c5ac2c59c3560e51e79f62fafba17f48e561d504cf42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979c5b1e4565900eed76bc588674cf75a52c7ddb1bb227eb6913c43b17316d940d68775d19427281b34534d60705277b9babb16ad116372ccfcfea48adfd7847
|
7
|
+
data.tar.gz: 4eeb72294ada48b88afda88ab5c706f44eea5a181ecb7ed0de31cab4321025a8fb7c29d414715da99eae0733ceecaba7c151ddfd0177ea9d9e4a8cc8900103f0
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,581 @@
|
|
1
|
+
# LeftClick Web Services Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
Up until version 6.1.0, we used the standard Gem version numbering starting at
|
6
|
+
version 0.0.1. From version 6.1.0 on the version will follow the API version
|
7
|
+
of LWS in the major/minor part of te version.
|
8
|
+
|
9
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
10
|
+
|
11
|
+
## [10.0.1] - 2024-10-10
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Bring back the dependency on the `net-http-persistent` gem (in case Faraday
|
16
|
+
1.x is used)
|
17
|
+
|
18
|
+
## [10.0.0] - 2024-10-10
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- Add vendored caching firmware from the Faraday Middleware project for use
|
23
|
+
with Faraday 2.x
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
|
27
|
+
- Tighten dependency on `faraday` gem to 1.0; extend support to 2.x (less
|
28
|
+
than 3.0)
|
29
|
+
- Rework the `Gemfile`/`gemspec` files; split up runtime and dev dependencies
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
- Correct the name of the minitest module
|
34
|
+
|
35
|
+
## [9.0.2] - 2024-08-12
|
36
|
+
|
37
|
+
### Fixed
|
38
|
+
|
39
|
+
- Fix crash when creating models that have has-many associations
|
40
|
+
|
41
|
+
## [9.0.1] - 2024-06-24
|
42
|
+
|
43
|
+
### Add
|
44
|
+
|
45
|
+
- Add missing `_ids` attributes for all has-many associations
|
46
|
+
|
47
|
+
### Fixed
|
48
|
+
|
49
|
+
- Fix dirty model/changes stracking for has-many associations (#12133)
|
50
|
+
- Various documentation improvements
|
51
|
+
|
52
|
+
### Removed
|
53
|
+
|
54
|
+
- Remove all collection item attributes (except for `items`) from the
|
55
|
+
collection model; they don't actually work
|
56
|
+
|
57
|
+
## [9.0.0] - 2024-06-19
|
58
|
+
|
59
|
+
### Changed
|
60
|
+
|
61
|
+
- Further restrict the depency on spyke
|
62
|
+
|
63
|
+
## [9.0.0.beta1] - 2024-06-05
|
64
|
+
|
65
|
+
### Changed
|
66
|
+
|
67
|
+
- Update the dependency on the `spyke` gem
|
68
|
+
|
69
|
+
## [8.1.1] - 2023-12-11
|
70
|
+
|
71
|
+
### Changed
|
72
|
+
|
73
|
+
- Relax the dependency on hashie to allow version 3.5 through 5
|
74
|
+
- Update the `leftclick.eu` domain to `leftclick.network`
|
75
|
+
- Remove unnecessary test file from the gemspec
|
76
|
+
|
77
|
+
## [8.1.0] - 2023-12-11
|
78
|
+
|
79
|
+
### Fixed
|
80
|
+
|
81
|
+
- Fix all tests (on the LWS side)
|
82
|
+
|
83
|
+
### Removed
|
84
|
+
|
85
|
+
- Remove the `start_app` attribute from the account model
|
86
|
+
|
87
|
+
## [7.5.2] - 2022-05-13
|
88
|
+
|
89
|
+
### Changed
|
90
|
+
|
91
|
+
- Use safe loading when loading stubs/config YAML (#12134)
|
92
|
+
|
93
|
+
### Fixed
|
94
|
+
|
95
|
+
- Fix compatibility issue with newer versions of Psych (#12134)
|
96
|
+
|
97
|
+
## [7.5.1] - 2022-03-02
|
98
|
+
|
99
|
+
### Added
|
100
|
+
|
101
|
+
- Add attributes to the customizable model (#12132)
|
102
|
+
|
103
|
+
### Changed
|
104
|
+
|
105
|
+
- Renamed the `hint_message` attribute to `title` on the customizable model
|
106
|
+
|
107
|
+
## [7.5.0] - 2022-01-21
|
108
|
+
|
109
|
+
### Added
|
110
|
+
|
111
|
+
- Add the `email` attribute to the folder model (#12130)
|
112
|
+
- Add the `service_reason` attribute to the player model (#12131)
|
113
|
+
|
114
|
+
## [7.4.1] - 2021-10-21
|
115
|
+
|
116
|
+
### Changed
|
117
|
+
|
118
|
+
- Relax the dependency on the `spyke` gem
|
119
|
+
|
120
|
+
## [7.4.0] - 2021-10-21
|
121
|
+
|
122
|
+
### Changed
|
123
|
+
|
124
|
+
- Relax the dependency on the `net-http-persisent` gem
|
125
|
+
|
126
|
+
### Fixed
|
127
|
+
|
128
|
+
- Fix missing default documentation for option `http_persistent`
|
129
|
+
|
130
|
+
## [7.3.2] - 2021-10-04
|
131
|
+
|
132
|
+
### Fixed
|
133
|
+
|
134
|
+
- Fix some model URIs (endpoint not in plural form)
|
135
|
+
|
136
|
+
## [7.3.1] - 2021-09-29
|
137
|
+
|
138
|
+
### Added
|
139
|
+
|
140
|
+
- Add the `invite_remarks` and `reservation_required` attributes to the
|
141
|
+
location model (#12127)
|
142
|
+
- Add the `layout_kind` attribute to the channel model (#12128)
|
143
|
+
- Add the `uuid` attribute to the slide model (#12129)
|
144
|
+
|
145
|
+
### Changed
|
146
|
+
|
147
|
+
- Update the `status` attribute of the layout version model to allow for
|
148
|
+
the "stage" status (#12128)
|
149
|
+
- Updated the copyright, company name and address
|
150
|
+
|
151
|
+
## [7.3.0] - 2021-04-22
|
152
|
+
|
153
|
+
### Changed
|
154
|
+
|
155
|
+
- Start using Rubocop 1.8; add basic To Do config
|
156
|
+
|
157
|
+
### Fixed
|
158
|
+
|
159
|
+
- Fixed small Rubocop offences
|
160
|
+
|
161
|
+
## [7.2.5] - 2021-01-13
|
162
|
+
|
163
|
+
### Added
|
164
|
+
|
165
|
+
- Add support for HTTP proxy configuration (#12126)
|
166
|
+
- Add method `endpoint` on app modules that returns the currently used
|
167
|
+
endpoint (#12096)
|
168
|
+
|
169
|
+
### Changed
|
170
|
+
|
171
|
+
- Default options in config file are merged into environment-specific
|
172
|
+
configuration
|
173
|
+
|
174
|
+
### Fixed
|
175
|
+
|
176
|
+
- Documentation tweaks
|
177
|
+
|
178
|
+
## [7.2.4] - 2021-01-11
|
179
|
+
|
180
|
+
### Added
|
181
|
+
|
182
|
+
- Add support for short environment names ("prod" and "dev")
|
183
|
+
|
184
|
+
### Changed
|
185
|
+
|
186
|
+
- Relax the `faraday_middleware` gem dependency to less than 2.0 (#12118)
|
187
|
+
- Use API token (middleware) for Active Storage (#12125)
|
188
|
+
|
189
|
+
## [7.2.3] - 2020-12-02
|
190
|
+
|
191
|
+
### Added
|
192
|
+
|
193
|
+
- Added the "reserved" and "permanent_reserved" status variant for the location
|
194
|
+
model
|
195
|
+
- Added the `import_ref` attribute to the location model
|
196
|
+
- Added the `definition` attribute to the layout element model
|
197
|
+
|
198
|
+
### Changed
|
199
|
+
|
200
|
+
- Enabled HTTP caching for LWS Console
|
201
|
+
- Switched to Bundler version 2.1
|
202
|
+
|
203
|
+
### Fixed
|
204
|
+
|
205
|
+
- Fixed small documentation errors and inaccurracies
|
206
|
+
|
207
|
+
## [7.2.2] - 2020-11-06
|
208
|
+
|
209
|
+
### Changed
|
210
|
+
|
211
|
+
- HTTP caching is disable by default; opt-in via config
|
212
|
+
- Updated the README to show HTTP caching in an example
|
213
|
+
|
214
|
+
## [7.2.1] - 2020-10-29
|
215
|
+
|
216
|
+
### Added
|
217
|
+
|
218
|
+
- Added HTTP caching using faraday-http-cache gem (#12014)
|
219
|
+
|
220
|
+
### Fixed
|
221
|
+
|
222
|
+
- Fixed `#dig` on models stumbling over missing methods/attributes
|
223
|
+
|
224
|
+
## [7.2.0] - 2020-10-23
|
225
|
+
|
226
|
+
### Added
|
227
|
+
|
228
|
+
- Added the `address`, `birthdate`, `city`, `country` and `zip_code` attributes
|
229
|
+
to the person model (#12123)
|
230
|
+
- Added the `recent_os` attribute to the player model (#12121)
|
231
|
+
|
232
|
+
### Fixed
|
233
|
+
|
234
|
+
- Fixed storage uploads (almost) always failing (#12124)
|
235
|
+
|
236
|
+
## [7.1.4] - 2020-09-17
|
237
|
+
|
238
|
+
### Added
|
239
|
+
|
240
|
+
- Added the `archive_storage_id` and `archive_url` attributes to the layout
|
241
|
+
version model
|
242
|
+
- Added the `company`, `company_id`, `name` and `serial_number` attributes
|
243
|
+
to the reader model (#12113)
|
244
|
+
|
245
|
+
### Changed
|
246
|
+
|
247
|
+
- Updated the copyright and company address
|
248
|
+
|
249
|
+
## [7.1.3] - 2020-09-03
|
250
|
+
|
251
|
+
### Added
|
252
|
+
|
253
|
+
- Added the `name` and `status_updated_at` attributes to the player model
|
254
|
+
- Added the `comments`, `duration`, `edit_account_ids`, `editable_by_me` and
|
255
|
+
`thumbnail_url` attributes to the slide model (#12119)
|
256
|
+
- Added the `category_ids`, `company_shared_ids`, `description_html`,
|
257
|
+
`duration_kind`, `public`, `rotation` and `thumbnail_url` attributes to the
|
258
|
+
layout model (#12122)
|
259
|
+
|
260
|
+
### Changed
|
261
|
+
|
262
|
+
- Renamed the `operation_hours` (from `operational_hours`) and `feedback`
|
263
|
+
(from `feedbacks`) attributes on the player model
|
264
|
+
- Renamed the `company_owner` (from `company`) and `company_owner_id`
|
265
|
+
(from `company_id`) atributes on the layout model
|
266
|
+
|
267
|
+
### Fixed
|
268
|
+
|
269
|
+
- LS Console environment argument now correctly switches to that
|
270
|
+
environment (#12144)
|
271
|
+
- Correctly show the debug modes for LWS Console
|
272
|
+
- Documentation fixes and improvements
|
273
|
+
|
274
|
+
## [7.1.2] - 2020-07-07
|
275
|
+
|
276
|
+
### Added
|
277
|
+
|
278
|
+
- Added the journal model to the Presence app
|
279
|
+
|
280
|
+
### Fixed
|
281
|
+
|
282
|
+
- Use fixed model IDs to find models in tests wherever possible
|
283
|
+
|
284
|
+
## [7.1.1] - 2020-06-17
|
285
|
+
|
286
|
+
### Added
|
287
|
+
|
288
|
+
- Added a `deep_dup` method to the generic model
|
289
|
+
|
290
|
+
### Fixed
|
291
|
+
|
292
|
+
- Documentation fixes and tweaks
|
293
|
+
|
294
|
+
## [7.1.0] - 2020-05-11
|
295
|
+
|
296
|
+
### Added
|
297
|
+
|
298
|
+
- Added the `reset_reason` attribute to the location model (#12121)
|
299
|
+
- Added the `checkout_alter_status` and `status` attribute to the location model
|
300
|
+
- Added the `location_status_change_permissions` attribute to the person model
|
301
|
+
|
302
|
+
### Changed
|
303
|
+
|
304
|
+
- Add compatibility with newer Pry versions
|
305
|
+
- Changed the `feedbacks` attribute on the player model to a plain hash (#12110)
|
306
|
+
|
307
|
+
### Removed
|
308
|
+
|
309
|
+
- Removed the player feedback and player feedback result models (#12110)
|
310
|
+
|
311
|
+
## [7.0.4] - 2020-03-25
|
312
|
+
|
313
|
+
### Fixed
|
314
|
+
|
315
|
+
- Decreased minimum test coverage to 95% to work around simplecov issue
|
316
|
+
|
317
|
+
## [7.0.3] - 2020-03-25
|
318
|
+
|
319
|
+
### Added
|
320
|
+
|
321
|
+
- Added `image_storage_id` and `image_url` attributes to the location model (#12117)
|
322
|
+
- Added `image_storage_id` and `image_url` attributes to the location map model (#12117)
|
323
|
+
- Added `image_storage_id` and `image_url` attributes to the person model (#12117)
|
324
|
+
- Added the `Storage` class to the Presence app
|
325
|
+
- Added the `Storage.download` helper method
|
326
|
+
|
327
|
+
### Deprecated
|
328
|
+
|
329
|
+
- Deprecated the `picture_url` on the location map model (#12117)
|
330
|
+
- Deprecated the `picture_url` on the person model (#12117)
|
331
|
+
- Deprecated the `Generic::Storage.create` helper method in favour of
|
332
|
+
`Generic::Storage.upload`
|
333
|
+
|
334
|
+
## [7.0.2] - 2020-03-19
|
335
|
+
|
336
|
+
### Added
|
337
|
+
|
338
|
+
- Added `processing`, `permission` and `tempory` attributes to the collection
|
339
|
+
model (#12115)
|
340
|
+
- Added `status` attribute to the slide model (#12116)
|
341
|
+
- Added associations between the slide, channel and channel group models
|
342
|
+
- Added a lot of missing attributes to the digital signage models
|
343
|
+
|
344
|
+
### Fixed
|
345
|
+
|
346
|
+
- Fixed digital signage test queries
|
347
|
+
|
348
|
+
## [7.0.1] - 2020-02-20
|
349
|
+
|
350
|
+
### Added
|
351
|
+
|
352
|
+
- Added `kind` attribute to the layout mode (#12122)
|
353
|
+
- Added `hostname` attribute to the player model (#12122)
|
354
|
+
|
355
|
+
### Fixed
|
356
|
+
|
357
|
+
- Tweaked documentation of the `checkin_status` attribute
|
358
|
+
|
359
|
+
## [7.0.0] - 2020-02-03
|
360
|
+
|
361
|
+
### Added
|
362
|
+
|
363
|
+
- Added `checkin_status` attribute to the location model (#12111)
|
364
|
+
- Added `people_responsible_for` attribute to the person model (#12111)
|
365
|
+
- Added `person_responsible`, `person_responsible_id` attributes to the person
|
366
|
+
model (#12111)
|
367
|
+
|
368
|
+
### Fixed
|
369
|
+
|
370
|
+
- Fixed the digital signage test queries for displays
|
371
|
+
- Fixed the caching test for newer `faraday_middleware` gem versions
|
372
|
+
|
373
|
+
## [6.4.0] - 2020-01-08
|
374
|
+
|
375
|
+
### Added
|
376
|
+
|
377
|
+
- Added `company_name` attribute to the person model (#11997)
|
378
|
+
- Added `time_zone` attribute to the location model (#12109)
|
379
|
+
|
380
|
+
### Fixed
|
381
|
+
|
382
|
+
- Fixed the layout version model URI
|
383
|
+
- Removed duplicate generic attributes from models
|
384
|
+
- Fixed some typos in attribute name and order
|
385
|
+
|
386
|
+
## [6.3.2] - 2019-09-26
|
387
|
+
|
388
|
+
### Added
|
389
|
+
|
390
|
+
- Expanded the models and attributes in the presence app (#12108)
|
391
|
+
- Added a `#dig` method for the generic/all models
|
392
|
+
|
393
|
+
### Fixed
|
394
|
+
|
395
|
+
- Fixed the reduced/dropped test coverage (#12107)
|
396
|
+
|
397
|
+
## [6.3.1] - 2019-09-05
|
398
|
+
|
399
|
+
### Changed
|
400
|
+
|
401
|
+
- Reworked the JSON parser to handle metadata better
|
402
|
+
- Updated/reworked the Resource app models: added/removed/updated attributes
|
403
|
+
where necessary (#12106)
|
404
|
+
|
405
|
+
### Removed
|
406
|
+
|
407
|
+
- Removed some attributes that are already part of the generic model from
|
408
|
+
DigitalSignage app models
|
409
|
+
|
410
|
+
## [6.3.0] - 2019-09-05
|
411
|
+
|
412
|
+
### Added
|
413
|
+
|
414
|
+
- Added slide, layout and related models to the DigitalSignage app (#12103)
|
415
|
+
- Added the `Storage` class to the DigitalSignage and Resource apps
|
416
|
+
|
417
|
+
### Changed
|
418
|
+
|
419
|
+
- All non-persisted objects are always saved (even without changes)
|
420
|
+
|
421
|
+
### Fixed
|
422
|
+
|
423
|
+
- Fixed typos in documentation
|
424
|
+
- Fixed some code style issues
|
425
|
+
- Default to an empty object if the API provides no data
|
426
|
+
|
427
|
+
## v6.2.3
|
428
|
+
|
429
|
+
- Move common attributes to the generic model and add `url`/`url_html` (#12004)
|
430
|
+
- Add password expiration attributes to the `Company` and `User` model of
|
431
|
+
the Auth app (#12012)
|
432
|
+
- Add new attributes to the `Collection` model of the Resource app (#12012)
|
433
|
+
|
434
|
+
## v6.2.2.1
|
435
|
+
|
436
|
+
- Add missing dependency on net-http-persistent in the gemspec file
|
437
|
+
|
438
|
+
## v6.2.2
|
439
|
+
|
440
|
+
- Add some more attributes to the Presence app
|
441
|
+
- Use persistent HTTP connections from now on (#12101)
|
442
|
+
* Add a configuration option for enabling/disabling persistent HTTP
|
443
|
+
connections
|
444
|
+
- Add support for dirtiness checking for all models (#12100)
|
445
|
+
* Only save models using the HTTP if dirty
|
446
|
+
|
447
|
+
## v6.2.1
|
448
|
+
|
449
|
+
- Add new models and attributes to the Presence app (#12098, #12099)
|
450
|
+
- Replace Fixnum by Integer in the documentation (for Ruby ≥ 2.3)
|
451
|
+
|
452
|
+
## v6.2.0
|
453
|
+
|
454
|
+
- Add the Resource app implementation (#12097)
|
455
|
+
- Update the CorporateWebsite app for recent API changes
|
456
|
+
|
457
|
+
## v6.1.5
|
458
|
+
|
459
|
+
- Update the gemspec to relax the dependency on WebMock to support 2.x and 3.x
|
460
|
+
|
461
|
+
## v6.1.4
|
462
|
+
|
463
|
+
- Fix LWS Console environment command-line parameter not overriding the config
|
464
|
+
- Print LWS setup on LWS Console start
|
465
|
+
|
466
|
+
### Apps
|
467
|
+
|
468
|
+
- Add some fields to the DigitalSignage app (closes: #12001)
|
469
|
+
- Fix some relations in the Auth app (closes: #12026)
|
470
|
+
|
471
|
+
## v6.1.3
|
472
|
+
|
473
|
+
- Fix `#find` on has many-associations not working
|
474
|
+
|
475
|
+
### Development
|
476
|
+
|
477
|
+
- Many fixes in the gemspec
|
478
|
+
- Use the SpecReporter for tests
|
479
|
+
|
480
|
+
## v6.1.2
|
481
|
+
|
482
|
+
- Small tweaks to LWS Console
|
483
|
+
- Add LWS Console documentation (in the README)
|
484
|
+
- Documentation improvements
|
485
|
+
|
486
|
+
### Development
|
487
|
+
|
488
|
+
- Fix caching tests not tearing down the specific setup
|
489
|
+
|
490
|
+
## v6.1.1
|
491
|
+
|
492
|
+
- Support a global and user-specific config file for LWS Console
|
493
|
+
- Use a separate history and specific prompt for LWS Console
|
494
|
+
- Small documentation fixes
|
495
|
+
- Speed up the tests
|
496
|
+
|
497
|
+
## v6.1.0
|
498
|
+
|
499
|
+
- Switch to LWS/LeftClick platform release versions
|
500
|
+
- Switch to Spyke as the REST ORM library (closes: #10671)
|
501
|
+
- Add some Her backward compatibility support
|
502
|
+
- Use JSON as the wire format for sending data to LWS
|
503
|
+
- Switch to using our own exceptions (see LWS::Errors)
|
504
|
+
- Add support for setting the LWS API token in the environment
|
505
|
+
- Switch to Pry as the REPL used by the LWS Console
|
506
|
+
- Add commands to the LWS Console to toggle debug options
|
507
|
+
- Add option parsing and app/environment/debug mode selection to LWS Console
|
508
|
+
|
509
|
+
### Apps
|
510
|
+
|
511
|
+
- Add a first implementation of the Digital Signage app (closes: #11110)
|
512
|
+
- Update some fields for the Ticket app (closes: #11997)
|
513
|
+
- Add the Reader model to the Presence app, add fields to the Location model
|
514
|
+
|
515
|
+
### Development
|
516
|
+
|
517
|
+
- Reorganize the file structure of the library
|
518
|
+
- Add and improve tests and documentation
|
519
|
+
- Document and fix model relations throughout all apps
|
520
|
+
- Documentation fixes for switch to Spyke
|
521
|
+
|
522
|
+
## v0.4.2
|
523
|
+
|
524
|
+
- Documentation fixes
|
525
|
+
- Obtain full test coverage by adding some tests
|
526
|
+
|
527
|
+
## v0.4.1
|
528
|
+
|
529
|
+
- Test improvements; use simplecov for coverage metrics.
|
530
|
+
|
531
|
+
## v0.4.0
|
532
|
+
|
533
|
+
- Add support for the ticket and corporate website app/web service
|
534
|
+
- Gem/packaging and documentation fixes
|
535
|
+
|
536
|
+
## v0.3.1
|
537
|
+
|
538
|
+
- Add a release_if_needed task
|
539
|
+
|
540
|
+
…
|
541
|
+
|
542
|
+
## v0.0.1
|
543
|
+
|
544
|
+
Initial release
|
545
|
+
|
546
|
+
[6.3.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.2.3...v6.3.0
|
547
|
+
[6.3.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.3.0...v6.3.1
|
548
|
+
[6.3.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.3.1...v6.3.2
|
549
|
+
[6.4.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.3.2...v6.4.0
|
550
|
+
[7.0.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.4.0...v7.0.0
|
551
|
+
[7.0.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.0...v7.0.1
|
552
|
+
[7.0.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.1...v7.0.2
|
553
|
+
[7.0.3]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.2...v7.0.3
|
554
|
+
[7.0.4]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.3...v7.0.4
|
555
|
+
[7.1.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.4...v7.1.0
|
556
|
+
[7.1.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.0...v7.1.1
|
557
|
+
[7.1.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.1...v7.1.2
|
558
|
+
[7.1.3]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.2...v7.1.3
|
559
|
+
[7.1.4]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.3...v7.1.4
|
560
|
+
[7.2.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.4...v7.2.0
|
561
|
+
[7.2.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.0...v7.2.1
|
562
|
+
[7.2.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.1...v7.2.2
|
563
|
+
[7.2.3]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.2...v7.2.3
|
564
|
+
[7.2.4]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.3...v7.2.4
|
565
|
+
[7.2.5]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.4...v7.2.5
|
566
|
+
[7.3.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.5...v7.3.0
|
567
|
+
[7.3.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.3.0...v7.3.1
|
568
|
+
[7.3.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.3.1...v7.3.2
|
569
|
+
[7.4.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.3.2...v7.4.0
|
570
|
+
[7.4.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.4.0...v7.4.1
|
571
|
+
[7.5.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.4.1...v7.5.0
|
572
|
+
[7.5.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.5.0...v7.5.1
|
573
|
+
[7.5.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.5.1...v7.5.2
|
574
|
+
[8.1.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.5.2...v8.1.0
|
575
|
+
[8.1.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v8.1.0...v8.1.1
|
576
|
+
[9.0.0.beta1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v8.1.1...v9.0.0.beta1
|
577
|
+
[9.0.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.0.beta1...v9.0.0
|
578
|
+
[9.0.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.0...v9.0.1
|
579
|
+
[9.0.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.1...v9.0.2
|
580
|
+
[10.0.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.2...v10.0.0
|
581
|
+
[10.0.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v10.0.0...v10.0.1
|
data/README.md
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
# LeftClick Web Services
|
2
|
+
|
3
|
+
LWS is a library for Ruby provides access to the LeftClick web
|
4
|
+
services/applications using a model-based structure that abstracts from API
|
5
|
+
calls using the available REST interfaces.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
In your Gemfile, add:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem "lws"
|
13
|
+
```
|
14
|
+
|
15
|
+
or install the `ruby-lws` package.
|
16
|
+
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
First, you have to initialize the library. For example, with Rails, you
|
21
|
+
would create a new `config/initializers/lws.rb` file with these lines:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# config/initializers/lws.rb
|
25
|
+
LWS.setup do |config|
|
26
|
+
config.api_token = "…" # Get it from some place
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
After that, due to the fact that LWS is based on
|
31
|
+
[Spyke](https://github.com/balvig/spyke), you can access the objects in the
|
32
|
+
LeftClick Web Services similary to many ActiveRecord-like ORM's:
|
33
|
+
|
34
|
+
### Get all map markers of the first map
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
map = Maps::Map.all.first
|
38
|
+
markers = map.markers
|
39
|
+
```
|
40
|
+
|
41
|
+
### Create an account for company with ID 6
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
company = Company.find(6)
|
45
|
+
account = Auth::Account.create(name: "Foo Bar",
|
46
|
+
company: company)
|
47
|
+
```
|
48
|
+
|
49
|
+
### Destroy all locations named "Test"
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
loc = Presence::Location.where(name: "Test")
|
53
|
+
loc.destroy
|
54
|
+
```
|
55
|
+
|
56
|
+
## Configuration
|
57
|
+
|
58
|
+
The following example uses a much more elaborate setup:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
LWS.setup do |config|
|
62
|
+
config.api_token_middleware = TokenAuthenticator
|
63
|
+
config.caching_object = MyRedisCache.new
|
64
|
+
config.environment = :development
|
65
|
+
config.endpoints = { maps: "https://maps.leftclick.cloud" }
|
66
|
+
config.http_caching = true
|
67
|
+
config.http_debug = true
|
68
|
+
config.json_debug = true
|
69
|
+
config.logger = Rails.logger
|
70
|
+
config.proxy = "http://proxyserver:8080"
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
74
|
+
In this setup, a caching object is used that follows the
|
75
|
+
`FaradayMiddleWare::Caching` API. It uses all development API endpoints,
|
76
|
+
except for maps, which is overriden to use the production endpoint. Also
|
77
|
+
HTTP request and JSON data debug logging is enabled and LWS will use
|
78
|
+
the Rails logger to log the messages. Also HTTP responses will be cached
|
79
|
+
in accordance to their ETag/last modification time and the proxy server with
|
80
|
+
URL `http://proxyserver:8080` will be used.
|
81
|
+
Finally, a custom API token authenticator class is used that should implement
|
82
|
+
the `Faraday::Middleware` interface and set the `X-Token` header with the
|
83
|
+
runtime determined API token as value, for example:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
class TokenAuthenticator < Faraday::Middleware
|
87
|
+
|
88
|
+
def call(env)
|
89
|
+
env[:request_headers]["X-Token"] = … # Some calculated token
|
90
|
+
@app.call(env)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
The `LC_LWS_ENV` environment variable is supported to override the LWS
|
97
|
+
environment. Allowed values are "production" (default) and "development".
|
98
|
+
The `LC_LWS_API_TOKEN` is supported to set the LWS API token default.
|
99
|
+
This only works if a custom API token middleware is not used.
|
100
|
+
|
101
|
+
## LWS Console
|
102
|
+
|
103
|
+
This library comes with the program `lwsconsole`, which is a command-line
|
104
|
+
tool that can be used to interactively use the library. (This is similar
|
105
|
+
to the Rails console.) See `lwsconsole --help` for the supported
|
106
|
+
command-line arguments.
|
107
|
+
|
108
|
+
LWS Console will perform the setup for you and give you a prompt in the
|
109
|
+
`LWS` module namespace or the module of an app if this is selected via the
|
110
|
+
arguments. It uses the production environment per default using the token
|
111
|
+
provided by a command-line argument. These defaults can be overriden using
|
112
|
+
the configuration. For example, to rename a map:
|
113
|
+
|
114
|
+
```console
|
115
|
+
$ lwsconsole -t "my_token" -a maps
|
116
|
+
[1] lwsconsole(LWS::Maps)> Map.all.map(&:name)
|
117
|
+
=> ["Gebouw 1",
|
118
|
+
"Gebouw 3"]
|
119
|
+
[2] lwsconsole(LWS::Maps)> map = Map.find(2)
|
120
|
+
=> #<LWS::Maps::Map(maps/(:id)) id: 2 name: "Gebouw 3" ... markers: []>
|
121
|
+
[3] lwsconsole(LWS::Maps)> map.name = "Gebouw 2"
|
122
|
+
"Gebouw 2"
|
123
|
+
[4] lwsconsole(LWS::Maps)> map.save
|
124
|
+
nil
|
125
|
+
```
|
126
|
+
|
127
|
+
Besides the API calls, LWS console supports a few commands to change its
|
128
|
+
behaviour:
|
129
|
+
|
130
|
+
* `http_debug true|false`: Toggles HTTP debugging for API calls
|
131
|
+
* `http_debug_headers true|false`: Toggles logging of HTTP headers in the HTTP debug output
|
132
|
+
* `json_debug true|false`: Toggles JSON debug output for API calls
|
133
|
+
* `reload!`: Reloads all apps
|
134
|
+
|
135
|
+
```
|
136
|
+
[5] lwsconsole(LWS::Maps)> http_debug true
|
137
|
+
true
|
138
|
+
```
|
139
|
+
|
140
|
+
LWS Console keeps a history of all calls and commands, use the command
|
141
|
+
`history --all` to seem them. Use the command `help` to see all other
|
142
|
+
available commands (provided by Pry).
|
143
|
+
|
144
|
+
### Configuration files
|
145
|
+
|
146
|
+
LWS Console will look for the configuration files first in
|
147
|
+
`/etc/LeftClick/lws.yml` and then `~/.config/LeftClick/lws.yml`; they are
|
148
|
+
in the YAML format.
|
149
|
+
|
150
|
+
The configuration file can set defaults per environment. It is possible to
|
151
|
+
set the API key, endpoints and debug modes.
|
152
|
+
|
153
|
+
```yaml
|
154
|
+
development:
|
155
|
+
api_token: "my_token"
|
156
|
+
endpoints:
|
157
|
+
maps: "https://maps.leftclick.cloud
|
158
|
+
http_debug: true
|
159
|
+
http_debug_headers: true
|
160
|
+
json_debug: true
|
161
|
+
```
|
162
|
+
|
163
|
+
To override the default environment or to set default options, use the default section.
|
164
|
+
For example:
|
165
|
+
|
166
|
+
```yaml
|
167
|
+
default:
|
168
|
+
environment: "development"
|
169
|
+
json_debug: true
|
170
|
+
```
|
data/lib/lws/apps/generic.rb
CHANGED
@@ -255,13 +255,15 @@ module LWS::Generic
|
|
255
255
|
# without caching).
|
256
256
|
@as_connection = Faraday.new(url: api.url_prefix, proxy: config.proxy) do |c|
|
257
257
|
# Request
|
258
|
-
c.request :json
|
259
258
|
c.use LWS::Middleware::RequestHeaders, config.api_token
|
260
259
|
c.use config.api_token_middleware if config.api_token_middleware.present?
|
260
|
+
c.use LWS::Middleware::JSONEncoder
|
261
261
|
|
262
262
|
# Response
|
263
|
-
c.use LWS::JSONLogger, config.logger if config.json_debug
|
264
|
-
|
263
|
+
c.use LWS::Middleware::JSONLogger, config.logger if config.json_debug
|
264
|
+
if config.http_debug
|
265
|
+
c.use LWS::Middleware::HTTPLogger, config.logger, config.http_debug_headers
|
266
|
+
end
|
265
267
|
|
266
268
|
# Adapter
|
267
269
|
if config.http_persistent
|
@@ -271,19 +273,21 @@ module LWS::Generic
|
|
271
273
|
end
|
272
274
|
end
|
273
275
|
|
274
|
-
# A plain file connection to LWS (with token
|
276
|
+
# A plain file connection to LWS (with token authentication and caching but without
|
275
277
|
# JSON request/response).
|
276
278
|
@lws_connection = Faraday.new(url: api.url_prefix, proxy: config.proxy) do |c|
|
277
279
|
# Request
|
278
280
|
if config.caching_object
|
279
|
-
c.use
|
281
|
+
c.use LWS::Middleware::ObjectCaching, config.caching_object
|
280
282
|
end
|
281
283
|
c.use LWS::Middleware::RequestHeaders, config.api_token
|
282
284
|
c.use config.api_token_middleware if config.api_token_middleware.present?
|
283
285
|
|
284
286
|
# Response
|
285
|
-
c.use
|
286
|
-
|
287
|
+
c.use LWS::Middleware::FollowRedirects, limit: 3
|
288
|
+
if config.http_debug
|
289
|
+
c.use LWS::Middleware::HTTPLogger, config.logger, config.http_debug_headers
|
290
|
+
end
|
287
291
|
|
288
292
|
# Adapter
|
289
293
|
if config.http_persistent
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# Vendored copy from the `faraday-middleware` gem version 1.2.0
|
2
|
+
# See also: https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/response/caching.rb
|
3
|
+
#
|
4
|
+
# Copyright (c) 2011 Erik Michaels-Ober, Wynn Netherland, et al.
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
# frozen_string_literal: true
|
25
|
+
|
26
|
+
require 'faraday'
|
27
|
+
require 'forwardable'
|
28
|
+
require 'digest/sha1'
|
29
|
+
|
30
|
+
# :nocov:
|
31
|
+
module LWS::Middleware
|
32
|
+
# Public: Caches GET responses and pulls subsequent ones from the cache.
|
33
|
+
class Caching < Faraday::Middleware
|
34
|
+
attr_reader :cache
|
35
|
+
|
36
|
+
# Internal: List of status codes that can be cached:
|
37
|
+
# * 200 - 'OK'
|
38
|
+
# * 203 - 'Non-Authoritative Information'
|
39
|
+
# * 300 - 'Multiple Choices'
|
40
|
+
# * 301 - 'Moved Permanently'
|
41
|
+
# * 302 - 'Found'
|
42
|
+
# * 404 - 'Not Found'
|
43
|
+
# * 410 - 'Gone'
|
44
|
+
CACHEABLE_STATUS_CODES = [200, 203, 300, 301, 302, 404, 410].freeze
|
45
|
+
|
46
|
+
extend Forwardable
|
47
|
+
def_delegators :'Faraday::Utils', :parse_query, :build_query
|
48
|
+
|
49
|
+
# Public: initialize the middleware.
|
50
|
+
#
|
51
|
+
# cache - An object that responds to read and write (default: nil).
|
52
|
+
# options - An options Hash (default: {}):
|
53
|
+
# :ignore_params - String name or Array names of query
|
54
|
+
# params that should be ignored when forming
|
55
|
+
# the cache key (default: []).
|
56
|
+
# :write_options - Hash of settings that should be passed as the
|
57
|
+
# third options parameter to the cache's #write
|
58
|
+
# method. If not specified, no options parameter
|
59
|
+
# will be passed.
|
60
|
+
# :full_key - Boolean - use full URL as cache key:
|
61
|
+
# (url.host + url.request_uri)
|
62
|
+
# :status_codes - Array of http status code to be cache
|
63
|
+
# (default: CACHEABLE_STATUS_CODE)
|
64
|
+
#
|
65
|
+
# Yields if no cache is given. The block should return a cache object.
|
66
|
+
def initialize(app, cache = nil, options = {})
|
67
|
+
super(app)
|
68
|
+
if cache.is_a?(Hash) && block_given?
|
69
|
+
options = cache
|
70
|
+
cache = nil
|
71
|
+
end
|
72
|
+
@cache = cache || yield
|
73
|
+
@options = options
|
74
|
+
end
|
75
|
+
|
76
|
+
def call(env)
|
77
|
+
if env[:method] == :get
|
78
|
+
if env[:parallel_manager]
|
79
|
+
# callback mode
|
80
|
+
cache_on_complete(env)
|
81
|
+
else
|
82
|
+
# synchronous mode
|
83
|
+
key = cache_key(env)
|
84
|
+
unless (response = cache.read(key)) && response
|
85
|
+
response = @app.call(env)
|
86
|
+
store_response_in_cache(key, response)
|
87
|
+
end
|
88
|
+
finalize_response(response, env)
|
89
|
+
end
|
90
|
+
else
|
91
|
+
@app.call(env)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def cache_key(env)
|
96
|
+
url = env[:url].dup
|
97
|
+
if url.query && params_to_ignore.any?
|
98
|
+
params = parse_query url.query
|
99
|
+
params.reject! { |k,| params_to_ignore.include? k }
|
100
|
+
url.query = params.any? ? build_query(params) : nil
|
101
|
+
end
|
102
|
+
url.normalize!
|
103
|
+
digest = full_key? ? url.host + url.request_uri : url.request_uri
|
104
|
+
Digest::SHA1.hexdigest(digest)
|
105
|
+
end
|
106
|
+
|
107
|
+
def params_to_ignore
|
108
|
+
@params_to_ignore ||= Array(@options[:ignore_params]).map(&:to_s)
|
109
|
+
end
|
110
|
+
|
111
|
+
def full_key?
|
112
|
+
@full_key ||= @options[:full_key]
|
113
|
+
end
|
114
|
+
|
115
|
+
def custom_status_codes
|
116
|
+
@custom_status_codes ||= begin
|
117
|
+
codes = CACHEABLE_STATUS_CODES & Array(@options[:status_codes]).map(&:to_i)
|
118
|
+
codes.any? ? codes : CACHEABLE_STATUS_CODES
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def cache_on_complete(env)
|
123
|
+
key = cache_key(env)
|
124
|
+
if (cached_response = cache.read(key))
|
125
|
+
finalize_response(cached_response, env)
|
126
|
+
else
|
127
|
+
# response.status is nil at this point
|
128
|
+
# any checks need to be done inside on_complete block
|
129
|
+
@app.call(env).on_complete do |response_env|
|
130
|
+
store_response_in_cache(key, response_env.response)
|
131
|
+
response_env
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def store_response_in_cache(key, response)
|
137
|
+
return unless custom_status_codes.include?(response.status)
|
138
|
+
|
139
|
+
if @options[:write_options]
|
140
|
+
cache.write(key, response, @options[:write_options])
|
141
|
+
else
|
142
|
+
cache.write(key, response)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def finalize_response(response, env)
|
147
|
+
response = response.dup if response.frozen?
|
148
|
+
env[:response] = response
|
149
|
+
unless env[:response_headers]
|
150
|
+
env.update response.env
|
151
|
+
# FIXME: omg hax
|
152
|
+
response.instance_variable_set('@env', env)
|
153
|
+
end
|
154
|
+
response
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
# :nocov:
|
@@ -16,7 +16,9 @@ module LWS
|
|
16
16
|
|
17
17
|
# @private
|
18
18
|
# @!visibility private
|
19
|
-
class HTTPLogger <
|
19
|
+
class HTTPLogger <
|
20
|
+
# Use `Faraday::Response::Middleware` if it exists (Faraday < 2.0)
|
21
|
+
defined?(Faraday::Response::Middleware) ? Faraday::Response::Middleware : Faraday::Middleware
|
20
22
|
|
21
23
|
def initialize(app, logger, show_headers)
|
22
24
|
if logger.nil?
|
@@ -40,7 +42,6 @@ module LWS
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def on_complete(env)
|
43
|
-
super
|
44
45
|
@logger.debug "<<< HTTP #{env[:status].to_s}"
|
45
46
|
if @show_headers
|
46
47
|
env[:response_headers].each do |hdr, val|
|
@@ -16,7 +16,9 @@ module LWS
|
|
16
16
|
|
17
17
|
# @private
|
18
18
|
# @!visibility private
|
19
|
-
class JSONLogger <
|
19
|
+
class JSONLogger <
|
20
|
+
# Use `Faraday::Response::Middleware` if it exists (Faraday < 2.0)
|
21
|
+
defined?(Faraday::Response::Middleware) ? Faraday::Response::Middleware : Faraday::Middleware
|
20
22
|
|
21
23
|
def initialize(app, logger)
|
22
24
|
if logger.nil?
|
@@ -16,7 +16,9 @@ module LWS
|
|
16
16
|
|
17
17
|
# @private
|
18
18
|
# @!visibility private
|
19
|
-
class JSONParser <
|
19
|
+
class JSONParser <
|
20
|
+
# Use `Faraday::Response::Middleware` if it exists (Faraday < 2.0)
|
21
|
+
defined?(Faraday::Response::Middleware) ? Faraday::Response::Middleware : Faraday::Middleware
|
20
22
|
|
21
23
|
def parse(body)
|
22
24
|
json = MultiJson.load(body, symbolize_keys: true)
|
data/lib/lws/middleware.rb
CHANGED
@@ -19,7 +19,36 @@ module LWS
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
+
require "lws/middleware/caching"
|
22
23
|
require "lws/middleware/http_logger"
|
23
24
|
require "lws/middleware/json_logger"
|
24
25
|
require "lws/middleware/json_parser"
|
25
26
|
require "lws/middleware/request_headers"
|
27
|
+
|
28
|
+
# Set up Faraday 1.0/2.0 portability using middleware class aliases.
|
29
|
+
module LWS
|
30
|
+
module Middleware
|
31
|
+
FollowRedirects =
|
32
|
+
if defined? Faraday::FollowRedirects::Middleware
|
33
|
+
Faraday::FollowRedirects::Middleware
|
34
|
+
else
|
35
|
+
FaradayMiddleware::FollowRedirects
|
36
|
+
end
|
37
|
+
|
38
|
+
JSONEncoder =
|
39
|
+
if defined? Faraday::Request::Json
|
40
|
+
Faraday::Request::Json
|
41
|
+
else
|
42
|
+
FaradayMiddleware::EncodeJson
|
43
|
+
end
|
44
|
+
|
45
|
+
ObjectCaching =
|
46
|
+
if defined? FaradayMiddleware::Caching
|
47
|
+
FaradayMiddleware::Caching
|
48
|
+
else
|
49
|
+
# Use this vendored middleware implementation because it is not
|
50
|
+
# available for Faraday ≥ 2.0
|
51
|
+
Caching
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/lws/version.rb
CHANGED
data/lib/lws.rb
CHANGED
@@ -9,8 +9,16 @@
|
|
9
9
|
# Schootense Dreef 20A, 5708 HZ Helmond, The Netherlands,
|
10
10
|
# info@leftclick.eu, +3185-4444-004.
|
11
11
|
|
12
|
-
require "
|
12
|
+
require "faraday"
|
13
13
|
require "faraday/http_cache"
|
14
|
+
if Gem::Version.new(Faraday::VERSION) < Gem::Version.new("2.0")
|
15
|
+
# For Faraday < 2.0 load deprecated middleware.
|
16
|
+
require "faraday_middleware"
|
17
|
+
else
|
18
|
+
# For Faraday ≥ 2.0 load these middleware gems separately.
|
19
|
+
require "faraday/follow_redirects"
|
20
|
+
require "faraday/net_http_persistent"
|
21
|
+
end
|
14
22
|
require "hashie"
|
15
23
|
require "multi_json"
|
16
24
|
require "spyke"
|
@@ -115,7 +123,7 @@ module LWS
|
|
115
123
|
api = Faraday.new(url: api_url, proxy: config.proxy) do |c|
|
116
124
|
# Request
|
117
125
|
if config.caching_object
|
118
|
-
c.use
|
126
|
+
c.use Middleware::ObjectCaching, config.caching_object
|
119
127
|
end
|
120
128
|
if config.http_caching
|
121
129
|
logger = config.http_debug ? config.logger : nil
|
@@ -125,13 +133,15 @@ module LWS
|
|
125
133
|
end
|
126
134
|
c.use RequestHeaders, config.api_token
|
127
135
|
c.use config.api_token_middleware if config.api_token_middleware.present?
|
128
|
-
c.
|
136
|
+
c.use Middleware::JSONEncoder
|
129
137
|
|
130
138
|
# Response
|
131
|
-
c.use JSONLogger, config.logger if config.json_debug
|
132
|
-
c.use JSONParser
|
133
|
-
c.use
|
134
|
-
|
139
|
+
c.use Middleware::JSONLogger, config.logger if config.json_debug
|
140
|
+
c.use Middleware::JSONParser
|
141
|
+
c.use Middleware::FollowRedirects, limit: 3
|
142
|
+
if config.http_debug
|
143
|
+
c.use Middleware::HTTPLogger, config.logger, config.http_debug_headers
|
144
|
+
end
|
135
145
|
|
136
146
|
# Adapter
|
137
147
|
if config.http_persistent
|
metadata
CHANGED
@@ -1,15 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 10.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeftClick B.V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: faraday-http-cache
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,6 +64,26 @@ dependencies:
|
|
44
64
|
- - "<"
|
45
65
|
- !ruby/object:Gem::Version
|
46
66
|
version: '2.0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: net-http-persistent
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '2.9'
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '5.0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.9'
|
84
|
+
- - "<"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '5.0'
|
47
87
|
- !ruby/object:Gem::Dependency
|
48
88
|
name: hashie
|
49
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,26 +118,6 @@ dependencies:
|
|
78
118
|
- - "~>"
|
79
119
|
- !ruby/object:Gem::Version
|
80
120
|
version: '1.12'
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: net-http-persistent
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '2.9'
|
88
|
-
- - "<"
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '4.0'
|
91
|
-
type: :runtime
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '2.9'
|
98
|
-
- - "<"
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version: '4.0'
|
101
121
|
- !ruby/object:Gem::Dependency
|
102
122
|
name: pry
|
103
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,108 +172,10 @@ dependencies:
|
|
152
172
|
- - "<"
|
153
173
|
- !ruby/object:Gem::Version
|
154
174
|
version: '4'
|
155
|
-
- !ruby/object:Gem::Dependency
|
156
|
-
name: bundler
|
157
|
-
requirement: !ruby/object:Gem::Requirement
|
158
|
-
requirements:
|
159
|
-
- - "~>"
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '2.1'
|
162
|
-
type: :development
|
163
|
-
prerelease: false
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
-
requirements:
|
166
|
-
- - "~>"
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
version: '2.1'
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: minitest
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - "~>"
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: '5.10'
|
176
|
-
type: :development
|
177
|
-
prerelease: false
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
179
|
-
requirements:
|
180
|
-
- - "~>"
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
version: '5.10'
|
183
|
-
- !ruby/object:Gem::Dependency
|
184
|
-
name: minitest-reporters
|
185
|
-
requirement: !ruby/object:Gem::Requirement
|
186
|
-
requirements:
|
187
|
-
- - "~>"
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '1.0'
|
190
|
-
type: :development
|
191
|
-
prerelease: false
|
192
|
-
version_requirements: !ruby/object:Gem::Requirement
|
193
|
-
requirements:
|
194
|
-
- - "~>"
|
195
|
-
- !ruby/object:Gem::Version
|
196
|
-
version: '1.0'
|
197
|
-
- !ruby/object:Gem::Dependency
|
198
|
-
name: rake
|
199
|
-
requirement: !ruby/object:Gem::Requirement
|
200
|
-
requirements:
|
201
|
-
- - "~>"
|
202
|
-
- !ruby/object:Gem::Version
|
203
|
-
version: '12.3'
|
204
|
-
type: :development
|
205
|
-
prerelease: false
|
206
|
-
version_requirements: !ruby/object:Gem::Requirement
|
207
|
-
requirements:
|
208
|
-
- - "~>"
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
version: '12.3'
|
211
|
-
- !ruby/object:Gem::Dependency
|
212
|
-
name: simplecov
|
213
|
-
requirement: !ruby/object:Gem::Requirement
|
214
|
-
requirements:
|
215
|
-
- - "~>"
|
216
|
-
- !ruby/object:Gem::Version
|
217
|
-
version: '0.14'
|
218
|
-
type: :development
|
219
|
-
prerelease: false
|
220
|
-
version_requirements: !ruby/object:Gem::Requirement
|
221
|
-
requirements:
|
222
|
-
- - "~>"
|
223
|
-
- !ruby/object:Gem::Version
|
224
|
-
version: '0.14'
|
225
|
-
- !ruby/object:Gem::Dependency
|
226
|
-
name: simplecov-rcov
|
227
|
-
requirement: !ruby/object:Gem::Requirement
|
228
|
-
requirements:
|
229
|
-
- - "~>"
|
230
|
-
- !ruby/object:Gem::Version
|
231
|
-
version: '0.2'
|
232
|
-
type: :development
|
233
|
-
prerelease: false
|
234
|
-
version_requirements: !ruby/object:Gem::Requirement
|
235
|
-
requirements:
|
236
|
-
- - "~>"
|
237
|
-
- !ruby/object:Gem::Version
|
238
|
-
version: '0.2'
|
239
|
-
- !ruby/object:Gem::Dependency
|
240
|
-
name: yard
|
241
|
-
requirement: !ruby/object:Gem::Requirement
|
242
|
-
requirements:
|
243
|
-
- - "~>"
|
244
|
-
- !ruby/object:Gem::Version
|
245
|
-
version: '0.9'
|
246
|
-
type: :development
|
247
|
-
prerelease: false
|
248
|
-
version_requirements: !ruby/object:Gem::Requirement
|
249
|
-
requirements:
|
250
|
-
- - "~>"
|
251
|
-
- !ruby/object:Gem::Version
|
252
|
-
version: '0.9'
|
253
175
|
description: |-
|
254
|
-
This library for Ruby provides access to the LeftClick
|
255
|
-
|
256
|
-
|
176
|
+
This library for Ruby provides access to the LeftClick Web
|
177
|
+
Services and its applications using a model-based structure that abstracts
|
178
|
+
from API calls using the available REST interfaces.
|
257
179
|
email:
|
258
180
|
- gem@leftclick.eu
|
259
181
|
executables:
|
@@ -261,6 +183,8 @@ executables:
|
|
261
183
|
extensions: []
|
262
184
|
extra_rdoc_files: []
|
263
185
|
files:
|
186
|
+
- CHANGELOG.md
|
187
|
+
- README.md
|
264
188
|
- bin/lwsconsole
|
265
189
|
- lib/lws.rb
|
266
190
|
- lib/lws/apps/auth.rb
|
@@ -274,6 +198,7 @@ files:
|
|
274
198
|
- lib/lws/config.rb
|
275
199
|
- lib/lws/errors.rb
|
276
200
|
- lib/lws/middleware.rb
|
201
|
+
- lib/lws/middleware/caching.rb
|
277
202
|
- lib/lws/middleware/http_logger.rb
|
278
203
|
- lib/lws/middleware/json_logger.rb
|
279
204
|
- lib/lws/middleware/json_parser.rb
|
@@ -301,5 +226,5 @@ requirements: []
|
|
301
226
|
rubygems_version: 3.3.15
|
302
227
|
signing_key:
|
303
228
|
specification_version: 4
|
304
|
-
summary: LeftClick
|
229
|
+
summary: LeftClick Web Services library for Ruby
|
305
230
|
test_files: []
|