Skip to content

Commit

Permalink
Add version command (#30)
Browse files Browse the repository at this point in the history
* Add version command

* Update changelog
  • Loading branch information
pacso authored Dec 5, 2024
1 parent 46ec30b commit d70218e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ 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]
- No unreleased changes!
### Added
- Version command, which outputs the installed version of the gem ([#30](https://github.com/pacso/aoc_rb/pull/30) by [@pacso](https://github.com/pacso))

## [0.2.6]
### Changed
Expand Down
6 changes: 6 additions & 0 deletions lib/aoc_rb/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def prep(year = options[:year], day = options[:day])
fetch(year, day)
bootstrap(year, day)
end

desc "version", "prints the current installed version of AocRb"

def version
puts "AocRb version #{AocRb::VERSION}"
end
end
end

Expand Down
6 changes: 6 additions & 0 deletions lib/aoc_rb/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def new(name)
gemfile_src = File.join(File.dirname(__FILE__), "../../templates/Gemfile")
File.open(gemfile_dst, "w") { |f| f.write(File.read(gemfile_src))}
end

desc "version", "prints the current installed version of AocRb"

def version
puts "AocRb version #{AocRb::VERSION}"
end
end
end

Expand Down
8 changes: 8 additions & 0 deletions spec/lib/aoc_rb/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,12 @@
end
end
end

describe "version" do
it "returns the current version" do
within_test_app do
expect { AocRb::App.start %w(version) }.to output("AocRb version #{AocRb::VERSION}\n").to_stdout
end
end
end
end
8 changes: 5 additions & 3 deletions spec/system/aoc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
end

it "can create a new project" do
expect { system %(aoc new dummy) }
.to change { File.exist? "dummy" }
.from(false).to(true)
expect { `aoc new dummy` }.to change { File.exist? "dummy" }.from(false).to(true)
end

it "can output the installed version" do
expect(`aoc version`).to eq "AocRb version #{AocRb::VERSION}\n"
end
end

0 comments on commit d70218e

Please sign in to comment.