Sha256: 3d741028dce3c08a8c2307051ecc02d12510696374ef3d38931dc00e24eda3f8

Contents?: true

Size: 579 Bytes

Versions: 3

Compression:

Stored size: 579 Bytes

Contents

module LogCabin
  module Modules
    ##
    # Pull state from a local file
    module Grep
      include Prospectus.helpers.find(:regex)

      def load!
        fail('No file specified') unless @file
        line = read_file
        @state.value = regex_helper(line)
      end

      private

      def read_file
        File.read(@file).each_line do |line|
          line = line.chomp
          return line if line.match(@find)
        end
        fail("No lines in #{@file} matched #{@find}")
      end

      def file(value)
        @file = value
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prospectus-0.0.4 lib/prospectus/modules/grep.rb
prospectus-0.0.3 lib/prospectus/modules/grep.rb
prospectus-0.0.2 lib/prospectus/modules/grep.rb