Class: StaticSiteBuilder::Generator

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

Overview

Generates new static site projects.

Creates a complete project structure including Gemfile, build configuration files, example pages, and development server setup.

Examples:

Generate a site

generator = StaticSiteBuilder::Generator.new("my-site")
generator.generate

Constant Summary collapse

DEFAULT_PORT =

Reference StaticSiteBuilder constants for consistency

StaticSiteBuilder::DEFAULT_PORT
DEFAULT_WS_PORT =
StaticSiteBuilder::DEFAULT_WS_PORT

Instance Method Summary collapse

Constructor Details

#initialize(app_name, options = {}) ⇒ Generator

Initializes a new generator instance.

Parameters:

  • app_name (String) —

    The name of the site to generate (will be used as directory name)



26
27
28
29
30
# File 'lib/generator.rb', line 26

def initialize(app_name, options = {})
  @app_name = app_name
  @app_path = Pathname.new(app_name)
  @options = {}
end

Instance Method Details

#generate ⇒ void

This method returns an undefined value.

Generates the complete static site project.

Creates the directory structure, configuration files, example pages, build scripts, and all necessary dependencies. Provides next steps after successful generation.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/generator.rb', line 38

def generate
  puts "Generating static site: #{@app_name}"

  create_directory_structure
  create_gemfile
  create_config_files
  create_app_structure
  create_build_files
  create_sitemap_config
  create_example_pages
  create_readme
  create_gitignore

  puts "\n✓ Site generated successfully!"
  puts "\nNext steps:"
  puts "  cd #{@app_name}"
  puts "  bundle install"
  puts "  bundle exec rake dev:server    # Start development server with live reload"
  puts "  # or"
  puts "  bundle exec rake build:all     # Build for deployment"
end