Version 0.2.0 - required ruby>=2.7. **-kw-options. BETA
This commit is contained in:
parent
0a0392d532
commit
6af5922217
1
Gemfile
1
Gemfile
|
@ -1,4 +1,5 @@
|
|||
source "https://rubygems.org"
|
||||
ruby '>=2.7'
|
||||
|
||||
# Specify your gem's dependencies in knot.gemspec
|
||||
gemspec
|
||||
|
|
|
@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|||
spec.summary = %q{Provides interface to knot-server.}
|
||||
spec.description = %q{Implements knot-protocol to provide an interface to knot-DNS-server}
|
||||
spec.homepage = 'https://git.denkn.at/deac/knot'
|
||||
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
||||
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
||||
|
||||
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
||||
|
||||
|
|
10
lib/knot.rb
10
lib/knot.rb
|
@ -2,3 +2,13 @@ require 'knot/version'
|
|||
require 'knot/errors'
|
||||
require 'knot/protocol'
|
||||
require 'knot/interface'
|
||||
|
||||
module Knot
|
||||
class <<self
|
||||
def new *as, **os
|
||||
Protocol.new *as, **os
|
||||
end
|
||||
alias connect new
|
||||
alias open new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -153,33 +153,36 @@ class Knot::Conf
|
|||
|
||||
$~.named_captures.delete_if {|_,v| v.nil? }
|
||||
|
||||
when nil
|
||||
{}
|
||||
|
||||
else
|
||||
raise ArgumentError, "Invalid Item-format"
|
||||
end
|
||||
end
|
||||
|
||||
def get item = nil
|
||||
@protocol.call (item ? parse_item( item) : {}).update( command: 'conf-get')
|
||||
@protocol.call **parse_item( item).update( command: 'conf-get')
|
||||
end
|
||||
|
||||
# Sets or adds a new value to item.
|
||||
# knot knows single-value items like `server.rundir` and multi-value items like `server.listen`.
|
||||
# If you set a single-value, it will replace the old value. On a multi-value, it will add it.
|
||||
def set item, value
|
||||
@protocol.call parse_item( item).update( command: 'conf-set', data: value)
|
||||
@protocol.call **parse_item( item).update( command: 'conf-set', data: value)
|
||||
end
|
||||
|
||||
# Removes value from item. If you provide a value, this value will be removed.
|
||||
def unset item, value = nil
|
||||
@protocol.call parse_item( item).update( command: 'conf-unset', data: value)
|
||||
@protocol.call **parse_item( item).update( command: 'conf-unset', data: value)
|
||||
end
|
||||
alias delete unset
|
||||
|
||||
def list item = nil
|
||||
@protocol.call (item ? parse_item( item) : {}).update( command: 'conf-list')
|
||||
@protocol.call **parse_item( item).update( command: 'conf-list')
|
||||
end
|
||||
|
||||
def read item = nil
|
||||
@protocol.call (item ? parse_item( item) : {}).update( command: 'conf-read')
|
||||
@protocol.call **parse_item( item).update( command: 'conf-read')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require 'iounpack'
|
||||
require 'stringio'
|
||||
require_relative 'errors'
|
||||
|
||||
module Knot
|
||||
|
@ -51,6 +52,26 @@ module Knot::Protocol::Type
|
|||
end
|
||||
end
|
||||
|
||||
#class Knot::KnotC
|
||||
# attr_accessor :debug, :binary
|
||||
#
|
||||
# def initialize path = nil, binary: nil
|
||||
# @path = path
|
||||
# @binary = binary || 'knotc'
|
||||
# @conf = Knot::Conf.new self
|
||||
# @zones = Hash.new {|h, zone| h[zone] = Knot::Zone.new zone, self }
|
||||
# end
|
||||
#
|
||||
# def call command:, flags: nil, section: nil, item: nil, id: nil, zone: nil, owner: nil, ttl: nil, type: nil, data: nil, filter: nil
|
||||
# cs =
|
||||
# case command.to_s
|
||||
# when 'conf-begin', 'conf-commit', 'conf-abort', 'status', 'stop', 'reload'
|
||||
# [@binary, command, ]
|
||||
# else raise ArgumentError, "Unknown Command: #{command}"
|
||||
# end
|
||||
# end
|
||||
#end
|
||||
|
||||
module Knot::Protocol::Idx
|
||||
Idx = [
|
||||
:command, # 10, :CMD, # Control command name.
|
||||
|
@ -180,7 +201,7 @@ class Knot::Protocol
|
|||
def zone( zone) @zones[zone.to_s.to_sym] end
|
||||
|
||||
def conf_set( **opts) call **opts.update( command: 'conf-set') end
|
||||
def conf_unset( **opts) call **opts.update( command: 'conf-set') end
|
||||
def conf_unset( **opts) call **opts.update( command: 'conf-unset') end
|
||||
|
||||
def zone_set( **opts) call **opts.update( command: 'zone-set') end
|
||||
def zone_unset( **opts) call **opts.update( command: 'zone-unset') end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Knot
|
||||
VERSION = "0.1.2"
|
||||
VERSION = "0.2.0"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue