Class: ReadmeGenerator::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/readme_generator.rb

Overview

Main entry point for the README Generator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path = Dir.pwd, options = {}) ⇒ Generator

Returns a new instance of Generator.



14
15
16
17
# File 'lib/readme_generator.rb', line 14

def initialize(project_path = Dir.pwd, options = {})
  @project_path = File.expand_path(project_path)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'lib/readme_generator.rb', line 12

def options
  @options
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



12
13
14
# File 'lib/readme_generator.rb', line 12

def project_path
  @project_path
end

Instance Method Details

#generate(output_filename = 'README.md') ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/readme_generator.rb', line 19

def generate(output_filename = 'README.md')
  scanner = Scanner.new(project_path)
  project_info = scanner.scan

  template_builder = TemplateBuilder.new(project_info, options)
  readme_content = template_builder.build

  output_path = File.join(project_path, output_filename)
  File.write(output_path, readme_content)

  output_path
end