Sha256: 3554ee0d57aec9939010522197dd314cd82c24e59c899c3e938652cf695ac06d

Contents?: true

Size: 602 Bytes

Versions: 7

Compression:

Stored size: 602 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
        @find ||= '.*'
        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

7 entries across 7 versions & 1 rubygems

Version Path
prospectus-0.0.12 lib/prospectus/modules/grep.rb
prospectus-0.0.11 lib/prospectus/modules/grep.rb
prospectus-0.0.10 lib/prospectus/modules/grep.rb
prospectus-0.0.9 lib/prospectus/modules/grep.rb
prospectus-0.0.8 lib/prospectus/modules/grep.rb
prospectus-0.0.6 lib/prospectus/modules/grep.rb
prospectus-0.0.5 lib/prospectus/modules/grep.rb