{"id":20445848,"url":"https://github.com/rapid7/metasploit-version","last_synced_at":"2025-09-24T17:30:22.709Z","repository":{"id":16791352,"uuid":"19549889","full_name":"rapid7/metasploit-version","owner":"rapid7","description":"Shared examples for testing that the version of gems follow semantic naming rule tied to the branch and tag.","archived":false,"fork":false,"pushed_at":"2023-10-04T11:39:42.000Z","size":242,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":65,"default_branch":"master","last_synced_at":"2024-12-16T16:50:16.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Gherkin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapid7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-05-07T20:49:22.000Z","updated_at":"2023-10-04T11:39:25.000Z","dependencies_parsed_at":"2022-08-25T14:12:01.613Z","dependency_job_id":null,"html_url":"https://github.com/rapid7/metasploit-version","commit_stats":{"total_commits":129,"total_committers":5,"mean_commits":25.8,"dds":"0.12403100775193798","last_synced_commit":"43e1424633f9f14567e2ea6acbc916735b40b8fc"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fmetasploit-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapid7","download_url":"https://codeload.github.com/rapid7/metasploit-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234098980,"owners_count":18779649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:14:51.091Z","updated_at":"2025-09-24T17:30:22.080Z","avatar_url":"https://github.com/rapid7.png","language":"Gherkin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Metasploit::Version [![Build Status](https://travis-ci.org/rapid7/metasploit-version.svg)](https://travis-ci.org/rapid7/metasploit-version)[![Code Climate](https://codeclimate.com/github/rapid7/metasploit-version.png)](https://codeclimate.com/github/rapid7/metasploit-version)[![Coverage Status](https://coveralls.io/repos/rapid7/metasploit-version/badge.png?branch=feature%2FMSP-9923-port)](https://coveralls.io/r/rapid7/metasploit-version?branch=feature%2FMSP-9923-port)[![Dependency Status](https://gemnasium.com/rapid7/metasploit-version.svg)](https://gemnasium.com/rapid7/metasploit-version)[![Inline docs](http://inch-ci.org/github/rapid7/metasploit-version.svg?branch=master)](http://inch-ci.org/github/rapid7/metasploit-version)[![Gem Version](https://badge.fury.io/rb/metasploit-version.png)](http://badge.fury.io/rb/metasploit-version)[![PullReview stats](https://www.pullreview.com/github/rapid7/metasploit-version/badges/feature/MSP-9923-port.svg?)](https://www.pullreview.com/github/rapid7/metasploit-version/reviews/feature/MSP-9923-port)\n\nMetasploit::Version allows your gem to declare the pieces of its [semantic version](semver.org) as constant and for\nyour `VERSION` `String` to be automatically derived from those constants.  Shared examples are available to test that\nthe `PRERELEASE` `String` matches the expected pattern of using the branch relative name and being undefined on master.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'metasploit-version'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install metasploit-version\n\n## Usage\n\n### Gem version.rb\n\nYour gem's version.rb file should have a `Version` `Module` that defines the parts of the semantic version and\n`extend Metasploit::Version::Full`.  Then, `VERSION` in your gem's top-level namespace `Module` can be set to\n`Version.full`\n\n    module MyNamespace\n      module MyGem\n        # Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.\n        module Version\n          #\n          # CONSTANTS\n          #\n\n          # The major version number\n          MAJOR = 0\n\n          # The minor version number, scoped to the {MAJOR} version number.\n          MINOR = 0\n\n          # The patch number, scoped to the {MINOR} version number.\n          PATCH = 1\n\n          # The prerelease version, scoped to the {PATCH} version number.\n          PRERELEASE = '\u003crelative-name\u003e'\n          \n          #\n          # Module Methods\n          #\n    \n          # The full version string, including the {MyNamespace::MyGem::Version::MAJOR},\n          # {MyNamespace::MyGem::Version::MINOR}, {MyNamespace::MyGem::Version::PATCH}, and optionally, the\n          # `MyNamespace::MyGem::Version::PRERELEASE` in the\n          # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.\n          #\n          # @return [String] '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}'\n          #   on master.  '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}-PRERELEASE'\n          #   on any branch other than master.\n          def self.full\n            version = \"#{MAJOR}.#{MINOR}.#{PATCH}\"\n    \n            if defined? PRERELEASE\n              version = \"#{version}-#{PRERELEASE}\"\n            end\n    \n            version\n          end\n    \n          # The full gem version string, including the {MyNamespace::MyGem::Version::MAJOR},\n          # {MyNamespace::MyGem::Version::MINOR}, {MyNamespace::MyGem::Version::PATCH}, and optionally, the\n          # `MyNamespace::MyGem::Version::PRERELEASE` in the\n          # {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.\n          #\n          # @return [String] '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}'\n          #   on master.  '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}.PRERELEASE'\n          #   on any branch other than master.\n          def self.gem\n            full.gsub('-', '.pre.')\n          end\n        end\n\n        # (see Version.gem)\n        GEM_VERSION = Version.gem\n\n        # (see Version.full)\n        VERSION = Version.full\n      end\n    end\n\nOn a branch such the relative name is the portion after the branch type as in `bug/\u003crelative-name\u003e`,\n`chore/\u003crelative-name\u003e`, `feature/\u003crelative-name\u003e`, or `staging/\u003crelative-name\u003e`.  On master, the gem is assumed to\nno longer be in prerelease, so `PRERELEASE` should not be defined.  If it is defined, the\n`'Metasploit::Version Version Module'` shared example will fail.\n\n### spec_helper.rb\n\nIn your `spec_helper.rb`, require the shared examples from `metasploit-version`.\n\n    # Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions\n    gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first\n\n    Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|\n      require f\n    end\n\n### Gem namespace spec\n\nThe spec for your gem's namespace `Module` should use the `'Metasploit::Version VERSION constant'` shared example.\n\n    require 'spec_helper'\n\n    describe MyNamespace::MyGem do\n      it_should_behave_like 'Metasploit::Version VERSION constant'\n      it_should_behave_like 'Metasploit::Version GEM_VERSION constant'\n    end\n\n### Gem Version spec\n\nThe spec for your gem's `Version` `Module` defined in the `version.rb` file should use the\n`'Metasploit::Version Version Module'` shared example.\n\n    require 'spec_helper'\n\n    describe MyNamespace::MyGem::Version do\n      it_should_behave_like 'Metasploit::Version Version Module'\n    end\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Fmetasploit-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapid7%2Fmetasploit-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Fmetasploit-version/lists"}