exel 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/exel.rb +1 -1
- data/lib/exel/context.rb +0 -14
- data/lib/exel/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +1 -2
- data/lib/exel/old_context.rb +0 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddd9afec5ea8298052cc0ee3aee03dedb9c1e085
|
4
|
+
data.tar.gz: 51c89e0ccad9b2be2dbc8961c52d0c80fad5fe24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c0b0b05b1d5fbd01de78c75e342e7a4beb557d9c4bc70ff5aed5835e50c108e6f3326b6fc095e15375fc38a0872decaa6df63d2f627cbcaa26a6852a12c144
|
7
|
+
data.tar.gz: 3628008c5f8479ef6dab87a5229bc024117b49a3ba668a16e451f1dbdf0b216b323bd8ac80a4154eda090ac0db1c322e805ef6861a07f21c881224577e068979
|
data/lib/exel.rb
CHANGED
@@ -47,5 +47,5 @@ module EXEL
|
|
47
47
|
end
|
48
48
|
|
49
49
|
root = File.expand_path('../..', __FILE__)
|
50
|
-
Dir[File.join(root, 'lib/exel/**/*.rb')].
|
50
|
+
Dir[File.join(root, 'lib/exel/**/*.rb')].each { |file| require file }
|
51
51
|
end
|
data/lib/exel/context.rb
CHANGED
@@ -28,31 +28,17 @@ module EXEL
|
|
28
28
|
# Given a string representing the URI to a serialized context, downloads and returns the deserialized context
|
29
29
|
#
|
30
30
|
# @return [Context]
|
31
|
-
# rubocop:disable Metrics/MethodLength
|
32
31
|
def self.deserialize(uri)
|
33
32
|
file = EXEL::Value.localize(uri)
|
34
33
|
|
35
34
|
begin
|
36
35
|
context = Marshal.load(file.read)
|
37
|
-
rescue
|
38
|
-
# temporarily in place for backwards compatibility
|
39
|
-
|
40
|
-
dir = File.expand_path('..', __FILE__)
|
41
|
-
|
42
|
-
EXEL.send(:remove_const, :Context)
|
43
|
-
load File.join(dir, 'old_context.rb')
|
44
|
-
|
45
|
-
context = Context.deserialize(uri)
|
46
|
-
|
47
|
-
EXEL.send(:remove_const, :Context)
|
48
|
-
load File.join(dir, 'context.rb')
|
49
36
|
ensure
|
50
37
|
file.close
|
51
38
|
end
|
52
39
|
|
53
40
|
context
|
54
41
|
end
|
55
|
-
# rubocop:enable Metrics/MethodLength
|
56
42
|
|
57
43
|
# Returns the value referenced by the given key. If it is a remote value, it will be converted to a local value and
|
58
44
|
# the local value will be returned.
|
data/lib/exel/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ CodeClimate::TestReporter.start
|
|
3
3
|
|
4
4
|
require 'pry'
|
5
5
|
|
6
|
-
Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].
|
6
|
+
Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each { |f| require f }
|
7
7
|
|
8
8
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
9
9
|
# in spec/support/ and its subdirectories.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yroo
|
@@ -208,7 +208,6 @@ files:
|
|
208
208
|
- lib/exel/listen_instruction.rb
|
209
209
|
- lib/exel/logging.rb
|
210
210
|
- lib/exel/null_instruction.rb
|
211
|
-
- lib/exel/old_context.rb
|
212
211
|
- lib/exel/processor_helper.rb
|
213
212
|
- lib/exel/processors/async_processor.rb
|
214
213
|
- lib/exel/processors/run_processor.rb
|
data/lib/exel/old_context.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
|
-
module EXEL
|
4
|
-
# This is here for one version for backwards compatibility with already serialized contexts, which can't
|
5
|
-
# be deserialized with the new +Context+ class
|
6
|
-
class Context
|
7
|
-
# Internal hash of keys/values in the context. Use {#[]} and {#[]=} to get and set values instead of this.
|
8
|
-
attr_reader :table
|
9
|
-
|
10
|
-
# Accepts an optional hash of keys and values to initialize the context with.
|
11
|
-
def initialize(initial_context = {})
|
12
|
-
@table = initial_context
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns a deep copy of this context. The copy and the original will have no shared object references.
|
16
|
-
#
|
17
|
-
# @return [Context]
|
18
|
-
def deep_dup
|
19
|
-
Context.deserialize(serialize)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Serializes this instance to a local file and uses the remote provider to upload it. Returns a URI indicating where
|
23
|
-
# the serialized context can be downloaded.
|
24
|
-
#
|
25
|
-
# @return [String] A URI such as +s3://bucket/file+, +file:///path/to/file+, etc.
|
26
|
-
def serialize
|
27
|
-
EXEL::Value.remotize(serialized_context)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Given a string representing the URI to a serialized context, downloads and returns the deserialized context
|
31
|
-
#
|
32
|
-
# @return [Context]
|
33
|
-
def self.deserialize(uri)
|
34
|
-
file = EXEL::Value.localize(uri)
|
35
|
-
context = Marshal.load(file.read)
|
36
|
-
file.close
|
37
|
-
context
|
38
|
-
end
|
39
|
-
|
40
|
-
def foobar
|
41
|
-
puts 'hi'
|
42
|
-
end
|
43
|
-
|
44
|
-
# Returns the value referenced by the given key
|
45
|
-
def [](key)
|
46
|
-
value = EXEL::Value.localize(@table[key])
|
47
|
-
value = get_deferred(value)
|
48
|
-
@table[key] = value
|
49
|
-
value
|
50
|
-
end
|
51
|
-
|
52
|
-
# Stores the given key/value pair
|
53
|
-
def []=(key, value)
|
54
|
-
@table[key] = value
|
55
|
-
end
|
56
|
-
|
57
|
-
# Adds the given key/value pairs to the context, overriding any keys that are already present.
|
58
|
-
#
|
59
|
-
# @return [Context]
|
60
|
-
def merge!(hash)
|
61
|
-
@table.merge!(hash)
|
62
|
-
self
|
63
|
-
end
|
64
|
-
|
65
|
-
# Removes the value referenced by +key+ from the context
|
66
|
-
def delete(key)
|
67
|
-
@table.delete(key)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Two Contexts are equal if they contain the same key/value pairs
|
71
|
-
def ==(other)
|
72
|
-
other.is_a?(EXEL::Context) && table == other.table
|
73
|
-
end
|
74
|
-
|
75
|
-
# Returns true if this instance contains all of the given key/value pairs
|
76
|
-
def include?(hash)
|
77
|
-
@table.merge(hash) == @table
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def serialized_context
|
83
|
-
file = Tempfile.new(SecureRandom.uuid, encoding: 'ascii-8bit')
|
84
|
-
file.write(Marshal.dump(Context.new(remotized_table)))
|
85
|
-
file.rewind
|
86
|
-
file
|
87
|
-
end
|
88
|
-
|
89
|
-
def remotized_table
|
90
|
-
@table.each_with_object({}) { |(key, value), acc| acc[key] = EXEL::Value.remotize(value) }
|
91
|
-
end
|
92
|
-
|
93
|
-
def get_deferred(value)
|
94
|
-
if deferred?(value)
|
95
|
-
value = value.get(self)
|
96
|
-
elsif value.is_a?(Array)
|
97
|
-
value.map! { |v| get_deferred(v) }
|
98
|
-
elsif value.is_a?(Hash)
|
99
|
-
value.each { |k, v| value[k] = get_deferred(v) }
|
100
|
-
end
|
101
|
-
|
102
|
-
value
|
103
|
-
end
|
104
|
-
|
105
|
-
def deferred?(value)
|
106
|
-
value.is_a?(DeferredContextValue)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|