From 5c794cd2b0962d2716f6e5892e6cf1c3235b1bb9 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 12:41:06 -0800 Subject: [PATCH] Use the Classname::VERSION pattern Instead of having a hardcoded version identifier in multiple locations, we can leverage the Classname::VERSION pattern to have a single canonical version number that everything can reference programmatically. --- lib/vmfloaty.rb | 2 +- lib/vmfloaty/version.rb | 9 ++------- vmfloaty.gemspec | 5 ++++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/vmfloaty.rb b/lib/vmfloaty.rb index 3f718d9..a30ca11 100644 --- a/lib/vmfloaty.rb +++ b/lib/vmfloaty.rb @@ -16,7 +16,7 @@ class Vmfloaty include Commander::Methods def run - program :version, Version.get + program :version, Vmfloaty::VERSION program :description, 'A CLI helper tool for Puppet Labs vmpooler to help you stay afloat' config = Conf.read_config diff --git a/lib/vmfloaty/version.rb b/lib/vmfloaty/version.rb index 8674f33..9e40ace 100644 --- a/lib/vmfloaty/version.rb +++ b/lib/vmfloaty/version.rb @@ -1,8 +1,3 @@ - -class Version - @version = '0.7.8' - - def self.get - @version - end +class Vmfloaty + VERSION = '0.7.8'.freeze end diff --git a/vmfloaty.gemspec b/vmfloaty.gemspec index 2be8ab4..52820b6 100644 --- a/vmfloaty.gemspec +++ b/vmfloaty.gemspec @@ -1,6 +1,9 @@ +$LOAD_PATH.push File.expand_path('../lib', __FILE__) +require 'vmfloaty/version' + Gem::Specification.new do |s| s.name = 'vmfloaty' - s.version = '0.7.8' + s.version = Vmfloaty::VERSION s.authors = ['Brian Cain'] s.email = ['brian.cain@puppetlabs.com'] s.license = 'Apache-2.0'