Class: GBud::ProjectMetadata
- Inherits:
-
Object
- Object
- GBud::ProjectMetadata
- Defined in:
- lib/gbud/project_metadata.rb
Overview
ProjectMetadata
- Author
-
Richard Davis
- Copyright
-
Copyright 2017 Richard Davis
- License
-
GNU Public License 3
The means by which user input describing project metadata is captured to be used by GBud::ProjectBuilder objects.
Instance Attribute Summary collapse
-
#authors ⇒ Object
List of the project authors.
-
#description ⇒ Object
A longer description of the project.
-
#email ⇒ Object
Email address for project.
-
#license ⇒ Object
readonly
The project license (defaults to GPL-3.0).
-
#name ⇒ Object
The name of the project.
-
#summary ⇒ Object
A short project summary.
-
#url ⇒ Object
The URL for project.
-
#version ⇒ Object
readonly
The project version (defaults to 0.0.1).
Instance Method Summary collapse
-
#initialize ⇒ ProjectMetadata
constructor
Instantiates a ProjectMetadata object.
-
#to_hash ⇒ Object
Returns the object attributes as a hash.
-
#validate_email(email) ⇒ Object
Validates that the given email meets criteria.
-
#validate_name(name) ⇒ Object
Validates that the given name meets criteria.
-
#validate_url(url) ⇒ Object
Validates that the given url meets criteria.
Constructor Details
#initialize ⇒ ProjectMetadata
Instantiates a ProjectMetadata object
49 50 51 52 |
# File 'lib/gbud/project_metadata.rb', line 49 def initialize @version = '0.0.1' @license = 'GPL-3.0' end |
Instance Attribute Details
#authors ⇒ Object
List of the project authors
37 38 39 |
# File 'lib/gbud/project_metadata.rb', line 37 def end |
#description ⇒ Object
A longer description of the project
35 36 37 |
# File 'lib/gbud/project_metadata.rb', line 35 def description @description end |
#email ⇒ Object
Email address for project
39 40 41 |
# File 'lib/gbud/project_metadata.rb', line 39 def email @email end |
#license ⇒ Object (readonly)
The project license (defaults to GPL-3.0)
45 46 47 |
# File 'lib/gbud/project_metadata.rb', line 45 def license @license end |
#name ⇒ Object
The name of the project
31 32 33 |
# File 'lib/gbud/project_metadata.rb', line 31 def name @name end |
#summary ⇒ Object
A short project summary
33 34 35 |
# File 'lib/gbud/project_metadata.rb', line 33 def summary @summary end |
#url ⇒ Object
The URL for project
41 42 43 |
# File 'lib/gbud/project_metadata.rb', line 41 def url @url end |
#version ⇒ Object (readonly)
The project version (defaults to 0.0.1)
43 44 45 |
# File 'lib/gbud/project_metadata.rb', line 43 def version @version end |
Instance Method Details
#to_hash ⇒ Object
Returns the object attributes as a hash
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/gbud/project_metadata.rb', line 80 def to_hash { name: @name, authors: , email: @email, url: @url, summary: @summary, description: @description, version: @version, license: @license } end |
#validate_email(email) ⇒ Object
Validates that the given email meets criteria
101 102 103 |
# File 'lib/gbud/project_metadata.rb', line 101 def validate_email(email) /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i =~ email end |
#validate_name(name) ⇒ Object
Validates that the given name meets criteria
95 96 97 |
# File 'lib/gbud/project_metadata.rb', line 95 def validate_name(name) /\A[a-z][a-z0-9_\-]*\Z/i =~ name end |
#validate_url(url) ⇒ Object
Validates that the given url meets criteria
107 108 109 |
# File 'lib/gbud/project_metadata.rb', line 107 def validate_url(url) %r{https?:\/\/[\S]+} =~ url end |