Class: GBud::ProjectMetadata

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeProjectMetadata

Instantiates a ProjectMetadata object



47
48
49
50
# File 'lib/gbud/project_metadata.rb', line 47

def initialize
  @version = '0.0.1'
  @license = 'GPL-3.0'
end

Instance Attribute Details

#authorsObject

List of the project authors



35
36
37
# File 'lib/gbud/project_metadata.rb', line 35

def authors
  @authors
end

#descriptionObject

A longer description of the project



33
34
35
# File 'lib/gbud/project_metadata.rb', line 33

def description
  @description
end

#emailObject

Email address for project



37
38
39
# File 'lib/gbud/project_metadata.rb', line 37

def email
  @email
end

#licenseObject (readonly)

The project license (defaults to GPL-3.0)



43
44
45
# File 'lib/gbud/project_metadata.rb', line 43

def license
  @license
end

#nameObject

The name of the project



29
30
31
# File 'lib/gbud/project_metadata.rb', line 29

def name
  @name
end

#summaryObject

A short project summary



31
32
33
# File 'lib/gbud/project_metadata.rb', line 31

def summary
  @summary
end

#urlObject

The URL for project



39
40
41
# File 'lib/gbud/project_metadata.rb', line 39

def url
  @url
end

#versionObject (readonly)

The project version (defaults to 0.0.1)



41
42
43
# File 'lib/gbud/project_metadata.rb', line 41

def version
  @version
end

Instance Method Details

#to_hashObject

Returns the object attributes as a hash



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/gbud/project_metadata.rb', line 78

def to_hash
  {
    name: @name,
    authors: @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



99
100
101
# File 'lib/gbud/project_metadata.rb', line 99

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



93
94
95
# File 'lib/gbud/project_metadata.rb', line 93

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



105
106
107
# File 'lib/gbud/project_metadata.rb', line 105

def validate_url(url)
  %r{https?:\/\/[\S]+} =~ url
end