evt-transform 0.1.2.0 → 0.1.3.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
- SHA1:
3
- metadata.gz: 189c3684a2419199b1d142b6eeb53ea0aa66a3bb
4
- data.tar.gz: c745f1f2993c8774ba118cede313e3d96e27de5a
2
+ SHA256:
3
+ metadata.gz: 8dfc383c07eccd30d0da3059af8ace4292e879e967506b496b877df82a150c16
4
+ data.tar.gz: 931175ac1c40ccc04218f928a01fd915913c7d32a365173f592a0a9a2d923168
5
5
  SHA512:
6
- metadata.gz: efab3be2495b5370f86fa62091e5fc9c88aab46567b6e17cf7a32b4c19b7e90f3fdbb82856ab4ff94fd7dd12d8b7a2ec4ec6752d3ce2f2ded96aa7baed610583
7
- data.tar.gz: c6ea87881964a40fc07fb3bcba29d81b6a55584147689c31458e8d3e1267d05abf55ec2394c032091081acf89a03b70e61f319cbf635d3da8ae6f8dc14db798c
6
+ metadata.gz: b3ab2ded9cb2d24e4127510e14d37bcd057eb74162a4aa39dd02b501fbe8093837d861ada503bdd6057065b53fd7223d62df27bc85b9be402c14c4a936218230
7
+ data.tar.gz: 39b6cfc738ce60cf2679669ed8b56f505235645abcb1af10ab29f367a42d71142c79857482fba02c43b2b5fc179993f539902ff74c965d9007bb5f5ade334240
@@ -1,8 +1,10 @@
1
1
  require 'transform/controls/text'
2
2
  require 'transform/controls/raw_data'
3
3
  require 'transform/controls/subject'
4
- require 'transform/controls/subject_instance_receives_class'
5
- require 'transform/controls/no_transform'
4
+ require 'transform/controls/subject/instance_receives_class'
5
+ require 'transform/controls/subject/transform'
6
+ require 'transform/controls/subject/transformer'
7
+ require 'transform/controls/no_transformer'
6
8
  require 'transform/controls/no_transform_methods'
7
9
  require 'transform/controls/no_format'
8
10
  require 'transform/controls/no_format_methods'
@@ -0,0 +1,51 @@
1
+ module Transform
2
+ module Controls
3
+ module Subject
4
+ module Transform
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
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
+ module SomeFormat
38
+ def self.write(raw_data)
39
+ Controls::Text.example
40
+ end
41
+
42
+ def self.read(text)
43
+ Controls::RawData.example
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ module Transform
2
+ module Controls
3
+ module Subject
4
+ Transformer = Subject
5
+ end
6
+ end
7
+ end
@@ -22,7 +22,11 @@ module Transform
22
22
  end
23
23
 
24
24
  def get_transformer(subject_const)
25
- subject_const.const_get(:Transformer)
25
+ if transformer_const?(subject_const)
26
+ return subject_const.const_get(:Transformer)
27
+ elsif transform_const?(subject_const)
28
+ return subject_const.const_get(:Transform)
29
+ end
26
30
  end
27
31
 
28
32
  def subject_const(subject)
@@ -30,9 +34,9 @@ module Transform
30
34
  end
31
35
 
32
36
  def assure_transformer(subject_const)
33
- unless transformer_const?(subject_const)
34
- raise Error, "#{subject_const.name} doesn't have a `Transformer' namespace"
35
- end
37
+ return if transform_const?(subject_const) || transformer_const?(subject_const)
38
+
39
+ raise Error, "#{subject_const.name} doesn't have a `Transformer' or 'Transform' namespace"
36
40
  end
37
41
 
38
42
  def transformer?(subject)
@@ -41,7 +45,11 @@ module Transform
41
45
  end
42
46
 
43
47
  def transformer_const?(subject_const)
44
- subject_const.const_defined?(:Transformer)
48
+ subject_const.constants.any?{ |c| c.to_sym == :Transformer }
49
+ end
50
+
51
+ def transform_const?(subject_const)
52
+ subject_const.constants.any?{ |c| c.to_sym == :Transform }
45
53
  end
46
54
 
47
55
  def assure_format(format_name, transformer)
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.1.2.0
4
+ version: 0.1.3.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: 2017-06-29 00:00:00.000000000 Z
11
+ date: 2018-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-log
@@ -48,11 +48,13 @@ files:
48
48
  - lib/transform/controls.rb
49
49
  - lib/transform/controls/no_format.rb
50
50
  - lib/transform/controls/no_format_methods.rb
51
- - lib/transform/controls/no_transform.rb
52
51
  - lib/transform/controls/no_transform_methods.rb
52
+ - lib/transform/controls/no_transformer.rb
53
53
  - lib/transform/controls/raw_data.rb
54
54
  - lib/transform/controls/subject.rb
55
- - lib/transform/controls/subject_instance_receives_class.rb
55
+ - lib/transform/controls/subject/instance_receives_class.rb
56
+ - lib/transform/controls/subject/transform.rb
57
+ - lib/transform/controls/subject/transformer.rb
56
58
  - lib/transform/controls/text.rb
57
59
  - lib/transform/copy.rb
58
60
  - lib/transform/log.rb
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
81
  version: '0'
80
82
  requirements: []
81
83
  rubyforge_project:
82
- rubygems_version: 2.6.11
84
+ rubygems_version: 2.7.3
83
85
  signing_key:
84
86
  specification_version: 4
85
87
  summary: Common interface for object and format transformation, and transformer discovery