device_cloud 0.0.11 → 0.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.
- data/lib/device_cloud/push_notification/base_notification.rb +5 -1
- data/lib/device_cloud/push_notification/data_notification.rb +0 -5
- data/lib/device_cloud/version.rb +1 -1
- data/spec/device_cloud/push_notification/base_notification_spec.rb +35 -26
- data/spec/device_cloud/push_notification/data_notification_spec.rb +0 -4
- data/spec/version_spec.rb +1 -1
- metadata +2 -2
@@ -25,8 +25,12 @@ module DeviceCloud
|
|
25
25
|
@file_data.file_name
|
26
26
|
end
|
27
27
|
|
28
|
+
def raw_data
|
29
|
+
@file_data.fdData
|
30
|
+
end
|
31
|
+
|
28
32
|
def mac_address
|
29
|
-
return '' unless device_id
|
33
|
+
return '' unless device_id
|
30
34
|
device_id.sub(/\Am:/, '').scan(/.{2}|.+/).join(':')
|
31
35
|
end
|
32
36
|
|
data/lib/device_cloud/version.rb
CHANGED
@@ -1,32 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DeviceCloud::PushNotification::BaseNotification do
|
4
|
-
let(:
|
4
|
+
let(:data_string) { "{\"value\": {}, \"class\": \"alert\", \"queued_dt\": \"2013-06-24T14:47:47Z\", \"type\": \"foo\", \"id\": \"0966595cdcdd11e2abf50013950e6012\", \"device_id\": \"m:0013950E6012\"}" }
|
5
|
+
let(:raw_file_data) do
|
5
6
|
{
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
"id" => {
|
8
|
+
"fdPath" => " /db/4044_MadGlory_Interactive/00000000-00000000-001395FF-FF0E6012/alert/",
|
9
|
+
"fdName" => "foo-0966595cdcdd11e2abf50013950e6012.json"
|
10
|
+
},
|
11
|
+
"fdLastModifiedDate" => "2013-06-24T14:52:55.421Z",
|
12
|
+
"fdSize" => 156,
|
13
|
+
"fdContentType" => "application/json",
|
14
|
+
"fdData" => Base64.encode64(data_string),
|
15
|
+
"fdArchive" => false,
|
16
|
+
"cstId" => 4044,
|
17
|
+
"fdType" => "file",
|
18
|
+
"fdCreatedDate" => "2013-06-24T14:52:55.421Z"
|
11
19
|
}
|
12
20
|
end
|
13
|
-
|
14
|
-
|
15
|
-
full_path: '/some/place/file_name.json',
|
16
|
-
data: data,
|
17
|
-
file_name: 'file_name.json'
|
18
|
-
)
|
19
|
-
end
|
21
|
+
|
22
|
+
let(:file_data) { DeviceCloud::PushNotification::Message::FileData.new raw_file_data }
|
20
23
|
|
21
24
|
subject { DeviceCloud::PushNotification::BaseNotification.new file_data }
|
22
25
|
|
23
26
|
describe "attributes" do
|
24
|
-
its(:id) { should eq data['id'] }
|
25
|
-
its(:full_path) { should eq
|
26
|
-
its(:device_id) { should eq data['device_id'] }
|
27
|
-
its(:type) { should eq data['type'] }
|
28
|
-
its(:queued_at) { should eq data['queued_dt'] }
|
29
|
-
its(:value) { should eq data['value'] }
|
27
|
+
its(:id) { should eq file_data.data['id'] }
|
28
|
+
its(:full_path) { should eq(raw_file_data['id']['fdPath'] + raw_file_data['id']['fdName']) }
|
29
|
+
its(:device_id) { should eq file_data.data['device_id'] }
|
30
|
+
its(:type) { should eq file_data.data['type'] }
|
31
|
+
its(:queued_at) { should eq file_data.data['queued_dt'] }
|
32
|
+
its(:value) { should eq file_data.data['value'] }
|
30
33
|
end
|
31
34
|
|
32
35
|
describe "#data" do
|
@@ -41,21 +44,27 @@ describe DeviceCloud::PushNotification::BaseNotification do
|
|
41
44
|
|
42
45
|
describe "#mac_address" do
|
43
46
|
context "when device_id present" do
|
44
|
-
its(:mac_address) { should eq('13:
|
47
|
+
its(:mac_address) { should eq('00:13:95:0E:60:12') }
|
45
48
|
end
|
46
49
|
|
47
50
|
context 'when device_id blank' do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
+
let(:data_string) { "{\"value\": {}, \"class\": \"alert\", \"queued_dt\": \"2013-06-24T14:47:47Z\", \"type\": \"foo\", \"id\": \"0966595cdcdd11e2abf50013950e6012\", \"device_id\": \"\"}" }
|
52
|
+
|
53
|
+
its(:mac_address) { should eq '' }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when device_id is not present" do
|
57
|
+
let(:data_string) { "{\"value\": {}, \"class\": \"alert\", \"queued_dt\": \"2013-06-24T14:47:47Z\", \"type\": \"foo\", \"id\": \"0966595cdcdd11e2abf50013950e6012\"}" }
|
51
58
|
|
52
59
|
its(:mac_address) { should eq '' }
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
63
|
describe "#file_name" do
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
its(:file_name) { should eq file_data.file_name}
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#raw_data" do
|
68
|
+
its(:raw_data) { should eq raw_file_data['fdData'] }
|
60
69
|
end
|
61
70
|
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.0
|
4
|
+
version: 0.1.0
|
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-08-
|
12
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|