lws 6.3.2 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6735eba2229b17c2690bddf74524980752e5deea2e893d65e2789be1138df2a3
4
- data.tar.gz: b5e0914b8295744c2e5ee2670d44835962faf000ccc307c75b0ff8de6b80e141
3
+ metadata.gz: dc635406b8325652b128c7214d332b1686fbd4ba0fee74bc4c8716d75d3a349a
4
+ data.tar.gz: 93953a65dec58a2a509866b4f0252d2c7e4a68227e09258f3376d946c5503ae6
5
5
  SHA512:
6
- metadata.gz: b82822f7f43fb6752b3f137fdad30be4e0a0f90e9084c22e5c3db6b6cbad70e49acf15772b2b3ae5f73e16037e134db3afa3bcd13956835089168219f76d4e9f
7
- data.tar.gz: a3bbf82f1eb2c003bea92750544e4447b76949ca5cdff28730d7502e9826cb4d5cacb52299cbf4c2a88dae336fd48c6ccb769f1524fce7a9217cd8c5116b85df
6
+ metadata.gz: 65fe4cc5990944a1512cbcd73868b76268f5fdc937ae5de344e57a7a4a5f05abe38256bc4d8d057a0e505871caa9f45dceb3fd859e9616a61afed5b3853c29fd
7
+ data.tar.gz: 60bba2e6c25ad035deb2193dc93cc9f3553364ea9bf7b0997e19f422ce5e8575118c143a7cf7862ce96b4dd47d515b0c46b17d2cb398a5f5d0328f26f119c96e
@@ -485,10 +485,6 @@ module LWS::DigitalSignage
485
485
  class Layout < LWS::Generic::Model
486
486
  use_api LWS::DigitalSignage.api
487
487
 
488
- # @!attribute id [r]
489
- # @return [Integer] the (unique) ID of the layout
490
- attribute :id
491
-
492
488
  # @!attribute categories
493
489
  # @return [Array<Layout::Category>] the categories associated with
494
490
  # the layout
@@ -565,10 +561,6 @@ module LWS::DigitalSignage
565
561
  use_api LWS::DigitalSignage.api
566
562
  uri "layout/categories(/:id)"
567
563
 
568
- # @!attribute id [r]
569
- # @return [Integer] the (unique) ID of the layout category
570
- attribute :id
571
-
572
564
  # @!attribute description
573
565
  # @return [String, nil] the description of the layout category
574
566
  attribute :description
@@ -592,10 +584,6 @@ module LWS::DigitalSignage
592
584
  class Layout::Element < LWS::Generic::Model
593
585
  use_api LWS::DigitalSignage.api
594
586
 
595
- # @!attribute id [r]
596
- # @return [Integer] the (unique) ID of the layout element
597
- attribute :id
598
-
599
587
  # @!attribute asset_storage_ids
600
588
  # @return [Array<String>] the storage IDs of the assets of the layout element
601
589
  attribute :asset_storage_ids
@@ -650,11 +638,6 @@ module LWS::DigitalSignage
650
638
  class Layout::Element::Customizable < LWS::Generic::Model
651
639
  use_api LWS::DigitalSignage.api
652
640
 
653
- # @!attribute id [r]
654
- # @return [Integer] the (unique) ID of the layout element customizable
655
- # property
656
- attribute :id
657
-
658
641
  # @!attribute attr
659
642
  # @return [String] the customizable attribute/property name
660
643
  attribute :attr
@@ -691,10 +674,6 @@ module LWS::DigitalSignage
691
674
  class Layout::Element::Property < LWS::Generic::Model
692
675
  use_api LWS::DigitalSignage.api
693
676
 
694
- # @!attribute id [r]
695
- # @return [Integer] the (unique) ID of the layout element property
696
- attribute :id
697
-
698
677
  # @!attribute attr
699
678
  # @return [String] the attribute/property name
700
679
  attribute :attr
@@ -723,11 +702,7 @@ module LWS::DigitalSignage
723
702
  # This class is only used within the context of the {Layout} class.
724
703
  class Layout::Version < LWS::Generic::Model
725
704
  use_api LWS::DigitalSignage.api
726
- uri "layout/Layout_id/versions(/:id)"
727
-
728
- # @!attribute id [r]
729
- # @return [Integer] the (unique) ID of the layout version
730
- attribute :id
705
+ uri "layout/:layout_id/versions(/:id)"
731
706
 
732
707
  # @!attribute elements
733
708
  # @return [Array<Layout::Element>] the elements contained in the layout
@@ -1702,10 +1677,6 @@ module LWS::DigitalSignage
1702
1677
  class Slide < LWS::Generic::Model
1703
1678
  use_api LWS::DigitalSignage.api
1704
1679
 
1705
- # @!attribute id [r]
1706
- # @return [Integer] the (unique) ID of the slide
1707
- attribute :id
1708
-
1709
1680
  # @!attribute account
1710
1681
  # @return [LWS::Auth::Account] the account used for creating the slide
1711
1682
  belongs_to :account, class_name: "LWS::Auth::Account"
@@ -1748,10 +1719,6 @@ module LWS::DigitalSignage
1748
1719
  class Slide::Schedule < LWS::Generic::Model
1749
1720
  use_api LWS::DigitalSignage.api
1750
1721
 
1751
- # @!attribute id [r]
1752
- # @return [Integer] the (unique) ID of the slide schedule
1753
- attribute :id
1754
-
1755
1722
  # @!attribute date_end
1756
1723
  # @return [Date] the date after which the slide schedule becomes inactive
1757
1724
  attribute :date_end
@@ -92,15 +92,15 @@ module LWS::Generic
92
92
  attribute :id
93
93
 
94
94
  # @!attribute created_at [r]
95
- # @return [String] the timestamp of when the app was created
95
+ # @return [String] the timestamp of when the model was created
96
96
  attribute :created_at
97
97
 
98
98
  # @!attribute updated_at [r]
99
- # @return [String] the timestamp of when the app was last updated
99
+ # @return [String] the timestamp of when the model was last updated
100
100
  attribute :updated_at
101
101
 
102
102
  # @!attribute url [r]
103
- # @return [String] the URL of the model on the REST API
103
+ # @return [String] the URL of the model on the REST API
104
104
  attribute :url
105
105
 
106
106
  # @!attribute url_html [r]
@@ -165,10 +165,6 @@ module LWS::Generic
165
165
 
166
166
  # = The configuration class
167
167
  class Configuration < Model
168
- # @!attribute id [r]
169
- # @return [Integer] the (unique) ID of the configuration
170
- attribute :id
171
-
172
168
  # @!attribute key
173
169
  # @return [String] the configuration key
174
170
  attribute :key
@@ -176,14 +172,6 @@ module LWS::Generic
176
172
  # @!attribute value
177
173
  # @return [String] the configuration value
178
174
  attribute :value
179
-
180
- # @!attribute created_at [r]
181
- # @return [String] the timestamp of when the configuration was created
182
- attribute :created_at
183
-
184
- # @!attribute updated_at [r]
185
- # @return [String] the timestamp of when the configuration was last updated
186
- attribute :updated_at
187
175
  end
188
176
 
189
177
  # = The storage class
@@ -128,6 +128,11 @@ module LWS::Presence
128
128
  # including descendant locations
129
129
  attribute :capacity_used_precentage_tree
130
130
 
131
+ # @!attribute checkin_status
132
+ # @return ["available", "busy", "away", "disabled", nil]
133
+ # the presence status to set people to when checking in
134
+ attribute :checkin_status
135
+
131
136
  # @!attribute checkout_location
132
137
  # @return [Location, nil] the location to move people to when they
133
138
  # are checked out
@@ -157,8 +162,9 @@ module LWS::Presence
157
162
  attribute :lat
158
163
 
159
164
  # @!attribute logoff_time
165
+ # The format of the time is +HH:MM+ and should be interpreted in the time zone
166
+ # of the location (see also {#time_zone}).
160
167
  # @return [String] the time everybody is automatically logged off
161
- # (format HH:MM)
162
168
  attribute :logoff_time
163
169
 
164
170
  # @!attribute long
@@ -215,6 +221,10 @@ module LWS::Presence
215
221
  # @return [Array<Reader>] the (RFID/code/ID/...) readers linked to this location
216
222
  has_many :readers
217
223
 
224
+ # @!attribute time_zone
225
+ # @return [String] the time zone of the location
226
+ attribute :time_zone
227
+
218
228
  # @!attribute uuid
219
229
  # @return [String] the UUID of the location
220
230
  attribute :uuid
@@ -357,6 +367,13 @@ module LWS::Presence
357
367
  # @return [Integer] the ID of the company the person belongs to
358
368
  attribute :company_id
359
369
 
370
+ # @!attribute company_name
371
+ # @note
372
+ # This is not the name of the company the person belongs to, but
373
+ # possibly a guest/visitor working for another company!
374
+ # @return [String] the name of the company the person works for
375
+ attribute :company_name
376
+
360
377
  # @!attribute customer_reference
361
378
  # @return [String, nil] the customer specific reference for the person
362
379
  attribute :customer_reference
@@ -392,10 +409,6 @@ module LWS::Presence
392
409
  # @return [Float, nil] the exact latitude of the person's location
393
410
  attribute :lat
394
411
 
395
- # @!attribute long
396
- # @return [Float, nil] the exact longitude of the person's location
397
- attribute :long
398
-
399
412
  # @!attribute location
400
413
  # @return [Location] the location the person is located at
401
414
  belongs_to :location
@@ -409,21 +422,39 @@ module LWS::Presence
409
422
  # @return [Integer] the ID of the location the person is located at
410
423
  attribute :location_id
411
424
 
425
+ # @!attribute long
426
+ # @return [Float, nil] the exact longitude of the person's location
427
+ attribute :long
428
+
412
429
  # @!attribute name
413
430
  # @return [String] the name of the person
414
431
  attribute :name
415
432
 
433
+ # @!attribute people_responsible_for
434
+ # @return [Array<Person>] the people the person is responsible for
435
+ has_many :people_responsible_for, class_name: "LWS::Presence::Person"
436
+
437
+ # @!attribute person_responsible
438
+ # @return [Person, nil] the person responsible for this person
439
+ belongs_to :person_responsible, class_name: "LWS::Presence::Person",
440
+ foreign_key: "person_responsible_id",
441
+ uri: "people/:id"
442
+
443
+ # @!attribute person_responsible_id
444
+ # @return [Integer, nil] the ID of the person responsible for this person
445
+ attribute :person_responsible_id
446
+
447
+ # @!attribute phone_extension
448
+ # @return [String] the fixed phonenumber extension of the person
449
+ attribute :phone_extension
450
+
416
451
  # @!attribute phone_fixed
417
452
  # @return [String] the fixed phonenumber of the person
418
453
  attribute :phone_fixed
419
454
 
420
455
  # @!attribute phone_mobile
421
456
  # @return [String] the mobile phonenumber of the person
422
- attribute :phone_moblie
423
-
424
- # @!attribute phone_extension
425
- # @return [String] the fixed phonenumber extension of the person
426
- attribute :phone_extension
457
+ attribute :phone_mobile
427
458
 
428
459
  # @!attribute picture_url
429
460
  # @return [String, nil] the URL of the picture of the person
data/lib/lws/version.rb CHANGED
@@ -13,6 +13,6 @@ module LWS
13
13
 
14
14
  # The LWS library version.
15
15
  # @note The major and minor version parts match the LWS API version!
16
- VERSION = '6.3.2'.freeze
16
+ VERSION = "7.0.0".freeze
17
17
 
18
18
  end
data/test/caching_test.rb CHANGED
@@ -55,9 +55,9 @@ class TestCaching < MiniTest::Test
55
55
  assert_nil(@cache_mock.last_read_key)
56
56
  assert_nil(@cache_mock.last_written_key)
57
57
  assert_nil(@cache_mock.last_written_value)
58
- config = LWS::Auth::Configuration.all.first
59
- assert_equal("/configurations", @cache_mock.last_read_key)
60
- assert_equal("/configurations", @cache_mock.last_written_key)
58
+ _configs = LWS::Auth::Configuration.all.to_a
59
+ refute_nil(@cache_mock.last_read_key)
60
+ assert_equal(@cache_mock.last_read_key, @cache_mock.last_written_key)
61
61
  refute_nil(@cache_mock.last_written_value)
62
62
  end
63
63
 
@@ -179,7 +179,7 @@ class TestDigitalSignageDisplay < MiniTest::Test
179
179
  include LWS::DigitalSignage
180
180
 
181
181
  def setup
182
- @display = Display.all.first
182
+ @display = Display.find(1)
183
183
  end
184
184
 
185
185
  def test_valid
@@ -201,7 +201,7 @@ class TestDigitalSignageDisplayInput < MiniTest::Test
201
201
  include LWS::DigitalSignage
202
202
 
203
203
  def setup
204
- @display = Display.all.first
204
+ @display = Display.find(1)
205
205
  # Display inputs only exist as child objects of a display
206
206
  @display_input = @display.inputs.first
207
207
  end
@@ -153,6 +153,9 @@ class TestPresencePerson < MiniTest::Test
153
153
  assert_instance_of(Appointment, @person.appointments.first)
154
154
  assert_instance_of(LWS::Auth::Company, @person.company)
155
155
  assert_instance_of(Location, @person.location)
156
+ # FIXME: The list of people responsible for is not included in the serializer.
157
+ #assert_instance_of(Person, @person.people_responsible_for.first)
158
+ assert_instance_of(Person, @person.person_responsible)
156
159
  end
157
160
 
158
161
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lws
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.2
4
+ version: 7.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: 2019-09-26 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware
@@ -229,14 +229,7 @@ executables:
229
229
  extensions: []
230
230
  extra_rdoc_files: []
231
231
  files:
232
- - ".gitignore"
233
- - ".yardopts"
234
- - CHANGELOG.md
235
- - Gemfile
236
- - README.md
237
- - Rakefile
238
232
  - bin/lwsconsole
239
- - copyright.txt
240
233
  - lib/lws.rb
241
234
  - lib/lws/apps/auth.rb
242
235
  - lib/lws/apps/corporate_website.rb
@@ -255,7 +248,6 @@ files:
255
248
  - lib/lws/middleware/request_headers.rb
256
249
  - lib/lws/stubbing.rb
257
250
  - lib/lws/version.rb
258
- - lws.gemspec
259
251
  - test/api_token_middleware_test.rb
260
252
  - test/auth_test.rb
261
253
  - test/caching_test.rb
@@ -304,27 +296,27 @@ signing_key:
304
296
  specification_version: 4
305
297
  summary: LeftClick web services library for Ruby
306
298
  test_files:
299
+ - test/support/with_env.rb
300
+ - test/json_parser_test.rb
301
+ - test/test_helper.rb
302
+ - test/setup_test.rb
303
+ - test/ticket_test.rb
307
304
  - test/api_token_middleware_test.rb
305
+ - test/stubbing_test.rb
306
+ - test/presence_test.rb
307
+ - test/digital_signage_test.rb
308
+ - test/generic_test.rb
309
+ - test/logger_test.rb
308
310
  - test/auth_test.rb
309
- - test/caching_test.rb
311
+ - test/resource_test.rb
312
+ - test/maps_test.rb
313
+ - test/corporate_website_test.rb
314
+ - test/config/tokens.yml
310
315
  - test/config/empty.yml
311
316
  - test/config/endpoints.yml
312
- - test/config/full.yml
313
317
  - test/config/invalid.yml
314
318
  - test/config/switch_env.yml
315
- - test/config/tokens.yml
316
- - test/corporate_website_test.rb
317
- - test/digital_signage_test.rb
319
+ - test/config/full.yml
320
+ - test/caching_test.rb
318
321
  - test/fixtures/auth.yml
319
322
  - test/fixtures/permissions.yml
320
- - test/generic_test.rb
321
- - test/json_parser_test.rb
322
- - test/logger_test.rb
323
- - test/maps_test.rb
324
- - test/presence_test.rb
325
- - test/resource_test.rb
326
- - test/setup_test.rb
327
- - test/stubbing_test.rb
328
- - test/support/with_env.rb
329
- - test/test_helper.rb
330
- - test/ticket_test.rb
data/.gitignore DELETED
@@ -1,16 +0,0 @@
1
- # RubyMine IDE
2
- /.idea/
3
-
4
- # Ignore YARD stuff
5
- .yardoc
6
- doc/
7
-
8
- # Ignore Simplecov/coverage report
9
- /coverage/
10
-
11
- # Ignore gem stuff
12
- *.gem
13
- .bundle
14
- Gemfile.lock
15
- pkg/*
16
- vendor/
data/.yardopts DELETED
@@ -1,8 +0,0 @@
1
- --hide-void-return
2
- --no-private
3
- --protected
4
- --readme README.md
5
- --title 'LeftClick Web Services Documentation'
6
- 'lib/**/*.rb'
7
- -
8
- '*.md'
data/CHANGELOG.md DELETED
@@ -1,162 +0,0 @@
1
- # LeftClick Web Services Changelog
2
-
3
- Up until version 6.1.0, we used the standard Gem version numbering starting at
4
- version 0.0.1. From version 6.1.0 on the version will follow the API version
5
- of LWS in the major/minor part of te version.
6
-
7
- The changelog follows the [Keep a Changelog] format from version 6.3.0 on.
8
-
9
- ## [6.3.2] - 2019-09-26
10
- ### Added
11
- * Expanded the models and attributes in the presence app (#12108)
12
- * Added a `#dig` method for the generic/all models
13
-
14
- ### Fixed
15
- * Fixed the reduced/dropped test coverage (#12107)
16
-
17
- ## [6.3.1] - 2019-09-05
18
- ### Changed
19
- * Reworked the JSON parser to handle metadata better
20
- * Updated/reworked the Resource app models: added/removed/updated attributes
21
- where necessary (#12106)
22
-
23
- ### Removed
24
- * Removed some attributes that are already part of the generic model from
25
- DigitalSignage app models
26
-
27
- ## [6.3.0] - 2019-09-05
28
- ### Added
29
- * Added slide, layout and related models to the DigitalSignage app (#12103)
30
- * Added the `Storage` class to the DigitalSignage and Resource apps
31
-
32
- ### Changed
33
- * All non-persisted objects are always saved (even without changes)
34
-
35
- ### Fixed
36
- * Fixed typos in documentation
37
- * Fixed some code style issues
38
- * Default to an empty object if the API provides no data
39
-
40
- ## v6.2.3
41
-
42
- * Move common attributes to the generic model and add `url`/`url_html` (#12004)
43
- * Add password expiration attributes to the `Company` and `User` model of
44
- the Auth app (#12012)
45
- * Add new attributes to the `Collection` model of the Resource app (#12012)
46
-
47
- ## v6.2.2.1
48
-
49
- * Add missing dependency on net-http-persistent in the gemspec file
50
-
51
- ## v6.2.2
52
-
53
- * Add some more attributes to the Presence app
54
- * Use persistent HTTP connections from now on (#12101)
55
- * Add a configuration option for enabling/disabling persistent HTTP
56
- connections
57
- * Add support for dirtiness checking for all models (#12100)
58
- * Only save models using the HTTP if dirty
59
-
60
- ## v6.2.1
61
-
62
- * Add new models and attributes to the Presence app (#12098, #12099)
63
- * Replace Fixnum by Integer in the documentation (for Ruby ≥ 2.3)
64
-
65
- ## v6.2.0
66
-
67
- * Add the Resource app implementation (#12097)
68
- * Update the CorporateWebsite app for recent API changes
69
-
70
- ## v6.1.5
71
-
72
- * Update the gemspec to relax the dependency on WebMock to support 2.x and 3.x
73
-
74
- ## v6.1.4
75
-
76
- * Fix LWS Console environment command-line parameter not overriding the config
77
- * Print LWS setup on LWS Console start
78
-
79
- ### Apps
80
-
81
- * Add some fields to the DigitalSignage app (closes: #12001)
82
- * Fix some relations in the Auth app (closes: #12026)
83
-
84
- ## v6.1.3
85
-
86
- * Fix `#find` on has many-associations not working
87
-
88
- ### Development
89
-
90
- * Many fixes in the gemspec
91
- * Use the SpecReporter for tests
92
-
93
- ## v6.1.2
94
-
95
- * Small tweaks to LWS Console
96
- * Add LWS Console documentation (in the README)
97
- * Documentation improvements
98
-
99
- ### Development
100
-
101
- * Fix caching tests not tearing down the specific setup
102
-
103
- ## v6.1.1
104
-
105
- * Support a global and user-specific config file for LWS Console
106
- * Use a separate history and specific prompt for LWS Console
107
- * Small documentation fixes
108
- * Speed up the tests
109
-
110
- ## v6.1.0
111
-
112
- * Switch to LWS/LeftClick platform release versions
113
- * Switch to Spyke as the REST ORM library (closes: #10671)
114
- * Add some Her backward compatibility support
115
- * Use JSON as the wire format for sending data to LWS
116
- * Switch to using our own exceptions (see LWS::Errors)
117
- * Add support for setting the LWS API token in the environment
118
- * Switch to Pry as the REPL used by the LWS Console
119
- * Add commands to the LWS Console to toggle debug options
120
- * Add option parsing and app/environment/debug mode selection to LWS Console
121
-
122
- ### Apps
123
-
124
- * Add a first implementation of the Digital Signage app (closes: #11110)
125
- * Update some fields for the Ticket app (closes: #11997)
126
- * Add the Reader model to the Presence app, add fields to the Location model
127
-
128
- ### Development
129
-
130
- * Reorganize the file structure of the library
131
- * Add and improve tests and documentation
132
- * Document and fix model relations throughout all apps
133
- * Documentation fixes for switch to Spyke
134
-
135
- ## v0.4.2
136
-
137
- * Documentation fixes
138
- * Obtain full test coverage by adding some tests
139
-
140
- ## v0.4.1
141
-
142
- * Test improvements; use simplecov for coverage metrics.
143
-
144
- ## v0.4.0
145
-
146
- * Add support for the ticket and corporate website app/web service
147
- * Gem/packaging and documentation fixes
148
-
149
- ## v0.3.1
150
-
151
- * Add a release_if_needed task
152
-
153
-
154
-
155
- ## v0.0.1
156
-
157
- Initial release
158
-
159
- [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
160
- [6.3.0]: https://gitlab.leftclick.eu/platform/ruby-lws/compare/v6.2.3...v6.3.0
161
- [6.3.1]: https://gitlab.leftclick.eu/platform/ruby-lws/compare/v6.3.0...v6.3.1
162
- [6.3.1]: https://gitlab.leftclick.eu/platform/ruby-lws/compare/v6.3.1...v6.3.2
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in lws.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,154 +0,0 @@
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 someplace
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
- ```ruby
35
- map = Maps::Map.all.first
36
- markers = map.markers
37
-
38
- company = Company.find(6)
39
- account = Auth::Account.create(name: "Foo Bar",
40
- company: company)
41
-
42
- loc = Presence::Location.where(name: "Test")
43
- loc.destroy
44
- ```
45
-
46
- ## Configuration
47
-
48
- The following example uses a much more elaborate setup:
49
-
50
- ```ruby
51
- LWS.setup do |config|
52
- config.api_token_middleware = TokenAuthenticator
53
- config.caching_object = MyRedisCache.new
54
- config.environment = :development
55
- config.endpoints = { maps: "https://maps.leftclick.cloud" }
56
- config.http_debug = true
57
- config.json_debug = true
58
- config.logger = Rails.logger
59
- end
60
- ```
61
-
62
- In this setup, a caching object is used that follows the
63
- `FaradayMiddleWare::Caching` API. It uses all development API endpoints,
64
- except for maps, which is overriden to use the production endpoint. Also
65
- HTTP request and JSON data debug logging is enabled and LWS will use
66
- the Rails logger to log the messages.
67
- Also a custom API token authenticator class is used that should implement
68
- the `Faraday::Middleware` interface and set the `X-Token` header with the
69
- runtime determined API token as value, for example:
70
-
71
- ```ruby
72
- class TokenAuthenticator < Faraday::Middleware
73
-
74
- def call(env)
75
- env[:request_headers]["X-Token"] = … # Some calculated token
76
- @app.call(env)
77
- end
78
-
79
- end
80
- ```
81
-
82
- The `LC_LWS_ENV` environment variable is supported to override the LWS
83
- environment. Allowed values are "production" (default) and "development".
84
- The `LC_LWS_API_TOKEN` is supported to set the LWS API token default.
85
- This only works if a custom API token middleware is not used.
86
-
87
- ## LWS Console
88
-
89
- This library comes with the program `lwsconsole`, which is a command-line
90
- tool that can be used to interactively use the library. (This is similar
91
- to the Rails console.) See `lwsconsole --help` for the supported
92
- command-line arguments.
93
-
94
- LWS Console will perform the setup for you and give you a prompt in the
95
- `LWS` module namespace or the module of an app if this is selected via the
96
- arguments. It uses the production environment per default using the token
97
- provided by a command-line argument. These defaults can be overriden using
98
- the configuration. For example, to rename a map:
99
-
100
- ```sh
101
- $ lwsconsole -t "my_token" -a maps
102
- [1] lwsconsole(LWS::Maps)> Map.all.map(&:name)
103
- => ["Gebouw 1",
104
- "Gebouw 3"]
105
- [2] lwsconsole(LWS::Maps)> map = Map.find(2)
106
- => #<LWS::Maps::Map(maps/(:id)) id: 2 name: "Gebouw 3" ... markers: []>
107
- [3] lwsconsole(LWS::Maps)> map.name = "Gebouw 2"
108
- "Gebouw 2"
109
- [4] lwsconsole(LWS::Maps)> map.save
110
- nil
111
- ```
112
-
113
- Besides the API calls, LWS console supports a few commands to change its
114
- behaviour:
115
-
116
- * `http_debug true|false`: Toggles HTTP debugging for API calls
117
- * `http_debug_headers true|false`: Toggles logging of HTTP headers in the HTTP debug output
118
- * `json_debug true|false`: Toggles JSON debug output for API calls
119
- * `reload!`: Reloads all apps
120
-
121
- ```
122
- [5] lwsconsole(LWS::Maps)> http_debug true
123
- true
124
- ```
125
-
126
- LWS Console keeps a history of all calls and commands, use the command
127
- `history --all` to seem them. Use the command `help` to see all other
128
- available commands (provided by Pry).
129
-
130
- ### Configuration files
131
-
132
- LWS Console will look for the configuration files first in
133
- `/etc/LeftClick/lws.yml` and then `~/.config/LeftClick/lws.yml`; they are
134
- in the YAML format.
135
-
136
- The configuration file can set defaults per environment. It is possible to
137
- set the API key, endpoints and debug modes.
138
-
139
- ```yaml
140
- development:
141
- api_token: "my_token"
142
- endpoints:
143
- maps: "https://maps.leftclick.cloud
144
- http_debug: true
145
- http_debug_headers: true
146
- json_debug: true
147
- ```
148
-
149
- To override the default environment, use the default section. For example:
150
-
151
- ```yaml
152
- default:
153
- environment: "development"
154
- ```
data/Rakefile DELETED
@@ -1,75 +0,0 @@
1
- # Rakefile with tasks for the LeftClick web services
2
-
3
- require 'bundler/gem_tasks'
4
- require "rake/testtask"
5
- require "yard"
6
-
7
- desc "Release if not yet released"
8
- task :release_if_needed do
9
- gh = Bundler::GemHelper.instance
10
- released_gems = Gem::SpecFetcher.fetcher.detect { |gem| gem.name == gh.gemspec.name }
11
- released_versions = released_gems.map { |tup, _| tup.version }
12
- if released_versions.include? gh.gemspec.version
13
- Bundler.ui.confirm "Already released this gem"
14
- else
15
- Rake::Task["release"].invoke
16
- end
17
- end
18
-
19
- Rake::TestTask.new do |t|
20
- t.libs << "test" << "lib"
21
- t.pattern = "test/*_test.rb"
22
- t.warning = false
23
- end
24
-
25
- YARD::Rake::YardocTask.new
26
-
27
- task doc: :yard
28
-
29
- desc "Insert/update copyright headers in all script files"
30
- task :copyright do
31
- copyright_text = File.read("copyright.txt")
32
-
33
- Dir["**/*.{pl,perl,rb,sh}"].sort.each do |script_file|
34
- if File.symlink? script_file
35
- puts "I: script file is a symlink: #{script_file}, skipping!"
36
- next
37
- end
38
-
39
- puts "I: processing script file #{script_file}"
40
- lines = File.readlines(script_file)
41
- new_script_file = script_file + ".new"
42
- new_perm = File.stat(script_file).mode
43
- File.open(new_script_file, "w", new_perm) do |new_file|
44
- found_copyright = false
45
- removing_old_copyright = false
46
- lines.each do |line|
47
- if found_copyright
48
- new_file.print line
49
- next
50
- end
51
-
52
- if line =~ /^#..+/
53
- new_file.print line unless removing_old_copyright
54
- next
55
- end
56
- if line =~ /^([^#]|$)/
57
- new_file.print copyright_text
58
- new_file.puts unless line.chomp.empty?
59
- removing_old_copyright = false
60
- found_copyright = true
61
- elsif line =~ /^\#$/
62
- removing_old_copyright = true
63
- next
64
- else
65
- raise "got unexpected line in header: #{line.chomp}"
66
- end
67
-
68
- new_file.print line
69
- end
70
- end
71
- File.rename(new_script_file, script_file)
72
- end
73
- end
74
-
75
- task default: :test
data/copyright.txt DELETED
@@ -1,9 +0,0 @@
1
- #
2
- # Copyright © 2016 LeftClick B.V.
3
- #
4
- # This software is property of LeftClick B.V. and cannot be redistributed
5
- # and/or modified without permission. The software or any of its parts
6
- # cannot be used for any other purposes than the LeftClick services and
7
- # only during a valid license subscription. For more information, please
8
- # contact LeftClick B.V. at: Geldropseweg 8B, 5731 SG Mierlo, The
9
- # Netherlands, info@leftclick.eu, +31492-782120.
data/lws.gemspec DELETED
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../lib/lws/version", __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "lws"
6
- s.version = LWS::VERSION
7
- s.authors = ["LeftClick B.V."]
8
- s.email = ["gem@leftclick.eu"]
9
- s.homepage = "https://leftclick.eu/"
10
- s.summary = "LeftClick web services library for Ruby"
11
- s.description = %q{This library for Ruby provides access to the LeftClick
12
- web services/applications using a model-based structure that abstracts from API calls
13
- using the available REST interfaces.}
14
-
15
- s.add_runtime_dependency 'faraday_middleware', '>= 0.10.0', '< 1.0'
16
- s.add_runtime_dependency 'hashie', '~> 3.5'
17
- s.add_runtime_dependency 'multi_json', '~> 1.12'
18
- s.add_runtime_dependency 'net-http-persistent', '~> 2.9'
19
- s.add_runtime_dependency 'pry', '~> 0.11'
20
- s.add_runtime_dependency 'spyke', '~> 5.3'
21
- s.add_runtime_dependency 'webmock', '>= 2', '< 4'
22
-
23
- s.add_development_dependency 'bundler', '~> 1.16'
24
- s.add_development_dependency 'minitest', '~> 5.10'
25
- s.add_development_dependency 'minitest-reporters', '~> 1.0'
26
- s.add_development_dependency 'rake', '~> 12.3'
27
- s.add_development_dependency 'simplecov', '~> 0.14'
28
- s.add_development_dependency 'simplecov-rcov', '~> 0.2'
29
- s.add_development_dependency 'yard', '~> 0.9'
30
-
31
- s.files = `git ls-files`.split("\n")
32
- s.test_files = `git ls-files -- test/*`.split("\n")
33
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
34
- s.require_paths = ["lib"]
35
- end