This repository has been archived by the owner on Apr 5, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
externalize mapping of archive information
- Loading branch information
Showing
25 changed files
with
622 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
...-maven-core/src/main/java/com/github/klieber/phantomjs/archive/LinuxPhantomJSArchive.java
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
...maven-core/src/main/java/com/github/klieber/phantomjs/archive/MacOSXPhantomJSArchive.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...s-maven-core/src/main/java/com/github/klieber/phantomjs/archive/PhantomJSArchiveImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.github.klieber.phantomjs.archive; | ||
|
||
import com.github.klieber.phantomjs.archive.mapping.ArchiveFormat; | ||
|
||
public class PhantomJSArchiveImpl implements PhantomJSArchive { | ||
|
||
private final ArchiveFormat archiveFormat; | ||
private final String version; | ||
|
||
public PhantomJSArchiveImpl(ArchiveFormat archiveFormat, | ||
String version) { | ||
this.archiveFormat = archiveFormat; | ||
this.version = version; | ||
} | ||
|
||
@Override | ||
public String getExtension() { | ||
return this.archiveFormat.getExtension(); | ||
} | ||
|
||
@Override | ||
public String getArchiveName() { | ||
return applyTemplate(this.archiveFormat.getFileTemplate()); | ||
} | ||
|
||
@Override | ||
public String getPathToExecutable() { | ||
return applyTemplate(this.archiveFormat.getExecutableTemplate()); | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
@Override | ||
public String getClassifier() { | ||
return this.archiveFormat.getClassifier(); | ||
} | ||
|
||
private String applyTemplate(String template) { | ||
return template | ||
.replaceAll("\\{version}", this.version) | ||
.replaceAll("\\{classifier}", this.archiveFormat.getClassifier()) | ||
.replaceAll("\\{extension}", this.archiveFormat.getExtension()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...core/src/main/java/com/github/klieber/phantomjs/archive/UnsupportedPlatformException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.github.klieber.phantomjs.archive; | ||
|
||
import com.github.klieber.phantomjs.os.OperatingSystem; | ||
|
||
public class UnsupportedPlatformException extends RuntimeException { | ||
|
||
private static final String MESSAGE = "Unsupported platform: %s"; | ||
|
||
public UnsupportedPlatformException(OperatingSystem operatingSystem) { | ||
super(String.format(MESSAGE, operatingSystem)); | ||
} | ||
} |
Oops, something went wrong.