device_cloud 0.0.7 → 0.0.8

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.
@@ -2,6 +2,12 @@ module DeviceCloud
2
2
  class PushNotification::DataNotification < PushNotification::BaseNotification
3
3
  def initialize(file_data)
4
4
  @file_data = file_data
5
+ @id = data['id']
6
+ end
7
+
8
+ def file_name
9
+ return '' unless id
10
+ id['fdName']
5
11
  end
6
12
 
7
13
  def handle!
@@ -1,3 +1,3 @@
1
1
  module DeviceCloud
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,19 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DeviceCloud::PushNotification::DataNotification do
4
- describe "#handle!" do
5
- let(:data) do
6
- {
7
- 'id' => 1234,
8
- 'device_id' => 'm:1392301029',
9
- 'type' => 'some type',
10
- 'queued_dt' => '2013-06-24T14:52:55.421Z',
11
- 'value' => {'this' => 'is a value'}
12
- }
13
- end
14
- let(:file_data) { OpenStruct.new(data: data, full_path: '/foo/bar/baz.json') }
4
+ let(:data) do
5
+ {
6
+ 'id' => {
7
+ 'fdPath' => '/db/MadGlory/Meter/data/',
8
+ 'fdName' => 'foobar_1.jpg'
9
+ },
10
+ 'device_id' => 'm:1392301029',
11
+ 'type' => 'some type',
12
+ 'queued_dt' => '2013-06-24T14:52:55.421Z',
13
+ 'value' => {'this' => 'is a value'}
14
+ }
15
+ end
16
+ let(:file_data) { OpenStruct.new(data: data, full_path: '/foo/bar/baz.json') }
15
17
 
16
- subject { DeviceCloud::PushNotification::DataNotification.new file_data }
18
+ subject { DeviceCloud::PushNotification::DataNotification.new file_data }
19
+
20
+ describe "#handle!" do
17
21
 
18
22
  it "should call the DeviceCloud.data_notification_handler with self" do
19
23
  handled_data = nil
@@ -23,4 +27,17 @@ describe DeviceCloud::PushNotification::DataNotification do
23
27
  expect(handled_data).to eq subject
24
28
  end
25
29
  end
30
+
31
+ describe "#file_name" do
32
+ context 'when id is present' do
33
+ its(:file_name) { should eq data['id']['fdName']}
34
+ end
35
+
36
+ context 'when id is nil' do
37
+ before(:each) do
38
+ data['id'] = nil
39
+ end
40
+ its(:file_name) { should eq '' }
41
+ end
42
+ end
26
43
  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.7'
5
+ DeviceCloud::VERSION.should == '0.0.8'
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.7
4
+ version: 0.0.8
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 00:00:00.000000000 Z
12
+ date: 2013-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler