Skip to content

Commit d70218e

Browse files
authored
Add version command (#30)
* Add version command * Update changelog
1 parent 46ec30b commit d70218e

5 files changed

Lines changed: 27 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
- No unreleased changes!
8+
### Added
9+
- 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))
910

1011
## [0.2.6]
1112
### Changed

lib/aoc_rb/app.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ def prep(year = options[:year], day = options[:day])
142142
fetch(year, day)
143143
bootstrap(year, day)
144144
end
145+
146+
desc "version", "prints the current installed version of AocRb"
147+
148+
def version
149+
puts "AocRb version #{AocRb::VERSION}"
150+
end
145151
end
146152
end
147153

lib/aoc_rb/cli.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def new(name)
4747
gemfile_src = File.join(File.dirname(__FILE__), "../../templates/Gemfile")
4848
File.open(gemfile_dst, "w") { |f| f.write(File.read(gemfile_src))}
4949
end
50+
51+
desc "version", "prints the current installed version of AocRb"
52+
53+
def version
54+
puts "AocRb version #{AocRb::VERSION}"
55+
end
5056
end
5157
end
5258

spec/lib/aoc_rb/app_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,4 +456,12 @@
456456
end
457457
end
458458
end
459+
460+
describe "version" do
461+
it "returns the current version" do
462+
within_test_app do
463+
expect { AocRb::App.start %w(version) }.to output("AocRb version #{AocRb::VERSION}\n").to_stdout
464+
end
465+
end
466+
end
459467
end

spec/system/aoc_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
end
99

1010
it "can create a new project" do
11-
expect { system %(aoc new dummy) }
12-
.to change { File.exist? "dummy" }
13-
.from(false).to(true)
11+
expect { `aoc new dummy` }.to change { File.exist? "dummy" }.from(false).to(true)
12+
end
13+
14+
it "can output the installed version" do
15+
expect(`aoc version`).to eq "AocRb version #{AocRb::VERSION}\n"
1416
end
1517
end

0 commit comments

Comments
 (0)