Skip to content

Commit 98aa449

Browse files
author
Jari Salo
committed
Use newer Sequel gem
- there was a lot of depreciation warnings about dropping support of schema plugin in the future version. - updated code to work without schema plugin - refreshed other dependencies - bump up gemspec
1 parent 0a5f564 commit 98aa449

File tree

5 files changed

+45
-33
lines changed

5 files changed

+45
-33
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.2.0
2+
- move to use newer sequel gem
3+
* this drops support for schema plugin
4+
- refresh other dependencies as well
5+
16
# 0.1.10
27
- FIX: check error_status from snmp_response and act based on that
38

Gemfile.lock

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
PATH
22
remote: .
33
specs:
4-
corona (0.0.12)
5-
asetus
6-
sequel
7-
slop
8-
snmp
9-
sqlite3
4+
corona (0.2.0)
5+
asetus (~> 0.3)
6+
sequel (~> 5.10)
7+
slop (~> 3.6)
8+
snmp (~> 1.2)
9+
sqlite3 (~> 1.4)
1010

1111
GEM
1212
remote: https://rubygems.org/
1313
specs:
14-
asetus (0.0.7)
15-
slop
16-
sequel (4.9.0)
17-
slop (3.5.0)
18-
snmp (1.1.1)
19-
sqlite3 (1.3.9)
14+
asetus (0.3.0)
15+
sequel (5.24.0)
16+
slop (3.6.0)
17+
snmp (1.3.2)
18+
sqlite3 (1.4.1)
2019

2120
PLATFORMS
2221
ruby
2322

2423
DEPENDENCIES
2524
corona!
25+
26+
BUNDLED WITH
27+
2.0.2

corona.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'corona'
3-
s.version = '0.1.10'
3+
s.version = '0.2.0'
44
s.licenses = %w( 'Apache-2.0' )
55
s.platform = Gem::Platform::RUBY
66
s.authors = [ 'Saku Ytti' ]
@@ -13,9 +13,9 @@ Gem::Specification.new do |s|
1313
s.executables = %w( corona )
1414
s.require_path = 'lib'
1515

16-
s.add_runtime_dependency 'sequel', '~> 4.12'
17-
s.add_runtime_dependency 'sqlite3', '~> 1.3'
16+
s.add_runtime_dependency 'sequel', '~> 5.10'
17+
s.add_runtime_dependency 'sqlite3', '~> 1.4'
1818
s.add_runtime_dependency 'snmp', '~> 1.2'
19-
s.add_runtime_dependency 'slop', '~> 3.5'
20-
s.add_runtime_dependency 'asetus', '~> 0.1'
19+
s.add_runtime_dependency 'slop', '~> 3.6'
20+
s.add_runtime_dependency 'asetus', '~> 0.3'
2121
end

lib/corona/db/db.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ class DB
33
require 'sequel'
44
require 'sqlite3'
55
def initialize
6-
Sequel::Model.plugin :schema
76
@db = Sequel.sqlite(CFG.db, :max_connections => 1, :pool_timeout => 60)
7+
create_table #unless @db.table_exists?(:devices)
88
require_relative 'model'
99
end
1010

@@ -27,5 +27,25 @@ def old ip, oid_sysName
2727
sysName = Device[:oid_sysName => oid_sysName]
2828
[ip, sysName]
2929
end
30+
31+
private
32+
33+
def create_table
34+
@db.create_table? :devices do
35+
primary_key :id
36+
String :ip
37+
String :ptr
38+
String :model
39+
String :oid_ifDescr
40+
Boolean :active
41+
Time :first_seen
42+
Time :last_seen
43+
String :oid_sysName
44+
String :oid_sysLocation
45+
String :oid_sysDescr
46+
String :oid_sysObjectID
47+
end
48+
end
49+
3050
end
3151
end

lib/corona/db/model.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
module Corona
22
class DB
33
class Device < Sequel::Model
4-
set_schema do
5-
primary_key :id
6-
String :ip
7-
String :ptr
8-
String :model
9-
String :oid_ifDescr
10-
Boolean :active
11-
Time :first_seen
12-
Time :last_seen
13-
String :oid_sysName
14-
String :oid_sysLocation
15-
String :oid_sysDescr
16-
String :oid_sysObjectID
17-
end
18-
create_table unless table_exists?
194
end
205
end
216
end

0 commit comments

Comments
 (0)