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



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

#authorsObject

List of the project authors



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

def authors
  @authors
end

#descriptionObject

A longer description of the project



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

def description
  @description
end

#emailObject

Email address for project



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

def email
  @email
end

#licenseObject (readonly)

The project license (defaults to GPL-3.0)



45
46
47
# File 'lib/gbud/project_metadata.rb', line 45

def license
  @license
end

#nameObject

The name of the project



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

def name
  @name
end

#summaryObject

A short project summary



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

def summary
  @summary
end

#urlObject

The URL for project



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

def url
  @url
end

#versionObject (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_hashObject

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: @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