Class: Muwu::ProjectValidator

Inherits:
Object
  • Object
show all
Includes:
Muwu
Defined in:
lib/muwu/project_builder/project_validator.rb

Constant Summary

Constants included from Muwu

GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION

Instance Method Summary collapse

Methods included from Muwu

debug, read

Constructor Details

#initialize(project) ⇒ ProjectValidator

Returns a new instance of ProjectValidator.



8
9
10
# File 'lib/muwu/project_builder/project_validator.rb', line 8

def initialize(project)
  @project = project
end

Instance Method Details

#validate_file_cssObject



17
18
19
20
21
22
23
24
# File 'lib/muwu/project_builder/project_validator.rb', line 17

def validate_file_css
  if @project.css_manifest_file_does_exist
    return true
  else
    @project.exceptions_add ProjectException::CssManifestFileNotFound.new(@project.css_manifest_filename)
    return false
  end
end

#validate_file_metadataObject



27
28
29
30
31
32
33
34
# File 'lib/muwu/project_builder/project_validator.rb', line 27

def 
  if @project.
    return true
  else
    @project.exceptions_add ProjectException::MetadataFileNotFound.new(@project)
    return false
  end
end

#validate_file_optionsObject



37
38
39
40
41
42
43
44
# File 'lib/muwu/project_builder/project_validator.rb', line 37

def validate_file_options
  if @project.options_file_does_exist
    return true
  else
    @project.exceptions_add ProjectException::OptionsFileNotFound.new(@project)
    return false
  end
end

#validate_file_outlineObject



47
48
49
50
51
52
53
54
# File 'lib/muwu/project_builder/project_validator.rb', line 47

def validate_file_outline
  if @project.outline_file_does_exist
    return true
  else
    @project.exceptions_add ProjectException::OutlineFileNotFound.new(@project)
    return false
  end
end

#validate_outline_step_navigator(index) ⇒ Object



57
58
59
60
# File 'lib/muwu/project_builder/project_validator.rb', line 57

def validate_outline_step_navigator(index)
  validate_outline_step_navigator_if_single_document(index)
  return validate_outline_step_navigator_if_automatic(index)
end

#validate_outline_step_navigator_if_automatic(index) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/muwu/project_builder/project_validator.rb', line 63

def validate_outline_step_navigator_if_automatic(index)
  if @project.will_not_generate_navigators_automatically
    return true
  elsif @project.will_generate_navigators_automatically
    @project.exceptions_add ProjectException::NavigatorsWillBeGeneratedAutomatically.new(index)
    return false
  end
end

#validate_outline_step_navigator_if_single_document(index) ⇒ Object



73
74
75
76
77
# File 'lib/muwu/project_builder/project_validator.rb', line 73

def validate_outline_step_navigator_if_single_document(index)
  if @project.outline_has_only_one_document
    @project.exceptions_add ProjectException::NavigatorNotRecommendedWithSingleDocument.new(index)
  end
end

#validate_outline_step_subcontents(index) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/muwu/project_builder/project_validator.rb', line 80

def validate_outline_step_subcontents(index)
  if @project.will_not_generate_subcontents_automatically
    return true
  elsif @project.will_generate_subcontents_automatically
    @project.exceptions_add ProjectException::SubcontentsWillBeGeneratedAutomatically.new(@index)
    return false
  end
end

#validate_output_destination_and_formatsObject



90
91
92
93
94
# File 'lib/muwu/project_builder/project_validator.rb', line 90

def validate_output_destination_and_formats
  if @project.output_destination_requests_stdout && @project.output_formats_several
    @project.exceptions_add ProjectException::MultipleFormatsRequestedWithStdout.new
  end
end

#validate_scenario_if_more_than_one_documentObject



97
98
99
100
101
102
103
104
# File 'lib/muwu/project_builder/project_validator.rb', line 97

def validate_scenario_if_more_than_one_document
  if @project.outline_has_more_than_one_document && @project.output_destination_requests_stdout
    @project.exceptions_add ProjectException::MultipleDocumentsOutlinedWithStdout.new
  end
  if @project.outline_has_more_than_one_document && @project.will_embed_at_least_one_asset
    @project.exceptions_add ProjectException::DryOutputRecommendedWithMultipleDocuments.new
  end
end

#validate_task_metadata(task) ⇒ Object



107
108
109
110
111
112
113
114
115
# File 'lib/muwu/project_builder/project_validator.rb', line 107

def (task)
  values_missing = task..select { |k,v| v.to_s == ''}
  if values_missing.empty?
    return true
  else
    values_missing.each_pair { |k,v| @project.exceptions_add ProjectException::MetadataValueNotGiven.new(task, k) }
    return false
  end
end

#validate_task_text_item(task) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/muwu/project_builder/project_validator.rb', line 118

def validate_task_text_item(task)
  if task.is_parent_heading
    return validate_task_text_item_parent_heading(task)
  elsif task.is_not_parent_heading
    return validate_task_text_item_child_heading(task)
  end
end

#validate_task_text_item_child_heading(task) ⇒ Object



127
128
129
130
131
132
133
134
# File 'lib/muwu/project_builder/project_validator.rb', line 127

def validate_task_text_item_child_heading(task)
  if task.source_file_does_exist
    return true
  else
    @project.exceptions_add ProjectException::TextSourceFileNotFound.new(task)
    return false
  end
end

#validate_task_text_item_parent_heading(task) ⇒ Object



137
138
139
140
141
142
143
144
145
146
# File 'lib/muwu/project_builder/project_validator.rb', line 137

def validate_task_text_item_parent_heading(task)
  if task.source_file_does_exist
    return true
  else
    if @project.options.warning_if_parent_heading_lacks_source
      @project.exceptions_add ProjectException::TextSourceFileNotFound.new(task)
      return false
    end
  end
end

#validate_task_title(task) ⇒ Object



150
151
152
# File 'lib/muwu/project_builder/project_validator.rb', line 150

def validate_task_title(task)
  return (task)
end