Class: Jared::PluginList
- Inherits:
-
Object
- Object
- Jared::PluginList
- Defined in:
- lib/jared/plugin_list.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize ⇒ PluginList
constructor
A new instance of PluginList.
- #parse ⇒ Object
Constructor Details
#initialize ⇒ PluginList
Returns a new instance of PluginList.
3 4 5 |
# File 'lib/jared/plugin_list.rb', line 3 def initialize @file = "#{Dir.home}/.jared/data/jared-plugins.json" end |
Instance Method Details
#fetch ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jared/plugin_list.rb', line 7 def fetch begin list = open('https://raw.githubusercontent.com/cyberarm/jared-plugins/master/jared-plugins.json').read rescue if File.exist?(@file) # We'll live. else puts "Connection error.\nCould not fetch jared-plugins.json from github.com.\n:(" exit end File.open(@file, 'w') {|file| file.write list} end end |
#parse ⇒ Object
22 23 24 |
# File 'lib/jared/plugin_list.rb', line 22 def parse MultiJson.load(File.open(@file).read) end |