Sha256: 8d841071d12ae66bd9bc5592ceebce8b68360aa5e5750c4a23b0e9b34a56accf

Contents?: true

Size: 626 Bytes

Versions: 8

Compression:

Stored size: 626 Bytes

Contents

require 'wisper'

module Riserva::Commands
  class ApplicationCommand
    include Wisper::Publisher

    class NotImplementedError < StandardError; end

    def initialize
      subscribe(build_listener.new)
    end

    def files
      listeners.first.files
    end

    def call(path)
      @path = Pathname.new(path)
      valid?
    end

    private

    def valid?
      @path.exist?
    end

    def build_listener
      class_name = self.class.name.split('::').last
      listener = "Riserva::Listeners::#{class_name}".safe_constantize
      raise NotImplementedError if listener.nil?

      listener
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riserva-0.1.7 lib/riserva/commands/application_command.rb
riserva-0.1.6 lib/riserva/commands/application_command.rb
riserva-0.1.5 lib/riserva/commands/application_command.rb
riserva-0.1.4 lib/riserva/commands/application_command.rb
riserva-0.1.3 lib/riserva/commands/application_command.rb
riserva-0.1.2 lib/riserva/commands/application_command.rb
riserva-0.1.1 lib/riserva/commands/application_command.rb
riserva-0.1.0 lib/riserva/commands/application_command.rb