hollerith 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hollerith/function_runner.rb +4 -4
- data/lib/hollerith/{base_functions.rb → system_functions.rb} +29 -23
- data/lib/hollerith/{argument_decoder.rb → utilities/argument_decoder.rb} +0 -0
- data/lib/hollerith/{value_getter.rb → utilities/value_getter.rb} +10 -5
- data/lib/hollerith.rb +5 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eb9f7b4d84224f78944e3bd09ad18078468dc6503e3771dd6c8e07226e0ed3a
|
4
|
+
data.tar.gz: 0e6f3461c7f1d618e1ec56eeef77c5eeb5844b889556350969b7c8806c08e313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1644214a56d13b14b6a55c8516169b25f92cae4d89112c086d0ae43283944cefc35701a410001873455f81d23b66bb3937b0da40358dc80387087a494928c42
|
7
|
+
data.tar.gz: e22614ffe560113598e579316b5851c7a0ba9462e11ac9b35dbba1bd86f3277ac228658127eaaf918e0ee02d4331a3375c4036e37a2906ba66bb4ca2156ccb1f
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'hollerith/value_getter'
|
2
|
-
require 'hollerith/argument_decoder'
|
3
|
-
require 'hollerith/
|
1
|
+
require 'hollerith/utilities/value_getter'
|
2
|
+
require 'hollerith/utilities/argument_decoder'
|
3
|
+
require 'hollerith/system_functions'
|
4
4
|
|
5
|
-
class Hollerith::FunctionRunner < Hollerith::
|
5
|
+
class Hollerith::FunctionRunner < Hollerith::SystemFunctions
|
6
6
|
attr_reader :user_context_change
|
7
7
|
|
8
8
|
def initialize declaration, main_context, user_context, user_defined_functions
|
@@ -1,28 +1,34 @@
|
|
1
|
-
class Hollerith::
|
1
|
+
class Hollerith::SystemFunctions
|
2
|
+
|
3
|
+
BASE_VALID_FUNCTIONS = %w[
|
4
|
+
for_each
|
5
|
+
set
|
6
|
+
if
|
7
|
+
or
|
8
|
+
and
|
9
|
+
negate
|
10
|
+
count
|
11
|
+
make_external_request
|
12
|
+
custom_function
|
13
|
+
puts
|
14
|
+
concat
|
15
|
+
blank_array
|
16
|
+
array_push
|
17
|
+
array_value
|
18
|
+
eql
|
19
|
+
add
|
20
|
+
subtract
|
21
|
+
multiply
|
22
|
+
divide
|
23
|
+
split
|
24
|
+
].freeze
|
2
25
|
|
3
26
|
def valid_functions
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
and
|
10
|
-
negate
|
11
|
-
count
|
12
|
-
make_external_request
|
13
|
-
custom_function
|
14
|
-
puts
|
15
|
-
concat
|
16
|
-
blank_array
|
17
|
-
array_push
|
18
|
-
array_value
|
19
|
-
eql
|
20
|
-
add
|
21
|
-
subtract
|
22
|
-
multiply
|
23
|
-
divide
|
24
|
-
split
|
25
|
-
)
|
27
|
+
BASE_VALID_FUNCTIONS + custom_system_functions
|
28
|
+
end
|
29
|
+
|
30
|
+
def custom_system_functions
|
31
|
+
[]
|
26
32
|
end
|
27
33
|
|
28
34
|
# Example usage: `%%_for_each($$_planets,%%_custom_function(get_distance_from_sun),each_planet)`
|
File without changes
|
@@ -15,7 +15,7 @@ class Hollerith::ValueGetter
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def get value_to_get
|
18
|
-
if !value_to_get.is_a?
|
18
|
+
if !value_to_get.is_a?(String)
|
19
19
|
return value_to_get
|
20
20
|
elsif value_to_get.downcase == 'true'
|
21
21
|
return true
|
@@ -39,13 +39,15 @@ class Hollerith::ValueGetter
|
|
39
39
|
@user_context_change.deep_merge!(runner.user_context_change || {})
|
40
40
|
|
41
41
|
get(result)
|
42
|
-
elsif
|
42
|
+
elsif value_is_in_quotes?(value_to_get)
|
43
43
|
value_to_get[1..-2]
|
44
44
|
else
|
45
45
|
value_to_get
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
private
|
50
|
+
|
49
51
|
def read_hash_value hash_key
|
50
52
|
split_hash_key = hash_key.split('.')
|
51
53
|
base_hash_key = split_hash_key.shift
|
@@ -69,11 +71,14 @@ class Hollerith::ValueGetter
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
72
|
-
|
73
|
-
# TODO: Add dot notation handling here.
|
74
|
-
# - Read all rails attributes, hash values or instance variables.
|
75
74
|
# FIXME: Variable getting needs to be DRYed up.
|
76
75
|
|
77
76
|
return hash_key_value
|
78
77
|
end
|
78
|
+
|
79
|
+
def value_is_in_quotes? value_to_get
|
80
|
+
value_to_get.is_a?(String) &&
|
81
|
+
(value_to_get.start_with?("'") || value_to_get.start_with?('"')) &&
|
82
|
+
(value_to_get.end_with?("'") || value_to_get.end_with?('"'))
|
83
|
+
end
|
79
84
|
end
|
data/lib/hollerith.rb
CHANGED
@@ -79,7 +79,9 @@ class Hollerith
|
|
79
79
|
if value_to_return
|
80
80
|
return value_to_return
|
81
81
|
else
|
82
|
-
raise ArgumentError.new(
|
82
|
+
raise ArgumentError.new(
|
83
|
+
"Variable not found #{value_to_return} in this context"
|
84
|
+
)
|
83
85
|
end
|
84
86
|
else
|
85
87
|
raise ArgumentError.new("Invalid variable definition #{variable}")
|
@@ -122,6 +124,6 @@ class Hollerith
|
|
122
124
|
end
|
123
125
|
|
124
126
|
require 'hollerith/function_runner'
|
125
|
-
require 'hollerith/value_getter'
|
126
|
-
require 'hollerith/argument_decoder'
|
127
|
+
require 'hollerith/utilities/value_getter'
|
128
|
+
require 'hollerith/utilities/argument_decoder'
|
127
129
|
require 'hollerith/base_functions'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hollerith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Kochanowicz
|
@@ -32,10 +32,10 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- lib/hollerith.rb
|
35
|
-
- lib/hollerith/argument_decoder.rb
|
36
|
-
- lib/hollerith/base_functions.rb
|
37
35
|
- lib/hollerith/function_runner.rb
|
38
|
-
- lib/hollerith/
|
36
|
+
- lib/hollerith/system_functions.rb
|
37
|
+
- lib/hollerith/utilities/argument_decoder.rb
|
38
|
+
- lib/hollerith/utilities/value_getter.rb
|
39
39
|
homepage: https://rubygems.org/gems/hollerith
|
40
40
|
licenses:
|
41
41
|
- MIT
|