m2x 2.0.0 → 2.0.1

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.
data/lib/m2x/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module M2X
2
2
  class Client
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
data/lib/megatest.rb CHANGED
@@ -3,50 +3,82 @@
3
3
  require "time"
4
4
  require "pp"
5
5
 
6
- require_relative "./m2x"
6
+ require "m2x"
7
+ # require_relative "./m2x"
7
8
 
8
- m2x = M2X::Client.new("cdc032a8d7bfbf1ce5948a8c474eaa25")#, "http://localhost:9393")
9
+ $m2x = M2X::Client.new("cdc032a8d7bfbf1ce5948a8c474eaa25")
10
+ $running = true
9
11
 
10
- arduino = m2x.create_device(name: "My Arduino test", description: "Long test of Ruby gem", visibility: "private")
12
+ stop = Proc.new { $running = false }
11
13
 
12
- arduino.create_stream("temperature")
13
- arduino.create_stream("humidity")
14
- arduino.create_stream("loudness")
14
+ trap(:INT, &stop)
15
+ trap(:TERM, &stop)
15
16
 
16
- arduino.post_updates({
17
- values: {
18
- temperature: [
19
- { timestamp: (Time.now - 2).iso8601, value: rand(0..37) },
20
- { timestamp: (Time.now + 2).iso8601, value: rand(0..37) }
21
- ],
22
- humidity: [
23
- { timestamp: (Time.now - 3).iso8601, value: rand(0..100) },
24
- { timestamp: (Time.now + 3).iso8601, value: rand(0..100) }
25
- ]
26
- },
27
- location: { latitude: 80.3712, longitude: 100, elevation: 300 }
28
- })
17
+ 1.times do |i|
18
+ break unless $running
19
+ puts "Creating device #{i}"
29
20
 
30
- loudness = arduino.stream("loudness")
21
+ device = $m2x.create_device(name: "Test Device #{i}", description: "Some test device", visibility: "public")
22
+ fail $m2x.last_response.inspect if $m2x.last_response.error?
31
23
 
32
- loudness.post_values(1000.times.map{ |i| { timestamp: (Time.now + i).iso8601, value: rand(0..120) } })
24
+ device = $m2x.device(device["id"])
25
+ fail $m2x.last_response.inspect if $m2x.last_response.error?
33
26
 
34
- loudness.update_value(rand(90..9999))
27
+ device.create_stream("testdevicestream", type: "numeric", unit: { label: "points", symbol: "pt" })
28
+ fail $m2x.last_response.inspect if $m2x.last_response.error?
35
29
 
36
- raspberries = m2x.create_distribution(name: "Raspberries", description: "Group of raspberries", visibility: "private")
30
+ stream = device.stream("testdevicestream")
37
31
 
38
- all_raspberries = 10.times.map{ |i| raspberries.add_device(i.to_s) }
32
+ values = 2.times.map{ sleep 0.001; { timestamp: Time.now.utc.iso8601(3), value: rand(0..999999) } }
39
33
 
40
- all_raspberries.each do |device|
41
- device.update_location(latitude: rand(-90..90), longitude: rand(-180..180), elevation: rand(0..7000))
34
+ stream.post_values(values)
35
+ fail $m2x.last_response.inspect if $m2x.last_response.error?
42
36
  end
43
37
 
44
- pp loudness.stats.json
45
- pp loudness.sampling(interval: 1).json
46
- pp loudness.values.json
38
+ puts "All devices created"
47
39
 
48
- loudness.delete_values!((Time.now - 3600).iso8601, Time.now.iso8601)
49
40
 
50
- loudness.delete!
51
- arduino.delete!
52
- raspberries.delete!
41
+ # m2x.api_base = SQL1
42
+ # puts arduino.create_stream("temperature")
43
+ # m2x.api_base = EWR2
44
+ # puts arduino.create_stream("humidity")
45
+ # m2x.api_base = DPA1
46
+ # puts arduino.create_stream("loudness")
47
+
48
+ # arduino.post_updates({
49
+ # values: {
50
+ # temperature: [
51
+ # { timestamp: (Time.now - 2).iso8601, value: rand(0..37) },
52
+ # { timestamp: (Time.now + 2).iso8601, value: rand(0..37) }
53
+ # ],
54
+ # humidity: [
55
+ # { timestamp: (Time.now - 3).iso8601, value: rand(0..100) },
56
+ # { timestamp: (Time.now + 3).iso8601, value: rand(0..100) }
57
+ # ]
58
+ # },
59
+ # location: { latitude: 80.3712, longitude: 100, elevation: 300 }
60
+ # })
61
+
62
+ # loudness = arduino.stream("loudness")
63
+
64
+ # loudness.post_values(1000.times.map{ |i| { timestamp: (Time.now + i).iso8601, value: rand(0..120) } })
65
+
66
+ # loudness.update_value(rand(90..9999))
67
+
68
+ # raspberries = m2x.create_distribution(name: "Raspberries", description: "Group of raspberries", visibility: "private")
69
+
70
+ # all_raspberries = 10.times.map{ |i| raspberries.add_device(i.to_s) }
71
+
72
+ # all_raspberries.each do |device|
73
+ # device.update_location(latitude: rand(-90..90), longitude: rand(-180..180), elevation: rand(0..7000))
74
+ # end
75
+
76
+ # pp loudness.stats.json
77
+ # pp loudness.sampling(interval: 1).json
78
+ # pp loudness.values.json
79
+
80
+ # loudness.delete_values!((Time.now - 3600).iso8601, Time.now.iso8601)
81
+
82
+ # loudness.delete!
83
+ # arduino.delete!
84
+ # raspberries.delete!
data/m2x.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
16
16
  "LICENSE",
17
17
  "README.md",
18
18
  "lib/**/*.rb",
19
+ "lib/m2x/cacert.pem",
19
20
  "*.gemspec",
20
21
  "test/*.*"
21
22
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m2x
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro López
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-26 00:00:00.000000000 Z
13
+ date: 2014-12-30 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: AT&T’s M2X is a cloud-based fully managed data storage service for network
16
16
  connected machine-to-machine (M2M) devices. From trucks and turbines to vending
@@ -27,6 +27,7 @@ files:
27
27
  - LICENSE
28
28
  - README.md
29
29
  - lib/m2x.rb
30
+ - lib/m2x/cacert.pem
30
31
  - lib/m2x/client.rb
31
32
  - lib/m2x/device.rb
32
33
  - lib/m2x/distribution.rb
@@ -57,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
58
  version: '0'
58
59
  requirements: []
59
60
  rubyforge_project:
60
- rubygems_version: 2.2.2
61
+ rubygems_version: 2.4.4
61
62
  signing_key:
62
63
  specification_version: 4
63
64
  summary: Ruby client for AT&T M2X