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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34468329f30afcc69ad0decfe31ef293346aa16f
4
- data.tar.gz: 34a6064108cc26f6d5ee3b69653962911addf75b
3
+ metadata.gz: 8f98e7ed286afbc8f36bc63f732a74de14c518bf
4
+ data.tar.gz: d93d7017c56fc9e89c01e40b5b5cb325eb318bdb
5
5
  SHA512:
6
- metadata.gz: 42567538dadd2d31ab0013bde14b6abfd58dba8617fd5c45df909c1f56fc625b1a4d6a61d4a933fc21dbae2b34bc282ba0326740f880b85839424b5f322fa193
7
- data.tar.gz: 8f52ad15a86d56ea3df8bdddb12d6041f8eb9b697218d3b0ff6f78190870a18a1bffc12aa051589e02c4367b4928f65db10ddd8f78c416e3c6ef7b3690aab0d8
6
+ metadata.gz: 194e775943432b6aea87d091ee276b06107f89b6139753decc86575569448100d6342f2c38a53f8870a46acad175893503133218405fd034a8905dc5e59d4a54
7
+ data.tar.gz: 3689fcd9696f240039ed5b65eaece574e30be23806a322c525e086ab96c29970f610ebc73ae44cc4c8bc212d87a3c9de6b246c1dedc92b67202173aab77d1b38
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
- aid = VersionAid.new object
8
+ converter = Converter.new object
9
9
 
10
10
  case object
11
- when String then aid.convert_from_string
12
- when Array then aid.convert_from_array
13
- when Hash then aid.convert_from_hash
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 fail Errors::Conversion, Errors::Conversion.primitive_message
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 VersionAid
21
+ class Converter
22
22
  def initialize value
23
23
  @value = value
24
24
  end
25
25
 
26
- def convert_from_string
27
- fail(Errors::Conversion, Errors::Conversion.string_message) unless value =~ Version.string_format
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 convert_from_array
32
- fail(Errors::Conversion, Errors::Conversion.array_message) unless (0..3).cover?(value.size)
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 convert_from_hash
37
- fail(Errors::Conversion, Errors::Conversion.hash_message) unless required_keys?
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 :VersionAid
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
@@ -12,7 +12,7 @@ module Versionaire
12
12
  end
13
13
 
14
14
  def self.version
15
- "1.0.0"
15
+ "1.1.0"
16
16
  end
17
17
 
18
18
  def self.version_label
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.0.0
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-26 00:00:00.000000000 Z
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