Skip to content

Commit

Permalink
Merge pull request #33 from jleeothon/master
Browse files Browse the repository at this point in the history
Add is_version? method to String
  • Loading branch information
jlindsey authored Feb 14, 2018
2 parents ee9d331 + ec561f0 commit 8c8c4dc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
sudo: false
language: ruby
rvm:
- 2.1.10
- 2.2.5
- 2.3.1
- 2.4.3
- 2.5.0
4 changes: 4 additions & 0 deletions lib/semantic/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions spec/core_ext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8c8c4dc

Please sign in to comment.