/advent-of-ruby

Ruby template for solving Advent of Code puzzles

Primary LanguageRubyMIT LicenseMIT

In order to be fully prepared for the first day of Advent, you can use this small template to aid you in setting the file structure, scraping the puzzle data & running testing solutions for each day. Inspired by AoC Rust starter template developed by fspoettel.

Three options are available:

  rake setup # scaffold the file structure & scrape your day

  rake test # test a single day (e.g. rake 'test[10]') or the whole suite

  rake run # run a solution for a single day (e.g. rake 'run[12]')

Setup command

Running setup will open a prompt

  def display_menu
    choices = [
      { name: '🌟 Scaffold files for a delightful advent day 🌟', value: 'scaffold' },
      { name: '🎁 Scrape the festive data for an advent day 🎁', value: 'scrape' },
    ]

    prompt.select("", choices)
  end

where you can choose to either scaffold the files or scrape the data (or both).

Scaffold files command will generate the following file structure within your directory with some minimal boilerplate code to help you start writing the code immediately.

     src
     ├── day1.rb
     ├── day2.rb
     ├── ...


    spec
     ├── day1_spec.rb
     ├── day2_spec.rb
     ├── ...

Scrape data command will scrape the data for the day you provided via the CLI. Data is stored within a .txt file in the data directory. Part 2 will only be scrapped if you have completed part 1 for that day

     data
     ├── day1_part1.txt
     ├── day2_part2.txt
     ├── ...

Important!
To be able to scrape the data, you need to provide a cookie. Cookie can be restored from developers tools in the network tab.

Create a .env file in the rooot directory. Provide your cookie in .env file.

  AOC_COOKIE="your_cookie_goes_here"