Sha256: b5e3a339755bb6143e05f37b8a28dd162aa52b743680197f2810eae6ff13690f

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

module Spigoter
	module CLI
		def self.update(opts)
			puts opts
			Log.info "Updating!"
			unless File.exists?('plugins.json')
				Log.error "plugins.json doesn't exists, please, create one"
				exit(1)
			end
			unless Dir.exists?('plugins')
				Log.error "plugins directory doesn't exists, please, create it"
				exit(1)
			end

			file = File.read("plugins.json")
			plugins = JSON.parse(file)
			plugins.each do |plugin_data|
				Log.info "Getting plugin #{plugin_data['name']}"
				begin
					hash = Plugins.get_plugin(plugin_data)
					plugin_file = File.open("plugins/#{hash[:name]}", 'wb')
					plugin_file.write(hash[:file])
					Log.info "#{plugin_data['name']} was downloaded correctly"
				rescue Exception => e
					Log.error "Unkown source #{plugin_data['type']}"
				end
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spigoter-0.2.0 lib/spigoter/cli/cli_update.rb
spigoter-0.1.2 lib/spigoter/cli/cli_update.rb