diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a5eb93..e00a198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index c6c5cb2..3237463 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/corona.gemspec b/corona.gemspec index 9692e01..fce9ca3 100644 --- a/corona.gemspec +++ b/corona.gemspec @@ -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' ] @@ -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 diff --git a/lib/corona/db/db.rb b/lib/corona/db/db.rb index 8f9c2d6..9404c8c 100644 --- a/lib/corona/db/db.rb +++ b/lib/corona/db/db.rb @@ -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 @@ -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 diff --git a/lib/corona/db/model.rb b/lib/corona/db/model.rb index 6ed6383..a7e3c39 100644 --- a/lib/corona/db/model.rb +++ b/lib/corona/db/model.rb @@ -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