Skip to content

Commit

Permalink
Remove deprecated make_tmpname function
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram Seynhaeve authored and richardszalay committed Apr 9, 2019
1 parent c2f5b0e commit 2fe4a1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/spare_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ def self.temp_keychain(clear_list = false, type = nil, domain = nil) # :yields:
require 'securerandom'

password = SecureRandom.hex

extension = keychain_extension()
temp_keychain = Dir::Tmpname.make_tmpname(['spare-keys-', extension], nil)
temp_keychain = temporary_keychain_name('spare-keys')

`security create-keychain -p "#{password}" #{temp_keychain}`
`security set-keychain-settings #{temp_keychain}`
Expand Down Expand Up @@ -107,4 +105,10 @@ def self.expand_keychain_path(path)
return path
end

def self.temporary_keychain_name(prefix)
t = Time.now.strftime("%Y%m%d")
extension = keychain_extension()
"#{prefix}-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}#{extension}"
end

end
2 changes: 1 addition & 1 deletion spec/spare_keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

before(:context) do
require 'tempfile'
@example_keychain = Dir::Tmpname.make_tmpname(['spare-keys-spec-', SpareKeys.keychain_extension()], nil)
@example_keychain = SpareKeys.temporary_keychain_name('spare-keys-spec')
`security create-keychain -p "" #{@example_keychain}`
end

Expand Down

0 comments on commit 2fe4a1f

Please sign in to comment.