Sha256: 48c9c0557887b618a6f7ceb67e44d4cf4972c547b46a6b2369b243e3d62049fb
Contents?: true
Size: 1.26 KB
Versions: 7
Compression:
Stored size: 1.26 KB
Contents
module Vim module Jar module Importer autoload :Github, 'vim-jar/importer/github' def self.import(url) name_home_page = self.extract_from_url(url) if !::Vim::Jar::Plugin.exist? name_home_page["name"] other_info = self.extract_from_page_source(url) ::Vim::Jar::Plugin.insert name_home_page.merge!(other_info) File.open(config.yaml_path, "w+") do |f| f.puts ::Vim::Jar::Plugin.plugins.to_yaml end else raise ::Vim::Jar::ImportError.new("plugin #{name_home_page["name"]} exist") end end def self.extract_from_url(url) {"homepage" => url, "name" => url.split("/").last} end def self.extract_from_page_source(url) page_source = get_page_source(url) if is_github?(url) return Github.extract(page_source) else raise ::Vim::Jar::ImportError.new("Do not support import from #{url}") end end def self.is_github?(url) return !!(url =~ /github\.com/ ) end def self.get_page_source(url) c = ::Curl::Easy.perform(url) return c.body_str end def self.config ::Vim::Jar::Config.instance end end end end
Version data entries
7 entries across 7 versions & 1 rubygems