Class: Synvert::Snippet
- Inherits:
-
Object
- Object
- Synvert::Snippet
- Defined in:
- lib/synvert/snippet.rb
Overview
Manage synvert snippets.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(snippets_path) ⇒ Snippet
constructor
A new instance of Snippet.
-
#sync ⇒ Object
synchronize snippets from github.
Constructor Details
#initialize(snippets_path) ⇒ Snippet
Returns a new instance of Snippet.
14 15 16 |
# File 'lib/synvert/snippet.rb', line 14 def initialize(snippets_path) @snippets_path = snippets_path end |
Class Method Details
.fetch_core_version ⇒ Object
9 10 11 12 |
# File 'lib/synvert/snippet.rb', line 9 def self.fetch_core_version content = URI.open('https://rubygems.org/api/v1/versions/synvert-core.json').read JSON.parse(content).first['number'] end |
Instance Method Details
#sync ⇒ Object
synchronize snippets from github.
19 20 21 22 23 24 25 26 |
# File 'lib/synvert/snippet.rb', line 19 def sync if File.exist?(@snippets_path) FileUtils.cd @snippets_path Kernel.system('git pull --rebase') else Kernel.system("git clone https://github.com/xinminlabs/synvert-snippets.git #{@snippets_path}") end end |