Skip to content

Commit

Permalink
feat(choco): add ability to generate nuspec files
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Apr 11, 2021
1 parent 7196452 commit 493f754
Show file tree
Hide file tree
Showing 11 changed files with 1,423 additions and 5 deletions.
105 changes: 105 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions aer_data/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl PartialEq<str> for Description {
#[non_exhaustive]
pub struct PackageMetadata {
package_source_url: Option<Url>,
icon_url: Option<Url>,
/// The identifier of the package
id: String,

Expand Down Expand Up @@ -118,6 +119,7 @@ impl PackageMetadata {
pub fn new<T: AsRef<str>>(id: T) -> PackageMetadata {
PackageMetadata {
package_source_url: None,
icon_url: None,
id: id.as_ref().to_string(),
maintainers: crate::defaults::maintainer(),
summary: String::new(),
Expand Down Expand Up @@ -169,6 +171,13 @@ impl PackageMetadata {
}
}

/// The direct url to the icon of the software.
/// Typically hosted in a repository, and linked to with jsdelivr, rawhack,
/// etc.
pub fn icon_url(&self) -> &Option<Url> {
&self.icon_url
}

/// Returns the url to the landing page of the software.
pub fn project_url(&self) -> &Url {
&self.project_url
Expand Down Expand Up @@ -225,6 +234,13 @@ impl PackageMetadata {
Ok(())
}

/// Allows setting the url to the software icon for this package.
/// Will return [url::ParseError] if the specified url is not a url.
pub fn set_icon_url<U: AsRef<str>>(&mut self, url: U) -> Result<(), url::ParseError> {
self.icon_url = Some(Url::parse(url.as_ref())?);
Ok(())
}

/// Allows setting the url to the project (usually the home page of the
/// software). Will return [url::ParseError] if the specified url is not
/// a url.
Expand Down Expand Up @@ -271,6 +287,7 @@ mod tests {
fn new_should_create_default_metadata_with_expected_values() {
let expected = PackageMetadata {
package_source_url: None,
icon_url: None,
id: "test-package".to_owned(),
maintainers: crate::defaults::maintainer(),
project_url: crate::defaults::url(),
Expand Down
Loading

0 comments on commit 493f754

Please sign in to comment.