Sha256: ee1aa1998347137e3a6aa03f3743bbdc4bf69abab9623f104d0f5705e2a98a41

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 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.git #{@snippets_path}")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
synvert-0.18.2 lib/synvert/snippet.rb