Skip to content

Commit 2a9675a

Browse files
committed
Updated gem management tasks
1 parent 5350e99 commit 2a9675a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

tasks/github-gem.rb

+18-14
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def version_task
220220

221221
def check_version_task
222222
raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
223-
proposed_version = Gem::Version.new(ENV['VERSION'].dup || gemspec.version)
223+
proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
224224
raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
225225
end
226226

@@ -339,22 +339,26 @@ def update_gemspec(attribute, new_value, literal = false)
339339

340340
# Updates the tasks file using the latest file found on Github
341341
def update_tasks_task
342-
require 'net/http'
343-
344-
server = 'github.com'
345-
path = '/wvanbergen/github-gem/raw/master/tasks/github-gem.rake'
342+
require 'net/https'
343+
require 'uri'
344+
345+
uri = URI.parse('https://github.com/wvanbergen/github-gem/raw/master/tasks/github-gem.rake')
346+
http = Net::HTTP.new(uri.host, uri.port)
347+
http.use_ssl = true
348+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
349+
response = http.request(Net::HTTP::Get.new(uri.path))
346350

347-
Net::HTTP.start(server) do |http|
348-
response = http.get(path)
351+
if Net::HTTPSuccess === response
349352
open(__FILE__, "w") { |file| file.write(response.body) }
350-
end
351-
352-
relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
353-
if `#{git} ls-files -m #{relative_file}`.split("\n").any?
354-
sh git, 'add', relative_file
355-
sh git, 'commit', '-m', "Updated to latest gem release management tasks."
353+
relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
354+
if `#{git} ls-files -m #{relative_file}`.split("\n").any?
355+
sh git, 'add', relative_file
356+
sh git, 'commit', '-m', "Updated to latest gem release management tasks."
357+
else
358+
puts "Release managament tasks already are at the latest version."
359+
end
356360
else
357-
puts "Release managament tasks already are at the latest version."
361+
raise "Download failed with HTTP status #{response.code}!"
358362
end
359363
end
360364
end

0 commit comments

Comments
 (0)