device_cloud 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -21,8 +21,13 @@ module DeviceCloud
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def full_path
|
24
|
-
return '' unless id
|
25
|
-
id
|
24
|
+
return '' unless id.size > 0
|
25
|
+
id['fdPath'] + id['fdName']
|
26
|
+
end
|
27
|
+
|
28
|
+
def mac_address
|
29
|
+
return '' unless device_id.size > 0
|
30
|
+
device_id.sub(/\Am:/, '').scan(/.{2}|.+/).join(':')
|
26
31
|
end
|
27
32
|
|
28
33
|
def data
|
data/lib/device_cloud/utils.rb
CHANGED
data/lib/device_cloud/version.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe DeviceCloud::PushNotification::Base do
|
4
4
|
let(:data) do
|
5
5
|
{
|
6
|
-
'id' =>
|
6
|
+
'id' => {'fdPath' => '/some/place/','fdName' => 'file_name.json'},
|
7
7
|
'device_id' => 'm:1392301029',
|
8
8
|
'type' => 'some type',
|
9
9
|
'queued_dt' => '2013-06-24T14:52:55.421Z',
|
@@ -27,4 +27,32 @@ describe DeviceCloud::PushNotification::Base do
|
|
27
27
|
expect{subject.handle!}.to raise_error NotImplementedError
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
describe "#mac_address" do
|
32
|
+
context "when device_id present" do
|
33
|
+
its(:mac_address) { should eq('13:92:30:10:29') }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when device_id blank' do
|
37
|
+
before(:each) do
|
38
|
+
data['device_id'] = ''
|
39
|
+
end
|
40
|
+
|
41
|
+
its(:mac_address) { should eq '' }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#full_path" do
|
46
|
+
context "when id present" do
|
47
|
+
its(:full_path) { should eq(data['id']['fdPath'] + data['id']['fdName']) }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when id not present' do
|
51
|
+
before(:each) do
|
52
|
+
data['id'] = ''
|
53
|
+
end
|
54
|
+
|
55
|
+
its(:full_path) { should eq '' }
|
56
|
+
end
|
57
|
+
end
|
30
58
|
end
|
data/spec/version_spec.rb
CHANGED