class Grnplum::Command

Public Instance Methods

build(repository_url) click to toggle source
# File lib/grnplum/command.rb, line 24
def build(repository_url)
  FileUtils.mkdir_p(plugins_dir)
  Dir.chdir(plugins_dir) do
    rc = system("git", "clone", repository_url)
    basename = File.basename(repository_url, ".git")
    Dir.chdir(basename) do
      system("git", "pull") unless rc
      system("./autogen.sh && ./configure --prefix=#{install_dir} && make")
    end
  end
end
global(install_path=nil) click to toggle source
# File lib/grnplum/command.rb, line 11
def global(install_path=nil)
  unless install_path
    puts(install_dir)
    exit(true)
  end
  unless File.directory?(install_path)
    $stderr.puts("#{$0}: Invalid path: #{install_path}")
    exit(false)
  end
  File.write(config_path, install_path)
end
install(name) click to toggle source
# File lib/grnplum/command.rb, line 57
def install(name)
  Dir.chdir(plugin_dir(name)) do
    system("make", "install")
  end
end
list() click to toggle source
# File lib/grnplum/command.rb, line 38
def list
  Dir.glob("#{plugins_dir}/*") do |path|
    if options[:verbose]
      puts(path)
    else
    basename = File.basename(path)
    puts(basename)
    end
  end
end
test(name) click to toggle source
# File lib/grnplum/command.rb, line 50
def test(name)
  Dir.chdir(plugin_dir(name)) do
    system("test/run-test.sh")
  end
end
uninstall(name) click to toggle source
# File lib/grnplum/command.rb, line 64
def uninstall(name)
  Dir.chdir(plugin_dir(name)) do
    system("make", "uninstall")
  end
end
version() click to toggle source
# File lib/grnplum/command.rb, line 71
def version
  puts(VERSION)
end

Private Instance Methods

base_dir() click to toggle source
# File lib/grnplum/command.rb, line 76
def base_dir
  File.expand_path("~/.grnplum")
end
config_name() click to toggle source
# File lib/grnplum/command.rb, line 80
def config_name
  ".groonga-installed-path"
end
config_path() click to toggle source
# File lib/grnplum/command.rb, line 84
def config_path
  File.join(base_dir, config_name)
end
install_dir() click to toggle source
# File lib/grnplum/command.rb, line 88
def install_dir
  unless File.file?(config_path)
    $stderr.puts("#{$0}: Please set INSTALL_DIR.")
    $stderr.puts("Usage: #{$0} global INSTALL_DIR")
    $stderr.puts(" e.g.: #{$0} global /tmp/local")
    exit(false)
  end
  File.read(config_path)
end
plugin_dir(name) click to toggle source
# File lib/grnplum/command.rb, line 105
def plugin_dir(name)
  File.join(plugins_dir, name)
end
plugins_dir() click to toggle source
# File lib/grnplum/command.rb, line 98
def plugins_dir
  File.join(base_dir,
            "install_directories",
            install_dir.gsub("/", "_"),
            "plugins")
end