Sha256: c3a5db39fe4e0687f4c76d6ab9861cf7bf5b968a82e6b1484c0d0e6e193f9ced

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

#!/usr/bin/env ruby

require 'fileutils'
require 'dyndoc/init/home'
dyndoc_home = Dyndoc.home
#p Dyndoc.home

lib_dir = ENV["DYNDOC_LIBRARY"] || File.join(dyndoc_home,"library")
repo_dir = File.join(lib_dir,".repository")

old_pwd = Dir.pwd

cmd = ARGV[0].to_sym
case cmd

# dyndoc-package install rcqls/dyndoc-share
when :install  #default is github from now!
owner,package=File.split(ARGV[1])
package = package[0...-4] if package =~ /\.git$/
package_dir = File.join(repo_dir,owner)
FileUtils.mkdir_p package_dir
FileUtils.cd package_dir
`git clone https://github.com/#{owner}/#{package}.git`

# dyndoc-package update rcqls/dyndoc-share
when :update
FileUtils.cd File.join(repo_dir,ARGV[1])
`git pull`

# dyndoc-package link rcqls/dyndoc-share/library/RCqls (default to RCqls)
# dyndoc-package link rcqls/dyndoc-share/library/RCqls RCqls
# dyndoc-package link <real local path to expand>
when :link
path = File.expand_path(ARGV[1])
unless (local = (File.directory? path) )
	path = ARGV[1] # not expanded
end
path,package = File.split(path)
target = ARGV[2] || package
target = File.join(lib_dir,target)
FileUtils.rm target if File.symlink? target #unlink first
source = local ? path : File.join(repo_dir,path,package)
FileUtils.ln_sf source,target

# dyndoc-package unlink RCqls
when :unlink
package = ARGV[1]
if RUBY_PLATFORM =~ /(?:msys|mingw)/
	FileUtils.rm_rf File.join(lib_dir,package)
else
	FileUtils.rm File.join(lib_dir,package)
end
when :ls
FileUtils.cd lib_dir
Dir["*"].each_with_index{|e,i| puts "#{i+1}) #{e}"}

when :repo
FileUtils.cd repo_dir
Dir[File.join("*","*")].each_with_index{|e,i| puts "#{i+1}) #{e}"}

end

FileUtils.cd old_pwd

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dyndoc-ruby-0.3.2 bin/dpm.rb
dyndoc-ruby-0.3.1 bin/dpm.rb
dyndoc-ruby-0.3.0 bin/dpm.rb
dyndoc-ruby-0.2.0 bin/dpm.rb