mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2025-02-28 16:31:44 -05:00
Finishing up what i have of the dependency installer
just source file copying and config file copying to go. phew.
This commit is contained in:
parent
da4fc58652
commit
3819688273
@ -1,3 +1,4 @@
|
|||||||
|
require 'uri'
|
||||||
require 'open3'
|
require 'open3'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
@ -17,11 +18,15 @@ module Octopress
|
|||||||
installer.install plugin
|
installer.install plugin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
INSTALL_DIR = File.join(Dir.pwd, ".plugins")
|
INSTALL_DIR = File.join(Dir.pwd, ".plugins")
|
||||||
USERNAME_REPO_REGEXP = /^([a-z0-9\-_]+)\/([a-z0-9\-_]+)$/
|
USERNAME_REPO_REGEXP = /^([a-z0-9\-_]+)\/([a-z0-9\-_]+)$/
|
||||||
OCTOPRESS_REPO_REGEXP = /^[a-z0-9\-_]+$/
|
OCTOPRESS_REPO_REGEXP = /^[a-z0-9\-_]+$/
|
||||||
GIT_REPO_REGEXP = /^(git:\/\/|https:\/\/|git@)[a-z0-9.]+(\/|:)([a-z0-9\-_]+)\/([a-z0-9\-_]+)\.git/
|
GIT_REPO_REGEXP = /^(git:\/\/|https:\/\/|git@)([a-z0-9.]+)(\/|:)([a-z0-9\-_]+)\/([a-z0-9\-_]+)\.git/
|
||||||
|
|
||||||
|
# Public: Create a new DependencyInstaller and initialize instance variables
|
||||||
|
#
|
||||||
|
# Returns nothing
|
||||||
def initialize
|
def initialize
|
||||||
@plugins = Set.new
|
@plugins = Set.new
|
||||||
end
|
end
|
||||||
@ -41,6 +46,26 @@ module Octopress
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Gets the directory for local storage
|
||||||
|
#
|
||||||
|
# plugin - the plugin name
|
||||||
|
#
|
||||||
|
# Returns the directory for the plugin
|
||||||
|
def namespace(plugin)
|
||||||
|
url = git_url(plugin)
|
||||||
|
match = url.match(GIT_REPO_REGEXP)
|
||||||
|
if match[1] == "git@"
|
||||||
|
url = "git://#{match[2]}/#{match[4]}/#{match[5]}.git"
|
||||||
|
end
|
||||||
|
path = URI(url).path
|
||||||
|
path[/([a-z0-9\-_]+)\/([a-z0-9\-_]+)\.git$/]
|
||||||
|
.gsub(/\.git$/, '')
|
||||||
|
.gsub(/octopress\//, '')
|
||||||
|
.gsub(/\s+/, '-')
|
||||||
|
.gsub(/\//, '-')
|
||||||
|
.gsub(/-+/, '-')
|
||||||
|
end
|
||||||
|
|
||||||
# Public: builds full installation directory path for plugin
|
# Public: builds full installation directory path for plugin
|
||||||
#
|
#
|
||||||
# plugin - the plugin name
|
# plugin - the plugin name
|
||||||
@ -100,9 +125,9 @@ module Octopress
|
|||||||
# Returns an Array of file paths which were copied
|
# Returns an Array of file paths which were copied
|
||||||
def copy_files(plugin)
|
def copy_files(plugin)
|
||||||
manifest_yml = manifest(plugin)
|
manifest_yml = manifest(plugin)
|
||||||
copy_javascript_files(plugin, manifest_yml["javascripts"])
|
copy_javascript_files(plugin, manifest_yml["javascripts"]) if manifest_yml["javascripts"]
|
||||||
copy_stylesheets_files(plugin, manifest_yml["stylesheets"])
|
copy_stylesheets_files(plugin, manifest_yml["stylesheets"]) if manifest_yml["stylesheets"]
|
||||||
copy_plugins_files(plugin, manifest_yml["plugins"])
|
copy_plugins_files(plugin, manifest_yml["plugins"]) if manifest_yml["plugins"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: install a plugin and its dependencies
|
# Public: install a plugin and its dependencies
|
||||||
@ -111,9 +136,7 @@ module Octopress
|
|||||||
#
|
#
|
||||||
# Returns the Array of all plugins installed so far
|
# Returns the Array of all plugins installed so far
|
||||||
def install(plugin)
|
def install(plugin)
|
||||||
deps = build_dependencies_tree(plugin)
|
@plugins.merge(build_dependencies_tree(plugin))
|
||||||
puts deps
|
|
||||||
@plugins.merge(deps)
|
|
||||||
@plugins.each do |plugin|
|
@plugins.each do |plugin|
|
||||||
copy_files(plugin)
|
copy_files(plugin)
|
||||||
end
|
end
|
||||||
@ -128,10 +151,10 @@ module Octopress
|
|||||||
# file - the file destination relative to the Octopress installation root
|
# file - the file destination relative to the Octopress installation root
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def copy_file(plugin, file)
|
def copy_file(plugin, repo_files, file)
|
||||||
source = File.join(install_dir(plugin), file)
|
source = File.join(install_dir(plugin), repo_files)
|
||||||
destination = File.join(Octopress.root, file)
|
destination = File.join(Octopress.root, file)
|
||||||
FileUtils.cp_r source, destination
|
FileUtils.cp_r(source, destination)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Private: Copy javascript files to local Octopress installation
|
# Private: Copy javascript files to local Octopress installation
|
||||||
@ -159,7 +182,7 @@ module Octopress
|
|||||||
# Returns nothing
|
# Returns nothing
|
||||||
def copy_stylesheets_files(plugin, files)
|
def copy_stylesheets_files(plugin, files)
|
||||||
[files].flatten.each do |file|
|
[files].flatten.each do |file|
|
||||||
copy_file(plugin, file, File.join("assets", "stylesheets", "custom", file))
|
copy_file(plugin, file, File.join("assets", "stylesheets", "plugins", namespace(plugin)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,7 +195,7 @@ module Octopress
|
|||||||
# Returns nothing
|
# Returns nothing
|
||||||
def copy_plugins_files(plugin, files)
|
def copy_plugins_files(plugin, files)
|
||||||
[files].flatten.each do |file|
|
[files].flatten.each do |file|
|
||||||
copy_file(plugin, file, File.join(Octopress.configuration[:plugins], file))
|
copy_file(plugin, file, File.join(Octopress.configuration[:plugins], File.basename(file)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user