Class: Texy::Document
- Inherits:
-
Object
- Object
- Texy::Document
- Includes:
- Thor::Actions, Thor::Base
- Defined in:
- lib/texy/document.rb
Direct Known Subclasses
Texy::Documents::ReleaseNotes, Texy::Documents::StatementOfWork
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#base_placeholders ⇒ Object
Placeholders dependent on this specific document, not the client in general.
- #branch ⇒ Object
-
#config_placeholders ⇒ Object
Placeholders dependent on the client configuration.
- #definition_file ⇒ Object
- #file ⇒ Object
- #file_no_extension ⇒ Object
- #folder ⇒ Object
-
#index_file_placeholders ⇒ Object
Placeholders located in the index file, not the LaTeX file.
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #substitute_placeholders(configuration:) ⇒ Object
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
13 14 15 16 17 |
# File 'lib/texy/document.rb', line 13 def initialize @client = ask("Which client folder will this #{type_humanized} be in?", :yellow) @number = ask("Which #{type_humanized} number is this?", :yellow).rjust(3, "0") @title = ask("What is the title of this document?", :yellow) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
11 12 13 |
# File 'lib/texy/document.rb', line 11 def client @client end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
11 12 13 |
# File 'lib/texy/document.rb', line 11 def number @number end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/texy/document.rb', line 11 def title @title end |
Instance Method Details
#base_placeholders ⇒ Object
Placeholders dependent on this specific document, not the client in general
61 62 63 64 65 66 67 |
# File 'lib/texy/document.rb', line 61 def base_placeholders { /TEMPLATE-PLACEHOLDER-PROJECT-NUMBER/ => ->(document) { document.number }, /TEMPLATE-PLACEHOLDER-PROJECT-TITLE/ => ->(document) { document.title }, /TEMPLATE-PLACEHOLDER-DOCUMENT-VERSION/ => ->(_document) { "1.0" } } end |
#branch ⇒ Object
19 20 21 |
# File 'lib/texy/document.rb', line 19 def branch "#{type}/#{client}-#{number}" end |
#config_placeholders ⇒ Object
Placeholders dependent on the client configuration
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/texy/document.rb', line 46 def config_placeholders { /TEMPLATE-PLACEHOLDER-CLIENT-NAME/ => ->(config) { config.client.name }, /TEMPLATE-PLACEHOLDER-CLIENT-NUMBER/ => ->(config) { config.client.number }, /TEMPLATE-PLACEHOLDER-CLIENT-SHORT-NAME/ => ->(config) { config.client.short_name }, /TEMPLATE-PLACEHOLDER-CLIENT-PRINCIPAL-NAME/ => ->(config) { config.client.principal.name }, /TEMPLATE-PLACEHOLDER-CLIENT-SIGNER-NAME/ => ->(config) { config.client.signer.name }, /TEMPLATE-PLACEHOLDER-CLIENT-SIGNER-ROLE/ => ->(config) { config.client.signer.role }, /TEMPLATE-PLACEHOLDER-NEAD-WERX-PRINCIPAL-NAME/ => ->(config) { config.company.principal.name }, /TEMPLATE-PLACEHOLDER-NEAD-WERX-SIGNER-NAME/ => ->(config) { config.company.signer.name }, /TEMPLATE-PLACEHOLDER-NEAD-WERX-SIGNER-ROLE/ => ->(config) { config.company.signer.role } } end |
#definition_file ⇒ Object
35 36 37 |
# File 'lib/texy/document.rb', line 35 def definition_file "lib/commands_and_definitions.tex" end |
#file ⇒ Object
31 32 33 |
# File 'lib/texy/document.rb', line 31 def file "#{file_no_extension}.tex" end |
#file_no_extension ⇒ Object
27 28 29 |
# File 'lib/texy/document.rb', line 27 def file_no_extension "#{client}_#{number}" end |
#folder ⇒ Object
23 24 25 |
# File 'lib/texy/document.rb', line 23 def folder "#{client}/#{number}" end |
#index_file_placeholders ⇒ Object
Placeholders located in the index file, not the LaTeX file
70 71 72 73 74 |
# File 'lib/texy/document.rb', line 70 def index_file_placeholders { /TEMPLATE-PLACEHOLDER-INDEX-TITLE/ => ->(document) { document.title } } end |
#substitute_placeholders(configuration:) ⇒ Object
39 40 41 42 43 |
# File 'lib/texy/document.rb', line 39 def substitute_placeholders(configuration:) perform_index_file_substitutions perform_base_substitutions perform_configuration_substitutions(configuration: configuration) end |