Sha256: b07ef4d756a8e66c660e51fd873c475452727c7c2084e6fbdfd04801f204e642
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
module Gritano module CLI def CLI._execute(cmd, console) begin output = console.execute(cmd) if output[0] output[1].to_s else "error: #{output[1]}" end rescue console.execute(["help"])[1] end end def CLI.execute(cmd, stdin = STDIN, home_dir = Etc.getpwuid.dir, repo_dir = Etc.getpwuid.dir) Gritano::Console.remote_console(false, home_dir) _execute(cmd, Gritano::Console::Gritano.new(stdin, home_dir, repo_dir)) end def CLI.check(cmd, login, stdin = STDIN, home_dir = Etc.getpwuid.dir, repo_dir = Etc.getpwuid.dir) Gritano::Console.remote_console(true, home_dir) _execute(cmd + [login], Gritano::Console::Remote.new(stdin, home_dir, repo_dir)) end def CLI.check_pub_key(key, home_dir = Etc.getpwuid.dir) ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(home_dir, '.gritano', 'database.yml')))) k = Key.find_by_key(key) if k return "command=\"gritano-remote #{k.user.login}\" #{k.key}" else return "invalid" end end def CLI.check_access(login, repo, access, home_dir = Etc.getpwuid.dir, repo_dir = Etc.getpwuid.dir) ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(home_dir, '.gritano', 'database.yml')))) user = User.find_by_login(login) if user repo = Gritano::Repository.find_by_name(repo) if repo return user.check_access(repo, access) end end return false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gritano-1.0.0 | lib/gritano/cli.rb |
gritano-0.11.2 | lib/gritano/cli.rb |