power-version 1.0.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.
- checksums.yaml +7 -0
- data/lib/version.rb +34 -0
- metadata +36 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a0cc69461995920331f502cf2536c2f6f6e06c95adcbc0debd5e681c522acdb5
|
|
4
|
+
data.tar.gz: 977c3b189f27b2beba62ce2b76dff62ba3d038114669f3789bf5b7f168fbcaa4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1ed4d1bae07d69134076e69f21d7ffbfbc2854f8b097b8e53f3030481a763289b3de5a1a9d481f45c625d81bf3e30fda56f8e32490a21a5b3dffec12ea14b4b3
|
|
7
|
+
data.tar.gz: c7f79c54dbd433b73a77893d2561492f3f46f5427c9108f37076688763dc65d383089806c0fd58a77401fd276702883977bfee1d6d7be2b3cadd8db94d8da065
|
data/lib/version.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Version < Data.define(:major, :minor, :patch)
|
|
4
|
+
include Comparable
|
|
5
|
+
|
|
6
|
+
def initialize(major: 0, minor: 0, patch: 0)
|
|
7
|
+
major, minor, patch = major.split(".", 3) if major.is_a?(String)
|
|
8
|
+
super(major: major.to_i, minor: minor.to_i, patch: patch.to_i)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def bump(level=:patch)
|
|
12
|
+
case level
|
|
13
|
+
when :major then with(major: major.succ, minor: 0, patch: 0)
|
|
14
|
+
when :minor then with(minor: minor.succ, patch: 0)
|
|
15
|
+
when :patch then with(patch: patch.succ)
|
|
16
|
+
else self
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def <=>(other)
|
|
21
|
+
deconstruct <=> other.deconstruct
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_s
|
|
25
|
+
deconstruct.join(".")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if defined?(ActiveRecord::Type::Value)
|
|
29
|
+
class Type < ActiveRecord::Type::Value
|
|
30
|
+
def serialize(version) = version.to_s
|
|
31
|
+
def cast(presentation) = Version[presentation]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: power-version
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Max Power
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
executables: []
|
|
13
|
+
extensions: []
|
|
14
|
+
extra_rdoc_files: []
|
|
15
|
+
files:
|
|
16
|
+
- lib/version.rb
|
|
17
|
+
licenses: []
|
|
18
|
+
metadata: {}
|
|
19
|
+
rdoc_options: []
|
|
20
|
+
require_paths:
|
|
21
|
+
- lib
|
|
22
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.2.0
|
|
27
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
28
|
+
requirements:
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '0'
|
|
32
|
+
requirements: []
|
|
33
|
+
rubygems_version: 4.0.5
|
|
34
|
+
specification_version: 4
|
|
35
|
+
summary: A ruby gem to work with version numbers
|
|
36
|
+
test_files: []
|