lws 6.1.0.beta6 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4481ad17a1652e8cb7f0f1979c136f1f5849a239
4
- data.tar.gz: bd6ca219e14eeedb2fdfa11c56a772901a494032
3
+ metadata.gz: 2eb1ec948cd52f1f5c3610ac4c3fc04d0ee1c711
4
+ data.tar.gz: 6368649a24fa9016db6e9e0ca52b77528ad83df2
5
5
  SHA512:
6
- metadata.gz: 2aaf64b05526bd03a3bab74caa925aeb4a22707fecc3f965be37db5aafb0f9a01674873df9cb524ac5638394e03f46bf2405c69c8853e7188d3f83c1588410fb
7
- data.tar.gz: b2f35929acd6b44b2cc348c66918a763bc1795792d2efcc422397db8874dd098654f9eb2041597c2b350a0798f57724a98f1e1d4ebf3584288294ac38ce818f4
6
+ metadata.gz: b669df0b60760d421f95d4994ff01d554758a40d54767982eb00705cbd988e2a10503200bd1eda281e94ddc3127bc303ede13c75c719e2c9575d0c9b1fd2a3cf
7
+ data.tar.gz: 0fd2381ff359b7be8e30c13622d663ccec20ab30e89404cb52127c29f2cb25a950deba303e04bfe6a9fe8a39d75a6385f0358b92630296599bd12d3bb46a64c8
@@ -0,0 +1,54 @@
1
+ # LWS Changelog
2
+
3
+ Up until v6.1.0, we used the standard Gem version numbering starting at v0.0.1.
4
+ From v6.1.0 on the version will follow the API version of LWS in the major/minor
5
+ part of te version.
6
+
7
+ ## v6.1.0
8
+
9
+ * Switch to LWS/LeftClick platform release versions
10
+ * Switch to Spyke as the REST ORM library (closes: #10671)
11
+ * Add some Her backward compatibility support
12
+ * Use JSON as the wire format for sending data to LWS
13
+ * Switch to using our own exceptions (see LWS::Errors)
14
+ * Add support for setting the LWS API token in the environment
15
+ * Switch to Pry as the REPL used by the LWS console
16
+ * Add commands to the LWS console to toggle debug options
17
+ * Add option parsing and app/environment/debug mode selection to LWS console
18
+
19
+ ### Apps
20
+
21
+ * Add a first implementation of the Digital Signage app (closes: #11110)
22
+ * Update some fields for the Ticket app (closes: #11997)
23
+ * Add the Reader model to the Presence app, add fields to the Location model
24
+
25
+ ### Development
26
+
27
+ * Reorganize the file structure of the library
28
+ * Add and improve tests and documentation
29
+ * Document and fix model relations throughout all apps
30
+ * Documentation fixes for switch to Spyke
31
+
32
+ ## v0.4.2
33
+
34
+ * Documentation fixes
35
+ * Obtain full test coverage by adding some tests
36
+
37
+ ## v0.4.1
38
+
39
+ * Test improvements; use simplecov for coverage metrics.
40
+
41
+ ## v0.4.0
42
+
43
+ * Add support for the ticket and corporate website app/web service
44
+ * Gem/packaging and documentation fixes
45
+
46
+ ## v0.3.1
47
+
48
+ * Add a release_if_needed task
49
+
50
+
51
+
52
+ ## v0.0.1
53
+
54
+ Initial release
@@ -0,0 +1,85 @@
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.endponts = { 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.
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ Rake::TestTask.new do |t|
22
22
  end
23
23
 
24
24
  YARD::Rake::YardocTask.new do |t|
25
- t.files = ["lib/**/*.rb", "-", "README.rdoc"]
25
+ t.files = ["lib/**/*.rb", "-", "README.md", "CHANGELOG.md"]
26
26
  t.options = ["--no-private",
27
27
  "--title", "LeftClick Web Services Documentation"]
28
28
  end
@@ -43,6 +43,21 @@ module LWS::Presence
43
43
  # @return [Fixnum] the (unique) ID of the location
44
44
  attribute :id
45
45
 
46
+ # @!attribute capacity
47
+ # @return [Fixnum] the capacity (maximum number of people) of the location
48
+ # (including descendant locations)
49
+ attribute :capacity
50
+
51
+ # @!attribute capacity_used
52
+ # @return [Fixnum] the used capacity (present number of people) of the location
53
+ # (including descendant locations)
54
+ attribute :capacity_used
55
+
56
+ # @!attribute capacity_used_percentage
57
+ # @return [Float] the used capacity percentage of the location
58
+ # (including descendant locations)
59
+ attribute :capacity_used_precentage
60
+
46
61
  # @!attribute company
47
62
  # @return [LWS::Auth::Company] the company the location belongs to
48
63
  belongs_to :company, class_name: "LWS::Auth::Company"
@@ -64,10 +79,24 @@ module LWS::Presence
64
79
  # @return [Float] the longitude of the location
65
80
  attribute :long
66
81
 
82
+ # @!attribute map_location_id
83
+ # @note
84
+ # There is not a relation for this at the moment!
85
+ # @return [Fixnum] the ID of the map location associated with the location
86
+ attribute :map_location_id
87
+
67
88
  # @!attribute name
68
89
  # @return [String] the name of the location
69
90
  attribute :name
70
91
 
92
+ # @!attribute parent
93
+ # @return [Location] the parent of the location
94
+ belongs_to :parent, class_name: "LWS::Presence::Location"
95
+
96
+ # @!attribute parent_id
97
+ # @return [Fixnum] the ID of the parent of the location
98
+ attribute :parent_id
99
+
71
100
  # @!attribute people
72
101
  # @return [Array<Person>] the people associated with the location
73
102
  has_many :people
@@ -76,6 +105,10 @@ module LWS::Presence
76
105
  # @return [Integer] the range around the location in meters
77
106
  attribute :range
78
107
 
108
+ # @!attribute readers
109
+ # @return [Array<Reader>] the (RFID/code/ID/...) readers linked to this location
110
+ has_many :readers
111
+
79
112
  # @!attribute created_at [r]
80
113
  # @return [String] the timestamp of when the location was created
81
114
  attribute :created_at
@@ -166,4 +199,37 @@ module LWS::Presence
166
199
  attribute :updated_at
167
200
  end
168
201
 
202
+ # = The reader class
203
+ class Reader < LWS::Generic::Model
204
+ use_api LWS::Presence.api
205
+
206
+ # @!attribute id [r]
207
+ # @return [Fixnum] the (unique) ID of the reader
208
+ attribute :id
209
+
210
+ # @!attribute gateway
211
+ # @return [Fixnum] the (32-bit) LCIO gateway ID of the reader
212
+ attribute :gateway
213
+
214
+ # @!attribute location
215
+ # @return [Location] the location of the reader
216
+ belongs_to :location
217
+
218
+ # @!attribute location_id
219
+ # @return [Fixnum] the ID of the location of the reader
220
+ attribute :location_id
221
+
222
+ # @!attribute node
223
+ # @return [Fixnum] the (8-bit) LCIO gateway node number of the reader
224
+ attribute :node
225
+
226
+ # @!attribute created_at [r]
227
+ # @return [String] the timestamp of when the reader was created
228
+ attribute :created_at
229
+
230
+ # @!attribute updated_at [r]
231
+ # @return [String] the timestamp of when the reader was last updated
232
+ attribute :updated_at
233
+ end
234
+
169
235
  end
@@ -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.1.0.beta6'
16
+ VERSION = '6.1.0'
17
17
 
18
18
  end
@@ -28,6 +28,7 @@ class TestPresenceLocation < MiniTest::Test
28
28
  def test_valid_associations
29
29
  assert_instance_of(LWS::Auth::Company, @location.company)
30
30
  assert_instance_of(Person, @location.people.first)
31
+ assert_instance_of(Reader, @location.readers.first)
31
32
  end
32
33
 
33
34
  end
@@ -52,3 +53,23 @@ class TestPresencePerson < MiniTest::Test
52
53
  end
53
54
 
54
55
  end
56
+
57
+ class TestPresenceReader < MiniTest::Test
58
+
59
+ include LWS::Presence
60
+
61
+ def setup
62
+ @reader = Reader.all.first
63
+ end
64
+
65
+ def test_valid
66
+ refute_nil(@reader)
67
+ assert_instance_of(Reader, @reader)
68
+ refute_nil(@reader.id)
69
+ end
70
+
71
+ def test_valid_associations
72
+ assert_instance_of(Location, @reader.location)
73
+ end
74
+
75
+ 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.1.0.beta6
4
+ version: 6.1.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: 2018-01-18 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday_middleware
@@ -230,8 +230,9 @@ extensions: []
230
230
  extra_rdoc_files: []
231
231
  files:
232
232
  - ".gitignore"
233
+ - CHANGELOG.md
233
234
  - Gemfile
234
- - README.rdoc
235
+ - README.md
235
236
  - Rakefile
236
237
  - bin/lwsconsole
237
238
  - copyright.txt
@@ -284,9 +285,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
284
285
  version: '0'
285
286
  required_rubygems_version: !ruby/object:Gem::Requirement
286
287
  requirements:
287
- - - ">"
288
+ - - ">="
288
289
  - !ruby/object:Gem::Version
289
- version: 1.3.1
290
+ version: '0'
290
291
  requirements: []
291
292
  rubyforge_project:
292
293
  rubygems_version: 2.5.1
@@ -1,75 +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
- gem "lws"
12
-
13
- or install the +ruby-lws+ package.
14
-
15
-
16
- == Usage
17
-
18
- First, you have to initialize the library. For example, with Rails, you
19
- would create a new +config/initializers/lws.rb+ file with these lines:
20
-
21
- # config/initializers/lws.rb
22
- LWS.setup do |config|
23
- config.api_token = "…" # Get it from someplace
24
- end
25
-
26
- After that, due to the fact that LWS is based on
27
- [Spyke](https://github.com/balvig/spyke), you can access the objects in the
28
- LeftClick Web Services similary to many ActiveRecord-like ORM's:
29
-
30
- map = Maps::Map.all.first
31
- markers = map.markers
32
-
33
- company = Company.find(6)
34
- account = Auth::Account.create(name: "Foo Bar",
35
- company: company)
36
-
37
- loc = Presence::Location.where(name: "Test")
38
- loc.destroy
39
-
40
- == Configuration
41
-
42
- The following example uses a much more elaborate setup:
43
-
44
- LWS.setup do |config|
45
- config.api_token_middleware = TokenAuthenticator
46
- config.caching_object = MyRedisCache.new
47
- config.environment = :development
48
- config.endponts = { maps: "https://maps.leftclick.cloud" }
49
- config.http_debug = true
50
- config.json_debug = true
51
- config.logger = Rails.logger
52
- end
53
-
54
- In this setup, a caching object is used that follows the
55
- +FaradayMiddleWare::Caching+ API. It uses all development API endpoints,
56
- except for maps, which is overriden to use the production endpoint. Also
57
- HTTP request and JSON data debug logging is enabled and LWS will use
58
- the Rails logger to log the messages.
59
- Also a custom API token authenticator class is used that should implement
60
- the +Faraday::Middleware+ interface and set the +X-Token+ header with the
61
- runtime determined API token as value, for example:
62
-
63
- class TokenAuthenticator < Faraday::Middleware
64
-
65
- def call(env)
66
- env[:request_headers]["X-Token"] = … # Some calculated token
67
- @app.call(env)
68
- end
69
-
70
- end
71
-
72
- The +LC_LWS_ENV+ environment variable is supported to override the LWS
73
- environment. Allowed values are "production" (default) and "development".
74
- The +LC_LWS_API_TOKEN+ is supported to set the LWS API token default.
75
- This only works if a custom API token middleware is not used.