Skip to content

Commit

Permalink
Fix output task and add spec task (#16)
Browse files Browse the repository at this point in the history
* fix output and add spec actions

* Update lib/aoc_rb/puzzle_source.rb

* Update lib/aoc_rb/app.rb

* Update CHANGELOG.md

Co-authored-by: Jon Pascoe <[email protected]>
  • Loading branch information
kauredo and pacso authored Dec 2, 2022
1 parent ad4685b commit 9e9f838
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Output task fixed (by [@kauredo](https://github.com/kauredo))
- Spec task added to run tests from a given day (by [@kauredo](https://github.com/kauredo))

## [0.2.3]
### Changed
Expand Down
16 changes: 13 additions & 3 deletions lib/aoc_rb/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,22 @@ def exec(year = options[:year], day = options[:day])
method_option :day, aliases: "-d", type: :numeric, default: Time.now.day

def output(year = options[:year], day = options[:day])
puzzle = AocRb::PuzzleSource.create_puzzle(year, day)
input = AocRb::PuzzleInput.load(year, day)
puzzle = AocRb::PuzzleSource.create_puzzle(year, day, input)

AocRb::PuzzleSource.run_part('part 1') { puzzle.part_1(input) }
AocRb::PuzzleSource.run_part('part 1') { puzzle.part_1 }
puts
AocRb::PuzzleSource.run_part('part 2') { puzzle.part_2(input) }
AocRb::PuzzleSource.run_part('part 2') { puzzle.part_2 }
end

desc "spec", "runs tests for today, or the specified date"
method_option :year, aliases: "-y", type: :numeric, default: Time.now.year
method_option :day, aliases: "-d", type: :numeric, default: Time.now.day

def spec(year = options[:year], day = options[:day])
spec_dir = File.join("spec", year.to_s, AocRb::Puzzle.padded(day))

Kernel.exec( "bundle exec rspec #{spec_dir}" )
end

desc "prep", "preps everything you need for a new puzzle"
Expand Down

0 comments on commit 9e9f838

Please sign in to comment.