From 1ec6a2cfe6c514eae58e1918573ff893814e8a8b Mon Sep 17 00:00:00 2001 From: Johnny Lee-Othon Date: Fri, 2 Feb 2018 20:00:11 +0100 Subject: [PATCH 1/2] Add is_version? to String --- lib/semantic/core_ext.rb | 4 ++++ spec/core_ext_spec.rb | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/semantic/core_ext.rb b/lib/semantic/core_ext.rb index deca955..f83056b 100644 --- a/lib/semantic/core_ext.rb +++ b/lib/semantic/core_ext.rb @@ -2,4 +2,8 @@ class String def to_version Semantic::Version.new self end + + def is_version? + (match Semantic::Version::SemVerRegexp) ? true : false + end end diff --git a/spec/core_ext_spec.rb b/spec/core_ext_spec.rb index f7ad456..c53fbbc 100644 --- a/spec/core_ext_spec.rb +++ b/spec/core_ext_spec.rb @@ -43,5 +43,21 @@ ) end end + + it 'extends String with a #is_version? method' do + expect('').to respond_to(:is_version?) + end + + it 'detects valid semantic version strings' do + @test_versions.each do |v| + expect(v.is_version?).to be true + end + end + + it 'detects invalid semantic version strings' do + @bad_versions.each do |v| + expect(v.is_version?).to be false + end + end end end From ec561f0147594e06f703249a7c1c3e8ac100d4d5 Mon Sep 17 00:00:00 2001 From: Johnny Lee-Othon Date: Fri, 2 Feb 2018 20:03:17 +0100 Subject: [PATCH 2/2] Added more rvm versions to .travis.yml --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5d7012d..6a3b60d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ +sudo: false language: ruby rvm: - 2.1.10 - 2.2.5 - 2.3.1 + - 2.4.3 + - 2.5.0