Sha256: ee8491bd5c223f804db5cc640a1c709dc3e01996683ca14c3057dd2e29252034

Contents?: true

Size: 745 Bytes

Versions: 1

Compression:

Stored size: 745 Bytes

Contents

require 'singleton'

module Logworm
  class ConfigFileNotFound < Exception ; end
  
  class Config
    
    include ::Singleton
      
    FILENAME = "./.logworm"
    
    def initialize
      @file_found = false
      @consumer_key = @consumer_secret = @token_key = @token_secret = nil
      begin
        f = File.new(FILENAME, 'r')
        @consumer_key, @consumer_secret, @token_key, @token_secret = f.readlines.map {|l| l.strip }
        @file_found = true
      rescue Errno::ENOENT => e
      end
    end
    
    def keys
      [@consumer_key, @consumer_secret, @token_key, @token_secret]
    end
    
    def file_found?
      @file_found and @consumer_key and @consumer_secret and @token_key and @token_secret
    end
    
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logworm-0.6.1 lib/base/config.rb