Class: VPL::Register
- Inherits:
-
Object
- Object
- VPL::Register
- Defined in:
- lib/vcpkg_pipeline/core/register.rb
Overview
VPL::Register
Instance Method Summary collapse
- #add(name, url) ⇒ Object
- #exist(name) ⇒ Object
- #list ⇒ Object
- #registeries ⇒ Object
- #remove(name) ⇒ Object
Instance Method Details
#add(name, url) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/vcpkg_pipeline/core/register.rb', line 39 def add(name, url) suffix = 0 while exist(name) suffix += 1 name = "#{name}-#{suffix}" end Git.clone(url, "#{registeries}/#{name}") end |
#exist(name) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/vcpkg_pipeline/core/register.rb', line 30 def exist(name) is_exist = false Dir["#{registeries}/*"].each do |reg| is_exist = name.eql? File.basename(reg) break if is_exist end is_exist end |
#list ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vcpkg_pipeline/core/register.rb', line 16 def list Dir["#{registeries}/*"].each do |reg| git = Git.open(reg) name = File.basename(reg) url = git.remote.url path = reg VPL.info("#{name}") puts "- URL:\t#{url}" puts "- Path:\t#{path}" puts "\n" end end |
#registeries ⇒ Object
10 11 12 13 14 |
# File 'lib/vcpkg_pipeline/core/register.rb', line 10 def registeries path = "#{ENV['HOME']}/.vpl/registries" `mkdir -p #{path}` unless File.directory? path path end |
#remove(name) ⇒ Object
49 50 51 52 53 |
# File 'lib/vcpkg_pipeline/core/register.rb', line 49 def remove(name) Dir["#{registeries}/*"].each do |reg| `rm -fr #{reg}` if name.eql? File.basename(reg) end end |