Sha256: 76d812b55dccb56b560c583572a93321bb869fbd239a0422c9411b1f4a352b5d
Contents?: true
Size: 896 Bytes
Versions: 11
Compression:
Stored size: 896 Bytes
Contents
# frozen_string_literal: true require 'open-uri' require 'json' require 'fileutils' 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 JSON.parse(content).first['number'] end def initialize(snippets_path) @snippets_path = snippets_path end # synchronize snippets from github. def sync 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
Version data entries
11 entries across 11 versions & 1 rubygems