lib/synvert/snippet.rb in synvert-0.9.0 vs lib/synvert/snippet.rb in synvert-0.10.0

- old
+ new

@@ -3,22 +3,25 @@ require 'json' module Synvert # Manage synvert snippets. class Snippet + def initialize(snippets_path) + @snippets_path = snippets_path + end + # synchronize snippets from github. - def self.sync - snippets_path = Core::Configuration.instance.get :default_snippets_path - if File.exist?(snippets_path) - FileUtils.cd snippets_path - system("git pull --rebase") + def sync + if File.exist?(@snippets_path) + FileUtils.cd @snippets_path + Kernel.system('git pull --rebase') else - system("git clone https://github.com/xinminlabs/synvert-snippets.git #{snippets_path}") + Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets.git #{@snippets_path}") end end - def self.fetch_core_version - content = open("https://rubygems.org/api/v1/versions/synvert-core.json").read - JSON.parse(content).first["number"] + def fetch_core_version + content = URI.open('https://rubygems.org/api/v1/versions/synvert-core.json').read + JSON.parse(content).first['number'] end end end