fluent-plugin-sakuraio 0.0.2 → 0.0.3

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: 88678ef837d3289a1c316c2b532c5d848c962fe7
4
- data.tar.gz: c5dbe0513449af18861ef7691eb7433c126f9d29
3
+ metadata.gz: 6712d46b36dde0fe009071239eb134000000772c
4
+ data.tar.gz: 6056609261455bfe84e5c6ea80870b5ac2eb1f49
5
5
  SHA512:
6
- metadata.gz: c93c20285c968dd13139bcda3547e2cd1fa8d88a7bf17298fb50c4dd4672a55808b43dbca5c04b14fbaee99e070046591a6921c479a006aaec93a47f551ddde9
7
- data.tar.gz: 49d1bda1432c942c0a1a34e5ee042876c035670418c2227a713f3d31bd857b68c8870bb47f5e2d1a6fc4ac2ccabb97d4bf267f18c7ca79296104a8159b1a70ed
6
+ metadata.gz: 32b94b4200dd4579a9bb50ba5a529c82e8a825ba4ba9943c6185e53f1954a09efae3cf4438c275a8a988e33303671b45f9ba0d90f08cc2bfeffd1dec7afb944c
7
+ data.tar.gz: c9033ee4c315d830bbc9aabb1bed03606ed154a5d665d624023b6f4ae3f727d79bfd421546412ad0c6998e35bbdd8897d332bf061dbb37537a6fb5765844ae91
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'fluent-plugin-sakuraio'
7
- spec.version = '0.0.2'
7
+ spec.version = '0.0.3'
8
8
  spec.authors = ['Yuya Kusakabe']
9
9
  spec.email = ['yuya.kusakabe@gmail.com']
10
10
 
@@ -61,6 +61,10 @@ module Fluent::Plugin
61
61
  j = parser.parse(text)
62
62
  records = []
63
63
  case j['type']
64
+ when 'connection' then
65
+ parse_connection(records, j)
66
+ when 'location' then
67
+ parse_location(records, j)
64
68
  when 'channels' then
65
69
  parse_channels(records, j)
66
70
  else
@@ -69,12 +73,41 @@ module Fluent::Plugin
69
73
  records
70
74
  end
71
75
 
76
+ def parse_connection(records, j)
77
+ record = {
78
+ 'tag' => j['module'] + '.connection',
79
+ 'record' => {
80
+ 'is_online' => j['payload']['is_online']
81
+ },
82
+ 'time' => Time.parse(j['datetime']).to_i
83
+ }
84
+ records.push(record)
85
+ records
86
+ end
87
+
88
+ def parse_location(records, j)
89
+ c = j['payload']['coordinate']
90
+ if c != 'null'
91
+ record = {
92
+ 'tag' => j['module'] + '.location',
93
+ 'record' => {
94
+ 'latitude' => c['latitude'],
95
+ 'longitude' => c['longitude'],
96
+ 'range_m' => c['range_m']
97
+ },
98
+ 'time' => Time.parse(j['datetime']).to_i
99
+ }
100
+ records.push(record)
101
+ end
102
+ records
103
+ end
104
+
72
105
  def parse_channels(records, j)
73
106
  message_time = Time.parse(j['datetime']).to_i
74
107
  tag = j['module']
75
108
  j['payload']['channels'].each do |c|
76
109
  record = {
77
- 'tag' => tag + '.' + c['channel'].to_s,
110
+ 'tag' => tag + '.channels.' + c['channel'].to_s,
78
111
  'record' => {
79
112
  'channel' => c['channel'],
80
113
  'type' => c['type'],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sakuraio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya Kusakabe