device_cloud 0.0.2 → 0.0.3

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.
@@ -21,8 +21,13 @@ module DeviceCloud
21
21
  end
22
22
 
23
23
  def full_path
24
- return '' unless id
25
- id.join
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
@@ -1,9 +1,5 @@
1
1
  module DeviceCloud
2
2
  module Utils
3
- def mac_address_from_device_id(device_id)
4
- device_id.sub(/\Am:/, '').scan(/.{2}|.+/).join(':')
5
- end
6
-
7
3
  def constantize(string)
8
4
  string.split("::").inject(Module) {|acc, val| acc.const_get(val)}
9
5
  end
@@ -1,3 +1,3 @@
1
1
  module DeviceCloud
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe DeviceCloud::PushNotification::Base do
4
4
  let(:data) do
5
5
  {
6
- 'id' => 1234,
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
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe 'DeviceCloud::VERSION' do
4
4
  it 'should be the correct version' do
5
- DeviceCloud::VERSION.should == '0.0.2'
5
+ DeviceCloud::VERSION.should == '0.0.3'
6
6
  end
7
7
  end
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: