semverse-2.0.0/0000755000004100000410000000000012754237022013376 5ustar www-datawww-datasemverse-2.0.0/Rakefile0000644000004100000410000000016512754237022015045 0ustar www-datawww-datarequire "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec semverse-2.0.0/Gemfile0000644000004100000410000000100612754237022014666 0ustar www-datawww-datasource "https://rubygems.org" gemspec group :development do gem "fuubar" gem "yard" gem "guard-rspec" gem "guard-spork" gem "coolline" require "rbconfig" if RbConfig::CONFIG["target_os"] =~ /darwin/i gem "ruby_gntp", require: false elsif RbConfig::CONFIG["target_os"] =~ /linux/i gem "libnotify", require: false elsif RbConfig::CONFIG["target_os"] =~ /mswin|mingw/i gem "win32console", require: false end end group :test do gem "spork" gem "rake" gem "rspec", "~> 3.0" end semverse-2.0.0/spec/0000755000004100000410000000000012754237022014330 5ustar www-datawww-datasemverse-2.0.0/spec/spec_helper.rb0000644000004100000410000000073112754237022017147 0ustar www-datawww-datarequire 'rubygems' require 'bundler' require 'spork' Spork.prefork do require 'rspec' APP_ROOT = File.expand_path('../../', __FILE__) Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| config.mock_with :rspec config.filter_run focus: true config.run_all_when_everything_filtered = true # Run specs in a random order config.order = :random end end Spork.each_run do require 'semverse' end semverse-2.0.0/spec/unit/0000755000004100000410000000000012754237022015307 5ustar www-datawww-datasemverse-2.0.0/spec/unit/semverse/0000755000004100000410000000000012754237022017140 5ustar www-datawww-datasemverse-2.0.0/spec/unit/semverse/version_spec.rb0000644000004100000410000002340712754237022022172 0ustar www-datawww-datarequire 'spec_helper' describe Semverse::Version do describe "ClassMethods" do subject { Semverse::Version } describe "::new" do context "a string containing a major, minor and patch separated by periods a pre-release and a build" do before(:each) { @version = subject.new("1.2.3-rc.1+build.1") } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "assigns a patch value" do expect(@version.patch).to eq(3) end it "assigns a pre_release value" do expect(@version.pre_release).to eq('rc.1') end it "assigns a build value" do expect(@version.build).to eq('build.1') end end context "a string containing a major, minor and patch separated by periods and a build" do before(:each) { @version = subject.new("1.2.3+pre-build.11.e0f985a") } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "assigns a patch value" do expect(@version.patch).to eq(3) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "assigns a build value" do expect(@version.build).to eq('pre-build.11.e0f985a') end end context "a string containing a major, minor, and patch separated by periods" do before(:each) { @version = subject.new("1.2.3") } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "assigns a patch value" do expect(@version.patch).to eq(3) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "doesn't assigns a build value" do expect(@version.build).to be_nil end end context "a five element array" do before(:each) { @version = subject.new([1,2,3,nil,'build.1']) } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "assigns a patch value" do expect(@version.patch).to eq(3) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "assigns a build value" do expect(@version.build).to eq('build.1') end end context "a four element array" do before(:each) { @version = subject.new([1,2,3,'alpha.1']) } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "assigns a patch value" do expect(@version.patch).to eq(3) end it "assigns a pre_release value" do expect(@version.pre_release).to eq('alpha.1') end it "doesn't assigns a build value" do expect(@version.build).to be_nil end end context "a three element array" do before(:each) { @version = subject.new([1,2,3]) } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "assigns a patch value" do expect(@version.patch).to eq(3) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "doesn't assigns a build value" do expect(@version.build).to be_nil end end context "a two element array" do before(:each) { @version = subject.new([1,2]) } it "assigns a major value" do expect(@version.major).to eq(1) end it "assigns a minor value" do expect(@version.minor).to eq(2) end it "sets the patch value to 0 (zero)" do expect(@version.patch).to eq(0) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "doesn't assigns a build value" do expect(@version.build).to be_nil end end context "a one element array" do before(:each) { @version = subject.new([1]) } it "assigns the major value" do expect(@version.major).to eq(1) end it "sets the minor value to 0 (zero)" do expect(@version.minor).to eq(0) end it "sets the patch value to 0 (zero)" do expect(@version.patch).to eq(0) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "doesn't assigns a build value" do expect(@version.build).to be_nil end end context "an empty array" do before(:each) { @version = subject.new(Array.new) } it "sets the majro value to 0 (zero)" do expect(@version.major).to eq(0) end it "sets the minor value to 0 (zero)" do expect(@version.minor).to eq(0) end it "sets the patch value to 0 (zero)" do expect(@version.patch).to eq(0) end it "doesn't assigns a pre_release value" do expect(@version.pre_release).to be_nil end it "doesn't assigns a build value" do expect(@version.build).to be_nil end end end describe "::split" do it "returns an array containing 5 elements" do expect(subject.split("1.2.0-alpha.1").size).to eq(5) end context "given a string only containing a major, minor and patch version" do it "returns an array containing 4 elements" do expect(subject.split("1.2.3").size).to eq(5) end it "returns nil as fourth element" do expect(subject.split("1.2.3")[3]).to be_nil end it "returns nil as fifth element" do expect(subject.split("1.2.3")[4]).to be_nil end end context "given a string only containing a major and minor version" do it "returns an array containing 4 elements" do expect(subject.split("1.2").size).to eq(3) end it "returns 0 as the third element" do expect(subject.split("1.2")[2]).to eq(0) end it "converts the third element to 0 if it's nil or blank" do expect(subject.split("1.2.")[2]).to eq(0) end end context "given a string with only a major version" do it "returns an array containing 3 elements" do expect(subject.split("1").size).to eq(3) end it "returns 0 as the second element" do expect(subject.split("1")[1]).to eq(0) end it "returns 0 as the third element" do expect(subject.split("1")[2]).to eq(0) end it "converts the second element to 0 if it's nil or blank" do expect(subject.split("1.")[1]).to eq(0) end end context "given a string with an invalid version" it "raises an InvalidVersionFormat error" do expect { subject.split("hello") }.to raise_error(Semverse::InvalidVersionFormat) end end describe "::coerce" do it "coerces a String to a Version object" do expect(subject.coerce("1.0.0")).to eql(subject.new("1.0.0")) end it "returns an object of the desired class without any additional processing" do version = subject.new("1.0.0") # we want object equality here to prove that the exact object was returned expect(subject.coerce(version)).to equal(version) end end end describe "#pre_release?" do context "when a pre-release value is set" do subject { described_class.new("1.2.3-alpha").pre_release? } it { should be true } end context "when no pre-release value is set" do subject { described_class.new("1.2.3").pre_release? } it { should be false } end end describe "#zero?" do context "major, minor and patch are equal to 0" do subject { described_class.new("0.0.0").zero? } it { should be true } end context "major is not equal to 0" do subject { described_class.new("1.0.0").zero? } it { should be false } end context "minor is not equal to 0" do subject { described_class.new("0.1.0").zero? } it { should be false } end context "patch is not equal to 0" do subject { described_class.new("0.0.1").zero? } it { should be false } end end describe "#to_s" do subject { Semverse::Version.new("1.0.0-rc.1+build.1") } it "returns a string containing the major.minor.patch-pre_release+build" do expect(subject.to_s).to eq("1.0.0-rc.1+build.1") end end describe "#<=>" do it "compares versions" do versions_list = %w[ 1.0.0-0 1.0.0-alpha 1.0.0-alpha.1 1.0.0-beta.2 1.0.0-beta.11 1.0.0-rc.1 1.0.0-rc.1+build.1 1.0.0 1.0.0+0.3.7 1.0.0+build 1.0.0+build.2.b8f12d7 1.0.0+build.11.e0f985a ] versions = versions_list.map { |version| Semverse::Version.new(version) } 100.times do shuffled_versions = versions.shuffle while shuffled_versions == versions shuffled_versions = shuffled_versions.shuffle end expect(shuffled_versions.sort.map(&:to_s)).to eq(versions_list) end end end end semverse-2.0.0/spec/unit/semverse/constraint_spec.rb0000644000004100000410000006177412754237022022702 0ustar www-datawww-datarequire 'spec_helper' RSpec::Matchers.define :satisfies do |*args| match do |constraint| expect(constraint.satisfies?(*args)).to be true end end describe Semverse::Constraint do let(:valid_string) { ">= 0.0.0" } let(:invalid_string) { "x23u7089213.*" } describe "ClassMethods" do subject { Semverse::Constraint } describe "::new" do it "returns a new instance of Constraint" do expect(subject.new(valid_string)).to be_a(Semverse::Constraint) end it "assigns the parsed operator to the operator attribute" do expect(subject.new(valid_string).operator).to eq(">=") end it "assigns the parsed operator to the operator attribute with no separation between operator and version" do expect(subject.new(">=0.0.0").operator).to eq(">=") end it "assigns the parsed version string as an instance of Version to the version attribute" do result = subject.new(valid_string) expect(result.version).to be_a(Semverse::Version) expect(result.version.to_s).to eq("0.0.0") end it "falls back to a default constraint if nil is provided" do result = subject.new(nil) expect(result.version.to_s).to eq("0.0.0") expect(result.operator).to eq(">=") end it "fall sback to a default constraint if a blank string is provided" do result = subject.new("") expect(result.version.to_s).to eq("0.0.0") expect(result.operator).to eq(">=") end context "given a string that does not match the Constraint REGEXP" do it "raises an InvalidConstraintFormat error" do expect { subject.new(invalid_string) }.to raise_error(Semverse::InvalidConstraintFormat) end end context "given a constraint that does not include a minor version (~>)" do it "has a nil value for minor" do expect(subject.new("~> 1").minor).to be_nil end it "has a nil value for patch" do expect(subject.new("~> 1").patch).to be_nil end end context "given a constraint that does not include a minor version (=)" do it "has a 0 for minor" do expect(subject.new("= 1").minor).to eq(0) end end context "given a constraint that does not include a patch version (~>)" do it "has a nil value for patch" do expect(subject.new("~> 1.2").patch).to be_nil end end context "given a constraint that does not include a patch version (=)" do it "has a 0 for patch" do expect(subject.new("= 1.2").patch).to eq(0) end end context "given a constraint that does not include a build version" do it "has a nil value for build" do expect(subject.new(">= 1.2.3-alpha").build).to be_nil end end context "given a constraint that does not include a pre release version" do it "has a nil value for pre release" do expect(subject.new(">= 1.2.3+build").pre_release).to be_nil end end end describe "::split" do let(:constraint_string) { nil } subject { described_class.split(constraint_string) } context "given a constraint containing the elements (operator, major, minor, patch, pre_release, build)" do let(:constraint_string) { ">= 1.2.3-alpha+build" } it "returns an array with the constraint operator at index 0" do expect(subject[0]).to eq(">=") end it "returns an array with the major version in index 1" do expect(subject[1]).to eq(1) end it "returns an array with the minor version at index 2" do expect(subject[2]).to eq(2) end it "returns an array with the patch version at index 3" do expect(subject[3]).to eq(3) end it "returns an array with the pre release version at index 4" do expect(subject[4]).to eq("alpha") end it "returns an array with the build version at index 5" do expect(subject[5]).to eq("build") end end context "given a constraint containing the elements (operator, major, minor, patch, pre_release)" do let(:constraint_string) { ">= 1.2.3-alpha" } it "returns an array with the constraint operator at index 0" do expect(subject[0]).to eq(">=") end it "returns an array with the major version in index 1" do expect(subject[1]).to eq(1) end it "returns an array with the minor version at index 2" do expect(subject[2]).to eq(2) end it "returns an array with the patch version at index 3" do expect(subject[3]).to eq(3) end it "returns an array with the pre release version at index 4" do expect(subject[4]).to eq("alpha") end it "returns an array with a nil value at index 5" do expect(subject[5]).to be_nil end end context "given a constraint containing the elements (operator, major, minor, patch)" do let(:constraint_string) { ">= 1.2.3" } it "returns an array with the constraint operator at index 0" do expect(subject[0]).to eq(">=") end it "returns an array with the major version in index 1" do expect(subject[1]).to eq(1) end it "returns an array with the minor version at index 2" do expect(subject[2]).to eq(2) end it "returns an array with the patch version at index 3" do expect(subject[3]).to eq(3) end it "returns an array with a nil value at index 4" do expect(subject[4]).to be_nil end it "returns an array with a nil value at index 5" do expect(subject[5]).to be_nil end end context "given a constraint containing the elements (operator, major, minor)" do let(:constraint_string) { ">= 1.2" } it "returns an array with the constraint operator at index 0" do expect(subject[0]).to eq(">=") end it "returns an array with the major version in index 1" do expect(subject[1]).to eq(1) end it "returns an array with the minor version at index 2" do expect(subject[2]).to eq(2) end it "returns an array with a nil value at index 3" do expect(subject[3]).to be_nil end it "returns an array with a nil value at index 4" do expect(subject[4]).to be_nil end it "returns an array with a nil value at index 5" do expect(subject[5]).to be_nil end end context "given a constraint containing the elements (operator, major)" do let(:constraint_string) { ">= 1" } it "returns an array with the constraint operator at index 0" do expect(subject[0]).to eq(">=") end it "returns an array with the major version in index 1" do expect(subject[1]).to eq(1) end it "returns an array with a nil value at index 2" do expect(subject[2]).to be_nil end it "returns an array with a nil value at index 3" do expect(subject[3]).to be_nil end it "returns an array with a nil value at index 4" do expect(subject[4]).to be_nil end it "returns an array with a nil value at index 5" do expect(subject[5]).to be_nil end end context "given a constraint which is missing an operator" do let(:constraint_string) { "1.2.3" } it "returns an equality operator at index 0" do expect(subject[0]).to eq("=") end end context "given a string that does not match the Constraint REGEXP" do let(:constraint_string) { "x23u7089213.*" } it "raises an InvalidConstraintFormat error" do expect { subject.split(invalid_string) }.to raise_error(Semverse::InvalidConstraintFormat) end end context "given a string that does not contain an operator" do let(:constraint_string) { "1.2.3" } it "returns a constraint constraint with a default operator (=)" do expect(subject[0]).to eq("=") end end end end describe "#satisfies?" do subject { Semverse::Constraint.new("= 1.0.0") } it { should satisfies("1.0.0") } it { should satisfies(Semverse::Version.new("1.0.0")) } context "strictly greater than (>) pre-release constraint" do subject { Semverse::Constraint.new("> 1.0.0-alpha") } it { should_not satisfies("0.9.9+build") } it { should_not satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "strictly greater than (>)" do subject { Semverse::Constraint.new("> 1.0.0") } it { should_not satisfies("0.9.9+build") } it { should_not satisfies("1.0.0-alpha") } it { should_not satisfies("1.0.0-alpha.2") } it { should_not satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "strictly greater than (>) build constraint" do subject { Semverse::Constraint.new("> 1.0.0+build") } it { should_not satisfies("0.9.9+build") } it { should_not satisfies("1.0.0-alpha") } it { should_not satisfies("1.0.0-alpha.2") } it { should_not satisfies("1.0.0") } it { should_not satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>) zero pre-release constraint" do subject { Semverse::Constraint.new("> 0.0.0-alpha") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>) zero constraint" do subject { Semverse::Constraint.new("> 0.0.0") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>) zero build constraint" do subject { Semverse::Constraint.new("> 0.0.0+build") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "strictly less than (<) pre-release constraint" do subject { Semverse::Constraint.new("< 1.0.0-alpha.3") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should_not satisfies("1.0.0") } it { should_not satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.1+build.2") } it { should_not satisfies("2.0.0") } end context "strictly less than (<)" do subject { Semverse::Constraint.new("< 1.0.0") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should_not satisfies("1.0.0") } it { should_not satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.1+build.2") } it { should_not satisfies("2.0.0") } end context "strictly less than (<) build constraint" do subject { Semverse::Constraint.new("< 1.0.0+build.20") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.1+build.2") } it { should_not satisfies("2.0.0") } end context "strictly equal to (=)" do subject { Semverse::Constraint.new("= 1.0.0") } it { should_not satisfies("0.9.9+build") } it { should satisfies("1.0.0") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.0-alpha") } end context "greater than or equal to (>=) pre-release constraint" do subject { Semverse::Constraint.new(">= 1.0.0-alpha") } it { should_not satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>=)" do subject { Semverse::Constraint.new(">= 1.0.0") } it { should_not satisfies("0.9.9+build") } it { should_not satisfies("1.0.0-alpha") } it { should_not satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>=) build constraint" do subject { Semverse::Constraint.new(">= 1.0.0+build") } it { should_not satisfies("0.9.9+build") } it { should_not satisfies("1.0.0-alpha") } it { should_not satisfies("1.0.0-alpha.2") } it { should_not satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>=) zero pre-release constraint" do subject { Semverse::Constraint.new(">= 0.0.0-alpha") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>=) zero constraint" do subject { Semverse::Constraint.new(">= 0.0.0") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "greater than or equal to (>=) zero build constraint" do subject { Semverse::Constraint.new(">= 0.0.0+build") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should satisfies("1.0.1-beta") } it { should satisfies("1.0.1") } it { should satisfies("1.0.1+build.2") } it { should satisfies("2.0.0") } end context "lower than or equal to (<=) pre-release constraint" do subject { Semverse::Constraint.new("<= 1.0.0") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should_not satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.1+build.2") } it { should_not satisfies("2.0.0") } end context "lower than or equal to (<=)" do subject { Semverse::Constraint.new("<= 1.0.0-alpha") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should_not satisfies("1.0.0-alpha.2") } it { should_not satisfies("1.0.0") } it { should_not satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.1+build.2") } it { should_not satisfies("2.0.0") } end context "lower than or equal to (<=) build constraint" do subject { Semverse::Constraint.new("<= 1.0.0+build") } it { should satisfies("0.9.9+build") } it { should satisfies("1.0.0-alpha") } it { should satisfies("1.0.0-alpha.2") } it { should satisfies("1.0.0") } it { should satisfies("1.0.0+build") } it { should_not satisfies("1.0.1-beta") } it { should_not satisfies("1.0.1") } it { should_not satisfies("1.0.1+build.2") } it { should_not satisfies("2.0.0") } end %w[~> ~].each do |operator| describe "aproximately (#{operator})" do context "when the last value in the constraint is for minor" do subject { Semverse::Constraint.new("#{operator} 1.2") } it { should_not satisfies("1.1.0") } it { should_not satisfies("1.2.0-alpha") } it { should satisfies("1.2.0") } it { should satisfies("1.2.3") } it { should satisfies("1.2.3+build") } it { should satisfies("1.3") } it { should satisfies("1.3.0") } it { should_not satisfies("2.0.0-0") } it { should_not satisfies("2.0.0") } end context "when the last value in the constraint is for patch" do subject { Semverse::Constraint.new("#{operator} 1.2.0") } it { should_not satisfies("1.1.0") } it { should_not satisfies("1.2.3-alpha") } it { should satisfies("1.2.2") } it { should satisfies("1.2.3") } it { should satisfies("1.2.5+build") } it { should_not satisfies("1.3.0-0") } it { should_not satisfies("1.3.0") } end context "when the last value in the constraint is for pre_release with a last numeric identifier" do subject { Semverse::Constraint.new("#{operator} 1.2.3-4") } it { should_not satisfies("1.2.3") } it { should satisfies("1.2.3-4") } it { should satisfies("1.2.3-10") } it { should satisfies("1.2.3-10.5+build.33") } it { should_not satisfies("1.2.3--") } it { should_not satisfies("1.2.3-alpha") } it { should_not satisfies("1.2.3") } it { should_not satisfies("1.2.4") } it { should_not satisfies("1.3.0") } end context "when the last value in the constraint is for pre_release with a last non-numeric identifier" do subject { Semverse::Constraint.new("#{operator} 1.2.3-alpha") } it { should_not satisfies("1.2.3-4") } it { should_not satisfies("1.2.3--") } it { should satisfies("1.2.3-alpha") } it { should satisfies("1.2.3-alpha.0") } it { should satisfies("1.2.3-beta") } it { should satisfies("1.2.3-omega") } it { should satisfies("1.2.3-omega.4") } it { should_not satisfies("1.2.3") } it { should_not satisfies("1.3.0") } end context "when the last value in the constraint is for build with a last numeric identifier and a pre-release" do subject { Semverse::Constraint.new("#{operator} 1.2.3-alpha+5") } it { should_not satisfies("1.2.3-alpha") } it { should_not satisfies("1.2.3-alpha.4") } it { should_not satisfies("1.2.3-alpha.4+4") } it { should satisfies("1.2.3-alpha+5") } it { should satisfies("1.2.3-alpha+5.5") } it { should satisfies("1.2.3-alpha+10") } it { should_not satisfies("1.2.3-alpha+-") } it { should_not satisfies("1.2.3-alpha+build") } it { should_not satisfies("1.2.3-beta") } it { should_not satisfies("1.2.3") } it { should_not satisfies("1.3.0") } end context "when the last value in the constraint is for build with a last non-numeric identifier and a pre-release" do subject { Semverse::Constraint.new("#{operator} 1.2.3-alpha+build") } it { should_not satisfies("1.2.3-alpha") } it { should_not satisfies("1.2.3-alpha.4") } it { should_not satisfies("1.2.3-alpha.4+4") } it { should satisfies("1.2.3-alpha+build") } it { should satisfies("1.2.3-alpha+build.5") } it { should satisfies("1.2.3-alpha+preview") } it { should satisfies("1.2.3-alpha+zzz") } it { should_not satisfies("1.2.3-alphb") } it { should_not satisfies("1.2.3-beta") } it { should_not satisfies("1.2.3") } it { should_not satisfies("1.3.0") } end context "when the last value in the constraint is for build with a last numeric identifier" do subject { Semverse::Constraint.new("#{operator} 1.2.3+5") } it { should_not satisfies("1.2.3") } it { should_not satisfies("1.2.3-alpha") } it { should_not satisfies("1.2.3+4") } it { should satisfies("1.2.3+5") } it { should satisfies("1.2.3+99") } it { should_not satisfies("1.2.3+5.build") } it { should_not satisfies("1.2.3+-") } it { should_not satisfies("1.2.3+build") } it { should_not satisfies("1.2.4") } it { should_not satisfies("1.3.0") } end context "when the last value in the constraint is for build with a last non-numeric identifier" do subject { Semverse::Constraint.new("#{operator} 1.2.3+build") } it { should_not satisfies("1.2.3-alpha") } it { should_not satisfies("1.2.3") } it { should_not satisfies("1.2.3+5") } it { should satisfies("1.2.3+build") } it { should satisfies("1.2.3+build.5") } it { should satisfies("1.2.3+preview") } it { should satisfies("1.2.3+zzz") } it { should_not satisfies("1.2.4-0") } it { should_not satisfies("1.2.4") } it { should_not satisfies("1.2.5") } it { should_not satisfies("1.3.0") } end end end end describe "#==" do subject { Semverse::Constraint.new("= 1.0.0") } it "returns true if the other object is a Semverse::Constraint with the same operator and version" do other = Semverse::Constraint.new("= 1.0.0") expect(subject).to eq(other) end it "returns false if the other object is a Semverse::Constraint with the same operator and different version" do other = Semverse::Constraint.new("= 9.9.9") expect(subject).to_not eq(other) end it "returns false if the other object is a Semverse::Constraint with the same version and different operator" do other = Semverse::Constraint.new("> 1.0.0") expect(subject).to_not eq(other) end it "returns false if the other object is not a Semverse::Constraint" do other = "chicken" expect(subject).to_not eq(other) end end describe "#to_s" do let(:constraint_string) { ">= 1.2.3-alpha+123" } subject { described_class.new(constraint_string).to_s } it { should eq(constraint_string) } context "when the constraint does not contain a minor or patch value" do let(:constraint_string) { "~> 1" } it { should eq(constraint_string) } end context "when the constraint does not contain a patch value" do let(:constraint_string) { "~> 1.2" } it { should eq(constraint_string) } end context "when the constraint does not contain a build value" do let(:constraint_string) { ">= 1.2.0-alpha"} it { should eq(constraint_string) } end context "when the constraint contains a pre_release value" do let(:constraint_string) { ">= 1.2.0+123"} it { should eq(constraint_string) } end end end semverse-2.0.0/spec/unit/semverse_spec.rb0000644000004100000410000000006012754237022020473 0ustar www-datawww-datarequire 'spec_helper' describe Semverse do end semverse-2.0.0/semverse.gemspec0000644000004100000410000000167612754237022016606 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'semverse/gem_version' Gem::Specification.new do |spec| spec.name = "semverse" spec.version = Semverse::VERSION spec.authors = ["Jamie Winsor"] spec.email = ["jamie@vialstudios.com"] spec.summary = %q{An elegant library for representing and comparing SemVer versions and constraints} spec.description = spec.summary spec.homepage = "https://github.com/berkshelf/semverse" spec.license = "Apache 2.0" spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.required_ruby_version = ">= 2.1.0" spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake" end semverse-2.0.0/.travis.yml0000644000004100000410000000032512754237022015507 0ustar www-datawww-datasudo: false language: ruby cache: bundler bundler_args: --without development matrix: include: - rvm: 2.1.9 - rvm: 2.2.5 - rvm: 2.3.1 allow_failures: - rvm: 2.3.1 script: bundle exec rake specsemverse-2.0.0/lib/0000755000004100000410000000000012754237022014144 5ustar www-datawww-datasemverse-2.0.0/lib/semverse/0000755000004100000410000000000012754237022015775 5ustar www-datawww-datasemverse-2.0.0/lib/semverse/errors.rb0000644000004100000410000000123612754237022017640 0ustar www-datawww-datamodule Semverse class SemverseError < StandardError; end class InvalidVersionFormat < SemverseError attr_reader :version # @param [#to_s] version def initialize(version) @version = version end def to_s "'#{version}' did not contain a valid version string: 'x.y.z' or 'x.y'." end end class InvalidConstraintFormat < SemverseError attr_reader :constraint # @param [#to_s] constraint def initialize(constraint) @constraint = constraint end def to_s "'#{constraint}' did not contain a valid operator or a valid version string." end end class NoSolutionError < SemverseError; end end semverse-2.0.0/lib/semverse/version.rb0000644000004100000410000001023212754237022020005 0ustar www-datawww-datamodule Semverse class Version class << self # Coerce the object into a version. # # @param [Version, String] # # @return [Version] def coerce(object) object.is_a?(self) ? object : new(object) end # @param [#to_s] version_string # # @raise [InvalidVersionFormat] # # @return [Array] def split(version_string) case version_string.to_s when /^(\d+)\.(\d+)\.(\d+)(-([0-9a-z\-\.]+))?(\+([0-9a-z\-\.]+))?$/i [ $1.to_i, $2.to_i, $3.to_i, $5, $7 ] when /^(\d+)\.(\d+)\.(\d+)?$/ [ $1.to_i, $2.to_i, $3.to_i ] when /^(\d+)\.(\d+)?$/ [ $1.to_i, $2.to_i, 0 ] when /^(\d+)$/ [ $1.to_i, 0, 0 ] else raise InvalidVersionFormat.new(version_string) end end end include Comparable attr_reader :major attr_reader :minor attr_reader :patch attr_reader :pre_release attr_reader :build # @overload initialize(version_array) # @param [Array] version_array # # @example # Version.new([1, 2, 3, 'rc.1', 'build.1']) => # # # @overload initialize(version_string) # @param [#to_s] version_string # # @example # Version.new("1.2.3-rc.1+build.1") => # # # @overload initialize(version) # @param [Semverse::Version] version # # @example # Version.new(Version.new("1.2.3-rc.1+build.1")) => # # def initialize(*args) if args.first.is_a?(Array) @major, @minor, @patch, @pre_release, @build = args.first else @major, @minor, @patch, @pre_release, @build = self.class.split(args.first.to_s) end @major ||= 0 @minor ||= 0 @patch ||= 0 @pre_release ||= nil @build ||= nil end # @param [Semverse::Version] other # # @return [Integer] def <=>(other) [:major, :minor, :patch].each do |release| ans = self.send(release) <=> other.send(release) return ans if ans != 0 end ans = pre_release_and_build_presence_score <=> other.pre_release_and_build_presence_score return ans if ans != 0 ans = identifiers_comparaison(other, :pre_release) return ans if ans != 0 if build && other.build return identifiers_comparaison(other, :build) else return build.to_s <=> other.build.to_s end 0 end # @return [Array] def identifiers(release) send(release).to_s.split('.').map do |str| str.to_i.to_s == str ? str.to_i : str end end def pre_release? !!pre_release end def zero? [major, minor, patch].all? { |n| n == 0 } end # @return [Integer] def pre_release_and_build_presence_score pre_release ? 0 : (build.nil? ? 1 : 2) end # @param [Semverse::Version] other # # @return [Integer] def identifiers_comparaison(other, release) [identifiers(release).length, other.identifiers(release).length].max.times do |i| if identifiers(release)[i].class == other.identifiers(release)[i].class ans = identifiers(release)[i] <=> other.identifiers(release)[i] return ans if ans != 0 elsif identifiers(release)[i] && other.identifiers(release)[i] return identifiers(release)[i].class.to_s <=> other.identifiers(release)[i].class.to_s elsif identifiers(release)[i] || other.identifiers(release)[i] return other.identifiers(release)[i].class.to_s <=> identifiers(release)[i].class.to_s end end 0 end # @param [Semverse::Version] other # # @return [Boolean] def eql?(other) other.is_a?(Version) && self == other end def inspect "#<#{self.class.to_s} #{to_s}>" end def to_s str = "#{major}.#{minor}.#{patch}" str += "-#{pre_release}" if pre_release str += "+#{build}" if build str end end end semverse-2.0.0/lib/semverse/gem_version.rb0000644000004100000410000000005012754237022020632 0ustar www-datawww-datamodule Semverse VERSION = "2.0.0" end semverse-2.0.0/lib/semverse/constraint.rb0000644000004100000410000001711312754237022020511 0ustar www-datawww-datamodule Semverse class Constraint class << self # Coerce the object into a constraint. # # @param [Constraint, String] # # @return [Constraint] def coerce(object) if object.nil? DEFAULT_CONSTRAINT else object.is_a?(self) ? object : new(object) end end # Returns all of the versions which satisfy all of the given constraints # # @param [Array, Array] constraints # @param [Array, Array] versions # # @return [Array] def satisfy_all(constraints, versions) constraints = Array(constraints).collect do |con| con.is_a?(Constraint) ? con : Constraint.new(con) end.uniq versions = Array(versions).collect do |ver| ver.is_a?(Version) ? ver : Version.new(ver) end.uniq versions.select do |ver| constraints.all? { |constraint| constraint.satisfies?(ver) } end end # Return the best version from the given list of versions for the given list of constraints # # @param [Array, Array] constraints # @param [Array, Array] versions # # @raise [NoSolutionError] if version matches the given constraints # # @return [Semverse::Version] def satisfy_best(constraints, versions) solution = satisfy_all(constraints, versions) if solution.empty? raise NoSolutionError end solution.sort.last end # Split a constraint string into an Array of two elements. The first # element being the operator and second being the version string. # # If the given string does not contain a constraint operator then (=) # will be used. # # If the given string does not contain a valid version string then # nil will be returned. # # @param [#to_s] constraint # # @example splitting a string with a constraint operator and valid version string # Constraint.split(">= 1.0.0") => [ ">=", "1.0.0" ] # # @example splitting a string without a constraint operator # Constraint.split("0.0.0") => [ "=", "1.0.0" ] # # @example splitting a string without a valid version string # Constraint.split("hello") => nil # # @return [Array, nil] def split(constraint) data = REGEX.match(constraint) if data.nil? raise InvalidConstraintFormat.new(constraint) else [ data[:operator] || DEFAULT_OPERATOR, data[:major].to_i, data[:minor] && data[:minor].to_i, data[:patch] && data[:patch].to_i, data[:pre_release], data[:build], ] end end # @param [Semverse::Constraint] constraint # @param [Semverse::Version] target_version # # @return [Boolean] def compare_approx(constraint, target_version) min = constraint.version max = if constraint.patch.nil? Version.new([min.major + 1, 0, 0, 0]) elsif constraint.build identifiers = constraint.version.identifiers(:build) replace = identifiers.last.to_i.to_s == identifiers.last.to_s ? "-" : nil Version.new([min.major, min.minor, min.patch, min.pre_release, identifiers.fill(replace, -1).join('.')]) elsif constraint.pre_release identifiers = constraint.version.identifiers(:pre_release) replace = identifiers.last.to_i.to_s == identifiers.last.to_s ? "-" : nil Version.new([min.major, min.minor, min.patch, identifiers.fill(replace, -1).join('.')]) else Version.new([min.major, min.minor + 1, 0, 0]) end min <= target_version && target_version < max end end # The default constraint string. # # @return [String] DEFAULT_OPERATOR = '='.freeze # The complete list of possible operators, paired with a proc to be used for # evaluation. # # @example # OPERATORS['='].call(constraint, version) # # @return [Hash] OPERATORS = { #:nodoc: '=' => ->(c, v) { v == c.version }, '!=' => ->(c, v) { v != c.version }, '>' => ->(c, v) { v > c.version }, '<' => ->(c, v) { v < c.version }, '>=' => ->(c, v) { v >= c.version }, '<=' => ->(c, v) { v <= c.version }, '~' => method(:compare_approx), '~>' => method(:compare_approx), }.freeze # This is a magical regular expression that matches the Semantic versioning # specification found at http://semver.org. In addition to supporting all # the possible versions, it also provides a named +match_data+ which makes # it really delightful to work with. # # @return [Regexp] REGEX = /\A ((?(#{OPERATORS.keys.join('|')}))[[:space:]]*)? (?\d+) (\.(?\d+))? (\.(?\d+))? (\-(?[0-9A-Za-z\-\.]+))? (\+(?[0-9A-Za-z\-\.]+))? \z/x.freeze attr_reader :operator attr_reader :major attr_reader :minor attr_reader :patch attr_reader :pre_release attr_reader :build # Return the Semverse::Version representation of the major, minor, and patch # attributes of this instance # # @return [Semverse::Version] attr_reader :version # @param [#to_s] constraint def initialize(constraint = '>= 0.0.0') constraint = constraint.to_s if constraint.nil? || constraint.empty? constraint = ">= 0.0.0" end @operator, @major, @minor, @patch, @pre_release, @build = self.class.split(constraint) unless ['~>', '~'].include?(@operator) @minor ||= 0 @patch ||= 0 end @version = Version.new([ self.major, self.minor, self.patch, self.pre_release, self.build, ]) end # Returns true or false if the given version would be satisfied by # the version constraint. # # @param [Version, #to_s] target # # @return [Boolean] def satisfies?(target) target = Version.coerce(target) if !version.zero? && greedy_match?(target) return false end OPERATORS[operator].call(self, target) end # dep-selector uses include? to determine if a version matches the # constriant. alias_method :include?, :satisfies? # @param [Object] other # # @return [Boolean] def ==(other) other.is_a?(self.class) && self.operator == other.operator && self.version == other.version end alias_method :eql?, :== # The detailed string representation of this constraint. # # @return [String] def inspect "#<#{self.class.to_s} #{to_s}>" end # The string representation of this constraint. # # @return [String] def to_s out = "#{operator} #{major}" out << ".#{minor}" if minor out << ".#{patch}" if patch out << "-#{pre_release}" if pre_release out << "+#{build}" if build out end private # Returns true if the given version is a pre-release and if the constraint # does not include a pre-release and if the operator isn't < or <=. # This avoids greedy matches, e.g. 2.0.0.alpha won't satisfy >= 1.0.0. # # @param [Semverse::Version] target_version # def greedy_match?(target_version) !['<', '<='].include?(self.operator) && target_version.pre_release? && !version.pre_release? end end end semverse-2.0.0/lib/semverse.rb0000644000004100000410000000036612754237022016327 0ustar www-datawww-datamodule Semverse require_relative 'semverse/errors' require_relative 'semverse/gem_version' require_relative 'semverse/version' require_relative 'semverse/constraint' DEFAULT_CONSTRAINT = Semverse::Constraint.new('>= 0.0.0').freeze end semverse-2.0.0/.gitignore0000644000004100000410000000023212754237022015363 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp semverse-2.0.0/LICENSE0000644000004100000410000002512412754237022014407 0ustar www-datawww-data Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2014, Jamie Winsor Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. semverse-2.0.0/README.md0000644000004100000410000000152112754237022014654 0ustar www-datawww-data# Semverse [![Gem Version](http://img.shields.io/gem/v/semverse.svg)][gem] [![Build Status](http://img.shields.io/travis/berkshelf/semverse.svg)][travis] An elegant library for representing and comparing SemVer versions and constraints ## Installation Add this line to your application's Gemfile: ``` gem 'semverse' ``` And then execute: ``` $ bundle ``` Or install it yourself as: ``` $ gem install semverse ``` ## Usage TODO: Write usage instructions here ## Contributing 1. Fork it ( ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request [gem]: https://rubygems.org/gems/semverse [travis]: http://travis-ci.org/berkshelf/semverse semverse-2.0.0/Guardfile0000644000004100000410000000067312754237022015231 0ustar www-datawww-dataguard 'spork', rspec_port: 8991 do watch('Gemfile') watch('spec/spec_helper.rb') { :rspec } end guard 'rspec', cli: "--color --drb --drb-port 8991 --format Fuubar", all_on_start: false, all_after_pass: false, notification: false do watch(%r{^spec/acceptance/.+_spec\.rb$}) watch(%r{^spec/unit/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end