Skip to content

Commit

Permalink
Use newer Sequel gem
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Jari Salo committed Sep 20, 2019
1 parent 0a5f564 commit 98aa449
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.2.0
- move to use newer sequel gem
* this drops support for schema plugin
- refresh other dependencies as well

# 0.1.10
- FIX: check error_status from snmp_response and act based on that

Expand Down
26 changes: 14 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
PATH
remote: .
specs:
corona (0.0.12)
asetus
sequel
slop
snmp
sqlite3
corona (0.2.0)
asetus (~> 0.3)
sequel (~> 5.10)
slop (~> 3.6)
snmp (~> 1.2)
sqlite3 (~> 1.4)

GEM
remote: https://rubygems.org/
specs:
asetus (0.0.7)
slop
sequel (4.9.0)
slop (3.5.0)
snmp (1.1.1)
sqlite3 (1.3.9)
asetus (0.3.0)
sequel (5.24.0)
slop (3.6.0)
snmp (1.3.2)
sqlite3 (1.4.1)

PLATFORMS
ruby

DEPENDENCIES
corona!

BUNDLED WITH
2.0.2
10 changes: 5 additions & 5 deletions corona.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'corona'
s.version = '0.1.10'
s.version = '0.2.0'
s.licenses = %w( 'Apache-2.0' )
s.platform = Gem::Platform::RUBY
s.authors = [ 'Saku Ytti' ]
Expand All @@ -13,9 +13,9 @@ Gem::Specification.new do |s|
s.executables = %w( corona )
s.require_path = 'lib'

s.add_runtime_dependency 'sequel', '~> 4.12'
s.add_runtime_dependency 'sqlite3', '~> 1.3'
s.add_runtime_dependency 'sequel', '~> 5.10'
s.add_runtime_dependency 'sqlite3', '~> 1.4'
s.add_runtime_dependency 'snmp', '~> 1.2'
s.add_runtime_dependency 'slop', '~> 3.5'
s.add_runtime_dependency 'asetus', '~> 0.1'
s.add_runtime_dependency 'slop', '~> 3.6'
s.add_runtime_dependency 'asetus', '~> 0.3'
end
22 changes: 21 additions & 1 deletion lib/corona/db/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class DB
require 'sequel'
require 'sqlite3'
def initialize
Sequel::Model.plugin :schema
@db = Sequel.sqlite(CFG.db, :max_connections => 1, :pool_timeout => 60)
create_table #unless @db.table_exists?(:devices)
require_relative 'model'
end

Expand All @@ -27,5 +27,25 @@ def old ip, oid_sysName
sysName = Device[:oid_sysName => oid_sysName]
[ip, sysName]
end

private

def create_table
@db.create_table? :devices do
primary_key :id
String :ip
String :ptr
String :model
String :oid_ifDescr
Boolean :active
Time :first_seen
Time :last_seen
String :oid_sysName
String :oid_sysLocation
String :oid_sysDescr
String :oid_sysObjectID
end
end

end
end
15 changes: 0 additions & 15 deletions lib/corona/db/model.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
module Corona
class DB
class Device < Sequel::Model
set_schema do
primary_key :id
String :ip
String :ptr
String :model
String :oid_ifDescr
Boolean :active
Time :first_seen
Time :last_seen
String :oid_sysName
String :oid_sysLocation
String :oid_sysDescr
String :oid_sysObjectID
end
create_table unless table_exists?
end
end
end

0 comments on commit 98aa449

Please sign in to comment.