Module: BEL::Gen::DocumentHeader
- Included in:
- Nanopub
- Defined in:
- lib/bel/gen/document_header.rb
Overview
The DocumentHeader module defines methods that generate a random document header for the Nanopub::Nanopub metadata.
Instance Method Summary collapse
-
#document_authors ⇒ String
Returns randomly chosen document authors.
-
#document_contact_info ⇒ String
Returns a randomly chosen document contact info.
-
#document_copyright ⇒ String
Returns a randomly chosen document copyright.
-
#document_description ⇒ String
Returns a randomly chosen document description.
-
#document_header(options = {}) ⇒ Hash
Returns a random document header.
-
#document_licenses ⇒ String
Returns randomly chosen document licenses.
-
#document_name ⇒ String
Returns a randomly chosen document name.
-
#document_version ⇒ String
Returns a randomly chosen document version.
Instance Method Details
#document_authors ⇒ String
Returns randomly chosen document authors.
80 81 82 83 84 85 86 |
# File 'lib/bel/gen/document_header.rb', line 80 def Rantly { array(range(1, 5)) { "#{sized(6) { string(:alpha) }} #{sized(2) { string(:upper) }}" }.join('|') } end |
#document_contact_info ⇒ String
Returns a randomly chosen document contact info.
74 75 76 |
# File 'lib/bel/gen/document_header.rb', line 74 def document_contact_info Rantly { email } end |
#document_copyright ⇒ String
Returns a randomly chosen document copyright.
68 69 70 |
# File 'lib/bel/gen/document_header.rb', line 68 def document_copyright "You, (c) #{Time.now.year}" end |
#document_description ⇒ String
Returns a randomly chosen document description.
23 24 25 26 27 28 29 30 31 |
# File 'lib/bel/gen/document_header.rb', line 23 def document_description Rantly { array(range(10,50)) { sized(range(3,8)) { string(:alpha).capitalize } }.join(' ').capitalize } end |
#document_header(options = {}) ⇒ Hash
Returns a random document header.
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/bel/gen/document_header.rb', line 116 def document_header( = {}) { :Name => [:name] || document_name, :Description => [:description] || document_description, :Version => [:version] || document_version, :Copyright => [:copyright] || document_copyright, :ContactInfo => [:contact_info] || document_contact_info, :Authors => [:authors] || , :Licenses => [:licenses] || document_licenses, } end |
#document_licenses ⇒ String
Returns randomly chosen document licenses.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/bel/gen/document_header.rb', line 90 def document_licenses Rantly { choose( 'Creative Commons Attribution (BY)', 'Creative Commons Share-alike (BY-SA)', 'Creative Commons Non-commercial (NC)', 'Creative Commons No Derivative Works (ND)', 'Open Data Commons Open Database License', 'Open Data Commons Attribution License', 'Open Data Commons Public Domain Dedication and License', 'Public Domain', ) } end |
#document_name ⇒ String
Returns a randomly chosen document name.
13 14 15 16 17 18 19 |
# File 'lib/bel/gen/document_header.rb', line 13 def document_name Rantly { array(range(1,4)) { string(:alpha).capitalize }.join(' ') } end |
#document_version ⇒ String
Returns a randomly chosen document version.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/bel/gen/document_header.rb', line 35 def document_version Rantly { if boolean # semver numeric = -> { range(0, 15) } "#{numeric.call}.#{numeric.call}.#{numeric.call}" else # rolling date year = -> { range(2000, Time.now.year) } month = -> { choose( '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12' ) } day = -> { choose( '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28' ) } "#{year.call}#{month.call}#{day.call}" end } end |