device_cloud 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module DeviceCloud
2
2
  class PushNotification::Base
3
- attr_reader :id, :device_id, :value, :queued_at, :type
3
+ attr_reader :id, :full_path, :device_id, :value, :queued_at, :type
4
4
 
5
5
  def self.handle!(file_data)
6
6
  event = new(file_data)
@@ -10,6 +10,7 @@ module DeviceCloud
10
10
  def initialize(file_data)
11
11
  @file_data = file_data
12
12
  @id = data["id"]
13
+ @full_path = file_data.full_path
13
14
  @device_id = data["device_id"]
14
15
  @type = data["type"]
15
16
  @queued_at = data["queued_dt"]
@@ -20,11 +21,6 @@ module DeviceCloud
20
21
  raise NotImplementedError
21
22
  end
22
23
 
23
- def full_path
24
- return '' unless id.size > 0
25
- id['fdPath'] + id['fdName']
26
- end
27
-
28
24
  def mac_address
29
25
  return '' unless device_id.size > 0
30
26
  device_id.sub(/\Am:/, '').scan(/.{2}|.+/).join(':')
@@ -1,3 +1,3 @@
1
1
  module DeviceCloud
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -3,19 +3,26 @@ require 'spec_helper'
3
3
  describe DeviceCloud::PushNotification::Base do
4
4
  let(:data) do
5
5
  {
6
- 'id' => {'fdPath' => '/some/place/','fdName' => 'file_name.json'},
6
+ 'id' => '1234',
7
7
  'device_id' => 'm:1392301029',
8
8
  'type' => 'some type',
9
9
  'queued_dt' => '2013-06-24T14:52:55.421Z',
10
10
  'value' => {'this' => 'is a value'}
11
11
  }
12
12
  end
13
- let(:file_data) { OpenStruct.new(data: data, full_path: '/foo/bar/baz.json') }
13
+ let(:file_data) do
14
+ OpenStruct.new(
15
+ full_path: '/some/place/file_name.json',
16
+ data: data,
17
+ full_path: '/foo/bar/baz.json'
18
+ )
19
+ end
14
20
 
15
21
  subject { DeviceCloud::PushNotification::Base.new file_data }
16
22
 
17
23
  describe "attributes" do
18
24
  its(:id) { should eq data['id'] }
25
+ its(:full_path) { should eq file_data.full_path }
19
26
  its(:device_id) { should eq data['device_id'] }
20
27
  its(:type) { should eq data['type'] }
21
28
  its(:queued_at) { should eq data['queued_dt'] }
@@ -41,18 +48,4 @@ describe DeviceCloud::PushNotification::Base do
41
48
  its(:mac_address) { should eq '' }
42
49
  end
43
50
  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
58
51
  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.3'
5
+ DeviceCloud::VERSION.should == '0.0.4'
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: