device_cloud 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -32,7 +32,7 @@ TODO: Write usage instructions here
|
|
32
32
|
"topic": "4044/FileData/db/4044_MadGlory_Interactive/00000000-00000000-001395FF-FF0E6017/event/parking_lot_event_exit-0966595cdcdd11e2abf50013950e6017.json",
|
33
33
|
"FileData": {
|
34
34
|
"id": {
|
35
|
-
"fdPath": "
|
35
|
+
"fdPath": "/db/4044_MadGlory_Interactive/00000000-00000000-001395FF-FF0E6017/event/",
|
36
36
|
"fdName": "parking_lot_event_exit-0966595cdcdd11e2abf50013950e6017.json"
|
37
37
|
},
|
38
38
|
"fdLastModifiedDate": "2013-10-21T19:34:56Z",
|
@@ -2,6 +2,8 @@ module DeviceCloud
|
|
2
2
|
class PushNotification::Message
|
3
3
|
attr_accessor :timestamp, :topic, :file_data, :operation, :group, :replay
|
4
4
|
|
5
|
+
KNOWN_TOPICS = %w{ event data alert }
|
6
|
+
|
5
7
|
def self.parse_raw_messages(raw_message_data)
|
6
8
|
if raw_message_data.is_a? Array
|
7
9
|
messages = raw_message_data.map {|message| new(message) }
|
@@ -22,6 +24,10 @@ module DeviceCloud
|
|
22
24
|
DeviceCloud.logger.info "DeviceCloud::PushNotification::Message Invalid (no FileData) - #{topic}" unless valid?
|
23
25
|
end
|
24
26
|
|
27
|
+
def topic_type
|
28
|
+
topic_matches.first
|
29
|
+
end
|
30
|
+
|
25
31
|
def parsed_file_data
|
26
32
|
return false unless valid?
|
27
33
|
@parsed_file_data ||= FileData.new file_data
|
@@ -34,5 +40,9 @@ module DeviceCloud
|
|
34
40
|
def valid?
|
35
41
|
!!file_data
|
36
42
|
end
|
43
|
+
private
|
44
|
+
def topic_matches
|
45
|
+
topic.split('/') & KNOWN_TOPICS
|
46
|
+
end
|
37
47
|
end
|
38
48
|
end
|
data/lib/device_cloud/version.rb
CHANGED
@@ -155,4 +155,9 @@ describe DeviceCloud::PushNotification::Message do
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
describe "#topic_type" do
|
160
|
+
subject { DeviceCloud::PushNotification::Message.new single_raw_message }
|
161
|
+
its(:topic_type) { should eq(single_raw_message['topic'].split('/')[5]) }
|
162
|
+
end
|
158
163
|
end
|
data/spec/version_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: device_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|