lex-influxdb 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: eb708108c27813912bec30b3b123712f241223c54e99900f0ae8c791684d863c
4
- data.tar.gz: 2abf3880ed1c8c7a7a991a2252503b29ce2be314498d6507af91d6cdfe3b9360
3
+ metadata.gz: ed3d5e8ac4f393e87b8051e804f0dca5986acfa295b3311874e9c3225a2de543
4
+ data.tar.gz: 822d4205e2ee398f6039c247739a644df0b2396bca25e44cdc11a7e6b5e97832
5
5
  SHA512:
6
- metadata.gz: b6d0a953d057a4ee8ebbbabe65e78a7ceb1e14f0b36b4df6d752290f6c975e0755a1672cdeb392a985537343df37be808cf1eaaefbbec48a7e8fc0868e388cb8
7
- data.tar.gz: 7265308ed5f1e796b53efeebc7d65a9c08de2ff51e5fe8202eb985722b17134cdb832d6ed3ba074946b72bbf091bc0ac186c52fae8d9ad7781d035ff28c86373
6
+ metadata.gz: ba9df55e0fe0dc9930c113d13c7d7610e1e70f5f484ec78b4b1073bc067950ff440a4f2f14f0d85791f416596b32d8ecaf57491826b43255fa51d4e2713d5730
7
+ data.tar.gz: f2f33e818f035668f96ab6c10ec809202656e4058ea92517d15f52ec5f4f1d88f6a8283e53683cc29d94db2abd7d59e6fe9287f148c2d7df60cd3a3259a87bd2
@@ -6,6 +6,8 @@ Metrics/ClassLength:
6
6
  Max: 1500
7
7
  Metrics/BlockLength:
8
8
  Max: 50
9
+ Metrics/ParameterLists:
10
+ Max: 10
9
11
  Layout/SpaceAroundEqualsInParameterDefault:
10
12
  EnforcedStyle: space
11
13
  Style/SymbolArray:
@@ -17,6 +19,7 @@ Style/Documentation:
17
19
  Enabled: false
18
20
  AllCops:
19
21
  TargetRubyVersion: 2.5
22
+ NewCops: enable
20
23
  Style/FrozenStringLiteralComment:
21
24
  Enabled: false
22
25
  Naming/FileName:
@@ -1,19 +1,135 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lex-influxdb (0.1.1)
4
+ lex-influxdb (0.1.2)
5
5
  influxdb
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ amq-protocol (2.3.2)
11
+ ast (2.4.1)
12
+ aws-eventstream (1.1.0)
13
+ aws-sigv4 (1.2.2)
14
+ aws-eventstream (~> 1, >= 1.0.2)
15
+ bunny (2.16.1)
16
+ amq-protocol (~> 2.3, >= 2.3.1)
17
+ concurrent-ruby (1.1.7)
18
+ concurrent-ruby-ext (1.1.7)
19
+ concurrent-ruby (= 1.1.7)
20
+ connection_pool (2.2.3)
21
+ daemons (1.3.1)
22
+ dalli (2.7.10)
23
+ diff-lcs (1.4.4)
24
+ docile (1.3.2)
25
+ faraday (1.0.1)
26
+ multipart-post (>= 1.2, < 3)
27
+ faraday_middleware (1.0.0)
28
+ faraday (~> 1.0)
29
+ ffi (1.13.1)
30
+ hashdiff (1.0.1)
10
31
  influxdb (0.8.0)
32
+ legion-cache (1.0.0)
33
+ connection_pool
34
+ dalli
35
+ redis
36
+ legion-crypt (0.2.0)
37
+ rbnacl
38
+ vault
39
+ legion-data (0.2.0)
40
+ legion-logging
41
+ legion-settings
42
+ mysql2
43
+ sequel
44
+ legion-exceptions (1.1.0)
45
+ legion-json (1.1.0)
46
+ multi_json
47
+ legion-logging (1.1.0)
48
+ rainbow (~> 3)
49
+ legion-settings (1.1.1)
50
+ legion-json
51
+ legion-logging
52
+ legion-transport (1.1.1)
53
+ bunny
54
+ concurrent-ruby
55
+ legionio (0.2.0)
56
+ concurrent-ruby
57
+ concurrent-ruby-ext
58
+ daemons
59
+ hashdiff
60
+ legion-cache
61
+ legion-crypt
62
+ legion-data
63
+ legion-exceptions
64
+ legion-json
65
+ legion-logging
66
+ legion-settings
67
+ legion-transport
68
+ sleepiq
69
+ vault
70
+ multi_json (1.15.0)
71
+ multipart-post (2.1.1)
72
+ mysql2 (0.5.3)
73
+ parallel (1.19.2)
74
+ parser (2.7.1.4)
75
+ ast (~> 2.4.1)
76
+ rainbow (3.0.0)
77
+ rake (13.0.1)
78
+ rbnacl (7.1.1)
79
+ ffi
80
+ redis (4.2.1)
81
+ regexp_parser (1.7.1)
82
+ rexml (3.2.4)
83
+ rspec (3.9.0)
84
+ rspec-core (~> 3.9.0)
85
+ rspec-expectations (~> 3.9.0)
86
+ rspec-mocks (~> 3.9.0)
87
+ rspec-core (3.9.2)
88
+ rspec-support (~> 3.9.3)
89
+ rspec-expectations (3.9.2)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.9.0)
92
+ rspec-mocks (3.9.1)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.9.0)
95
+ rspec-support (3.9.3)
96
+ rubocop (0.89.1)
97
+ parallel (~> 1.10)
98
+ parser (>= 2.7.1.1)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ regexp_parser (>= 1.7)
101
+ rexml
102
+ rubocop-ast (>= 0.3.0, < 1.0)
103
+ ruby-progressbar (~> 1.7)
104
+ unicode-display_width (>= 1.4.0, < 2.0)
105
+ rubocop-ast (0.3.0)
106
+ parser (>= 2.7.1.4)
107
+ ruby-progressbar (1.10.1)
108
+ sequel (5.35.0)
109
+ simplecov (0.19.0)
110
+ docile (~> 1.1)
111
+ simplecov-html (~> 0.11)
112
+ simplecov-html (0.12.2)
113
+ sleepiq (0.2.2)
114
+ dalli
115
+ faraday
116
+ faraday_middleware
117
+ thor
118
+ thor (1.0.1)
119
+ unicode-display_width (1.7.0)
120
+ vault (0.15.0)
121
+ aws-sigv4
11
122
 
12
123
  PLATFORMS
13
124
  ruby
14
125
 
15
126
  DEPENDENCIES
127
+ legionio
16
128
  lex-influxdb!
129
+ rake
130
+ rspec
131
+ rubocop
132
+ simplecov
17
133
 
18
134
  BUNDLED WITH
19
135
  2.1.4
data/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # Legion::Extensions::Influxdb
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/legion/extensions/influxdb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
3
+ Used to connect Legion with InfluxDB
5
4
 
6
5
  ## Installation
7
6
 
8
7
  Add this line to your application's Gemfile:
9
8
 
10
9
  ```ruby
11
- gem 'legion-extensions-influxdb'
10
+ gem 'lex-influxdb'
12
11
  ```
13
12
 
14
13
  And then execute:
@@ -17,22 +16,22 @@ And then execute:
17
16
 
18
17
  Or install it yourself as:
19
18
 
20
- $ gem install legion-extensions-influxdb
19
+ $ gem install lex-influxdb
20
+
21
+ ## Adding to Legion
22
+ You can manually install with a `gem install lex-influxdb` command or by adding it into your settings with something like this
23
+ ```json
24
+ {
25
+ "extensions": {
26
+ "influxdb": {
27
+ "enabled": true, "workers": 1
28
+ }
29
+ }
30
+ }
31
+ ```
21
32
 
22
33
  ## Usage
23
-
24
- TODO: Write usage instructions here
25
-
26
- ## Development
27
-
28
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
-
30
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
-
32
- ## Contributing
33
-
34
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/legion-extensions-influxdb.
35
-
34
+ *To be updated*
36
35
 
37
36
  ## License
38
37
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Used to connect Legion to influxdb'
13
13
  spec.homepage = 'https://bitbucket.org/legion-io/lex-influxdb'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/lex-influxdb/src'
@@ -23,9 +23,13 @@ Gem::Specification.new do |spec|
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  end
26
- spec.bindir = 'exe'
27
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
27
  spec.require_paths = ['lib']
29
28
 
30
29
  spec.add_dependency 'influxdb'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'rspec'
32
+ spec.add_development_dependency 'rubocop'
33
+ spec.add_development_dependency 'legionio'
34
+ spec.add_development_dependency 'simplecov'
31
35
  end
@@ -2,7 +2,8 @@ module Legion::Extensions::Influxdb
2
2
  module Helpers
3
3
  module Client
4
4
  def client(**_opts)
5
- @client ||= InfluxBD::Client.new
5
+ # @client ||= InfluxBD::Client.new
6
+ @client ||= InfluxBD::Client.new('esphome', { host: 'influx.home.whonodes.org', async: false })
6
7
  end
7
8
 
8
9
  def host
@@ -6,12 +6,19 @@ module Legion::Extensions::Influxdb
6
6
  {}
7
7
  end
8
8
 
9
- def self.write_points(metrics:, host: 'localhost', port: 8086, database: 'telegraf', **_opts)
10
- client = InfluxDB::Client.new(database, host: host, port: port)
9
+ def self.write_points(metrics:, host: 'localhost', port: 8086, database: 'telegraf', time_precision: 'ms', **_opts)
10
+ settings[:client] ||= InfluxDB::Client.new(database, host: host, port: port, async: false)
11
+ metrics = Legion::JSON.load(metrics) if metrics.is_a? String
12
+ if metrics[:timestamp].nil?
13
+ metrics[:timestamp] = Time.now.to_i
14
+ time_precision = 's'
15
+ end
11
16
 
12
- client.write_points(metrics)
17
+ settings[:client].write_point('sensors', metrics, time_precision)
13
18
  {}
14
19
  end
20
+
21
+ include Legion::Extensions::Helpers::Lex
15
22
  end
16
23
  end
17
24
  end
@@ -1,7 +1,7 @@
1
1
  module Legion
2
2
  module Extensions
3
3
  module Influxdb
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.2'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: influxdb
@@ -24,6 +24,76 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: legionio
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
27
97
  description: Used to connect Legion to influxdb
28
98
  email:
29
99
  - matthewdiverson@gmail.com
@@ -33,7 +103,6 @@ extra_rdoc_files: []
33
103
  files:
34
104
  - ".circleci/config.yml"
35
105
  - ".gitignore"
36
- - ".idea/lex-influxdb.iml"
37
106
  - ".rspec"
38
107
  - ".rubocop.yml"
39
108
  - Gemfile
@@ -62,7 +131,7 @@ metadata:
62
131
  homepage_uri: https://bitbucket.org/legion-io/lex-influxdb
63
132
  source_code_uri: https://bitbucket.org/legion-io/lex-influxdb/src
64
133
  changelog_uri: https://bitbucket.org/legion-io/lex-influxdb/src/master/CHANGELOG.md
65
- post_install_message:
134
+ post_install_message:
66
135
  rdoc_options: []
67
136
  require_paths:
68
137
  - lib
@@ -70,15 +139,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
139
  requirements:
71
140
  - - ">="
72
141
  - !ruby/object:Gem::Version
73
- version: 2.3.0
142
+ version: 2.5.0
74
143
  required_rubygems_version: !ruby/object:Gem::Requirement
75
144
  requirements:
76
145
  - - ">="
77
146
  - !ruby/object:Gem::Version
78
147
  version: '0'
79
148
  requirements: []
80
- rubygems_version: 3.0.8
81
- signing_key:
149
+ rubygems_version: 3.1.2
150
+ signing_key:
82
151
  specification_version: 4
83
152
  summary: LEX::Influxdb
84
153
  test_files: []
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$" />
8
- <orderEntry type="inheritedJdk" />
9
- <orderEntry type="sourceFolder" forTests="false" />
10
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
11
- <orderEntry type="library" scope="PROVIDED" name="chef (v15.8.23, RVM: ruby-2.6.3) [gem]" level="application" />
12
- <orderEntry type="library" scope="PROVIDED" name="influxdb (v0.8.0, RVM: ruby-2.6.3) [gem]" level="application" />
13
- </component>
14
- </module>