Sha256: 6c0da92e0a52e3f258cfce22e62b6a9896e0c0f35fbee7e30eb91926b1fbc965

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

module OpenSource
  module Owner
    extend self

    OSRC_PATH = File.expand_path("~/.osrc")

    def set_credentials credentials
      f = File.new(OSRC_PATH, "w")
      f.write <<-CREDENTIALS.gsub /^\s+/, ""
        name: #{credentials[:name]}
        email: #{credentials[:email]}
        escaped_email: &lt;#{credentials[:email]}&gt;
      CREDENTIALS
      f.close
    end

    def get_credentials
      credentials = {}

      IO.foreach(OSRC_PATH) do |line|
        current_line = line.strip
        if !current_line.empty?
          key, value = current_line.split(':')
          credentials[key.strip.to_sym] = value.strip
        end
      end

      credentials
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opensource-0.6.2 lib/open_source/owner.rb