eco-helpers 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/README.md +20 -0
- data/eco-helpers.gemspec +34 -0
- data/lib/eco-helpers.rb +15 -0
- data/lib/eco/api.rb +13 -0
- data/lib/eco/api/common.rb +10 -0
- data/lib/eco/api/common/people.rb +17 -0
- data/lib/eco/api/common/people/base_parser.rb +16 -0
- data/lib/eco/api/common/people/default_parsers.rb +40 -0
- data/lib/eco/api/common/people/default_parsers/boolean_parser.rb +28 -0
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +33 -0
- data/lib/eco/api/common/people/default_parsers/multi_parser.rb +33 -0
- data/lib/eco/api/common/people/default_parsers/numeric_parser.rb +23 -0
- data/lib/eco/api/common/people/default_parsers/select_parser.rb +29 -0
- data/lib/eco/api/common/people/entries.rb +120 -0
- data/lib/eco/api/common/people/person_entry.rb +380 -0
- data/lib/eco/api/common/people/person_factory.rb +114 -0
- data/lib/eco/api/common/people/person_modifier.rb +62 -0
- data/lib/eco/api/common/people/person_parser.rb +140 -0
- data/lib/eco/api/common/people/types.rb +47 -0
- data/lib/eco/api/common/session.rb +15 -0
- data/lib/eco/api/common/session/base_session.rb +46 -0
- data/lib/eco/api/common/session/environment.rb +47 -0
- data/lib/eco/api/common/session/file_manager.rb +90 -0
- data/lib/eco/api/common/session/logger.rb +105 -0
- data/lib/eco/api/common/session/mailer.rb +92 -0
- data/lib/eco/api/common/session/s3_uploader.rb +110 -0
- data/lib/eco/api/common/version_patches.rb +11 -0
- data/lib/eco/api/common/version_patches/external_person.rb +11 -0
- data/lib/eco/api/eco_faker.rb +59 -0
- data/lib/eco/api/organization.rb +13 -0
- data/lib/eco/api/organization/account.rb +23 -0
- data/lib/eco/api/organization/people.rb +118 -0
- data/lib/eco/api/organization/policy_groups.rb +51 -0
- data/lib/eco/api/organization/preferences.rb +28 -0
- data/lib/eco/api/organization/preferences_reference.json +23 -0
- data/lib/eco/api/organization/presets.rb +138 -0
- data/lib/eco/api/organization/presets_backup.rb +220 -0
- data/lib/eco/api/organization/presets_values.json +10 -0
- data/lib/eco/api/organization/tag_tree.rb +134 -0
- data/lib/eco/api/organization_old.rb +73 -0
- data/lib/eco/api/session.rb +180 -0
- data/lib/eco/api/session/batch.rb +132 -0
- data/lib/eco/api/session/batch_job.rb +152 -0
- data/lib/eco/api/session/batch_jobs.rb +131 -0
- data/lib/eco/api/session/batch_status.rb +138 -0
- data/lib/eco/api/session/task.rb +92 -0
- data/lib/eco/api/session_config.rb +179 -0
- data/lib/eco/api/session_config/api.rb +47 -0
- data/lib/eco/api/session_config/apis.rb +78 -0
- data/lib/eco/api/session_config/files.rb +30 -0
- data/lib/eco/api/session_config/logger.rb +54 -0
- data/lib/eco/api/session_config/mailer.rb +65 -0
- data/lib/eco/api/session_config/people.rb +89 -0
- data/lib/eco/api/session_config/s3_bucket.rb +62 -0
- data/lib/eco/api/session_config/use_cases.rb +30 -0
- data/lib/eco/api/usecases.rb +12 -0
- data/lib/eco/api/usecases/base_case.rb +14 -0
- data/lib/eco/api/usecases/case_data.rb +13 -0
- data/lib/eco/api/usecases/default_cases.rb +53 -0
- data/lib/eco/api/usecases/default_cases/change_email_case.rb +47 -0
- data/lib/eco/api/usecases/default_cases/create_details_case.rb +29 -0
- data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +49 -0
- data/lib/eco/api/usecases/default_cases/delete_case.rb +20 -0
- data/lib/eco/api/usecases/default_cases/email_as_id_case.rb +24 -0
- data/lib/eco/api/usecases/default_cases/hris_case.rb +67 -0
- data/lib/eco/api/usecases/default_cases/new_email_case.rb +26 -0
- data/lib/eco/api/usecases/default_cases/new_id_case.rb +26 -0
- data/lib/eco/api/usecases/default_cases/refresh_presets.rb +25 -0
- data/lib/eco/api/usecases/default_cases/reinvite_case.rb +22 -0
- data/lib/eco/api/usecases/default_cases/remove_account_case.rb +36 -0
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +24 -0
- data/lib/eco/api/usecases/default_cases/set_default_tag_case.rb +44 -0
- data/lib/eco/api/usecases/default_cases/set_supervisor_case.rb +39 -0
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +36 -0
- data/lib/eco/api/usecases/default_cases/update_details_case.rb +30 -0
- data/lib/eco/api/usecases/default_cases/upsert_account_case.rb +35 -0
- data/lib/eco/api/usecases/use_case.rb +177 -0
- data/lib/eco/api/usecases/use_group.rb +104 -0
- data/lib/eco/cli.rb +9 -0
- data/lib/eco/cli/input.rb +109 -0
- data/lib/eco/cli/input_multi.rb +137 -0
- data/lib/eco/cli/root.rb +8 -0
- data/lib/eco/cli/session.rb +9 -0
- data/lib/eco/cli/session/batch.rb +9 -0
- data/lib/eco/common.rb +7 -0
- data/lib/eco/common/base_cli.rb +116 -0
- data/lib/eco/common/language.rb +9 -0
- data/lib/eco/data.rb +9 -0
- data/lib/eco/data/crypto.rb +7 -0
- data/lib/eco/data/crypto/encryption.rb +318 -0
- data/lib/eco/data/files.rb +10 -0
- data/lib/eco/data/files/directory.rb +93 -0
- data/lib/eco/data/files/file_pattern.rb +32 -0
- data/lib/eco/data/files/helpers.rb +90 -0
- data/lib/eco/data/mapper.rb +54 -0
- data/lib/eco/data/random.rb +10 -0
- data/lib/eco/data/random/distribution.rb +133 -0
- data/lib/eco/data/random/fake.rb +320 -0
- data/lib/eco/data/random/values.rb +80 -0
- data/lib/eco/language.rb +12 -0
- data/lib/eco/language/curry.rb +28 -0
- data/lib/eco/language/hash_transform.rb +68 -0
- data/lib/eco/language/hash_transform_modifier.rb +114 -0
- data/lib/eco/language/match.rb +30 -0
- data/lib/eco/language/match_modifier.rb +190 -0
- data/lib/eco/language/models.rb +11 -0
- data/lib/eco/language/models/attribute_parser.rb +38 -0
- data/lib/eco/language/models/collection.rb +181 -0
- data/lib/eco/language/models/modifier.rb +68 -0
- data/lib/eco/language/models/wrap.rb +114 -0
- data/lib/eco/language/values_at.rb +159 -0
- data/lib/eco/lexic/dictionary.rb +33 -0
- data/lib/eco/lexic/dictionary/dictionary.txt +355484 -0
- data/lib/eco/lexic/dictionary/tags.json +38 -0
- data/lib/eco/scripting.rb +30 -0
- data/lib/eco/scripting/README.md +11 -0
- data/lib/eco/scripting/arguments.rb +40 -0
- data/lib/eco/tester.rb +97 -0
- data/lib/eco/version.rb +3 -0
- metadata +325 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Eco
|
4
|
+
module Data
|
5
|
+
module Random
|
6
|
+
class Values
|
7
|
+
|
8
|
+
attr_accessor :multiple, :unique
|
9
|
+
attr_reader :options, :weights, :options_weight, :quantity
|
10
|
+
attr_reader :generator, :generator_config
|
11
|
+
|
12
|
+
def initialize(init = {})
|
13
|
+
@multiple = init.fetch('multiple', false)
|
14
|
+
@unique = init.fetch('unique', true)
|
15
|
+
self.quantity = init.fetch('quantity', nil)
|
16
|
+
@options_weight = init.fetch('options_weight', nil)
|
17
|
+
@options = init.fetch('options', @options_weight&.keys)
|
18
|
+
@weights = @options_weight&.values
|
19
|
+
|
20
|
+
@generator_config = init.fetch('generator_config', { "decimals" => 0 })
|
21
|
+
if @weights
|
22
|
+
@generator_config['weights'] = @weights unless @generator_config.key?('weights')
|
23
|
+
@generator_config['balance'] = 'forged' unless @generator_config.key?('balance')
|
24
|
+
else
|
25
|
+
case
|
26
|
+
when @options&.instance_of?(Array)
|
27
|
+
@generator_config['weights'] = @weights unless @generator_config.key?('weights')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
@generator = Distribution.new(@generator_config)
|
31
|
+
@random = ::Random.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def quantity=(num_or_range) # attr_writer
|
35
|
+
val = num_or_range
|
36
|
+
case
|
37
|
+
when val.is_a?(Numeric)
|
38
|
+
num = val.round
|
39
|
+
rng = (num..num)
|
40
|
+
when val.instance_of?(Range)
|
41
|
+
rng = val
|
42
|
+
else
|
43
|
+
rng = (0..1)
|
44
|
+
end
|
45
|
+
@quantity = rng
|
46
|
+
end
|
47
|
+
|
48
|
+
def generate
|
49
|
+
if @multiple
|
50
|
+
quantity = @random.rand(@quantity)
|
51
|
+
value = []
|
52
|
+
quantity.times {
|
53
|
+
val = @unique? generate_option(exclude: value): generate_option
|
54
|
+
value.push(val)
|
55
|
+
}
|
56
|
+
value = value.uniq if @unique
|
57
|
+
else
|
58
|
+
value = generate_option
|
59
|
+
end
|
60
|
+
return value
|
61
|
+
end
|
62
|
+
|
63
|
+
def generate_option(exclude: [])
|
64
|
+
case
|
65
|
+
when @options&.instance_of?(Array)
|
66
|
+
val = @options[@generator.generate]
|
67
|
+
else
|
68
|
+
puts "something bad with @options"
|
69
|
+
end
|
70
|
+
#exclude_aux = Marshal.load(Marshal::dump(exclude))
|
71
|
+
exclude_aux = JSON.parse(exclude.to_json)
|
72
|
+
exclude_aux.pop
|
73
|
+
val = generate_option(exclude: exclude_aux) if exclude.include?(val)
|
74
|
+
return val
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/eco/language.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require_relative 'language/models'
|
7
|
+
require_relative 'language/curry'
|
8
|
+
require_relative 'language/hash_transform_modifier'
|
9
|
+
require_relative 'language/hash_transform'
|
10
|
+
require_relative 'language/values_at'
|
11
|
+
require_relative 'language/match_modifier'
|
12
|
+
require_relative 'language/match'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
|
4
|
+
def required_parameters(method)
|
5
|
+
method.parameters.select { |type, _| type == :req || :keyreq}
|
6
|
+
end
|
7
|
+
|
8
|
+
def required_parameters?(method)
|
9
|
+
required_parameters(method).length > 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def curry(method)
|
13
|
+
-> (*args, **kargs) {
|
14
|
+
required = method.parameters.select { |type, _| type == :req }
|
15
|
+
krequired = method.parameters.select { |type, _| type == :keyreq }
|
16
|
+
all_args = (required.length <= args.length)
|
17
|
+
all_keys = krequired.all? { |_, name| kargs.has_key?(name) }
|
18
|
+
if all_args && all_keys
|
19
|
+
final_args = (args + kargs.map {|k,v| {k => v} })
|
20
|
+
method.call(*final_args)
|
21
|
+
else
|
22
|
+
-> (*args_, **kargs_) { curry(method)[*args, *args_, **kargs, **kargs_] }
|
23
|
+
end
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
|
4
|
+
def sym_str_transform(value, mode = HashTransformModifier.new)
|
5
|
+
v = value
|
6
|
+
if value && (value.is_a?(Symbol) || value.is_a?(String))
|
7
|
+
if mode.symbolize? && !value.is_a?(Symbol)
|
8
|
+
colon = mode.colon? && !value.include?(" ") && (
|
9
|
+
starts = value.start_with?(":") ||
|
10
|
+
ends = value.end_with?(":")
|
11
|
+
)
|
12
|
+
if !mode.colon? || colon
|
13
|
+
value = value.slice(1, value.length) if colon && starts
|
14
|
+
value = value.slice(0, -1) if colon && ends
|
15
|
+
v = (value.to_sym rescue value) || value
|
16
|
+
end
|
17
|
+
elsif !value.is_a?(String) # stringify
|
18
|
+
v = (value.to_s rescue value) || value
|
19
|
+
v = ":" + v if mode.colon?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
v
|
23
|
+
end
|
24
|
+
|
25
|
+
def hash_transform(hash, mode = HashTransformModifier.new)
|
26
|
+
hash = (mode.clone?) ? Marshal.load(Marshal.dump(hash)) : hash
|
27
|
+
hash.keys.each do |key|
|
28
|
+
value = (mode.keys?) ? hash.delete(key) : hash[key]
|
29
|
+
value = (value.is_a?(Hash) && mode.recurse?) ? hash_transform(value, mode) : value
|
30
|
+
value = sym_str_transform(value, mode) if mode.values?
|
31
|
+
key = sym_str_transform(key, mode) if mode.keys?
|
32
|
+
hash[key] = value
|
33
|
+
end
|
34
|
+
hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def symbolize_keys(hash, mode = HashTransformModifier.new)
|
38
|
+
mode = mode.new.symbolize.keys
|
39
|
+
hash_transform(hash, mode)
|
40
|
+
end
|
41
|
+
|
42
|
+
def stringify_keys(hash, mode = HashTransformModifier.new)
|
43
|
+
mode = mode.new.stringify.keys
|
44
|
+
hash_transform(hash, mode)
|
45
|
+
end
|
46
|
+
|
47
|
+
def symbolize_values(hash, mode = HashTransformModifier.new)
|
48
|
+
mode = mode.new.symbolize.values
|
49
|
+
hash_transform(hash, mode)
|
50
|
+
end
|
51
|
+
|
52
|
+
def stringify_values(hash, mode = HashTransformModifier.new)
|
53
|
+
mode = mode.new.stringify.values
|
54
|
+
hash_transform(hash, mode)
|
55
|
+
end
|
56
|
+
|
57
|
+
def symbolize_hash(hash, mode = HashTransformModifier.new)
|
58
|
+
mode = mode.new.symbolize.keys.values
|
59
|
+
hash_transform(hash, mode)
|
60
|
+
end
|
61
|
+
|
62
|
+
def stringify_hash(hash, mode = HashTransformModifier.new)
|
63
|
+
mode = mode.new.stringify.keys.values
|
64
|
+
hash_transform(hash, mode)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
class HashTransformModifier < Eco::Language::Models::Modifier
|
4
|
+
|
5
|
+
FLAT_MODE = [:flat, :non_recursivre]
|
6
|
+
RECURSIVE_MODE = [:recurse, :deep, :recursive, :r]
|
7
|
+
|
8
|
+
COPY_MODE = [:copy, :clone, :c]
|
9
|
+
BANG_MODE = [:!, :bang]
|
10
|
+
|
11
|
+
COLON_MODE = [:colon, :colon_to_key, :only_colon]
|
12
|
+
ALL_TO_SYM = [:all_to_sym, :all]
|
13
|
+
|
14
|
+
STRINGIFY_MODE = [:stringify, :string, :to_s]
|
15
|
+
SYMBOLIZE_MODE = [:symbolize, :sym, :to_sym]
|
16
|
+
|
17
|
+
KEYS_MODE = [:keys]
|
18
|
+
NO_KEYS_MODE = [:no_keys]
|
19
|
+
|
20
|
+
NO_VALUES_MODE = [:no_values]
|
21
|
+
VALUES_MODE = [:values]
|
22
|
+
|
23
|
+
def reset_recursive
|
24
|
+
self < self.mode - (RECURSIVE_MODE | FLAT_MODE)
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset_bang
|
28
|
+
self < self.mode - (BANG_MODE | COPY_MODE)
|
29
|
+
end
|
30
|
+
|
31
|
+
def reset_colon_mode
|
32
|
+
self < self.mode - (COLON_MODE | ALL_TO_SYM)
|
33
|
+
end
|
34
|
+
|
35
|
+
def recurse
|
36
|
+
self.push(:recurse)
|
37
|
+
end
|
38
|
+
|
39
|
+
def non_recurse
|
40
|
+
self.push(:flat)
|
41
|
+
end
|
42
|
+
|
43
|
+
def copy
|
44
|
+
self.push(:copy)
|
45
|
+
end
|
46
|
+
|
47
|
+
def bang
|
48
|
+
self.push(:bang)
|
49
|
+
end
|
50
|
+
|
51
|
+
def colon
|
52
|
+
self.push(:colon)
|
53
|
+
end
|
54
|
+
|
55
|
+
def all
|
56
|
+
self.push(:all)
|
57
|
+
end
|
58
|
+
|
59
|
+
def symbolize
|
60
|
+
self.push(:symbolize)
|
61
|
+
end
|
62
|
+
|
63
|
+
def stringify
|
64
|
+
self.push(:stringify)
|
65
|
+
end
|
66
|
+
|
67
|
+
def keys
|
68
|
+
self.push(:keys)
|
69
|
+
end
|
70
|
+
|
71
|
+
def values
|
72
|
+
self.push(:values)
|
73
|
+
end
|
74
|
+
|
75
|
+
def recurse?
|
76
|
+
mode.any? { |m| RECURSIVE_MODE.include?(m) }
|
77
|
+
end
|
78
|
+
|
79
|
+
def clone?
|
80
|
+
mode.all? { |m| !BANG_MODE.include?(m) }
|
81
|
+
end
|
82
|
+
|
83
|
+
def colon?
|
84
|
+
mode.any? { |m| COLON_MODE.include?(m) }
|
85
|
+
end
|
86
|
+
|
87
|
+
def symbolize?
|
88
|
+
mode.any? { |m| SYMBOLIZE_MODE.include?(m) }
|
89
|
+
end
|
90
|
+
|
91
|
+
def keys?
|
92
|
+
mode.any? { |m| KEYS_MODE.include?(m) }
|
93
|
+
end
|
94
|
+
|
95
|
+
def values?
|
96
|
+
mode.any? { |m| VALUES_MODE.include?(m) }
|
97
|
+
end
|
98
|
+
|
99
|
+
protected
|
100
|
+
|
101
|
+
def resolve_mode
|
102
|
+
modifiers = self.to_a
|
103
|
+
modifiers = resolve(modifiers, RECURSIVE_MODE | FLAT_MODE)
|
104
|
+
modifiers = resolve(modifiers, BANG_MODE | COPY_MODE)
|
105
|
+
modifiers = resolve(modifiers, COLON_MODE | ALL_TO_SYM)
|
106
|
+
modifiers = resolve(modifiers, STRINGIFY_MODE | SYMBOLIZE_MODE)
|
107
|
+
modifiers = resolve(modifiers, KEYS_MODE | NO_KEYS_MODE)
|
108
|
+
modifiers = resolve(modifiers, VALUES_MODE | NO_VALUES_MODE)
|
109
|
+
modifiers
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
def match?(value, at, mode = MatchModifier.new)
|
4
|
+
out_match = ->(v) { match?(v, at, mode) }
|
5
|
+
in_match = ->(a) { match?(value, a, mode) }
|
6
|
+
|
7
|
+
case
|
8
|
+
when mode.reverse?
|
9
|
+
return match?(at , value, mode.new.reset_reverse)
|
10
|
+
when mode.pattern?
|
11
|
+
at = mode.to_regex(at)
|
12
|
+
return match?(value, at, mode.new.reset_pattern)
|
13
|
+
when value.is_a?(Array)
|
14
|
+
return value.any?(&out_match) if mode.any?
|
15
|
+
return value.all?(&out_match) # defaults to EVERY
|
16
|
+
when at.is_a?(Array)
|
17
|
+
return at.all?(&in_match) if mode.and?
|
18
|
+
return at.any?(&in_match) # defaullts to OR
|
19
|
+
when at.is_a?(Regexp)
|
20
|
+
return at.match?(value)
|
21
|
+
when value.is_a?(Regexp)
|
22
|
+
return value.match?(at)
|
23
|
+
else # final compare
|
24
|
+
m = (value == at) ||
|
25
|
+
(mode.insensitive? && at&.downcase == value&.downcase)
|
26
|
+
(mode.not?) ? !m : m
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module Eco
|
2
|
+
module Language
|
3
|
+
class MatchModifier < Eco::Language::Models::Modifier
|
4
|
+
|
5
|
+
VALUE_MODE = [ :value, :is, ]
|
6
|
+
PATTERN_MODE = [ :pattern, :contains, :regexp ]
|
7
|
+
|
8
|
+
REVERSE_MODE = [ :reverse, :at_to_value, :<< ]
|
9
|
+
NON_REVERSE_MODE = [ :normal, :value_to_at, :non_reverse, :>> ]
|
10
|
+
|
11
|
+
ALL_MODE = [ :all, :every ]
|
12
|
+
ANY_MODE = [ :any, :some ]
|
13
|
+
|
14
|
+
AND_MODE = [ :AND, :and, :&, :intersection, :intersect ]
|
15
|
+
OR_MODE = [ :OR, :or, :|, :union ]
|
16
|
+
|
17
|
+
CASE_MODE = [ :c, :case_sensitive, :case, :sensitive ]
|
18
|
+
INCASE_MODE = [ :i, :case_insensitive, :insensitive ]
|
19
|
+
|
20
|
+
YES_MODE = [ :==, :YES, :yes, :true, :include, :eq ]
|
21
|
+
NOT_MODE = [ :!, :NOT, :not, :false, :exclude, :diff ]
|
22
|
+
|
23
|
+
def to_regex(value)
|
24
|
+
case
|
25
|
+
when value.is_a?(Array)
|
26
|
+
return value.map { |v| self.to_regex(v) }
|
27
|
+
when value.is_a?(Regexp)
|
28
|
+
return value
|
29
|
+
when value.is_a?(String)
|
30
|
+
esub = Regexp.escape(value)
|
31
|
+
if self.insensitive?
|
32
|
+
return /#{esub}/i
|
33
|
+
else
|
34
|
+
return /#{esub}/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset_pattern
|
40
|
+
self < self.mode - (PATTERN_MODE | VALUE_MODE)
|
41
|
+
end
|
42
|
+
|
43
|
+
def reset_reverse
|
44
|
+
self < self.mode - (REVERSE_MODE | NON_REVERSE_MODE)
|
45
|
+
end
|
46
|
+
|
47
|
+
def reset_every
|
48
|
+
self < self.mode - (ALL_MODE | ANY_MODE)
|
49
|
+
end
|
50
|
+
|
51
|
+
def reset_and
|
52
|
+
self < self.mode - (AND_MODE | OR_MODE)
|
53
|
+
end
|
54
|
+
|
55
|
+
def reset_case
|
56
|
+
self < self.mode - (INCASE_MODE | CASE_MODE)
|
57
|
+
end
|
58
|
+
|
59
|
+
def reset_not
|
60
|
+
self < self.mode - (NOT_MODE | YES_MODE)
|
61
|
+
end
|
62
|
+
|
63
|
+
def pattern
|
64
|
+
self.push(:pattern)
|
65
|
+
end
|
66
|
+
|
67
|
+
def value
|
68
|
+
self.push(:value)
|
69
|
+
end
|
70
|
+
|
71
|
+
def reverse
|
72
|
+
self.push(:reverse)
|
73
|
+
end
|
74
|
+
|
75
|
+
def normal
|
76
|
+
self.push(:normal)
|
77
|
+
end
|
78
|
+
|
79
|
+
def every
|
80
|
+
self.push(:every)
|
81
|
+
end
|
82
|
+
|
83
|
+
def all
|
84
|
+
every
|
85
|
+
end
|
86
|
+
|
87
|
+
def some
|
88
|
+
self.push(:some)
|
89
|
+
end
|
90
|
+
|
91
|
+
def any
|
92
|
+
some
|
93
|
+
end
|
94
|
+
|
95
|
+
def and
|
96
|
+
self.push(:and)
|
97
|
+
end
|
98
|
+
|
99
|
+
def or
|
100
|
+
self.push(:or)
|
101
|
+
end
|
102
|
+
|
103
|
+
def case
|
104
|
+
self.push(:sensitive)
|
105
|
+
end
|
106
|
+
|
107
|
+
def insensitive
|
108
|
+
self.push(:insensitive)
|
109
|
+
end
|
110
|
+
|
111
|
+
def eq
|
112
|
+
self.push(:eq)
|
113
|
+
end
|
114
|
+
|
115
|
+
def not
|
116
|
+
self.push(:not)
|
117
|
+
end
|
118
|
+
|
119
|
+
def pattern?
|
120
|
+
mode.any? { |m| PATTERN_MODE.include?(m) }
|
121
|
+
end
|
122
|
+
|
123
|
+
def value?
|
124
|
+
mode.any? { |m| VALUE_MODE.include?(m) }
|
125
|
+
end
|
126
|
+
|
127
|
+
def reverse?
|
128
|
+
mode.any? { |m| REVERSE_MODE.include?(m) }
|
129
|
+
end
|
130
|
+
|
131
|
+
def non_reverse?
|
132
|
+
mode.any? { |m| NON_REVERSE_MODE.include?(m) }
|
133
|
+
end
|
134
|
+
|
135
|
+
def any?
|
136
|
+
mode.any? { |m| ANY_MODE.include?(m) }
|
137
|
+
end
|
138
|
+
|
139
|
+
def some?
|
140
|
+
self.any?
|
141
|
+
end
|
142
|
+
|
143
|
+
def all?
|
144
|
+
mode.any? { |m| ALL_MODE.include?(m) }
|
145
|
+
end
|
146
|
+
|
147
|
+
def every?
|
148
|
+
self.all?
|
149
|
+
end
|
150
|
+
|
151
|
+
def and?
|
152
|
+
mode.any? { |m| AND_MODE.include?(m) }
|
153
|
+
end
|
154
|
+
|
155
|
+
def or?
|
156
|
+
mode.any? { |m| OR_MODE.include?(m) }
|
157
|
+
end
|
158
|
+
|
159
|
+
def insensitive?
|
160
|
+
mode.any? { |m| INCASE_MODE.include?(m) }
|
161
|
+
end
|
162
|
+
|
163
|
+
def case_sensitive?
|
164
|
+
mode.any? { |m| CASE_MODE.include?(m) }
|
165
|
+
end
|
166
|
+
|
167
|
+
def not?
|
168
|
+
mode.any? { |m| NOT_MODE.include?(m) }
|
169
|
+
end
|
170
|
+
|
171
|
+
def yes?
|
172
|
+
mode.any? { |m| YES_MODE.include?(m) }
|
173
|
+
end
|
174
|
+
|
175
|
+
protected
|
176
|
+
|
177
|
+
def resolve_mode
|
178
|
+
modifiers = self.to_a
|
179
|
+
modifiers = resolve(modifiers, PATTERN_MODE | VALUE_MODE)
|
180
|
+
modifiers = resolve(modifiers, REVERSE_MODE | NON_REVERSE_MODE)
|
181
|
+
modifiers = resolve(modifiers, ALL_MODE | ANY_MODE)
|
182
|
+
modifiers = resolve(modifiers, AND_MODE | OR_MODE)
|
183
|
+
modifiers = resolve(modifiers, INCASE_MODE | CASE_MODE)
|
184
|
+
modifiers = resolve(modifiers, NOT_MODE | YES_MODE)
|
185
|
+
modifiers
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|