forked from qnyp/heroku-buildpack-ruby-bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_installer.rb
38 lines (33 loc) · 1.02 KB
/
plugin_installer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require "language_pack/shell_helpers"
module LanguagePack
module Helpers
# Takes an array of plugin names and vendor_url
# fetches plugins from url, installs them
class PluginsInstaller
attr_accessor :plugins, :vendor_url
include LanguagePack::ShellHelpers
def initialize(plugins, vendor_url = LanguagePack::Base::VENDOR_URL)
@plugins = plugins || []
@vendor_url = vendor_url
end
# vendors all the plugins into the slug
def install
return true unless plugins.any?
plugins.each { |plugin| vendor(plugin) }
end
def plugin_dir(name = "")
Pathname.new("vendor/plugins").join(name)
end
# vendors an individual plugin
# @param [String] name of the plugin
def vendor(name)
directory = plugin_dir(name)
return true if directory.exist?
directory.mkpath
Dir.chdir(directory) do |dir|
run("curl #{vendor_url}/#{name}.tgz -s -o - | tar xzf -")
end
end
end
end
end