lws 9.0.1 → 10.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +573 -0
- data/README.md +170 -0
- data/lib/lws/apps/generic.rb +12 -8
- 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 +29 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 853db9b24d98b75c7b419c19b8942411b30f74c1e03fae81279a1a4b77228342
|
4
|
+
data.tar.gz: 94afe71cf0b4a1e1c346b4980daf3fcd91059a5ade23db17c5a63a8444603af3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d57fd5aa31bef7f4329b62d2d598efa09ca2b6c83bbce691e3952bf1e641129144f527fca41c1e35241feefef51734d56a3230e6110b5e2cddb3101d570a00e7
|
7
|
+
data.tar.gz: 33082b8ba056f64543e91883309752b3978c992b88e2cda39969312c5938d997fb91b18bcc8fcfe7c43ce12dc66bdbf0b9f8e517c57d59d2bababb941451899a
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,573 @@
|
|
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.0] - 2024-10-10
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Add vendored caching firmware from the Faraday Middleware project for use
|
16
|
+
with Faraday 2.x
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- Tighten dependency on `faraday` gem to 1.0; extend support to 2.x (less
|
21
|
+
than 3.0)
|
22
|
+
- Rework the `Gemfile`/`gemspec` files; split up runtime and dev dependencies
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Correct the name of the minitest module
|
27
|
+
|
28
|
+
## [9.0.2] - 2024-08-12
|
29
|
+
|
30
|
+
### Fixed
|
31
|
+
|
32
|
+
- Fix crash when creating models that have has-many associations
|
33
|
+
|
34
|
+
## [9.0.1] - 2024-06-24
|
35
|
+
|
36
|
+
### Add
|
37
|
+
|
38
|
+
- Add missing `_ids` attributes for all has-many associations
|
39
|
+
|
40
|
+
### Fixed
|
41
|
+
|
42
|
+
- Fix dirty model/changes stracking for has-many associations (#12133)
|
43
|
+
- Various documentation improvements
|
44
|
+
|
45
|
+
### Removed
|
46
|
+
|
47
|
+
- Remove all collection item attributes (except for `items`) from the
|
48
|
+
collection model; they don't actually work
|
49
|
+
|
50
|
+
## [9.0.0] - 2024-06-19
|
51
|
+
|
52
|
+
### Changed
|
53
|
+
|
54
|
+
- Further restrict the depency on spyke
|
55
|
+
|
56
|
+
## [9.0.0.beta1] - 2024-06-05
|
57
|
+
|
58
|
+
### Changed
|
59
|
+
|
60
|
+
- Update the dependency on the `spyke` gem
|
61
|
+
|
62
|
+
## [8.1.1] - 2023-12-11
|
63
|
+
|
64
|
+
### Changed
|
65
|
+
|
66
|
+
- Relax the dependency on hashie to allow version 3.5 through 5
|
67
|
+
- Update the `leftclick.eu` domain to `leftclick.network`
|
68
|
+
- Remove unnecessary test file from the gemspec
|
69
|
+
|
70
|
+
## [8.1.0] - 2023-12-11
|
71
|
+
|
72
|
+
### Fixed
|
73
|
+
|
74
|
+
- Fix all tests (on the LWS side)
|
75
|
+
|
76
|
+
### Removed
|
77
|
+
|
78
|
+
- Remove the `start_app` attribute from the account model
|
79
|
+
|
80
|
+
## [7.5.2] - 2022-05-13
|
81
|
+
|
82
|
+
### Changed
|
83
|
+
|
84
|
+
- Use safe loading when loading stubs/config YAML (#12134)
|
85
|
+
|
86
|
+
### Fixed
|
87
|
+
|
88
|
+
- Fix compatibility issue with newer versions of Psych (#12134)
|
89
|
+
|
90
|
+
## [7.5.1] - 2022-03-02
|
91
|
+
|
92
|
+
### Added
|
93
|
+
|
94
|
+
- Add attributes to the customizable model (#12132)
|
95
|
+
|
96
|
+
### Changed
|
97
|
+
|
98
|
+
- Renamed the `hint_message` attribute to `title` on the customizable model
|
99
|
+
|
100
|
+
## [7.5.0] - 2022-01-21
|
101
|
+
|
102
|
+
### Added
|
103
|
+
|
104
|
+
- Add the `email` attribute to the folder model (#12130)
|
105
|
+
- Add the `service_reason` attribute to the player model (#12131)
|
106
|
+
|
107
|
+
## [7.4.1] - 2021-10-21
|
108
|
+
|
109
|
+
### Changed
|
110
|
+
|
111
|
+
- Relax the dependency on the `spyke` gem
|
112
|
+
|
113
|
+
## [7.4.0] - 2021-10-21
|
114
|
+
|
115
|
+
### Changed
|
116
|
+
|
117
|
+
- Relax the dependency on the `net-http-persisent` gem
|
118
|
+
|
119
|
+
### Fixed
|
120
|
+
|
121
|
+
- Fix missing default documentation for option `http_persistent`
|
122
|
+
|
123
|
+
## [7.3.2] - 2021-10-04
|
124
|
+
|
125
|
+
### Fixed
|
126
|
+
|
127
|
+
- Fix some model URIs (endpoint not in plural form)
|
128
|
+
|
129
|
+
## [7.3.1] - 2021-09-29
|
130
|
+
|
131
|
+
### Added
|
132
|
+
|
133
|
+
- Add the `invite_remarks` and `reservation_required` attributes to the
|
134
|
+
location model (#12127)
|
135
|
+
- Add the `layout_kind` attribute to the channel model (#12128)
|
136
|
+
- Add the `uuid` attribute to the slide model (#12129)
|
137
|
+
|
138
|
+
### Changed
|
139
|
+
|
140
|
+
- Update the `status` attribute of the layout version model to allow for
|
141
|
+
the "stage" status (#12128)
|
142
|
+
- Updated the copyright, company name and address
|
143
|
+
|
144
|
+
## [7.3.0] - 2021-04-22
|
145
|
+
|
146
|
+
### Changed
|
147
|
+
|
148
|
+
- Start using Rubocop 1.8; add basic To Do config
|
149
|
+
|
150
|
+
### Fixed
|
151
|
+
|
152
|
+
- Fixed small Rubocop offences
|
153
|
+
|
154
|
+
## [7.2.5] - 2021-01-13
|
155
|
+
|
156
|
+
### Added
|
157
|
+
|
158
|
+
- Add support for HTTP proxy configuration (#12126)
|
159
|
+
- Add method `endpoint` on app modules that returns the currently used
|
160
|
+
endpoint (#12096)
|
161
|
+
|
162
|
+
### Changed
|
163
|
+
|
164
|
+
- Default options in config file are merged into environment-specific
|
165
|
+
configuration
|
166
|
+
|
167
|
+
### Fixed
|
168
|
+
|
169
|
+
- Documentation tweaks
|
170
|
+
|
171
|
+
## [7.2.4] - 2021-01-11
|
172
|
+
|
173
|
+
### Added
|
174
|
+
|
175
|
+
- Add support for short environment names ("prod" and "dev")
|
176
|
+
|
177
|
+
### Changed
|
178
|
+
|
179
|
+
- Relax the `faraday_middleware` gem dependency to less than 2.0 (#12118)
|
180
|
+
- Use API token (middleware) for Active Storage (#12125)
|
181
|
+
|
182
|
+
## [7.2.3] - 2020-12-02
|
183
|
+
|
184
|
+
### Added
|
185
|
+
|
186
|
+
- Added the "reserved" and "permanent_reserved" status variant for the location
|
187
|
+
model
|
188
|
+
- Added the `import_ref` attribute to the location model
|
189
|
+
- Added the `definition` attribute to the layout element model
|
190
|
+
|
191
|
+
### Changed
|
192
|
+
|
193
|
+
- Enabled HTTP caching for LWS Console
|
194
|
+
- Switched to Bundler version 2.1
|
195
|
+
|
196
|
+
### Fixed
|
197
|
+
|
198
|
+
- Fixed small documentation errors and inaccurracies
|
199
|
+
|
200
|
+
## [7.2.2] - 2020-11-06
|
201
|
+
|
202
|
+
### Changed
|
203
|
+
|
204
|
+
- HTTP caching is disable by default; opt-in via config
|
205
|
+
- Updated the README to show HTTP caching in an example
|
206
|
+
|
207
|
+
## [7.2.1] - 2020-10-29
|
208
|
+
|
209
|
+
### Added
|
210
|
+
|
211
|
+
- Added HTTP caching using faraday-http-cache gem (#12014)
|
212
|
+
|
213
|
+
### Fixed
|
214
|
+
|
215
|
+
- Fixed `#dig` on models stumbling over missing methods/attributes
|
216
|
+
|
217
|
+
## [7.2.0] - 2020-10-23
|
218
|
+
|
219
|
+
### Added
|
220
|
+
|
221
|
+
- Added the `address`, `birthdate`, `city`, `country` and `zip_code` attributes
|
222
|
+
to the person model (#12123)
|
223
|
+
- Added the `recent_os` attribute to the player model (#12121)
|
224
|
+
|
225
|
+
### Fixed
|
226
|
+
|
227
|
+
- Fixed storage uploads (almost) always failing (#12124)
|
228
|
+
|
229
|
+
## [7.1.4] - 2020-09-17
|
230
|
+
|
231
|
+
### Added
|
232
|
+
|
233
|
+
- Added the `archive_storage_id` and `archive_url` attributes to the layout
|
234
|
+
version model
|
235
|
+
- Added the `company`, `company_id`, `name` and `serial_number` attributes
|
236
|
+
to the reader model (#12113)
|
237
|
+
|
238
|
+
### Changed
|
239
|
+
|
240
|
+
- Updated the copyright and company address
|
241
|
+
|
242
|
+
## [7.1.3] - 2020-09-03
|
243
|
+
|
244
|
+
### Added
|
245
|
+
|
246
|
+
- Added the `name` and `status_updated_at` attributes to the player model
|
247
|
+
- Added the `comments`, `duration`, `edit_account_ids`, `editable_by_me` and
|
248
|
+
`thumbnail_url` attributes to the slide model (#12119)
|
249
|
+
- Added the `category_ids`, `company_shared_ids`, `description_html`,
|
250
|
+
`duration_kind`, `public`, `rotation` and `thumbnail_url` attributes to the
|
251
|
+
layout model (#12122)
|
252
|
+
|
253
|
+
### Changed
|
254
|
+
|
255
|
+
- Renamed the `operation_hours` (from `operational_hours`) and `feedback`
|
256
|
+
(from `feedbacks`) attributes on the player model
|
257
|
+
- Renamed the `company_owner` (from `company`) and `company_owner_id`
|
258
|
+
(from `company_id`) atributes on the layout model
|
259
|
+
|
260
|
+
### Fixed
|
261
|
+
|
262
|
+
- LS Console environment argument now correctly switches to that
|
263
|
+
environment (#12144)
|
264
|
+
- Correctly show the debug modes for LWS Console
|
265
|
+
- Documentation fixes and improvements
|
266
|
+
|
267
|
+
## [7.1.2] - 2020-07-07
|
268
|
+
|
269
|
+
### Added
|
270
|
+
|
271
|
+
- Added the journal model to the Presence app
|
272
|
+
|
273
|
+
### Fixed
|
274
|
+
|
275
|
+
- Use fixed model IDs to find models in tests wherever possible
|
276
|
+
|
277
|
+
## [7.1.1] - 2020-06-17
|
278
|
+
|
279
|
+
### Added
|
280
|
+
|
281
|
+
- Added a `deep_dup` method to the generic model
|
282
|
+
|
283
|
+
### Fixed
|
284
|
+
|
285
|
+
- Documentation fixes and tweaks
|
286
|
+
|
287
|
+
## [7.1.0] - 2020-05-11
|
288
|
+
|
289
|
+
### Added
|
290
|
+
|
291
|
+
- Added the `reset_reason` attribute to the location model (#12121)
|
292
|
+
- Added the `checkout_alter_status` and `status` attribute to the location model
|
293
|
+
- Added the `location_status_change_permissions` attribute to the person model
|
294
|
+
|
295
|
+
### Changed
|
296
|
+
|
297
|
+
- Add compatibility with newer Pry versions
|
298
|
+
- Changed the `feedbacks` attribute on the player model to a plain hash (#12110)
|
299
|
+
|
300
|
+
### Removed
|
301
|
+
|
302
|
+
- Removed the player feedback and player feedback result models (#12110)
|
303
|
+
|
304
|
+
## [7.0.4] - 2020-03-25
|
305
|
+
|
306
|
+
### Fixed
|
307
|
+
|
308
|
+
- Decreased minimum test coverage to 95% to work around simplecov issue
|
309
|
+
|
310
|
+
## [7.0.3] - 2020-03-25
|
311
|
+
|
312
|
+
### Added
|
313
|
+
|
314
|
+
- Added `image_storage_id` and `image_url` attributes to the location model (#12117)
|
315
|
+
- Added `image_storage_id` and `image_url` attributes to the location map model (#12117)
|
316
|
+
- Added `image_storage_id` and `image_url` attributes to the person model (#12117)
|
317
|
+
- Added the `Storage` class to the Presence app
|
318
|
+
- Added the `Storage.download` helper method
|
319
|
+
|
320
|
+
### Deprecated
|
321
|
+
|
322
|
+
- Deprecated the `picture_url` on the location map model (#12117)
|
323
|
+
- Deprecated the `picture_url` on the person model (#12117)
|
324
|
+
- Deprecated the `Generic::Storage.create` helper method in favour of
|
325
|
+
`Generic::Storage.upload`
|
326
|
+
|
327
|
+
## [7.0.2] - 2020-03-19
|
328
|
+
|
329
|
+
### Added
|
330
|
+
|
331
|
+
- Added `processing`, `permission` and `tempory` attributes to the collection
|
332
|
+
model (#12115)
|
333
|
+
- Added `status` attribute to the slide model (#12116)
|
334
|
+
- Added associations between the slide, channel and channel group models
|
335
|
+
- Added a lot of missing attributes to the digital signage models
|
336
|
+
|
337
|
+
### Fixed
|
338
|
+
|
339
|
+
- Fixed digital signage test queries
|
340
|
+
|
341
|
+
## [7.0.1] - 2020-02-20
|
342
|
+
|
343
|
+
### Added
|
344
|
+
|
345
|
+
- Added `kind` attribute to the layout mode (#12122)
|
346
|
+
- Added `hostname` attribute to the player model (#12122)
|
347
|
+
|
348
|
+
### Fixed
|
349
|
+
|
350
|
+
- Tweaked documentation of the `checkin_status` attribute
|
351
|
+
|
352
|
+
## [7.0.0] - 2020-02-03
|
353
|
+
|
354
|
+
### Added
|
355
|
+
|
356
|
+
- Added `checkin_status` attribute to the location model (#12111)
|
357
|
+
- Added `people_responsible_for` attribute to the person model (#12111)
|
358
|
+
- Added `person_responsible`, `person_responsible_id` attributes to the person
|
359
|
+
model (#12111)
|
360
|
+
|
361
|
+
### Fixed
|
362
|
+
|
363
|
+
- Fixed the digital signage test queries for displays
|
364
|
+
- Fixed the caching test for newer `faraday_middleware` gem versions
|
365
|
+
|
366
|
+
## [6.4.0] - 2020-01-08
|
367
|
+
|
368
|
+
### Added
|
369
|
+
|
370
|
+
- Added `company_name` attribute to the person model (#11997)
|
371
|
+
- Added `time_zone` attribute to the location model (#12109)
|
372
|
+
|
373
|
+
### Fixed
|
374
|
+
|
375
|
+
- Fixed the layout version model URI
|
376
|
+
- Removed duplicate generic attributes from models
|
377
|
+
- Fixed some typos in attribute name and order
|
378
|
+
|
379
|
+
## [6.3.2] - 2019-09-26
|
380
|
+
|
381
|
+
### Added
|
382
|
+
|
383
|
+
- Expanded the models and attributes in the presence app (#12108)
|
384
|
+
- Added a `#dig` method for the generic/all models
|
385
|
+
|
386
|
+
### Fixed
|
387
|
+
|
388
|
+
- Fixed the reduced/dropped test coverage (#12107)
|
389
|
+
|
390
|
+
## [6.3.1] - 2019-09-05
|
391
|
+
|
392
|
+
### Changed
|
393
|
+
|
394
|
+
- Reworked the JSON parser to handle metadata better
|
395
|
+
- Updated/reworked the Resource app models: added/removed/updated attributes
|
396
|
+
where necessary (#12106)
|
397
|
+
|
398
|
+
### Removed
|
399
|
+
|
400
|
+
- Removed some attributes that are already part of the generic model from
|
401
|
+
DigitalSignage app models
|
402
|
+
|
403
|
+
## [6.3.0] - 2019-09-05
|
404
|
+
|
405
|
+
### Added
|
406
|
+
|
407
|
+
- Added slide, layout and related models to the DigitalSignage app (#12103)
|
408
|
+
- Added the `Storage` class to the DigitalSignage and Resource apps
|
409
|
+
|
410
|
+
### Changed
|
411
|
+
|
412
|
+
- All non-persisted objects are always saved (even without changes)
|
413
|
+
|
414
|
+
### Fixed
|
415
|
+
|
416
|
+
- Fixed typos in documentation
|
417
|
+
- Fixed some code style issues
|
418
|
+
- Default to an empty object if the API provides no data
|
419
|
+
|
420
|
+
## v6.2.3
|
421
|
+
|
422
|
+
- Move common attributes to the generic model and add `url`/`url_html` (#12004)
|
423
|
+
- Add password expiration attributes to the `Company` and `User` model of
|
424
|
+
the Auth app (#12012)
|
425
|
+
- Add new attributes to the `Collection` model of the Resource app (#12012)
|
426
|
+
|
427
|
+
## v6.2.2.1
|
428
|
+
|
429
|
+
- Add missing dependency on net-http-persistent in the gemspec file
|
430
|
+
|
431
|
+
## v6.2.2
|
432
|
+
|
433
|
+
- Add some more attributes to the Presence app
|
434
|
+
- Use persistent HTTP connections from now on (#12101)
|
435
|
+
* Add a configuration option for enabling/disabling persistent HTTP
|
436
|
+
connections
|
437
|
+
- Add support for dirtiness checking for all models (#12100)
|
438
|
+
* Only save models using the HTTP if dirty
|
439
|
+
|
440
|
+
## v6.2.1
|
441
|
+
|
442
|
+
- Add new models and attributes to the Presence app (#12098, #12099)
|
443
|
+
- Replace Fixnum by Integer in the documentation (for Ruby ≥ 2.3)
|
444
|
+
|
445
|
+
## v6.2.0
|
446
|
+
|
447
|
+
- Add the Resource app implementation (#12097)
|
448
|
+
- Update the CorporateWebsite app for recent API changes
|
449
|
+
|
450
|
+
## v6.1.5
|
451
|
+
|
452
|
+
- Update the gemspec to relax the dependency on WebMock to support 2.x and 3.x
|
453
|
+
|
454
|
+
## v6.1.4
|
455
|
+
|
456
|
+
- Fix LWS Console environment command-line parameter not overriding the config
|
457
|
+
- Print LWS setup on LWS Console start
|
458
|
+
|
459
|
+
### Apps
|
460
|
+
|
461
|
+
- Add some fields to the DigitalSignage app (closes: #12001)
|
462
|
+
- Fix some relations in the Auth app (closes: #12026)
|
463
|
+
|
464
|
+
## v6.1.3
|
465
|
+
|
466
|
+
- Fix `#find` on has many-associations not working
|
467
|
+
|
468
|
+
### Development
|
469
|
+
|
470
|
+
- Many fixes in the gemspec
|
471
|
+
- Use the SpecReporter for tests
|
472
|
+
|
473
|
+
## v6.1.2
|
474
|
+
|
475
|
+
- Small tweaks to LWS Console
|
476
|
+
- Add LWS Console documentation (in the README)
|
477
|
+
- Documentation improvements
|
478
|
+
|
479
|
+
### Development
|
480
|
+
|
481
|
+
- Fix caching tests not tearing down the specific setup
|
482
|
+
|
483
|
+
## v6.1.1
|
484
|
+
|
485
|
+
- Support a global and user-specific config file for LWS Console
|
486
|
+
- Use a separate history and specific prompt for LWS Console
|
487
|
+
- Small documentation fixes
|
488
|
+
- Speed up the tests
|
489
|
+
|
490
|
+
## v6.1.0
|
491
|
+
|
492
|
+
- Switch to LWS/LeftClick platform release versions
|
493
|
+
- Switch to Spyke as the REST ORM library (closes: #10671)
|
494
|
+
- Add some Her backward compatibility support
|
495
|
+
- Use JSON as the wire format for sending data to LWS
|
496
|
+
- Switch to using our own exceptions (see LWS::Errors)
|
497
|
+
- Add support for setting the LWS API token in the environment
|
498
|
+
- Switch to Pry as the REPL used by the LWS Console
|
499
|
+
- Add commands to the LWS Console to toggle debug options
|
500
|
+
- Add option parsing and app/environment/debug mode selection to LWS Console
|
501
|
+
|
502
|
+
### Apps
|
503
|
+
|
504
|
+
- Add a first implementation of the Digital Signage app (closes: #11110)
|
505
|
+
- Update some fields for the Ticket app (closes: #11997)
|
506
|
+
- Add the Reader model to the Presence app, add fields to the Location model
|
507
|
+
|
508
|
+
### Development
|
509
|
+
|
510
|
+
- Reorganize the file structure of the library
|
511
|
+
- Add and improve tests and documentation
|
512
|
+
- Document and fix model relations throughout all apps
|
513
|
+
- Documentation fixes for switch to Spyke
|
514
|
+
|
515
|
+
## v0.4.2
|
516
|
+
|
517
|
+
- Documentation fixes
|
518
|
+
- Obtain full test coverage by adding some tests
|
519
|
+
|
520
|
+
## v0.4.1
|
521
|
+
|
522
|
+
- Test improvements; use simplecov for coverage metrics.
|
523
|
+
|
524
|
+
## v0.4.0
|
525
|
+
|
526
|
+
- Add support for the ticket and corporate website app/web service
|
527
|
+
- Gem/packaging and documentation fixes
|
528
|
+
|
529
|
+
## v0.3.1
|
530
|
+
|
531
|
+
- Add a release_if_needed task
|
532
|
+
|
533
|
+
…
|
534
|
+
|
535
|
+
## v0.0.1
|
536
|
+
|
537
|
+
Initial release
|
538
|
+
|
539
|
+
[6.3.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.2.3...v6.3.0
|
540
|
+
[6.3.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.3.0...v6.3.1
|
541
|
+
[6.3.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.3.1...v6.3.2
|
542
|
+
[6.4.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.3.2...v6.4.0
|
543
|
+
[7.0.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v6.4.0...v7.0.0
|
544
|
+
[7.0.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.0...v7.0.1
|
545
|
+
[7.0.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.1...v7.0.2
|
546
|
+
[7.0.3]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.2...v7.0.3
|
547
|
+
[7.0.4]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.3...v7.0.4
|
548
|
+
[7.1.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.0.4...v7.1.0
|
549
|
+
[7.1.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.0...v7.1.1
|
550
|
+
[7.1.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.1...v7.1.2
|
551
|
+
[7.1.3]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.2...v7.1.3
|
552
|
+
[7.1.4]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.3...v7.1.4
|
553
|
+
[7.2.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.1.4...v7.2.0
|
554
|
+
[7.2.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.0...v7.2.1
|
555
|
+
[7.2.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.1...v7.2.2
|
556
|
+
[7.2.3]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.2...v7.2.3
|
557
|
+
[7.2.4]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.3...v7.2.4
|
558
|
+
[7.2.5]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.4...v7.2.5
|
559
|
+
[7.3.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.2.5...v7.3.0
|
560
|
+
[7.3.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.3.0...v7.3.1
|
561
|
+
[7.3.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.3.1...v7.3.2
|
562
|
+
[7.4.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.3.2...v7.4.0
|
563
|
+
[7.4.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.4.0...v7.4.1
|
564
|
+
[7.5.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.4.1...v7.5.0
|
565
|
+
[7.5.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.5.0...v7.5.1
|
566
|
+
[7.5.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.5.1...v7.5.2
|
567
|
+
[8.1.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v7.5.2...v8.1.0
|
568
|
+
[8.1.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v8.1.0...v8.1.1
|
569
|
+
[9.0.0.beta1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v8.1.1...v9.0.0.beta1
|
570
|
+
[9.0.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.0.beta1...v9.0.0
|
571
|
+
[9.0.1]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.0...v9.0.1
|
572
|
+
[9.0.2]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.1...v9.0.2
|
573
|
+
[10.0.0]: https://gitlab.leftclick.network/platform/ruby-lws/compare/v9.0.2...v10.0.0
|
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
@@ -101,7 +101,7 @@ module LWS::Generic
|
|
101
101
|
|
102
102
|
alias_method :"orig_#{name_sing}_ids=", :"#{name_sing}_ids="
|
103
103
|
define_method(:"#{name_sing}_ids=") do |ids|
|
104
|
-
|
104
|
+
if persisted? && ids.reject(&:blank?) != send(:"#{name_sing}_ids")
|
105
105
|
send(:"#{name_sing}_ids_will_change!")
|
106
106
|
end
|
107
107
|
send(:"orig_#{name_sing}_ids=", ids)
|
@@ -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.0
|
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
|
@@ -78,26 +98,6 @@ dependencies:
|
|
78
98
|
- - "~>"
|
79
99
|
- !ruby/object:Gem::Version
|
80
100
|
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
101
|
- !ruby/object:Gem::Dependency
|
102
102
|
name: pry
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,108 +152,10 @@ dependencies:
|
|
152
152
|
- - "<"
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
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
155
|
description: |-
|
254
|
-
This library for Ruby provides access to the LeftClick
|
255
|
-
|
256
|
-
|
156
|
+
This library for Ruby provides access to the LeftClick Web
|
157
|
+
Services and its applications using a model-based structure that abstracts
|
158
|
+
from API calls using the available REST interfaces.
|
257
159
|
email:
|
258
160
|
- gem@leftclick.eu
|
259
161
|
executables:
|
@@ -261,6 +163,8 @@ executables:
|
|
261
163
|
extensions: []
|
262
164
|
extra_rdoc_files: []
|
263
165
|
files:
|
166
|
+
- CHANGELOG.md
|
167
|
+
- README.md
|
264
168
|
- bin/lwsconsole
|
265
169
|
- lib/lws.rb
|
266
170
|
- lib/lws/apps/auth.rb
|
@@ -274,6 +178,7 @@ files:
|
|
274
178
|
- lib/lws/config.rb
|
275
179
|
- lib/lws/errors.rb
|
276
180
|
- lib/lws/middleware.rb
|
181
|
+
- lib/lws/middleware/caching.rb
|
277
182
|
- lib/lws/middleware/http_logger.rb
|
278
183
|
- lib/lws/middleware/json_logger.rb
|
279
184
|
- lib/lws/middleware/json_parser.rb
|
@@ -301,5 +206,5 @@ requirements: []
|
|
301
206
|
rubygems_version: 3.3.15
|
302
207
|
signing_key:
|
303
208
|
specification_version: 4
|
304
|
-
summary: LeftClick
|
209
|
+
summary: LeftClick Web Services library for Ruby
|
305
210
|
test_files: []
|