lws 0.4.2 → 6.1.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +4 -2
- data/bin/lwsconsole +32 -35
- data/lib/lws/auth.rb +425 -152
- data/lib/lws/corporate_website.rb +186 -68
- data/lib/lws/digital_signage.rb +1796 -0
- data/lib/lws/generic.rb +46 -50
- data/lib/lws/maps.rb +84 -38
- data/lib/lws/presence.rb +93 -73
- data/lib/lws/stubbing.rb +2 -2
- data/lib/lws/ticket.rb +230 -177
- data/lib/lws/version.rb +2 -2
- data/lib/lws.rb +66 -25
- data/lws.gemspec +3 -2
- data/test/api_token_middleware_test.rb +4 -4
- data/test/auth_test.rb +95 -8
- data/test/corporate_website_test.rb +44 -2
- data/test/digital_signage_test.rb +829 -0
- data/test/fixtures/auth.yml +4 -1
- data/test/fixtures/permissions.yml +0 -4
- data/test/generic_test.rb +0 -17
- data/test/json_parser_test.rb +57 -0
- data/test/logger_test.rb +2 -1
- data/test/maps_test.rb +22 -1
- data/test/presence_test.rb +18 -18
- data/test/setup_test.rb +5 -0
- data/test/stubbing_test.rb +4 -2
- data/test/test_helper.rb +3 -2
- data/test/ticket_test.rb +59 -44
- metadata +43 -24
data/lib/lws/generic.rb
CHANGED
@@ -15,65 +15,61 @@
|
|
15
15
|
module LWS::Generic
|
16
16
|
|
17
17
|
# = The generic model class
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
#
|
19
|
+
# This model forms the base for all LWS models.
|
20
|
+
class Model < Spyke::Base
|
21
21
|
include_root_in_json true
|
22
|
+
|
23
|
+
# @private
|
24
|
+
# @!visibility private
|
25
|
+
#
|
26
|
+
# Adds an attribute for this class.
|
27
|
+
#
|
28
|
+
# @note
|
29
|
+
# This is just a singular version helper method of the +attributes+
|
30
|
+
# method provided by Spyke.
|
31
|
+
# @param [Symbol] name the name of the attribute to add
|
32
|
+
# @return [void]
|
33
|
+
def self.attribute(name)
|
34
|
+
attributes(name)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @private
|
38
|
+
# @!visibility private
|
39
|
+
#
|
40
|
+
# Sets the Faraday API object used for this class. This will used by
|
41
|
+
# Spyke.
|
42
|
+
#
|
43
|
+
# @param api The Faraday connection that makes requests to the API
|
44
|
+
# @return [Faraday] A Faraday connection that makes requests to the API
|
45
|
+
def self.use_api(api)
|
46
|
+
self.connection = api
|
47
|
+
self.include_root_in_json self.name.split("::").last.underscore.to_sym
|
48
|
+
api
|
49
|
+
end
|
22
50
|
end
|
23
51
|
|
24
52
|
# = The configuration class
|
25
53
|
class Configuration < Model
|
26
|
-
|
27
|
-
#
|
28
|
-
|
29
|
-
#@!attribute key
|
30
|
-
# @return [String] the configuration key
|
31
|
-
|
32
|
-
#@!attribute value
|
33
|
-
# @return [String] the configuration value
|
34
|
-
|
35
|
-
#@!attribute created_at
|
36
|
-
# @return [String] the timestamp of when the configuration was created
|
37
|
-
|
38
|
-
#@!attribute updated_at
|
39
|
-
# @return [String] the timestamp of when the configuration was last updated
|
40
|
-
|
41
|
-
self # To ensure that YARD does not skip the attributes of this class
|
42
|
-
end
|
43
|
-
|
44
|
-
# = The task class
|
45
|
-
class Task < Model
|
46
|
-
#@!attribute id [r]
|
47
|
-
# @return [Fixnum] the (unique) ID of the task
|
48
|
-
|
49
|
-
#@!attribute name
|
50
|
-
# @return [String] the name of the task
|
51
|
-
|
52
|
-
#@!attribute interval
|
53
|
-
# @return [Fixnum] the interval in minutes
|
54
|
-
|
55
|
-
#@!attribute function
|
56
|
-
# @return [String] the function to run
|
57
|
-
|
58
|
-
#@!attribute last_ran
|
59
|
-
# @return [String] the time the task was last run
|
60
|
-
|
61
|
-
#@!attribute started
|
62
|
-
# @return [String] the time the task was started
|
63
|
-
|
64
|
-
#@!attribute node_name
|
65
|
-
# @return [String] the name of the node
|
54
|
+
# @!attribute id [r]
|
55
|
+
# @return [Fixnum] the (unique) ID of the configuration
|
56
|
+
attribute :id
|
66
57
|
|
67
|
-
|
68
|
-
#
|
58
|
+
# @!attribute key
|
59
|
+
# @return [String] the configuration key
|
60
|
+
attribute :key
|
69
61
|
|
70
|
-
|
71
|
-
#
|
62
|
+
# @!attribute value
|
63
|
+
# @return [String] the configuration value
|
64
|
+
attribute :value
|
72
65
|
|
73
|
-
|
74
|
-
#
|
66
|
+
# @!attribute created_at [r]
|
67
|
+
# @return [String] the timestamp of when the configuration was created
|
68
|
+
attribute :created_at
|
75
69
|
|
76
|
-
|
70
|
+
# @!attribute updated_at [r]
|
71
|
+
# @return [String] the timestamp of when the configuration was last updated
|
72
|
+
attribute :updated_at
|
77
73
|
end
|
78
74
|
|
79
75
|
end
|
data/lib/lws/maps.rb
CHANGED
@@ -20,7 +20,7 @@ module LWS::Maps
|
|
20
20
|
end
|
21
21
|
# :nocov:
|
22
22
|
|
23
|
-
|
23
|
+
# @!visibility private
|
24
24
|
def self.api
|
25
25
|
LWS.setup_api(LWS.config.endpoints[:maps] ||
|
26
26
|
ENDPOINT[LWS.config.environment])
|
@@ -33,72 +33,118 @@ module LWS::Maps
|
|
33
33
|
use_api LWS::Maps.api
|
34
34
|
end
|
35
35
|
|
36
|
-
# (see Generic::Task)
|
37
|
-
class Task < LWS::Generic::Task
|
38
|
-
use_api LWS::Maps.api
|
39
|
-
end
|
40
|
-
|
41
36
|
### App specific classes
|
42
37
|
|
43
38
|
# = The map class
|
44
39
|
class Map < LWS::Generic::Model
|
45
40
|
use_api LWS::Maps.api
|
46
41
|
|
47
|
-
|
48
|
-
#
|
42
|
+
# @!attribute id [r]
|
43
|
+
# @return [Fixnum] the (unique) ID of the map
|
44
|
+
attribute :id
|
49
45
|
|
50
|
-
|
51
|
-
#
|
46
|
+
# @!attribute company
|
47
|
+
# @return [LWS::Auth::Company] the company that maintains/owns the map
|
52
48
|
belongs_to :company, class_name: "LWS::Auth::Company"
|
53
49
|
|
54
|
-
|
55
|
-
#
|
50
|
+
# @!attribute company_id
|
51
|
+
# @return [Fixnum] the ID of the company that maintains/owns the map
|
52
|
+
attribute :company_id
|
56
53
|
|
57
|
-
|
58
|
-
#
|
54
|
+
# @!attribute markers
|
55
|
+
# @return [Array<Marker>] the list of associated markers
|
59
56
|
has_many :markers
|
60
57
|
|
61
|
-
|
62
|
-
#
|
58
|
+
# @!attribute name
|
59
|
+
# @return [String] the name of the map
|
60
|
+
attribute :name
|
61
|
+
|
62
|
+
# @!attribute source
|
63
|
+
# @return [Source] the map source used for tiling the map
|
64
|
+
belongs_to :source
|
63
65
|
|
64
|
-
|
65
|
-
#
|
66
|
+
# @!attribute source_id
|
67
|
+
# @return [Fixnum] the ID of the map source used for tiling the map
|
68
|
+
attribute :source_id
|
66
69
|
|
67
|
-
|
68
|
-
#
|
70
|
+
# @!attribute created_at [r]
|
71
|
+
# @return [String] the timestamp of when the map was created
|
72
|
+
attribute :created_at
|
73
|
+
|
74
|
+
# @!attribute updated_at [r]
|
75
|
+
# @return [String] the timestamp of when the map was last updated
|
76
|
+
attribute :updated_at
|
69
77
|
end
|
70
78
|
|
71
79
|
# = The map marker class
|
72
80
|
class Marker < LWS::Generic::Model
|
73
81
|
use_api LWS::Maps.api
|
74
82
|
|
75
|
-
|
76
|
-
#
|
83
|
+
# @!attribute id [r]
|
84
|
+
# @return [Fixnum] the (unique) ID of the map marker
|
85
|
+
attribute :id
|
86
|
+
|
87
|
+
# @attribute lat
|
88
|
+
# @return [String, nil] the latitude of the map marker
|
89
|
+
attribute :lat
|
90
|
+
|
91
|
+
# @attribute long
|
92
|
+
# @return [String, nil] the longitued of the map marker
|
93
|
+
attribute :long
|
77
94
|
|
78
|
-
|
79
|
-
#
|
95
|
+
# @!attribute map
|
96
|
+
# @return [Map] the map that the marker is placed on
|
80
97
|
belongs_to :map
|
81
98
|
|
82
|
-
|
83
|
-
#
|
99
|
+
# @!attribute map_id
|
100
|
+
# @return [Fixnum] the ID of the map that the marker is placed on
|
101
|
+
attribute :map_id
|
102
|
+
|
103
|
+
# @!attribute name
|
104
|
+
# @return [String] the name of the map marker
|
105
|
+
attribute :name
|
106
|
+
|
107
|
+
# @attribute website
|
108
|
+
# @return [String, nil] the website URL of the map marker
|
109
|
+
attribute :website
|
110
|
+
|
111
|
+
# @!attribute created_at [r]
|
112
|
+
# @return [String] the timestamp of when the map marker was created
|
113
|
+
attribute :created_at
|
114
|
+
|
115
|
+
# @!attribute updated_at [r]
|
116
|
+
# @return [String] the timestamp of when the map marker was last updated
|
117
|
+
attribute :updated_at
|
118
|
+
end
|
119
|
+
|
120
|
+
# = The map source class
|
121
|
+
class Source < LWS::Generic::Model
|
122
|
+
use_api LWS::Maps.api
|
84
123
|
|
85
|
-
|
86
|
-
#
|
124
|
+
# @!attribute id [r]
|
125
|
+
# @return [Fixnum] the (unique) ID of the map source
|
126
|
+
attribute :id
|
87
127
|
|
88
|
-
|
89
|
-
#
|
128
|
+
# @!attribute key
|
129
|
+
# @return [String] the key used by the map implementation to select the
|
130
|
+
# map source
|
131
|
+
attribute :key
|
90
132
|
|
91
|
-
|
92
|
-
#
|
133
|
+
# @!attribute maps
|
134
|
+
# @return [Array<Map>] the maps using the map source
|
135
|
+
has_many :maps
|
93
136
|
|
94
|
-
|
95
|
-
#
|
137
|
+
# @!attribute name
|
138
|
+
# @return [String] the name of the map source
|
139
|
+
attribute :name
|
96
140
|
|
97
|
-
|
98
|
-
#
|
141
|
+
# @!attribute created_at [r]
|
142
|
+
# @return [String] the timestamp of when the map source was created
|
143
|
+
attribute :created_at
|
99
144
|
|
100
|
-
|
101
|
-
#
|
145
|
+
# @!attribute updated_at [r]
|
146
|
+
# @return [String] the timestamp of when the map source was last updated
|
147
|
+
attribute :updated_at
|
102
148
|
end
|
103
149
|
|
104
150
|
end
|
data/lib/lws/presence.rb
CHANGED
@@ -20,7 +20,7 @@ module LWS::Presence
|
|
20
20
|
end
|
21
21
|
# :nocov:
|
22
22
|
|
23
|
-
|
23
|
+
# @!visibility private
|
24
24
|
def self.api
|
25
25
|
LWS.setup_api(LWS.config.endpoints[:presence] ||
|
26
26
|
ENDPOINT[LWS.config.environment])
|
@@ -33,117 +33,137 @@ module LWS::Presence
|
|
33
33
|
use_api LWS::Presence.api
|
34
34
|
end
|
35
35
|
|
36
|
-
# (see Generic::Task)
|
37
|
-
class Task < LWS::Generic::Task
|
38
|
-
use_api LWS::Presence.api
|
39
|
-
end
|
40
|
-
|
41
36
|
### App specific classes
|
42
37
|
|
43
38
|
# = The location class
|
44
39
|
class Location < LWS::Generic::Model
|
45
40
|
use_api LWS::Presence.api
|
46
41
|
|
47
|
-
|
48
|
-
#
|
42
|
+
# @!attribute id [r]
|
43
|
+
# @return [Fixnum] the (unique) ID of the location
|
44
|
+
attribute :id
|
49
45
|
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
|
-
#@!attribute lat
|
54
|
-
# @return [Float] the latitude of the location
|
46
|
+
# @!attribute company
|
47
|
+
# @return [LWS::Auth::Company] the company the location belongs to
|
48
|
+
belongs_to :company, class_name: "LWS::Auth::Company"
|
55
49
|
|
56
|
-
|
57
|
-
#
|
50
|
+
# @!attribute company_id
|
51
|
+
# @return [Fixnum] the ID of the company the location belongs to
|
52
|
+
attribute :company_id
|
58
53
|
|
59
|
-
|
60
|
-
#
|
54
|
+
# @!attribute lat
|
55
|
+
# @return [Float] the latitude of the location
|
56
|
+
attribute :lat
|
61
57
|
|
62
|
-
|
63
|
-
#
|
64
|
-
#
|
58
|
+
# @!attribute logoff_time
|
59
|
+
# @return [String] the time everybody is automatically logged off
|
60
|
+
# (format HH:MM)
|
61
|
+
attribute :logoff_time
|
65
62
|
|
66
|
-
|
67
|
-
#
|
68
|
-
|
63
|
+
# @!attribute long
|
64
|
+
# @return [Float] the longitude of the location
|
65
|
+
attribute :long
|
69
66
|
|
70
|
-
|
71
|
-
#
|
67
|
+
# @!attribute name
|
68
|
+
# @return [String] the name of the location
|
69
|
+
attribute :name
|
72
70
|
|
73
|
-
|
74
|
-
#
|
71
|
+
# @!attribute people
|
72
|
+
# @return [Array<Person>] the people associated with the location
|
75
73
|
has_many :people
|
76
74
|
|
77
|
-
|
78
|
-
#
|
75
|
+
# @!attribute range
|
76
|
+
# @return [Integer] the range around the location in meters
|
77
|
+
attribute :range
|
78
|
+
|
79
|
+
# @!attribute created_at [r]
|
80
|
+
# @return [String] the timestamp of when the location was created
|
81
|
+
attribute :created_at
|
79
82
|
|
80
|
-
|
81
|
-
#
|
83
|
+
# @!attribute updated_at [r]
|
84
|
+
# @return [String] the timestamp of when the location was last updated
|
85
|
+
attribute :updated_at
|
82
86
|
end
|
83
|
-
|
87
|
+
|
84
88
|
# = The person class
|
85
89
|
class Person < LWS::Generic::Model
|
86
90
|
use_api LWS::Presence.api
|
87
91
|
|
88
|
-
|
89
|
-
#
|
92
|
+
# @!attribute id [r]
|
93
|
+
# @return [Fixnum] the (unique) ID of the person
|
94
|
+
attribute :id
|
90
95
|
|
91
|
-
|
92
|
-
#
|
96
|
+
# @!attribute company
|
97
|
+
# @return [LWS::Auth::Company] the company the person belongs to
|
98
|
+
belongs_to :company, class_name: "LWS::Auth::Company"
|
93
99
|
|
94
|
-
|
95
|
-
# @return [
|
96
|
-
|
100
|
+
# @!attribute company_id
|
101
|
+
# @return [Fixnum] the ID of the company the person belongs to
|
102
|
+
attribute :company_id
|
97
103
|
|
98
|
-
|
99
|
-
#
|
104
|
+
# @!attribute customer_reference
|
105
|
+
# @return [String, nil] the customer specific reference for the person
|
106
|
+
attribute :customer_reference
|
100
107
|
|
101
|
-
|
102
|
-
# @return [
|
103
|
-
|
108
|
+
# @!attribute ero
|
109
|
+
# @return [Boolean] whether the person is emergency response
|
110
|
+
# certified
|
111
|
+
attribute :ero
|
104
112
|
|
105
|
-
|
106
|
-
#
|
113
|
+
# @!attribute extra_info
|
114
|
+
# @return [String, nil] some extra info for the person
|
115
|
+
attribute :extra_info
|
107
116
|
|
108
|
-
|
109
|
-
#
|
117
|
+
# @!attribute last_sync
|
118
|
+
# @return [String, nil] the last date/time the status was updated via a
|
119
|
+
# device or RFID tag
|
120
|
+
attribute :last_sync
|
110
121
|
|
111
|
-
|
112
|
-
#
|
122
|
+
# @!attribute lat
|
123
|
+
# @return [Float, nil] the exact latitude of the person's location
|
124
|
+
attribute :lat
|
113
125
|
|
114
|
-
|
115
|
-
#
|
116
|
-
|
126
|
+
# @!attribute long
|
127
|
+
# @return [Float, nil] the exact longitude of the person's location
|
128
|
+
attribute :long
|
117
129
|
|
118
|
-
|
119
|
-
#
|
130
|
+
# @!attribute location
|
131
|
+
# @return [Location] the location the person is located at
|
120
132
|
belongs_to :location
|
121
133
|
|
122
|
-
|
123
|
-
#
|
134
|
+
# @!attribute location_id
|
135
|
+
# @return [Fixnum] the ID of the location the person is located at
|
136
|
+
attribute :location_id
|
124
137
|
|
125
|
-
|
126
|
-
#
|
138
|
+
# @!attribute name
|
139
|
+
# @return [String] the name of the person
|
140
|
+
attribute :name
|
127
141
|
|
128
|
-
|
129
|
-
#
|
142
|
+
# @!attribute picture_url
|
143
|
+
# @return [String, nil] the URL of the picture of the person
|
144
|
+
attribute :picture_url
|
130
145
|
|
131
|
-
|
132
|
-
#
|
133
|
-
|
146
|
+
# @!attribute rfid
|
147
|
+
# @return [String, nil] the RFID tag ID linked to the person
|
148
|
+
attribute :rfid
|
134
149
|
|
135
|
-
|
136
|
-
#
|
150
|
+
# @!attribute status
|
151
|
+
# @return ["available", "busy", "away", "disabled", nil]
|
152
|
+
# the presence status of the person
|
153
|
+
attribute :status
|
137
154
|
|
138
|
-
|
139
|
-
#
|
140
|
-
#
|
155
|
+
# @!attribute udid
|
156
|
+
# @return [String, nil] the unique device ID (e.g. of a mobile phone)
|
157
|
+
# linked to the person
|
158
|
+
attribute :udid
|
141
159
|
|
142
|
-
|
143
|
-
#
|
160
|
+
# @!attribute created_at [r]
|
161
|
+
# @return [String] the timestamp of when the person was created
|
162
|
+
attribute :created_at
|
144
163
|
|
145
|
-
|
146
|
-
#
|
164
|
+
# @!attribute updated_at [r]
|
165
|
+
# @return [String] the timestamp of when the person was last updated
|
166
|
+
attribute :updated_at
|
147
167
|
end
|
148
168
|
|
149
169
|
end
|
data/lib/lws/stubbing.rb
CHANGED
@@ -96,8 +96,8 @@ module LWS
|
|
96
96
|
{}
|
97
97
|
end
|
98
98
|
raise "fixture #{fixture_name} not found (app: #{app_name}, URI: #{path})" unless fixture
|
99
|
-
|
100
|
-
app_endpoint_uri =
|
99
|
+
app_module = LWS.app_module(app_name)
|
100
|
+
app_endpoint_uri = app_module.api.url_prefix.dup
|
101
101
|
app_endpoint_uri.path = path
|
102
102
|
full_uri = "%s://%s:%s%s" % [app_endpoint_uri.scheme,
|
103
103
|
app_endpoint_uri.host,
|