Sha256: db1144b4a358302685f69e4734c935a8f5a1694998dcf47f32f7e6499f135e9e

Contents?: true

Size: 556 Bytes

Versions: 2

Compression:

Stored size: 556 Bytes

Contents

module Heckler
  class Preset
    PRESET_STUBS_DIRECTORY = File.join(__dir__, "/presets")

    def self.whitelisted_words(preset)
      return [] if preset.nil? || !stub_exists?(preset)

      get_words_from_stub("base") + get_words_from_stub(preset)
    end

    def self.get_words_from_stub(preset)
      path = File.join(PRESET_STUBS_DIRECTORY, "#{preset}.stub")
      File.read(path).lines.map(&:strip).reject(&:empty?)
    end

    def self.stub_exists?(preset)
      File.exist?(File.join(PRESET_STUBS_DIRECTORY, "#{preset}.stub"))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heckler-0.0.2 lib/heckler/preset.rb
heckler-0.0.1 lib/heckler/preset.rb