Sha256: 3900411a665dd97d3c9b77d0ad00001f355f7eea9fe71c167933f5ac8a5f920e

Contents?: true

Size: 504 Bytes

Versions: 4

Compression:

Stored size: 504 Bytes

Contents

class Nib::Plugin
  attr_reader :path

  def initialize(path)
    @path = path
  end

  def basename
    @basename ||= File.basename(path, '_plugin.rb')
  end

  def name
    @name ||= basename.tr('_', '-')
  end

  def constant
    @constant ||= Object.const_get(name.split('-').map(&:capitalize).join('::'))
  end

  def applies?
    @applies ||= begin
      require path

      constant.applies?
    end
  end

  def binstub
    "#{path[0..-"/lib/#{basename}_plugin.rb".length]}bin/#{name}"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nib-2.1.1 lib/nib/plugin.rb
nib-2.1.0 lib/nib/plugin.rb
nib-2.0.2 lib/nib/plugin.rb
nib-2.0.1 lib/nib/plugin.rb