./lib/security/keychain.rb in security-0.1.4 vs ./lib/security/keychain.rb in security-0.1.5
- old
+ new
@@ -1,31 +1,34 @@
+# frozen_string_literal: true
+
require 'shellwords'
module Security
+ # :nodoc:
class Keychain
- DOMAINS = [:user, :system, :common, :dynamic]
+ DOMAINS = %i[user system common dynamic].freeze
attr_reader :filename
def initialize(filename)
@filename = filename
end
def info
- system %{security show-keychain-info #{@filename.shellescape}}
+ system %(security show-keychain-info #{@filename.shellescape})
end
def lock
- system %{security lock-keychain #{@filename.shellescape}}
+ system %(security lock-keychain #{@filename.shellescape})
end
def unlock(password)
- system %{security unlock-keychain -p #{password.shellescape} #{@filename.shellescape}}
+ system %(security unlock-keychain -p #{password.shellescape} #{@filename.shellescape})
end
def delete
- system %{security delete-keychain #{@filename.shellescape}}
+ system %(security delete-keychain #{@filename.shellescape})
end
class << self
def create(filename, password)
raise NotImplementedError
@@ -36,15 +39,15 @@
keychains_from_output(`security list-keychains -d #{domain}`)
end
def lock
- system %{security lock-keychain -a}
+ system %(security lock-keychain -a)
end
def unlock(password)
- system %{security unlock-keychain -p #{password.shellescape}}
+ system %(security unlock-keychain -p #{password.shellescape})
end
def default_keychain
keychains_from_output(`security default-keychain`).first
end
@@ -54,10 +57,10 @@
end
private
def keychains_from_output(output)
- output.split(/\n/).collect{|line| new(line.strip.gsub(/^\"|\"$/, ""))}
+ output.split(/\n/).collect { |line| new(line.strip.gsub(/^"|"$/, '')) }
end
end
end
end