Class: Warbler::WebServer::Artifact
- Inherits:
-
Struct
- Object
- Struct
- Warbler::WebServer::Artifact
- Defined in:
- lib/warbler/web_server.rb
Instance Attribute Summary collapse
-
#artifact_id ⇒ Object
Returns the value of attribute artifact_id.
-
#group_id ⇒ Object
Returns the value of attribute group_id.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
Instance Attribute Details
#artifact_id ⇒ Object
Returns the value of attribute artifact_id
3 4 5 |
# File 'lib/warbler/web_server.rb', line 3 def artifact_id @artifact_id end |
#group_id ⇒ Object
Returns the value of attribute group_id
3 4 5 |
# File 'lib/warbler/web_server.rb', line 3 def group_id @group_id end |
#repo ⇒ Object
Returns the value of attribute repo
3 4 5 |
# File 'lib/warbler/web_server.rb', line 3 def repo @repo end |
#version ⇒ Object
Returns the value of attribute version
3 4 5 |
# File 'lib/warbler/web_server.rb', line 3 def version @version end |
Instance Method Details
#cached_path ⇒ Object
8 9 10 |
# File 'lib/warbler/web_server.rb', line 8 def cached_path @cached_path ||= File.("~/.m2/repository/#{path_fragment}") end |
#download_url ⇒ Object
12 13 14 |
# File 'lib/warbler/web_server.rb', line 12 def download_url @download_url ||= "#{repo}/#{path_fragment}" #:nocov: end |
#local_path ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/warbler/web_server.rb', line 16 def local_path unless File.exist?(cached_path) puts "Downloading #{artifact_id}-#{version}.jar" #:nocov: FileUtils.mkdir_p File.dirname(cached_path) #:nocov: require 'open-uri' #:nocov: begin open(download_url) do |stream| #:nocov: File.open(cached_path, "wb") do |f| #:nocov: while buf = stream.read(4096) #:nocov: f << buf #:nocov: end #:nocov: end #:nocov: end #:nocov: rescue => e e..concat " - #{download_url}" raise e end end cached_path end |
#path_fragment ⇒ Object
4 5 6 |
# File 'lib/warbler/web_server.rb', line 4 def path_fragment @path_fragment ||= "#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.jar" end |