Class: Vimmer::Installers::Github
- Inherits:
-
Object
- Object
- Vimmer::Installers::Github
- Defined in:
- lib/vimmer/installers/github.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#plugin_name ⇒ Object
readonly
Returns the value of attribute plugin_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Github
constructor
A new instance of Github.
- #install ⇒ Object
- #path_exists? ⇒ Boolean
- #uninstall ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Github
Returns a new instance of Github.
11 12 13 14 15 16 17 |
# File 'lib/vimmer/installers/github.rb', line 11 def initialize(args={}) if args[:path] initialize_with_path(args[:path]) elsif args[:name] initialize_with_name(args[:name]) end end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/vimmer/installers/github.rb', line 9 def path @path end |
#plugin_name ⇒ Object (readonly)
Returns the value of attribute plugin_name.
9 10 11 |
# File 'lib/vimmer/installers/github.rb', line 9 def plugin_name @plugin_name end |
Class Method Details
.is_github_url?(url) ⇒ Boolean
52 53 54 55 |
# File 'lib/vimmer/installers/github.rb', line 52 def self.is_github_url?(url) !(GITHUB_PUBLIC_URL_PATTERN.match(url) || GITHUB_GIT_URL_PATTERN.match(url)).nil? end |
.match?(url) ⇒ Boolean
48 49 50 |
# File 'lib/vimmer/installers/github.rb', line 48 def self.match?(url) is_github_url?(url) end |
Instance Method Details
#install ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/vimmer/installers/github.rb', line 20 def install if path_exists? git_clone(path, File.join(Vimmer.bundle_path, plugin_name)) Vimmer.add_plugin(plugin_name, path) puts "#{plugin_name} has been installed" else raise Vimmer::PluginNotFoundError end end |
#path_exists? ⇒ Boolean
43 44 45 |
# File 'lib/vimmer/installers/github.rb', line 43 def path_exists? `curl --head -w %{http_code} -o /dev/null #{remove_extension(path)} 2> /dev/null`.chomp == "200" end |
#uninstall ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vimmer/installers/github.rb', line 31 def uninstall plugin_path = File.join(Vimmer.bundle_path, plugin_name) if File.directory? plugin_path FileUtils.rm_rf(plugin_path) Vimmer.remove_plugin(plugin_name) puts "#{plugin_name} has been uninstalled" else raise Vimmer::PluginNotFoundError end end |