Class: ManageIQ::CrossRepo::Repository
- Inherits:
-
Object
- Object
- ManageIQ::CrossRepo::Repository
- Defined in:
- lib/manageiq/cross_repo/repository.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#org ⇒ Object
readonly
Returns the value of attribute org.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #core? ⇒ Boolean
- #ensure_clone ⇒ Object
-
#initialize(identifier, server: "https://github.com") ⇒ Repository
constructor
ManageIQ::CrossRepo::Repository.
Constructor Details
#initialize(identifier, server: "https://github.com") ⇒ Repository
ManageIQ::CrossRepo::Repository
14 15 16 17 18 |
# File 'lib/manageiq/cross_repo/repository.rb', line 14 def initialize(identifier, server: "https://github.com") @identifier = identifier @server = server @org, @repo, @ref, @sha, @url, @path = parse_identifier end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/manageiq/cross_repo/repository.rb', line 5 def identifier @identifier end |
#org ⇒ Object (readonly)
Returns the value of attribute org.
6 7 8 |
# File 'lib/manageiq/cross_repo/repository.rb', line 6 def org @org end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/manageiq/cross_repo/repository.rb', line 6 def path @path end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
6 7 8 |
# File 'lib/manageiq/cross_repo/repository.rb', line 6 def ref @ref end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
6 7 8 |
# File 'lib/manageiq/cross_repo/repository.rb', line 6 def repo @repo end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/manageiq/cross_repo/repository.rb', line 5 def server @server end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
6 7 8 |
# File 'lib/manageiq/cross_repo/repository.rb', line 6 def sha @sha end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/manageiq/cross_repo/repository.rb', line 6 def url @url end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 |
# File 'lib/manageiq/cross_repo/repository.rb', line 24 def ==(other) repo == other.repo && sha == other.sha end |
#core? ⇒ Boolean
20 21 22 |
# File 'lib/manageiq/cross_repo/repository.rb', line 20 def core? repo.casecmp("manageiq") == 0 end |
#ensure_clone ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/manageiq/cross_repo/repository.rb', line 28 def ensure_clone return if path.exist? require "mixlib/archive" require "open-uri" require "tmpdir" require "zlib" retries ||= 0 puts "Fetching #{tarball_url}#{retry_count(retries)}" Dir.mktmpdir do |dir| Mixlib::Archive.new(open_tarball_url(tarball_url)).extract(dir) content_dir = Pathname.new(dir).children.detect(&:directory?) FileUtils.mkdir_p(path.dirname) FileUtils.mv(content_dir, path) end rescue => e retries += 1 raise if retries > 3 sleep 1 retry end |