evt-transform 0.2.0.1 → 0.2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87309f4dedeadf10b24f0305dbd1ac325784437efa435847b6aeefcd9e704ba6
4
- data.tar.gz: dc7de644c23da63874398015adb181b6128a48f8e92c768dadab0a4be4e88d22
3
+ metadata.gz: 04bb5b7453e2e35521af286e26af946bb50266c530a4bfea6fc680e40f11c181
4
+ data.tar.gz: 4020bd4d9fa847de9288f06ff088c002a788771ec58cd04619430f21c25fc868
5
5
  SHA512:
6
- metadata.gz: 9da7d930c8c4e1874e96f94563c52c4945d10d76e2b5d01cd3aa628d018818755777234fcd9494b2fcbda1296a9cb0acc2d69c9567a57880cbc11f1a44793747
7
- data.tar.gz: 7fa33be25b31855abfba399b0e3ffcfc6ef338ae07e5607ed7b9d9c86d7b32f31bc2390955a5338e5a64ed277a5c90941c80929f9cc11a1ac0a541ea05d5a46d
6
+ metadata.gz: f71f4c15a0eb7ab795a13d872d2d23e68f732ba428320b2699fb2efebb24f3c5a192545528468f8327ca748ad3afb79501199461d490ca0e43c9be4297a31167
7
+ data.tar.gz: b7f20bdc336378a3a99f52c1b27da66aed1af55a1533e5e7a399ed6edeb5f80022a9ce18acb2d667816869674dddcf43332a5db2b2f4353c5f263a017afd4087
@@ -3,6 +3,7 @@ require 'transform/controls/raw_data'
3
3
  require 'transform/controls/subject/instance_receives_class'
4
4
  require 'transform/controls/subject/transform'
5
5
  require 'transform/controls/subject/transformer'
6
+ require 'transform/controls/subject/object_formatter'
6
7
  require 'transform/controls/subject'
7
8
  require 'transform/controls/no_transformer'
8
9
  require 'transform/controls/no_transform_methods'
@@ -0,0 +1,51 @@
1
+ module Transform
2
+ module Controls
3
+ module Subject
4
+ module ObjectFormatter
5
+ def self.example
6
+ instance = example_class.new
7
+ instance.some_attribute = Controls::RawData.example
8
+ instance
9
+ end
10
+
11
+ def self.example_class
12
+ Example
13
+ end
14
+
15
+ class Example
16
+ attr_accessor :some_attribute
17
+
18
+ def ==(other)
19
+ other.some_attribute == self.some_attribute
20
+ end
21
+
22
+ module Transform
23
+ def self.some_format
24
+ SomeFormat.new
25
+ end
26
+
27
+ def self.instance(raw_data)
28
+ instance = Example.new
29
+ instance.some_attribute = raw_data
30
+ instance
31
+ end
32
+
33
+ def self.raw_data(instance)
34
+ instance.some_attribute
35
+ end
36
+
37
+ class SomeFormat
38
+ def write(raw_data)
39
+ Controls::Text.example
40
+ end
41
+
42
+ def read(text)
43
+ Controls::RawData.example
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -8,7 +8,7 @@ module Transform
8
8
 
9
9
  transformer_reflection = transformer_reflection(cls)
10
10
 
11
- format_reflection = transformer_reflection.get(format_name)
11
+ format_reflection = transformer_reflection.get(format_name, coerce_constant: false)
12
12
 
13
13
  raw_data = format_reflection.(:read, input)
14
14
 
@@ -28,7 +28,7 @@ module Transform
28
28
  transformer_reflection = transformer_reflection(cls)
29
29
  end
30
30
 
31
- transformer = transformer_reflection.constant
31
+ transformer = transformer_reflection.target
32
32
 
33
33
  instance = get_instance(transformer, raw_data, cls)
34
34
 
@@ -4,7 +4,7 @@ module Transform
4
4
  Error = Class.new(RuntimeError)
5
5
 
6
6
  def transformer_reflection(subject)
7
- subject_constant = Reflect.subject_constant(subject)
7
+ subject_constant = Reflect.constant(subject)
8
8
 
9
9
  transformer_name = transformer_name(subject_constant)
10
10
 
@@ -34,7 +34,7 @@ module Transform
34
34
  end
35
35
 
36
36
  def transformer?(subject)
37
- subject_constant = Reflect.subject_constant(subject)
37
+ subject_constant = Reflect.constant(subject)
38
38
  transform_const?(subject_constant) || transformer_const?(subject_constant)
39
39
  end
40
40
  end
@@ -8,7 +8,7 @@ module Transform
8
8
 
9
9
  transformer_reflection = transformer_reflection(input)
10
10
 
11
- format_reflection = transformer_reflection.get(format_name)
11
+ format_reflection = transformer_reflection.get(format_name, coerce_constant: false)
12
12
 
13
13
  raw_data = raw_data(input, transformer_reflection)
14
14
 
@@ -25,7 +25,7 @@ module Transform
25
25
  logger.trace(tags: [:data, :instance]) { instance.pretty_inspect }
26
26
 
27
27
  if transformer_reflection.nil?
28
- subject_constant = Reflect.subject_constant(instance)
28
+ subject_constant = Reflect.constant(instance)
29
29
  transformer_name = transformer_name(subject_constant)
30
30
 
31
31
  if transformer_name.nil?
@@ -35,7 +35,9 @@ module Transform
35
35
  transformer_reflection = Reflect.(instance, transformer_name, strict: true)
36
36
  end
37
37
 
38
- transformer = transformer_reflection.constant
38
+ ## could be the object if not coercing to constant
39
+ ## transformer = transformer_reflection.constant
40
+ transformer = transformer_reflection.target
39
41
  raw_data = get_raw_data(transformer, instance)
40
42
 
41
43
  logger.debug { "Transformed to raw data" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-transform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.1
4
+ version: 0.2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-28 00:00:00.000000000 Z
11
+ date: 2018-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-log
@@ -65,6 +65,7 @@ files:
65
65
  - lib/transform/controls/raw_data.rb
66
66
  - lib/transform/controls/subject.rb
67
67
  - lib/transform/controls/subject/instance_receives_class.rb
68
+ - lib/transform/controls/subject/object_formatter.rb
68
69
  - lib/transform/controls/subject/transform.rb
69
70
  - lib/transform/controls/subject/transformer.rb
70
71
  - lib/transform/controls/text.rb