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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c59a38c72a716fdcb3c7515ac9c5f54d527856e6
4
- data.tar.gz: 1726521089a78f5678090c7dc218cccfd279502d
3
+ metadata.gz: '0442857a59d520bd7fad729cd578fb98593b5a9a'
4
+ data.tar.gz: 5d1db0d767a03f9d1cc5c398bae3509a1db2667e
5
5
  SHA512:
6
- metadata.gz: 774adf64bb740dc8974c354536912394e089144631d83d4636f9688e4bce24ddd8bf6b7f4eae3d6234dc7d31320520e16b2b4b80f9fafcb61717d3e2dd88ffc4
7
- data.tar.gz: 17caf2de157df7ae3c7e6bb6c7dc24b35577bf76c2eba996a4542373532008f11795d0c08532a2430f224b0a8ee32d827cdac502553051a71fe7b99058b8b0b3
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.capitalize
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).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
- raise ::Copper::RuntimeError, "#{value} is not an IP address" unless value.is_a?(::IPAddress)
31
- (@value.first.to_i <= value.to_i) && (@value.last.to_i >= value.to_i)
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
- return handle_attributes(elements[0].value(vars), vars)
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
@@ -1,5 +1,5 @@
1
1
  module Copper
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  COPYRIGHT_MESSAGE = "(c) 2018 Cloud66 Inc."
4
4
  APP_NAME = 'Copper'
5
5
  end
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.2
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-22 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler