Class: Warbler::WebServer::Artifact
- Inherits:
-
Struct
- Object
- Struct
- Warbler::WebServer::Artifact
- Defined in:
- lib/warbler/web_server.rb
Constant Summary collapse
- @@local_repository =
nil
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
- #cached_path ⇒ Object
- #download_url ⇒ Object
- #local_path ⇒ Object
- #local_repository ⇒ Object
- #path_fragment ⇒ Object
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
9 10 11 |
# File 'lib/warbler/web_server.rb', line 9 def cached_path @cached_path ||= File.join(local_repository, path_fragment) end |
#download_url ⇒ Object
13 14 15 |
# File 'lib/warbler/web_server.rb', line 13 def download_url @download_url ||= "#{repo}/#{path_fragment}" #:nocov: end |
#local_path ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/warbler/web_server.rb', line 17 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 |
#local_repository ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/warbler/web_server.rb', line 40 def local_repository @@local_repository ||= begin m2_home = File.join(user_home, '.m2') if File.exist?(settings = File.join(m2_home, 'settings.xml')) local_repo = detect_local_repository(settings) end if local_repo.nil? && mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME'] if File.exist?(settings = File.join(mvn_home, 'conf/settings.xml')) local_repo = detect_local_repository(settings) end end local_repo || File.join(m2_home, 'repository') end end |
#path_fragment ⇒ Object
5 6 7 |
# File 'lib/warbler/web_server.rb', line 5 def path_fragment @path_fragment ||= "#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.jar" end |