From 573f0d83a96472bbe32db9bf93dfd52fbec5db0a Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 11:48:06 -0800 Subject: [PATCH 1/7] Update Gemspec Formatting is slightly more idiomatic now. --- Gemfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 13c60e1..49db604 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,11 @@ source 'https://rubygems.org' -gem 'commander' -gem 'faraday', '0.9.2' -gem 'colorize', '~> 0.8' - -gem 'rspec' -gem 'webmock', '1.21.0' -gem 'rake' - gemspec + +gem 'rake', require: false + +group :test do + gem 'rspec', '~> 3.5.0' + gem 'rubocop', '~> 0.47' + gem 'webmock', '1.21.0' +end From 8babbe32ce336b41f86f62bd88d91603acdafcb4 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 11:51:21 -0800 Subject: [PATCH 2/7] Add Rubocop support to Rakefile --- Rakefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 755ebc1..efbd5a9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ require 'rubygems' require 'bundler/setup' require 'rspec/core/rake_task' +require 'rubocop/rake_task' # Immediately sync all stdout so that tools like buildbot can # immediately load in the output. @@ -8,7 +9,7 @@ $stdout.sync = true $stderr.sync = true # Change to the directory of this file. -Dir.chdir(File.expand_path("../", __FILE__)) +Dir.chdir(File.expand_path('../', __FILE__)) # This installs the tasks that help with gem creation and # publishing. @@ -16,7 +17,13 @@ Bundler::GemHelper.install_tasks # Install the `spec` task so that we can run tests. RSpec::Core::RakeTask.new(:spec) do |t| - t.rspec_opts = "--order defined" + t.rspec_opts = '--order defined' end + +desc 'Run RuboCop' +RuboCop::RakeTask.new(:rubocop) do |task| + task.options << '--display-cop-names' +end + # Default task is to run the unit tests -task :default => :spec +task default: :spec From ee0c73dfda1eee2855524937de5364acc0dbb42e Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 11:53:08 -0800 Subject: [PATCH 3/7] Add a little formatting to Rspec --- spec/spec_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8eaa8b4..decf5e7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,2 +1,8 @@ require 'vmfloaty' require 'webmock/rspec' + +RSpec.configure do |config| + config.color = true + config.tty = true + config.formatter = :documentation +end From 21c42dbffa389b0de91f7270c414a2e607995651 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 12:38:46 -0800 Subject: [PATCH 4/7] Clarify license in Gemspec As per https://opensource.org/licenses/alphabetical, the name should be Apache-2.0, not Apache. --- vmfloaty.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmfloaty.gemspec b/vmfloaty.gemspec index 15284d9..82e3f7a 100644 --- a/vmfloaty.gemspec +++ b/vmfloaty.gemspec @@ -3,7 +3,7 @@ Gem::Specification.new do |s| s.version = '0.7.8' s.authors = ['Brian Cain'] s.email = ['brian.cain@puppetlabs.com'] - s.license = 'Apache' + s.license = 'Apache-2.0' s.homepage = 'https://github.com/briancain/vmfloaty' s.description = 'A helper tool for vmpooler to help you stay afloat' s.summary = 'CLI application to interface with vmpooler' From 0380b5fc9addb570fc10eb163ff1ae5ca4c82819 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 12:39:22 -0800 Subject: [PATCH 5/7] Gemspec whitespace & tighter version constraints Pessimistic versioning means that Faraday 0.11.0 will be installed if the constraint is "~> 0.9", and that will break spec tests due to newer restrictions in Faraday around how HTTP requests are handled by rspec. We don't want to break tests. --- vmfloaty.gemspec | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vmfloaty.gemspec b/vmfloaty.gemspec index 82e3f7a..2be8ab4 100644 --- a/vmfloaty.gemspec +++ b/vmfloaty.gemspec @@ -7,11 +7,13 @@ Gem::Specification.new do |s| s.homepage = 'https://github.com/briancain/vmfloaty' s.description = 'A helper tool for vmpooler to help you stay afloat' s.summary = 'CLI application to interface with vmpooler' + s.executables = ['floaty'] s.files = Dir['LICENSE', 'README.md', 'lib/**/*'] s.test_files = Dir['spec/**/*'] s.require_path = 'lib' - s.add_dependency 'commander', '~> 4.3' - s.add_dependency 'faraday', '~> 0.9' - s.add_dependency 'colorize', '0.8.1' + + s.add_dependency 'commander', '~> 4.3.0' + s.add_dependency 'faraday', '~> 0.9.0' + s.add_dependency 'colorize', '~> 0.8.1' end From 5c794cd2b0962d2716f6e5892e6cf1c3235b1bb9 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 12:41:06 -0800 Subject: [PATCH 6/7] 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' From d7e3bc9a02206af2d5e2dc098dc76a230f2fbbc6 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 1 Mar 2017 12:45:39 -0800 Subject: [PATCH 7/7] Improve Travis platforms Ruby 2.0 is dead, but 2.1 is not. Of note is that Ruby 2.1 *will* be unsupported soon, but it's definitely not dead yet. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e10c011..41b77f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false language: ruby rvm: - - 2.0.0-p247 + - 2.1 script: rspec spec