Sha256: f1be24b5821effbab0f440feaf4163545716c6421d20883cb03f7865b1702d59

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

module SSH ; module Allow

  class RuleSet
    attr_reader :rules

    def initialize
      @rules = []
    end

    def allow(cmd, &block)
      push get_rule(:allow, cmd, block)
    end

    def allow!(cmd, &block)
      rule = get_rule(:allow, cmd, block)
      push(rule) or raise(%(Invalid rule: "#{cmd}"))
    end

    def read(path_to_rules)
      self.instance_eval(read_rules(path_to_rules))
    end

    private

    def push(rule)
      rule ? @rules.push(rule) : false
    end

    def get_rule(type, cmd, block)
      SSH::Allow::Rule.send(type, cmd, &block)
    end

    def read_rules(path_to_rules)
      IO.read(path_to_rules)
    end
  end

end ; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ssh-allow-0.6.0 lib/ssh/allow/rule_set.rb