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.
@@ -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.size > 0
33
+ return '' unless device_id
30
34
  device_id.sub(/\Am:/, '').scan(/.{2}|.+/).join(':')
31
35
  end
32
36
 
@@ -1,10 +1,5 @@
1
1
  module DeviceCloud
2
2
  class PushNotification::DataNotification < PushNotification::BaseNotification
3
-
4
- def raw_data
5
- @file_data.fdData
6
- end
7
-
8
3
  def handle!
9
4
  DeviceCloud.data_notification_handler.call(self)
10
5
  end
@@ -1,3 +1,3 @@
1
1
  module DeviceCloud
2
- VERSION = "0.0.11"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,32 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe DeviceCloud::PushNotification::BaseNotification do
4
- let(:data) do
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
- 'id' => '1234',
7
- 'device_id' => 'm:1392301029',
8
- 'type' => 'some type',
9
- 'queued_dt' => '2013-06-24T14:52:55.421Z',
10
- 'value' => {'this' => 'is a value'}
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
- let(:file_data) do
14
- OpenStruct.new(
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 file_data.full_path }
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:92:30:10:29') }
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
- before(:each) do
49
- data['device_id'] = ''
50
- end
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
- context 'when id is present' do
58
- its(:file_name) { should eq file_data.file_name}
59
- end
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
@@ -32,8 +32,4 @@ describe DeviceCloud::PushNotification::DataNotification do
32
32
  expect(handled_data).to eq subject
33
33
  end
34
34
  end
35
-
36
- describe "#raw_data" do
37
- its(:raw_data) { should eq raw_file_data['fdData'] }
38
- end
39
35
  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.11'
5
+ DeviceCloud::VERSION.should == '0.1.0'
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.11
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-15 00:00:00.000000000 Z
12
+ date: 2013-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler