class_interface 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/class_interface.rb +8 -4
- data/lib/class_interface/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d673f3122127a6d0be966062687001aef18a37c4
|
4
|
+
data.tar.gz: 5525615214e308b78291efcfc315fe1345ff5de2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9115e9849dabdfe64d2a8ad482fff685a62aa74e5c29278524819487c61ef2f29f32d2b10f13c1050701c4ffc7d0306600e3b0c0e368f21c62179faf02a42ea3
|
7
|
+
data.tar.gz: ae8db4d6bf1140e46594f78de02969c4d2a895764d34341f2641aa255d901ebb03313b93f10521bdb94b93ca03ca6c5538baf4c867bf14017b981f3cac3a468b
|
data/lib/class_interface.rb
CHANGED
@@ -72,14 +72,18 @@ def implements(interface_constant)
|
|
72
72
|
invalid_const_definitions += [const_name] unless if_const_class_type.class == Class
|
73
73
|
next if if_const_class_type.to_s == 'NilClass'
|
74
74
|
impl_const_value_type = Object.const_get("%s::%s" % [implementation_class, const_name]).class
|
75
|
+
ruby_version_lt_24 = (1.class.to_s == 'Fixnum')
|
76
|
+
ruby_version_gte_24 = (1.class.to_s == 'Integer')
|
75
77
|
# Ruby < 2.4
|
76
|
-
if
|
78
|
+
if ruby_version_lt_24 && if_const_class_type.to_s == 'Numeric' && %w[Fixnum Float Bignum].include?(impl_const_value_type.to_s)
|
77
79
|
# we are fine, specific case for numbers
|
78
80
|
# Ruby => 2.4
|
79
|
-
elsif
|
81
|
+
elsif ruby_version_gte_24 && if_const_class_type.to_s == 'Numeric' && %w[Integer Float].include?(impl_const_value_type.to_s)
|
80
82
|
# we are fine, specific case for numbers
|
81
|
-
elsif
|
82
|
-
(if_const_class_type == Fixnum && impl_const_value_type == Integer)
|
83
|
+
elsif ruby_version_lt_24 && ((if_const_class_type.to_s == 'Bignum' && impl_const_value_type.to_s == 'Integer') ||
|
84
|
+
(if_const_class_type.to_s == 'Fixnum' && impl_const_value_type.to_s == 'Integer') ||
|
85
|
+
(if_const_class_type.to_s == 'Integer' && impl_const_value_type.to_s == 'Fixnum') ||
|
86
|
+
(if_const_class_type.to_s == 'Integer' && impl_const_value_type.to_s == 'Bignum'))
|
83
87
|
# Ruby 2.4 unifies Fixnum and Bignum into Integer
|
84
88
|
elsif if_const_class_type != impl_const_value_type
|
85
89
|
raise ClassInterface::ImplementationConstantTypeError, "Value type of constant '#{implementation_class}::#{const_name}' does not match interface '#{if_const_string}'. (#{impl_const_value_type} given, #{if_const_class_type} expected)"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class_interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthäus Beyrle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.5.2
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Extends Ruby to support class interfaces
|