versionaire 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/versionaire/conversion.rb +26 -13
- data/lib/versionaire/errors/conversion.rb +4 -0
- data/lib/versionaire/identity.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f98e7ed286afbc8f36bc63f732a74de14c518bf
|
4
|
+
data.tar.gz: d93d7017c56fc9e89c01e40b5b5cb325eb318bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 194e775943432b6aea87d091ee276b06107f89b6139753decc86575569448100d6342f2c38a53f8870a46acad175893503133218405fd034a8905dc5e59d4a54
|
7
|
+
data.tar.gz: 3689fcd9696f240039ed5b65eaece574e30be23806a322c525e086ab96c29970f610ebc73ae44cc4c8bc212d87a3c9de6b246c1dedc92b67202173aab77d1b38
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -5,39 +5,48 @@ module Versionaire
|
|
5
5
|
# Conversion function (strict) for casting an object into a version.
|
6
6
|
# rubocop:disable Style/MethodName
|
7
7
|
def Version object
|
8
|
-
|
8
|
+
converter = Converter.new object
|
9
9
|
|
10
10
|
case object
|
11
|
-
when String then
|
12
|
-
when Array then
|
13
|
-
when Hash then
|
11
|
+
when String then converter.from_string
|
12
|
+
when Array then converter.from_array
|
13
|
+
when Hash then converter.from_hash
|
14
14
|
when Version then object
|
15
|
-
else
|
15
|
+
else converter.from_object
|
16
16
|
end
|
17
17
|
end
|
18
18
|
module_function :Version
|
19
19
|
|
20
20
|
# Aids with converting objects into valid versions.
|
21
|
-
class
|
21
|
+
class Converter
|
22
22
|
def initialize value
|
23
23
|
@value = value
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
|
26
|
+
def from_string
|
27
|
+
body = %(Use: "<major>.<minor>.<maintenance>" or "v<major>.<minor>.<maintenance>".)
|
28
|
+
fail(Errors::Conversion, error_message(value, body)) unless value =~ Version.string_format
|
28
29
|
Version.new string_to_arguments
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
-
|
32
|
+
def from_array
|
33
|
+
body = "Use: [], [<major>], [<major>, <minor>], or [<major>, <minor>, <maintenance>]."
|
34
|
+
fail(Errors::Conversion, error_message(value, body)) unless (0..3).cover?(value.size)
|
33
35
|
Version.new array_to_arguments
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
|
38
|
+
def from_hash
|
39
|
+
body = "Use: {major: <major>}, " \
|
40
|
+
"{major: <major>, minor: <minor>}, or " \
|
41
|
+
"{major: <major>, minor: <minor>, maintenance: <maintenance>}."
|
42
|
+
fail(Errors::Conversion, error_message(value, body)) unless required_keys?
|
38
43
|
Version.new value
|
39
44
|
end
|
40
45
|
|
46
|
+
def from_object
|
47
|
+
fail Errors::Conversion, error_message(value, "Use: String, Array, Hash, or Version.")
|
48
|
+
end
|
49
|
+
|
41
50
|
private
|
42
51
|
|
43
52
|
attr_reader :value
|
@@ -53,6 +62,10 @@ module Versionaire
|
|
53
62
|
def required_keys?
|
54
63
|
value.keys.all? { |key| Version.keys.include? key }
|
55
64
|
end
|
65
|
+
|
66
|
+
def error_message object, body
|
67
|
+
"Invalid version conversion: #{object}. #{body}"
|
68
|
+
end
|
56
69
|
end
|
57
|
-
private_constant :
|
70
|
+
private_constant :Converter
|
58
71
|
end
|
@@ -5,18 +5,22 @@ module Versionaire
|
|
5
5
|
# Thrown when attempting to convert (cast) a primitive to a version.
|
6
6
|
class Conversion < Base
|
7
7
|
def self.string_message
|
8
|
+
warn "[DEPRECATION]: .string_message is deprecated and will be removed in the next major release."
|
8
9
|
%(Invalid string conversion. Use: "<major>.<minor>.<maintenance>" or "v<major>.<minor>.<maintenance>".)
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.array_message
|
13
|
+
warn "[DEPRECATION]: .array_message is deprecated and will be removed in the next major release."
|
12
14
|
"Invalid array conversion. Use: [], [<major>], [<major>, <minor>], or [<major>, <minor>, <maintenance>]."
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.hash_message
|
18
|
+
warn "[DEPRECATION]: .array_message is deprecated and will be removed in the next major release."
|
16
19
|
"Invalid hash conversion. Use: {major: <major>, minor: <minor>, maintenance: <maintenance>}."
|
17
20
|
end
|
18
21
|
|
19
22
|
def self.primitive_message
|
23
|
+
warn "[DEPRECATION]: .primitive_message is deprecated and will be removed in the next major release."
|
20
24
|
"Invalid conversion. Use: String, Array, or Hash."
|
21
25
|
end
|
22
26
|
end
|
data/lib/versionaire/identity.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versionaire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
aSif+qBc6oHD7EQWPF5cZkzkIURuwNwPBngZGxIKaMAgRhjGFXzUMAaq++r59cS9
|
31
31
|
xTfQ4k6fglKEgpnLAXiKdo2c8Ym+X4rIKFfedQ==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2016-03
|
33
|
+
date: 2016-04-03 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: bundler
|
metadata.gz.sig
CHANGED
Binary file
|