From c5bbf28dd6902e33128793b5dc2109d129942d50 Mon Sep 17 00:00:00 2001 From: commitay Date: Fri, 15 Jun 2018 22:40:33 +1000 Subject: [PATCH] cask dsl versions: add minor_patch --- Library/Homebrew/cask/lib/hbc/dsl/version.rb | 4 ++++ Library/Homebrew/test/cask/dsl/version_spec.rb | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Library/Homebrew/cask/lib/hbc/dsl/version.rb b/Library/Homebrew/cask/lib/hbc/dsl/version.rb index 9605feb579..cac0490dff 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/version.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/version.rb @@ -84,6 +84,10 @@ module Hbc version { [major, minor, patch].reject(&:empty?).join(".") } end + def minor_patch + version { [minor, patch].reject(&:empty?).join(".") } + end + def before_comma version { split(",", 2)[0] } end diff --git a/Library/Homebrew/test/cask/dsl/version_spec.rb b/Library/Homebrew/test/cask/dsl/version_spec.rb index 497b91aa41..b35fb6287f 100644 --- a/Library/Homebrew/test/cask/dsl/version_spec.rb +++ b/Library/Homebrew/test/cask/dsl/version_spec.rb @@ -121,6 +121,14 @@ describe Hbc::DSL::Version, :cask do "1.2.3_4-5" => "1.2.3" end + describe "#minor_patch" do + include_examples "version expectations hash", :minor_patch, + "1" => "", + "1.2" => "2", + "1.2.3" => "2.3", + "1.2.3_4-5" => "2.3" + end + describe "#before_comma" do include_examples "version expectations hash", :before_comma, "1.2.3" => "1.2.3",