with-version 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a78fa4c49e7ff1cc9d33f1a9344cbe9d7ce95224693b4bf9b4e3d41ea436a40a
4
+ data.tar.gz: 65d8a5357cef1b1a69aeff518f1ca1d0e35d55920166bc2ae5b6f2484982d283
5
+ SHA512:
6
+ metadata.gz: 6b153188b7ad108b454044f7a8717420788d61e382c8feee963361525d0933316a19793357bfbb3d5d2c99ac5f82d6f6185cb6035cda2f4a09f48dfef7543f94
7
+ data.tar.gz: 1f42d854e9183a0cec864e5e48e1aa8de205646bce8ef792ceed275b13396e251e8c12c755b4c9e070cc450073892d6a33f7a200a9bf43c6357a9518fe1be66c
@@ -0,0 +1,3 @@
1
+ ### 0.1.0 (1/13/2020)
2
+
3
+ * Initial public release - [@dblock](https://github.com/dblock).
@@ -0,0 +1,125 @@
1
+ # Contributing to With::Version
2
+
3
+ This project is work of [many contributors](https://github.com/dblock/with-version/graphs/contributors).
4
+
5
+ You're encouraged to submit [pull requests](https://github.com/dblock/with-version/pulls), [propose features and discuss issues](https://github.com/dblock/with-version/issues).
6
+
7
+ In the examples below, substitute your Github username for `contributor` in URLs.
8
+
9
+ ### Fork the Project
10
+
11
+ Fork the [project on Github](https://github.com/dblock/with-version) and check out your copy.
12
+
13
+ ```
14
+ git clone https://github.com/contributor/with-version.git
15
+ cd with-version
16
+ git remote add upstream https://github.com/dblock/with-version.git
17
+ ```
18
+
19
+ ### Bundle Install and Test
20
+
21
+ Ensure that you can build the project and run tests.
22
+
23
+ ```
24
+ bundle install
25
+ bundle exec rake
26
+ ```
27
+
28
+ ## Contribute Code
29
+
30
+ ### Create a Topic Branch
31
+
32
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
33
+
34
+ ```
35
+ git checkout master
36
+ git pull upstream master
37
+ git checkout -b my-feature-branch
38
+ ```
39
+
40
+ ### Write Tests
41
+
42
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to [spec](spec).
43
+
44
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
45
+
46
+ ### Write Code
47
+
48
+ Implement your feature or bug fix.
49
+
50
+ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.
51
+
52
+ Make sure that `bundle exec rake` completes without errors.
53
+
54
+ ### Write Documentation
55
+
56
+ Document any external behavior in the [README](README.md).
57
+
58
+ ### Update Changelog
59
+
60
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Don't remove *Your contribution here*.
61
+
62
+ Make it look like every other line, including a link to the issue being fixed, your name and link to your Github account.
63
+
64
+ ### Commit Changes
65
+
66
+ Make sure git knows your name and email address:
67
+
68
+ ```
69
+ git config --global user.name "Your Name"
70
+ git config --global user.email "contributor@example.com"
71
+ ```
72
+
73
+ Writing good commit logs is important. A commit log should describe what changed and why.
74
+
75
+ ```
76
+ git add ...
77
+ git commit
78
+ ```
79
+
80
+ ### Push
81
+
82
+ ```
83
+ git push origin my-feature-branch
84
+ ```
85
+
86
+ ### Make a Pull Request
87
+
88
+ Go to https://github.com/contributor/with-version and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
89
+
90
+ ### Update CHANGELOG Again
91
+
92
+ Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
93
+
94
+ ```
95
+ * [#123](https://github.com/dblock/with-version/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
96
+ ```
97
+
98
+ Amend your previous commit and force push the changes.
99
+
100
+ ```
101
+ git commit --amend
102
+ git push origin my-feature-branch -f
103
+ ```
104
+
105
+ ### Rebase
106
+
107
+ If you've been working on a change for a while, rebase with upstream/master.
108
+
109
+ ```
110
+ git fetch upstream
111
+ git rebase upstream/master
112
+ git push origin my-feature-branch -f
113
+ ```
114
+
115
+ ### Check on Your Pull Request
116
+
117
+ Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
118
+
119
+ ### Be Patient
120
+
121
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
122
+
123
+ ## Thank You
124
+
125
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'rake'
8
+
9
+ group :development, :test do
10
+ gem 'rspec'
11
+ gem 'rubocop', '0.79.0'
12
+ end
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ with-version (0.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ ast (2.4.0)
10
+ diff-lcs (1.3)
11
+ jaro_winkler (1.5.4)
12
+ parallel (1.19.1)
13
+ parser (2.7.0.2)
14
+ ast (~> 2.4.0)
15
+ rainbow (3.0.0)
16
+ rake (13.0.1)
17
+ rspec (3.9.0)
18
+ rspec-core (~> 3.9.0)
19
+ rspec-expectations (~> 3.9.0)
20
+ rspec-mocks (~> 3.9.0)
21
+ rspec-core (3.9.1)
22
+ rspec-support (~> 3.9.1)
23
+ rspec-expectations (3.9.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.9.0)
26
+ rspec-mocks (3.9.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.9.0)
29
+ rspec-support (3.9.2)
30
+ rubocop (0.79.0)
31
+ jaro_winkler (~> 1.5.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.7.0.1)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (>= 1.4.0, < 1.7)
37
+ ruby-progressbar (1.10.1)
38
+ unicode-display_width (1.6.0)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ rake
45
+ rspec
46
+ rubocop (= 0.79.0)
47
+ with-version!
48
+
49
+ BUNDLED WITH
50
+ 2.1.4
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Daniel Doubrovkine.
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,48 @@
1
+ With::Version
2
+ ==========
3
+
4
+ [![Gem Version](http://img.shields.io/gem/v/with-version.svg)](http://badge.fury.io/rb/with-version)
5
+ [![Build Status](http://img.shields.io/travis/dblock/with-version.svg)](https://travis-ci.org/dblock/with-version)
6
+
7
+ Syntax sugar for version checks. Inspired by [usage in hashie](https://github.com/hashie/hashie/search?q=with_minimum_ruby&unscoped_q=with_minimum_ruby).
8
+
9
+ ## Usage
10
+
11
+ ### Ruby::Version
12
+
13
+ Use `with_minimum_ruby` to check against a Ruby version at class load time, instead of runtime.
14
+
15
+ ```ruby
16
+ require 'with-version'
17
+
18
+ class Example
19
+ include With::Version::Ruby
20
+
21
+ with_minimum_ruby '2.4.0' do
22
+ # only declared with Ruby 2.4.0 or newer
23
+ def dig(*keys)
24
+ puts "Digging #{keys.join(', ')} ..."
25
+ end
26
+ end
27
+ end
28
+ ```
29
+
30
+ ```ruby
31
+ # Ruby 2.3.0
32
+ undefined method `dig' for #<Example:0x00007fca9388a8a0> (NoMethodError)
33
+ ```
34
+
35
+ ```ruby
36
+ # Ruby 2.4.0
37
+ Digging x, y ...
38
+ ```
39
+
40
+ ## Contributing
41
+
42
+ You're encouraged to contribute to this gem. See [CONTRIBUTING](CONTRIBUTING.md) for details.
43
+
44
+ ## Copyright and License
45
+
46
+ Copyright (c) 2020, Daniel Doubrovkine and [Contributors](CHANGELOG.md).
47
+
48
+ This project is licensed under the [MIT License](LICENSE.md).
@@ -0,0 +1,67 @@
1
+ # Releasing With::Version
2
+
3
+ There're no hard rules about when to release with-version. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
4
+
5
+ ### Release
6
+
7
+ Run tests, check that all tests succeed locally.
8
+
9
+ ```
10
+ bundle install
11
+ rake
12
+ ```
13
+
14
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/with-version) for all supported platforms.
15
+
16
+ Increment the version, modify [lib/with-version/version.rb](lib/with-version/version.rb).
17
+
18
+ * Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.2.1` to `0.2.2`).
19
+ * Increment the second number if the release contains major features or breaking API changes (eg. change `0.2.1` to `0.3.0`).
20
+
21
+ Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
22
+
23
+ ```
24
+ ### 0.2.2 (7/10/2015)
25
+ ```
26
+
27
+ Remove the line with "Your contribution here.", since there will be no more contributions to this release.
28
+
29
+ Commit your changes.
30
+
31
+ ```
32
+ git add README.md CHANGELOG.md lib/with-version/version.rb
33
+ git commit -m "Preparing for release, 0.2.2."
34
+ git push origin master
35
+ ```
36
+
37
+ Release.
38
+
39
+ ```
40
+ $ rake release
41
+
42
+ with-version 0.2.2 built to pkg/with-version-0.2.2.gem.
43
+ Tagged v0.2.2.
44
+ Pushed git commits and tags.
45
+ Pushed with-version 0.2.2 to rubygems.org.
46
+ ```
47
+
48
+ ### Prepare for the Next Version
49
+
50
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
51
+
52
+ ```
53
+ Next Release
54
+ ============
55
+
56
+ * Your contribution here.
57
+ ```
58
+
59
+ Increment the third version number in [lib/with-version/version.rb](lib/with-version/version.rb).
60
+
61
+ Commit your changes.
62
+
63
+ ```
64
+ git add CHANGELOG.md lib/with-version/version.rb
65
+ git commit -m "Preparing for next development iteration, 0.2.3."
66
+ git push origin master
67
+ ```
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler/gem_tasks'
5
+
6
+ Bundler.setup :default, :development
7
+
8
+ require 'rspec/core'
9
+ require 'rspec/core/rake_task'
10
+
11
+ RSpec::Core::RakeTask.new(:spec) do |spec|
12
+ spec.pattern = FileList['spec/**/*_spec.rb']
13
+ end
14
+
15
+ require 'rubocop/rake_task'
16
+ RuboCop::RakeTask.new(:rubocop)
17
+
18
+ task default: %i[rubocop spec]
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'with-version/version'
4
+ require 'with-version/ruby'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'ruby/version'
4
+
5
+ module With
6
+ module Version
7
+ module Ruby
8
+ def self.included(base)
9
+ base.extend ClassMethods
10
+ end
11
+
12
+ module ClassMethods
13
+ def with_minimum_ruby(version)
14
+ if With::Version::Ruby::Version.new(RUBY_VERSION) >= With::Version::Ruby::Version.new(version)
15
+ yield
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) Chad Fowler, Rich Kilmer, Jim Weirich and others.
4
+ # Portions copyright (c) Engine Yard and Andre Arko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # 'Software'), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+
17
+ module With
18
+ module Version
19
+ module Ruby
20
+ class Version
21
+ include Comparable
22
+
23
+ attr_accessor :segments
24
+
25
+ def initialize(version)
26
+ @segments = split_to_segments(version)
27
+ end
28
+
29
+ def <=>(other)
30
+ lhsegments = segments
31
+ rhsegments = other.segments
32
+
33
+ lhsize = lhsegments.size
34
+ rhsize = rhsegments.size
35
+ limit = (lhsize > rhsize ? lhsize : rhsize) - 1
36
+
37
+ i = 0
38
+
39
+ while i <= limit
40
+ lhs = lhsegments[i] || 0
41
+ rhs = rhsegments[i] || 0
42
+ i += 1
43
+
44
+ next if lhs == rhs
45
+ return -1 if lhs.is_a?(String) && rhs.is_a?(Numeric)
46
+ return 1 if lhs.is_a?(Numeric) && rhs.is_a?(String)
47
+
48
+ return lhs <=> rhs
49
+ end
50
+
51
+ 0
52
+ end
53
+
54
+ private
55
+
56
+ def split_to_segments(version)
57
+ version.scan(/[0-9]+|[a-z]+/i).map do |segment|
58
+ /^\d+$/ =~ segment ? segment.to_i : segment
59
+ end.freeze
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module With
4
+ module Version
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+
5
+ require 'rubygems'
6
+ require 'rspec'
7
+ require 'with-version'
8
+
9
+ RSpec.configure(&:raise_errors_for_deprecations!)
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe With::Version::Ruby do
6
+ include With::Version::Ruby
7
+
8
+ NEXT_VERSION = Gem::Version.new(RUBY_VERSION).bump.to_s
9
+ PREV_VERSION = Gem::Version.new('1.9.3').to_s
10
+
11
+ context '#with_minimum_ruby' do
12
+ before :all do
13
+ @versions = []
14
+ end
15
+
16
+ context NEXT_VERSION do
17
+ with_minimum_ruby(NEXT_VERSION) do
18
+ it 'never runs' do
19
+ raise NEXT_VERSION
20
+ end
21
+ end
22
+ end
23
+
24
+ context RUBY_VERSION do
25
+ with_minimum_ruby(RUBY_VERSION) do
26
+ it 'includes the current version' do
27
+ @versions << RUBY_VERSION
28
+ end
29
+ end
30
+ end
31
+
32
+ context PREV_VERSION do
33
+ with_minimum_ruby(PREV_VERSION) do
34
+ it 'includes the current version' do
35
+ @versions << PREV_VERSION
36
+ end
37
+ end
38
+ end
39
+
40
+ after :all do
41
+ expect(@versions.sort).to eq([PREV_VERSION, RUBY_VERSION])
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe With::Version do
6
+ it 'has a version' do
7
+ expect(With::Version::VERSION).not_to be_nil
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
4
+ require 'with-version/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'with-version'
8
+ s.version = With::Version::VERSION
9
+ s.authors = ['Daniel Doubrovkine']
10
+ s.email = 'dblock@dblock.org'
11
+ s.platform = Gem::Platform::RUBY
12
+ s.required_rubygems_version = '>= 1.3.6'
13
+ s.files = Dir['**/*']
14
+ s.require_paths = ['lib']
15
+ s.homepage = 'http://github.com/dblock/with-version'
16
+ s.licenses = ['MIT']
17
+ s.summary = 'Syntax sugar for version checks.'
18
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: with-version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Doubrovkine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: dblock@dblock.org
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - CHANGELOG.md
20
+ - CONTRIBUTING.md
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - LICENSE.md
24
+ - README.md
25
+ - RELEASING.md
26
+ - Rakefile
27
+ - lib/with-version.rb
28
+ - lib/with-version/ruby.rb
29
+ - lib/with-version/ruby/version.rb
30
+ - lib/with-version/version.rb
31
+ - spec/spec_helper.rb
32
+ - spec/with-version/ruby_spec.rb
33
+ - spec/with-version/version_spec.rb
34
+ - with-version.gemspec
35
+ homepage: http://github.com/dblock/with-version
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.3.6
53
+ requirements: []
54
+ rubygems_version: 3.0.6
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Syntax sugar for version checks.
58
+ test_files: []