Class: Texy::Document

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions, Thor::Base
Defined in:
lib/texy/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDocument

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

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/texy/document.rb', line 11

def client
  @client
end

#numberObject (readonly)

Returns the value of attribute number.



11
12
13
# File 'lib/texy/document.rb', line 11

def number
  @number
end

#titleObject (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_placeholdersObject

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

#branchObject



19
20
21
# File 'lib/texy/document.rb', line 19

def branch
  "#{type}/#{client}-#{number}"
end

#config_placeholdersObject

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_fileObject



35
36
37
# File 'lib/texy/document.rb', line 35

def definition_file
  "lib/commands_and_definitions.tex"
end

#fileObject



31
32
33
# File 'lib/texy/document.rb', line 31

def file
  "#{file_no_extension}.tex"
end

#file_no_extensionObject



27
28
29
# File 'lib/texy/document.rb', line 27

def file_no_extension
  "#{client}_#{number}"
end

#folderObject



23
24
25
# File 'lib/texy/document.rb', line 23

def folder
  "#{client}/#{number}"
end

#index_file_placeholdersObject

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