lib/synvert/snippet.rb in synvert-0.19.0 vs lib/synvert/snippet.rb in synvert-0.19.1

- old
+ new

@@ -6,11 +6,11 @@ module Synvert # Manage synvert snippets. class Snippet def self.fetch_core_version - content = URI.open('https://rubygems.org/api/v1/versions/synvert-core.json').read + content = uri_open('https://rubygems.org/api/v1/versions/synvert-core.json').read JSON.parse(content).first['number'] end def initialize(snippets_path) @snippets_path = snippets_path @@ -21,9 +21,17 @@ if File.exist?(@snippets_path) FileUtils.cd @snippets_path Kernel.system('git checkout .; git pull --rebase') else Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets-ruby.git #{@snippets_path}") + end + end + + def self.uri_open(url) + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0') + URI.open(url) + else + open(url) end end end end