Sha256: a51ff81cabe4ffde70f32a7427f6e7ad6bcef4e063ea8a254740410b23ce8cf3

Contents?: true

Size: 1.36 KB

Versions: 9

Compression:

Stored size: 1.36 KB

Contents

class UseCase

  attr_accessor :files_to_write, :commands_to_execute

  USE_CASE_FILE_NAME = 'use_case.md'
  TEMPLATE_FILE_NAME = 'use_case_template.md'
  BUILDER_FILE_NAME = 'use_case_builder.rb'

  def initialize
    self.files_to_write = {}
    self.commands_to_execute = []
  end

  def build

    files_to_write.each_pair do |file_name, text|
      File.open(file_name, 'w') do |file|
        file.write(text)
      end
    end
    if File.exist?('includer.md')
      command = self.construct_include_command('includer.md','included.md', pristine = true)
      system(command)
    end
    commands_to_execute.each do |command|
      system(command)
    end
  end

  def construct_command(command, template_file_path, markdown_file_path, pristine = false)
    pristine_option = pristine ? '--pristine ' : ''
    "markdown_helper #{command} #{pristine_option}#{template_file_path} #{markdown_file_path}"
  end

  def construct_include_command(template_file_path, markdown_file_path, pristine = false)
    construct_command(:include, template_file_path, markdown_file_path, pristine)
  end

  def UseCase.construct_include_command(template_file_path, markdown_file_path, pristine = false)
    pristine_option = pristine ? '--pristine ' : ''
    "markdown_helper include #{pristine_option}#{template_file_path} #{markdown_file_path}"
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
markdown_helper-2.5.4 markdown/use_cases/use_case.rb
markdown_helper-2.5.3 markdown/use_cases/use_case.rb
markdown_helper-2.5.2 markdown/use_cases/use_case.rb
markdown_helper-2.5.1 markdown/use_cases/use_case.rb
markdown_helper-2.5.0 markdown/use_cases/use_case.rb
markdown_helper-2.4.0 markdown/use_cases/use_case.rb
markdown_helper-2.3.0 markdown/use_cases/use_case.rb
markdown_helper-2.2.0 markdown/use_cases/use_case.rb
markdown_helper-2.1.0 markdown/use_cases/use_case.rb