Skip to content

Commit

Permalink
Merge pull request #3 from CvX/master
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
xijo authored Feb 8, 2017
2 parents 4e7cc67 + edc5ec9 commit 4c05241
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 0 additions & 2 deletions letsencrypt_heroku.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Gem::Specification.new do |spec|
spec.add_dependency 'rainbow'
spec.add_dependency 'acme-client'
spec.add_dependency 'tty-spinner'
# See https://github.com/schubergphilis/letsencrypt/issues/36
spec.add_dependency 'json-jwt', '1.5.2'

spec.add_development_dependency 'bundler', '~> 1.12'
spec.add_development_dependency 'rake', '~> 10.0'
Expand Down
2 changes: 1 addition & 1 deletion lib/letsencrypt_heroku/process/update_certificates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def perform(context)
end

def has_already_cert(herokuapp)
Open3.popen3("heroku certs:info --app #{herokuapp}") do |stdin, stdout, stderr, wait_thr|
execute("heroku certs:info --app #{herokuapp}") do |stdin, stdout, stderr, wait_thr|
return wait_thr.value.success?
end
end
Expand Down
19 changes: 13 additions & 6 deletions lib/letsencrypt_heroku/tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,27 @@ def error(reason = nil)
raise LetsencryptHeroku::TaskError, reason
end

def execute(command)
def execute(command, &block)
log command
Open3.popen3("unset RUBYOPT; #{command}") do |stdin, stdout, stderr, wait_thr|
out, err = stdout.read, stderr.read
log out
log err
wait_thr.value.success? or error(err.force_encoding('utf-8').sub(' ▸ ', 'heroku: '))
if block
block.call(stdin, stdout, stderr, wait_thr)
else
out, err = stdout.read, stderr.read
log out
log err
wait_thr.value.success? or error(err.force_encoding('utf-8').sub(' ▸ ', 'heroku: '))
end
end
end

private

def logger
@logger ||= Logger.new(File.open('log/letsencrypt_heroku.log', File::WRONLY | File::APPEND | File::CREAT))
@logger ||= begin
Dir.mkdir('log') unless File.directory?('log')
Logger.new(File.open('log/letsencrypt_heroku.log', File::WRONLY | File::APPEND | File::CREAT))
end
end

def build_spinner(name)
Expand Down
4 changes: 0 additions & 4 deletions spec/letsencrypt_heroku_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
it 'has a version number' do
expect(LetsencryptHeroku::VERSION).not_to be nil
end

it 'does something useful' do
expect(false).to eq(true)
end
end
5 changes: 4 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
require 'letsencrypt_heroku'

require 'fileutils'
FileUtils.rm('log/letsencrypt_heroku.log')
require 'pathname'

log_path = 'log/letsencrypt_heroku.log'
FileUtils.rm(log_path) if Pathname.new(log_path).exist?

0 comments on commit 4c05241

Please sign in to comment.