Module: Phper
Defined Under Namespace
Classes: Agent, CLI, Commands
Instance Method Summary
collapse
Instance Method Details
#decode(str, salt = ".") ⇒ Object
59
60
61
62
63
|
# File 'lib/phper.rb', line 59
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 = ".") ⇒ Object
53
54
55
56
57
|
# File 'lib/phper.rb', line 53
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) ⇒ Object
git remoteの結果からプロジェクトを推測する
11
12
13
14
15
16
17
18
|
# File 'lib/phper.rb', line 11
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) ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/phper.rb', line 20
def git_remotes(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 ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/phper.rb', line 36
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? ⇒ Boolean
31
32
33
34
|
# File 'lib/phper.rb', line 31
def in_git?
%x{git status 2>/dev/null }
$?.to_i == 0
end
|
#name_of_key(key) ⇒ Object
3
4
5
6
7
8
|
# File 'lib/phper.rb', line 3
def name_of_key key
if key =~ / (\S+)$/
return $1
end
return nil
end
|