c66-copper 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/copper/data_types/data_type.rb +14 -3
- data/lib/copper/data_types/ip_addr.rb +16 -2
- data/lib/copper/set.rb +7 -1
- data/lib/copper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0442857a59d520bd7fad729cd578fb98593b5a9a'
|
4
|
+
data.tar.gz: 5d1db0d767a03f9d1cc5c398bae3509a1db2667e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a160e4b11c84e9c67f9ea695703209f8831f3eac7ae92d26cdc6019a9aaf69ed471bf2565d238b9e0b6b23d2b13ad63cf9abbe0e1a5a0dd0234a664caf699e2
|
7
|
+
data.tar.gz: a430c3fda59423add10983962110e045a153b2409a9098f05f64838569836f28b92f42ca58d78b6890a0abfda1962c9a9712091daf901a592ac18dd4ae02c8b0
|
@@ -15,7 +15,16 @@ module Copper
|
|
15
15
|
"Image" => "::Copper::DataTypes::Image",
|
16
16
|
"Copper::DataTypes::ImageClass" => "::Copper::DataTypes::Image",
|
17
17
|
"Copper::DataTypes::FilenameClass" => "::Copper::DataTypes::Filename",
|
18
|
-
"Copper::DataTypes::Filename" => "::Copper::DataTypes::Filename"
|
18
|
+
"Copper::DataTypes::Filename" => "::Copper::DataTypes::Filename",
|
19
|
+
"Filename" => "::Copper::DataTypes::Filename"
|
20
|
+
}
|
21
|
+
|
22
|
+
DATATYPE_MAP = {
|
23
|
+
"semver" => "Semver",
|
24
|
+
"ipaddress" => "IPAddress",
|
25
|
+
"image" => "Image",
|
26
|
+
"range" => "Range",
|
27
|
+
"filename" => "Filename",
|
19
28
|
}
|
20
29
|
|
21
30
|
def initialize(value)
|
@@ -27,9 +36,11 @@ module Copper
|
|
27
36
|
end
|
28
37
|
|
29
38
|
def as(clazz)
|
30
|
-
clazz = clazz
|
39
|
+
clazz = ::Copper::DataTypes::DataType::DATATYPE_MAP[clazz]
|
40
|
+
raise RuntimeError, "No class called #{clazz} found" if clazz.nil?
|
41
|
+
|
31
42
|
found_class = ::Copper::DataTypes::DataType.get_class(clazz)
|
32
|
-
return found_class.new(@value)
|
43
|
+
return found_class.new(@value)
|
33
44
|
end
|
34
45
|
|
35
46
|
# returns a DataType based on the given PORO
|
@@ -27,8 +27,15 @@ module Copper
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def in(value)
|
30
|
-
|
31
|
-
|
30
|
+
if value.is_a?(::Copper::DataTypes::IPAddress)
|
31
|
+
to_check = value.ip_address
|
32
|
+
elsif value.is_a?(::IPAddress)
|
33
|
+
to_check = value
|
34
|
+
else
|
35
|
+
raise ::Copper::RuntimeError, "#{value} is not an IP address"
|
36
|
+
end
|
37
|
+
|
38
|
+
(@value.first.to_i <= to_check.to_i) && (@value.last.to_i >= to_check.to_i)
|
32
39
|
end
|
33
40
|
|
34
41
|
def full_address
|
@@ -75,6 +82,13 @@ module Copper
|
|
75
82
|
@value.c?
|
76
83
|
end
|
77
84
|
|
85
|
+
def ip_address
|
86
|
+
@value
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_s
|
90
|
+
@value.to_string
|
91
|
+
end
|
78
92
|
end
|
79
93
|
|
80
94
|
end
|
data/lib/copper/set.rb
CHANGED
@@ -4,7 +4,13 @@ module Copper
|
|
4
4
|
include ::Copper::ExpressionUtils
|
5
5
|
|
6
6
|
def value(vars = {})
|
7
|
-
|
7
|
+
result = elements[0].value(vars)
|
8
|
+
if result.is_a?(::Array)
|
9
|
+
v = result
|
10
|
+
else
|
11
|
+
v = [result]
|
12
|
+
end
|
13
|
+
return handle_attributes(v, vars)
|
8
14
|
end
|
9
15
|
|
10
16
|
end
|
data/lib/copper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c66-copper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khash Sajadi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|