metasploit-version 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +32 -0
  4. data/.simplecov +60 -0
  5. data/.travis.yml +26 -0
  6. data/.yardopts +7 -0
  7. data/CONTRIBUTING.md +156 -0
  8. data/Gemfile +17 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +133 -0
  11. data/Rakefile +20 -0
  12. data/features/shared/examples/metasploit/version/gem_version_constant.feature +215 -0
  13. data/features/shared/examples/metasploit/version/version_constant.feature +183 -0
  14. data/features/shared/examples/metasploit/version/version_module.feature +275 -0
  15. data/features/shared/examples/metasploit/version/version_module/prerelease/git/branch.feature +234 -0
  16. data/features/shared/examples/metasploit/version/version_module/prerelease/git/detached_head.feature +97 -0
  17. data/features/shared/examples/metasploit/version/version_module/prerelease/git/master.feature +94 -0
  18. data/features/shared/examples/metasploit/version/version_module/prerelease/git/step_definitions/environment_variable_steps.rb +13 -0
  19. data/features/shared/examples/metasploit/version/version_module/prerelease/git/step_definitions/git_steps.rb +30 -0
  20. data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/branch.feature +173 -0
  21. data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/master.feature +90 -0
  22. data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/pull_request.feature +99 -0
  23. data/features/shared/examples/metasploit/version/version_module/prerelease/travis_ci/tag.feature +277 -0
  24. data/features/support/env.rb +41 -0
  25. data/features/support/simplecov_setup.rb +12 -0
  26. data/lib/metasploit/version.rb +19 -0
  27. data/lib/metasploit/version/branch.rb +172 -0
  28. data/lib/metasploit/version/version.rb +57 -0
  29. data/metasploit-version.gemspec +41 -0
  30. data/spec/lib/metasploit/version/branch_spec.rb +660 -0
  31. data/spec/lib/metasploit/version/version_spec.rb +5 -0
  32. data/spec/lib/metasploit/version_spec.rb +6 -0
  33. data/spec/spec_helper.rb +13 -0
  34. data/spec/support/shared/examples/metasploit/version/gem_version_constant.rb +17 -0
  35. data/spec/support/shared/examples/metasploit/version/version_constant.rb +17 -0
  36. data/spec/support/shared/examples/metasploit/version/version_module.rb +226 -0
  37. metadata +173 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 81bcd1c0b7d61d6e30a6fad4b1ac333dbb7581ab
4
+ data.tar.gz: 447c56d81b51a5437146f56d65eeeebc85122dff
5
+ SHA512:
6
+ metadata.gz: 5dd755bdc48758ee7729493f496e9c216c845208b5fd84e02abab70fe6a02472e1b21aad3e50e0eb7d701f823191bf7e97f0adda2a1401d4e350d6d14aa50715
7
+ data.tar.gz: a12d1c52252e8c7f4daddd712a6c99cc1d380977d3f5a58a4783f99122271fec2e91fd2f73c699644c7a3aa1ae614bf9e27f9169ade1932634c55f971d289e77
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,32 @@
1
+ # bundler
2
+ .bundle
3
+
4
+ # Rubymine
5
+ .idea
6
+
7
+ # aruba temporary files
8
+ /tmp
9
+
10
+ # simplecov
11
+ coverage
12
+
13
+ # @see http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
14
+ Gemfile.lock
15
+
16
+ # yard
17
+ /.yardoc
18
+ /doc
19
+
20
+ # RVM management
21
+ .ruby-version
22
+ .ruby-gemset
23
+
24
+ # Built Rubygems
25
+ pkg/*
26
+
27
+ # YARD database
28
+ .yardoc
29
+ # coverage report directory for simplecov/Rubymine
30
+ coverage
31
+ # generated yardocs
32
+ doc
@@ -0,0 +1,60 @@
1
+ # RM_INFO is set when using Rubymine. In Rubymine, starting SimpleCov is
2
+ # controlled by running with coverage, so don't explicitly start coverage (and
3
+ # therefore generate a report) when in Rubymine. This _will_ generate a report
4
+ # whenever `rake spec` is run.
5
+ unless ENV['RM_INFO']
6
+ SimpleCov.start
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ # ignore this file
11
+ add_filter '.simplecov'
12
+
13
+ # Rake tasks aren't tested with rspec
14
+ add_filter 'Rakefile'
15
+ add_filter 'lib/tasks'
16
+
17
+ #
18
+ # Changed Files in Git Group
19
+ # @see http://fredwu.me/post/35625566267/simplecov-test-coverage-for-changed-files-only
20
+ #
21
+
22
+ untracked = `git ls-files --exclude-standard --others`
23
+ unstaged = `git diff --name-only`
24
+ staged = `git diff --name-only --cached`
25
+ all = untracked + unstaged + staged
26
+ changed_filenames = all.split("\n")
27
+
28
+ add_group 'Changed' do |source_file|
29
+ changed_filenames.detect { |changed_filename|
30
+ source_file.filename.end_with?(changed_filename)
31
+ }
32
+ end
33
+
34
+ add_group 'Libraries', 'lib'
35
+
36
+ #
37
+ # Specs are reported on to ensure that all examples are being run and all
38
+ # lets, befores, afters, etc are being used.
39
+ #
40
+
41
+ add_group 'Specs', 'spec'
42
+ end
43
+
44
+ require 'codeclimate-test-reporter'
45
+ require 'coveralls'
46
+
47
+ if ENV['TRAVIS'] == 'true'
48
+ formatters = []
49
+
50
+ # don't use `CodeClimate::TestReporter.start` as it will overwrite some .simplecov settings
51
+ if CodeClimate::TestReporter.run?
52
+ formatters << CodeClimate::TestReporter::Formatter
53
+ end
54
+
55
+ formatters << Coveralls::SimpleCov::Formatter
56
+
57
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
58
+ *formatters
59
+ ]
60
+ end
@@ -0,0 +1,26 @@
1
+ env:
2
+ global:
3
+ secure: "G0LDGrupZ+RAFzoPwd6bjfrWfwoU/V9RTswQXIUNmi640rW/CP86a8F9hQcAXdUwy7Ag1cwmlEEv2JDDbLopQdNvkh8B7M3PSIpmJWlBsj+UPMMcCz04oYiQB3G6xgYb4xeuY6cNqxiY2rTJMHlfUfTlSJf1Z0dh6hAS3alHpGw="
4
+ matrix:
5
+ - RAKE_TASK=cucumber
6
+ - RAKE_TASK=spec
7
+ language: ruby
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
11
+ fast_finish: true
12
+ # documentation coverage is not influenced by ruby version, but the dependencies differ for MRI and JRuby, so
13
+ # rake yard for both.
14
+ include:
15
+ - rvm: 2.1
16
+ env: RAKE_TASK=yard
17
+ - rvm: jruby
18
+ env: RAKE_TASK=yard
19
+ rvm:
20
+ - 1.9.3
21
+ - 2.0
22
+ - 2.1
23
+ - ruby-head
24
+ - jruby
25
+ - rbx-2.2
26
+ script: "bundle exec rake $RAKE_TASK"
@@ -0,0 +1,7 @@
1
+ --markup markdown
2
+ --private
3
+ --protected
4
+ lib/**/*.rb
5
+ -
6
+ CONTRIBUTING.md
7
+ README.md
@@ -0,0 +1,156 @@
1
+ # Contributing
2
+
3
+ ## Forking
4
+
5
+ [Fork this repository](https://github.com/rapid7/metasploit-version/fork)
6
+
7
+ ## Branching
8
+
9
+ Branch names follow the format `TYPE/ISSUE/SUMMARY`. You can create it with `git checkout -b TYPE/ISSUE/SUMMARY`.
10
+
11
+ ### `TYPE`
12
+
13
+ `TYPE` can be `bug`, `chore`, or `feature`.
14
+
15
+ ### `ISSUE`
16
+
17
+ `ISSUE` is either a [Github issue](https://github.com/rapid7/metasploit-version/issues) or an issue from some other
18
+ issue tracking software.
19
+
20
+ ### `SUMMARY`
21
+
22
+ `SUMMARY` is is short summary of the purpose of the branch composed of lower case words separated by '-' so that it is a valid `PRERELEASE` for the Gem version.
23
+
24
+ ## Changes
25
+
26
+ ### `PRERELEASE`
27
+
28
+ 1. Update `PRERELEASE` to match the `SUMMARY` in the branch name. If you branched from `master`, and [version.rb](lib/metasploit/version/version.rb) does not have `PRERELEASE` defined, then adding the following lines after `PATCH`:
29
+ ```
30
+ # The prerelease version, scoped to the {PATCH} version number.
31
+ PRERELEASE = '<SUMMARY>'
32
+ ```
33
+ 2. `rake spec`
34
+ 3. Verify the specs pass, which indicates that `PRERELEASE` was updated correctly.
35
+ 4. Commit the change `git commit -a`
36
+
37
+ ### Your changes
38
+
39
+ Make your changes or however many commits you like, commiting each with `git commit`.
40
+
41
+ ### Pre-Pull Request Testing
42
+
43
+ 1. Run specs one last time before opening the Pull Request: `rake spec`
44
+ 2. Verify there was no failures.
45
+
46
+ ### Push
47
+
48
+ Push your branch to your fork on gitub: `git push push TYPE/ISSUE/SUMMARY`
49
+
50
+ ### Pull Request
51
+
52
+ * [Create new Pull Request](https://github.com/rapid7/metasploit-version/compare/)
53
+ * Add a Verification Steps comment
54
+
55
+ ```
56
+ # Verification Steps
57
+
58
+ - [ ] `bundle install`
59
+
60
+ ## `rake spec`
61
+ - [ ] `rake spec`
62
+ - [ ] VERIFY no failures
63
+ ```
64
+ You should also include at least one scenario to manually check the changes outside of specs.
65
+
66
+ * Add a Post-merge Steps comment
67
+
68
+ The 'Post-merge Steps' are a reminder to the reviewer of the Pull Request of how to update the [`PRERELEASE`](lib/metasploit/version/version.rb) so that [version_spec.rb](spec/lib/metasploit/version/version_spec.rb) passes on the target branch after the merge.
69
+
70
+ DESTINATION is the name of the destination branch into which the merge is being made. SOURCE_SUMMARY is the SUMMARY from TYPE/ISSUE/SUMMARY branch name for the SOURCE branch that is being made.
71
+
72
+ When merging to `master`:
73
+
74
+ ```
75
+ # Post-merge Steps
76
+
77
+ Perform these steps prior to pushing to master or the build will be broke on master.
78
+
79
+ ## Version
80
+ - [ ] Edit `lib/metasploit/version/version.rb`
81
+ - [ ] Remove `PRERELEASE` and its comment as `PRERELEASE` is not defined on master.
82
+
83
+ ## Gem build
84
+ - [ ] gem build *.gemspec
85
+ - [ ] VERIFY the gem has no '.pre' version suffix.
86
+
87
+ ## RSpec
88
+ - [ ] `rake spec`
89
+ - [ ] VERIFY version examples pass without failures
90
+
91
+ ## Commit & Push
92
+ - [ ] `git commit -a`
93
+ - [ ] `git push origin master`
94
+ ```
95
+
96
+ When merging to DESTINATION other than `master`:
97
+
98
+ ```
99
+ # Post-merge Steps
100
+
101
+ Perform these steps prior to pushing to DESTINATION or the build will be broke on DESTINATION.
102
+
103
+ ## Version
104
+ - [ ] Edit `lib/metasploit/version/version.rb`
105
+ - [ ] Change `PRERELEASE` from `SOURCE_SUMMARY` to `DESTINATION_SUMMARY` to match the branch (DESTINATION) summary (DESTINATION_SUMMARY)
106
+
107
+ ## Gem build
108
+ - [ ] gem build *.gemspec
109
+ - [ ] VERIFY the prerelease suffix has change on the gem.
110
+
111
+ ## RSpec
112
+ - [ ] `rake spec`
113
+ - [ ] VERIFY version examples pass without failures
114
+
115
+ ## Commit & Push
116
+ - [ ] `git commit -a`
117
+ - [ ] `git push origin DESTINATION`
118
+ ```
119
+
120
+ * Add a 'Release Steps' comment
121
+
122
+ The 'Release Steps' are a reminder to the reviewer of the Pull Request of how to release the gem.
123
+
124
+ ```
125
+ # Release
126
+
127
+ Complete these steps on DESTINATION
128
+
129
+ ## `VERSION`
130
+
131
+ ### Compatible changes
132
+
133
+ If your change are compatible with the previous branch's API, then increment [`PATCH`](lib/metasploit/version/version.rb).
134
+
135
+ ### Incompatible changes
136
+
137
+ If your changes are incompatible with the previous branch's API, then increment [`MINOR`](lib/metasploit/version/version.rb) and reset [`PATCH`](lib/metasploit/version/version.rb) to `0`.
138
+
139
+ - [ ] Following the rules for [semantic versioning 2.0](http://semver.org/spec/v2.0.0.html), update [`MINOR`](lib/metasploit/version/version.rb) and [`PATCH`](lib/metasploit/version/version.rb) and commit the changes.
140
+
141
+ ## JRuby
142
+ - [ ] `rvm use jruby@metasploit-version`
143
+ - [ ] `rm Gemfile.lock`
144
+ - [ ] `bundle install`
145
+ - [ ] `rake release`
146
+
147
+ ## MRI Ruby
148
+ - [ ] `rvm use ruby-2.1@metasploit-version`
149
+ - [ ] `rm Gemfile.lock`
150
+ - [ ] `bundle install`
151
+ - [ ] `rake release`
152
+ ```
153
+
154
+ ### Downstream dependencies
155
+
156
+ There are currently no known downstream dependencies
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in metasploit-version.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ # Test the shared example
8
+ gem 'aruba'
9
+ # Upload spec coverage to codeclimate.com
10
+ gem 'codeclimate-test-reporter', require: false
11
+ # Upload spec coverage to coveralls.io
12
+ gem 'coveralls', require: false
13
+ # Test the shared example
14
+ gem 'cucumber'
15
+ # code coverage for specs
16
+ gem 'simplecov', require: false
17
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Luke Imhoff
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,133 @@
1
+ # 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)
2
+
3
+ Metasploit::Version allows your gem to declare the pieces of its [semantic version](semver.org) as constant and for
4
+ your `VERSION` `String` to be automatically derived from those constants. Shared examples are available to test that
5
+ the `PRERELEASE` `String` matches the expected pattern of using the branch relative name and being undefined on master.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'metasploit-version'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install metasploit-version
20
+
21
+ ## Usage
22
+
23
+ ### Gem version.rb
24
+
25
+ Your gem's version.rb file should have a `Version` `Module` that defines the parts of the semantic version and
26
+ `extend Metasploit::Version::Full`. Then, `VERSION` in your gem's top-level namespace `Module` can be set to
27
+ `Version.full`
28
+
29
+ module MyNamespace
30
+ module MyGem
31
+ # Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
32
+ module Version
33
+ #
34
+ # CONSTANTS
35
+ #
36
+
37
+ # The major version number
38
+ MAJOR = 0
39
+
40
+ # The minor version number, scoped to the {MAJOR} version number.
41
+ MINOR = 0
42
+
43
+ # The patch number, scoped to the {MINOR} version number.
44
+ PATCH = 1
45
+
46
+ # The prerelease version, scoped to the {PATCH} version number.
47
+ PRERELEASE = '<relative-name>'
48
+
49
+ #
50
+ # Module Methods
51
+ #
52
+
53
+ # The full version string, including the {MyNamespace::MyGem::Version::MAJOR},
54
+ # {MyNamespace::MyGem::Version::MINOR}, {MyNamespace::MyGem::Version::PATCH}, and optionally, the
55
+ # `MyNamespace::MyGem::Version::PRERELEASE` in the
56
+ # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
57
+ #
58
+ # @return [String] '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}'
59
+ # on master. '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}-PRERELEASE'
60
+ # on any branch other than master.
61
+ def self.full
62
+ version = "#{MAJOR}.#{MINOR}.#{PATCH}"
63
+
64
+ if defined? PRERELEASE
65
+ version = "#{version}-#{PRERELEASE}"
66
+ end
67
+
68
+ version
69
+ end
70
+
71
+ # The full gem version string, including the {MyNamespace::MyGem::Version::MAJOR},
72
+ # {MyNamespace::MyGem::Version::MINOR}, {MyNamespace::MyGem::Version::PATCH}, and optionally, the
73
+ # `MyNamespace::MyGem::Version::PRERELEASE` in the
74
+ # {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
75
+ #
76
+ # @return [String] '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}'
77
+ # on master. '{MyNamespace::MyGem::Version::MAJOR}.{MyNamespace::MyGem::Version::MINOR}.{MyNamespace::MyGem::Version::PATCH}.PRERELEASE'
78
+ # on any branch other than master.
79
+ def self.gem
80
+ full.gsub('-', '.pre.')
81
+ end
82
+ end
83
+
84
+ # (see Version.gem)
85
+ GEM_VERSION = Version.gem
86
+
87
+ # (see Version.full)
88
+ VERSION = Version.full
89
+ end
90
+ end
91
+
92
+ On a branch such the relative name is the portion after the branch type as in `bug/<relative-name>`,
93
+ `chore/<relative-name>`, `feature/<relative-name>`, or `staging/<relative-name>`. On master, the gem is assumed to
94
+ no longer be in prerelease, so `PRERELEASE` should not be defined. If it is defined, the
95
+ `'Metasploit::Version Version Module'` shared example will fail.
96
+
97
+ ### spec_helper.rb
98
+
99
+ In your `spec_helper.rb`, require the shared examples from `metasploit-version`.
100
+
101
+ # Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
102
+ gem_specification = Gem::Specification.find_all_by_name('metasploit-version').first
103
+
104
+ Dir[File.join(gem_specification.gem_dir, 'spec', 'support', '**', '*.rb')].each do |f|
105
+ require f
106
+ end
107
+
108
+ ### Gem namespace spec
109
+
110
+ The spec for your gem's namespace `Module` should use the `'Metasploit::Version VERSION constant'` shared example.
111
+
112
+ require 'spec_helper'
113
+
114
+ describe MyNamespace::MyGem do
115
+ it_should_behave_like 'Metasploit::Version VERSION constant'
116
+ it_should_behave_like 'Metasploit::Version GEM_VERSION constant'
117
+ end
118
+
119
+ ### Gem Version spec
120
+
121
+ The spec for your gem's `Version` `Module` defined in the `version.rb` file should use the
122
+ `'Metasploit::Version Version Module'` shared example.
123
+
124
+ require 'spec_helper'
125
+
126
+ describe MyNamespace::MyGem::Version do
127
+ it_should_behave_like 'Metasploit::Version Version Module'
128
+ end
129
+
130
+ ## Contributing
131
+
132
+ See [CONTRIBUTING.md](CONTRIBUTING.md)
133
+