module Phper
Public Instance Methods
decode(str,salt=".")
click to toggle source
# File lib/phper.rb, line 58 def decode(str,salt=".") dec = OpenSSL::Cipher::Cipher.new('aes256') dec.decrypt.pkcs5_keyivgen(salt) (dec.update(Array.new([str]).pack("H*")) + dec.final) end
encode(str,salt=".")
click to toggle source
# File lib/phper.rb, line 52 def encode(str,salt=".") enc = OpenSSL::Cipher::Cipher.new('aes256') enc.encrypt.pkcs5_keyivgen(salt) ((enc.update(str) + enc.final).unpack("H*")).first.to_s end
git_remote(base_dir)
click to toggle source
git remoteの結果からプロジェクトを推測する
# File lib/phper.rb, line 10 def git_remote(base_dir) %x{git remote -v 2> /dev/null }.each_line{ |line| if line =~ /\sgitosis@git\.phper\.jp:(.+)\/(.+)\.git\s/ return [$1,$2].join("-") end } nil end
git_remotes(git)
click to toggle source
# File lib/phper.rb, line 19 def git_remotes(git) # %x{git remote add phper #{project["project"]["git"]}} r = [] %x{git remote -v 2> /dev/null }.each_line{ |line| if line.include?(git) r << $1 if line =~ /^(\S+)/ end } r.uniq end
git_root()
click to toggle source
# File lib/phper.rb, line 35 def git_root root = nil begin startdir = FileUtils.pwd until File.directory?(".git") FileUtils.cd('..') raise "can't find git project" if FileUtils.pwd == "/" end root = FileUtils.pwd rescue =>e puts e ensure FileUtils.cd(startdir) end return root end
in_git?()
click to toggle source
# File lib/phper.rb, line 30 def in_git? %x{git status 2>/dev/null } $?.to_i == 0 end
name_of_key(key)
click to toggle source
# File lib/phper.rb, line 2 def name_of_key key if key =~ / (\S+)$/ return $1 end return nil end