Sha256: ca035f1c2fd0a29bff70327542ff7be77abdaa3fb417be6facf65bbc37031778

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

require "osx_keychain"

module CocoaPodsKeys
  class Keyring
    attr_accessor :keys, :path, :name

    def initialize(name, path, keys=[])
      @name = name
      @path = path
      @keys = keys
    end

    def self.from_hash(hash)
      new(hash["name"], hash["path"], hash["keys"])
    end

    def to_hash
      { "keys" => @keys, "path" => @path, "name" => @name }
    end

    def code_name
      name.split(/[^a-zA-Z0-9_]/).map { |s| s[0].upcase + s[1..-1] }.join('')
    end

    def save(key, value)
      keychain = OSXKeychain.new
      keychain[keychain_prefix + name, key] = value
    end

    def keychain_data
      keychain = OSXKeychain.new
      Hash[
        @keys.map { |key| [key, keychain[keychain_prefix + name, key]] }
      ]
    end

    def keychain_prefix
      "cocoapods-keys-"
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocoapods-keys-0.9.5 lib/keyring.rb
cocoapods-keys-0.9.0 lib/keyring.rb