m2x 0.0.6 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 953d66feeb0f903a566aafd0c9273954cd8cd759
4
- data.tar.gz: d162fdab9078d428eca77d8c23fbbb7605a936e1
3
+ metadata.gz: 070f2ced4954ff8aacc0fddfa8f978a184f10f10
4
+ data.tar.gz: 3775ec1a82b2702a458b01d2d316e6985284683c
5
5
  SHA512:
6
- metadata.gz: 6a40530f1aefd62547d015ce3a6326d2fbdb483d658252b0ea8ca5a77252d238e1d9ea2f48837805b9fe5f23e6cdaded709e4e2584326cd5fc3d84ed376cb537
7
- data.tar.gz: a06f61fad7f52dd0aa9a90cc033f0a3501cfdcf7f44688c88b901eaa73d1250c833858bd8b6c21904133e2da652238552b103603028c81ab3d6bb506b66707fc
6
+ metadata.gz: e7ff4b69bed09f01ee6c409d620dcc35fd5231c4f386fcd8fd14ee402d8d53d269d19f7c325a51972147c2eae7c5768824fd17063867bb1b68905e6829f907a9
7
+ data.tar.gz: 9223ce1c387be2808175a35b6280789eb4728bea561bb926ff66b7e8cc3a82385bac4003e77913d73f90be4d2838e70daacd1732d88effc29d707f0e6c3396b2
data/README.md CHANGED
@@ -17,38 +17,59 @@ Getting Started
17
17
 
18
18
  In order to be able to use this gem you will need an [AT&T M2X](https://m2x.att.com/) API key and a Data Source ID. If you don't have an API key, create an account and, once registered and with your account activated, create a new [Data Source Blueprint](https://m2x.att.com/blueprints), and copy the `Feed ID` and `API Key` values. The following script will send your CPU load average to three different streams named `load_1m`, `load_5m` and `load_15`. Check that there's no need to create a stream in order to write values into it:
19
19
 
20
- #! /usr/bin/env ruby
20
+ ```ruby
21
+ #! /usr/bin/env ruby
21
22
 
22
- #
23
- # See https://github.com/attm2x/m2x-ruby/blob/master/README.md#example-usage
24
- # for instructions
25
- #
23
+ #
24
+ # See https://github.com/attm2x/m2x-ruby/blob/master/README.md#example-usage
25
+ # for instructions
26
+ #
26
27
 
27
- require "m2x"
28
+ require "time"
29
+ require "m2x"
28
30
 
29
- API_KEY = "<YOUR-FEED-API-KEY>"
30
- FEED = "<YOUR-FEED-ID>"
31
+ API_KEY = "<YOUR-FEED-API-KEY>"
32
+ FEED = "<YOUR-FEED-ID>"
31
33
 
32
- m2x = M2X.new(API_KEY)
34
+ m2x = M2X.new(API_KEY)
33
35
 
34
- @run = true
35
- trap(:INT) { @run = false }
36
+ @run = true
37
+ trap(:INT) { @run = false }
36
38
 
37
- # Match `uptime` load averages output for both Linux and OSX
38
- UPTIME_RE = /(\d+\.\d+),? (\d+\.\d+),? (\d+\.\d+)$/
39
+ # Match `uptime` load averages output for both Linux and OSX
40
+ UPTIME_RE = /(\d+\.\d+),? (\d+\.\d+),? (\d+\.\d+)$/
39
41
 
40
- while @run
41
- load_1m, load_5m, load_15m = `uptime`.match(UPTIME_RE).captures
42
+ def load_avg
43
+ `uptime`.match(UPTIME_RE).captures
44
+ end
42
45
 
43
- # Write the different values into AT&T M2X
44
- m2x.feeds.update_stream(FEED, "load_1m", value: load_1m)
45
- m2x.feeds.update_stream(FEED, "load_5m", value: load_5m)
46
- m2x.feeds.update_stream(FEED, "load_15m", value: load_15m)
46
+ # Create the streams if they don't exist
47
+ m2x.feeds.update_stream(FEED, "load_1m")
48
+ m2x.feeds.update_stream(FEED, "load_5m")
49
+ m2x.feeds.update_stream(FEED, "load_15m")
47
50
 
48
- sleep 1
49
- end
51
+ while @run
52
+ load_1m, load_5m, load_15m = load_avg
50
53
 
51
- puts
54
+ # Write the different values into AT&T M2X
55
+ now = Time.now.iso8601
56
+
57
+ values = {
58
+ load_1m: [ { value: load_1m, at: now } ],
59
+ load_5m: [ { value: load_5m, at: now } ],
60
+ load_15m: [ { value: load_15m, at: now } ]
61
+ }
62
+
63
+ res = m2x.feeds.post_multiple(FEED, values)
64
+
65
+ abort res.json["message"] unless res.code == 202
66
+
67
+ sleep 1
68
+ end
69
+
70
+ puts
71
+
72
+ ```
52
73
 
53
74
  You can find the script in [`examples/m2x-uptime.rb`](examples/m2x-uptime.rb).
54
75
 
@@ -66,4 +87,4 @@ Additional labels for pre-release and build metadata are available as extensions
66
87
 
67
88
  ## License
68
89
 
69
- This gem is delivered under the MIT license. See [LICENSE](LICENSE) for the terms.
90
+ This gem is provided under the MIT license. See [LICENSE](LICENSE) for applicable terms.
@@ -85,7 +85,7 @@ class M2X
85
85
  # If the stream doesn't exist it will create it. See
86
86
  # https://m2x.att.com/developer/documentation/feed#Create-Update-Data-Stream
87
87
  # for details.
88
- def update_stream(id, name, params)
88
+ def update_stream(id, name, params={})
89
89
  @client.put("/feeds/#{URI.encode(id)}/streams/#{URI.encode(name)}", {}, params)
90
90
  end
91
91
 
@@ -1,3 +1,3 @@
1
1
  class M2X
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.version = ::M2X::VERSION
8
8
  s.summary = "Ruby client for AT&T M2X"
9
9
  s.description = "AT&T’s M2X is a cloud-based fully managed data storage service for network connected machine-to-machine (M2M) devices. From trucks and turbines to vending machines and freight containers, M2X enables the devices that power your business to connect and share valuable data."
10
- s.authors = ["Leandro López", "Matías Flores"]
11
- s.email = ["inkel.ar@gmail.com", "flores.matias@gmail.com"]
10
+ s.authors = ["Leandro López", "Matías Flores", "Federico Saravia"]
11
+ s.email = ["inkel.ar@gmail.com", "flores.matias@gmail.com", "fedesaravia@gmail.com"]
12
12
  s.homepage = "http://github.com/attm2x/m2x-ruby"
13
13
  s.licenses = ["MIT"]
14
14
 
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: m2x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro López
8
8
  - Matías Flores
9
+ - Federico Saravia
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-03-28 00:00:00.000000000 Z
13
+ date: 2014-09-05 00:00:00.000000000 Z
13
14
  dependencies: []
14
15
  description: AT&T’s M2X is a cloud-based fully managed data storage service for network
15
16
  connected machine-to-machine (M2M) devices. From trucks and turbines to vending
@@ -18,12 +19,14 @@ description: AT&T’s M2X is a cloud-based fully managed data storage service fo
18
19
  email:
19
20
  - inkel.ar@gmail.com
20
21
  - flores.matias@gmail.com
22
+ - fedesaravia@gmail.com
21
23
  executables: []
22
24
  extensions: []
23
25
  extra_rdoc_files: []
24
26
  files:
25
27
  - LICENSE
26
28
  - README.md
29
+ - lib/m2x.rb
27
30
  - lib/m2x/batches.rb
28
31
  - lib/m2x/blueprints.rb
29
32
  - lib/m2x/client.rb
@@ -31,7 +34,6 @@ files:
31
34
  - lib/m2x/feeds.rb
32
35
  - lib/m2x/keys.rb
33
36
  - lib/m2x/version.rb
34
- - lib/m2x.rb
35
37
  - m2x.gemspec
36
38
  homepage: http://github.com/attm2x/m2x-ruby
37
39
  licenses:
@@ -43,17 +45,17 @@ require_paths:
43
45
  - lib
44
46
  required_ruby_version: !ruby/object:Gem::Requirement
45
47
  requirements:
46
- - - '>='
48
+ - - ">="
47
49
  - !ruby/object:Gem::Version
48
50
  version: '0'
49
51
  required_rubygems_version: !ruby/object:Gem::Requirement
50
52
  requirements:
51
- - - '>='
53
+ - - ">="
52
54
  - !ruby/object:Gem::Version
53
55
  version: '0'
54
56
  requirements: []
55
57
  rubyforge_project:
56
- rubygems_version: 2.0.3
58
+ rubygems_version: 2.2.2
57
59
  signing_key:
58
60
  specification_version: 4
59
61
  summary: Ruby client for AT&T M2X