poros 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/poros/version.rb +1 -1
- data/lib/poros.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae72d23c993aa92ac6dddd554b07d75019e914a1e0edc703de4fd6259712a1f3
|
4
|
+
data.tar.gz: 9168cac5343f7c9ca7c49dc8dbc9d5d926b15912e26175b75dc09a235932952a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3136fe7ad7558e3a4c06b30c2a964a35270c1fc6da66c8720eda6e224b74b339d8f1cbfa8a9ba6f47cd081085869e6d75f009fb00ca4a478982ec96ab7698b
|
7
|
+
data.tar.gz: c4635bb7871ea244cd378d06e111f5a509bcd82434f56635bfc8da071b8be2a5816191e96eb8e491d3cd9580441b4c28953fa0d24b86fc46acf774c49fa00f1b
|
data/.gitignore
CHANGED
data/lib/poros/version.rb
CHANGED
data/lib/poros.rb
CHANGED
@@ -112,6 +112,12 @@ module Poros
|
|
112
112
|
index_data[key].keys.flat_map { |value_name|
|
113
113
|
index_data[key][value_name] if value =~ value_name
|
114
114
|
}.compact
|
115
|
+
when Array
|
116
|
+
value.flat_map { |value_name| index_data[key][value_name] }
|
117
|
+
when Proc
|
118
|
+
index_data[key].keys.flat_map { |value_name|
|
119
|
+
index_data[key][value_name] if value.call(value_name)
|
120
|
+
}.compact
|
115
121
|
else
|
116
122
|
index_data[key].has_key?(value) ?
|
117
123
|
index_data[key][value] : []
|
@@ -120,11 +126,16 @@ module Poros
|
|
120
126
|
|
121
127
|
if table_scan.size > 0
|
122
128
|
scanned_results = Dir.glob(File.join(data_directory, '*.yml')).map { |file|
|
129
|
+
next if file == index_file
|
123
130
|
data = YAML.load(File.read(file))
|
124
131
|
data[:uuid] if table_scan.all? { |key, value|
|
125
132
|
case value
|
126
133
|
when Regexp
|
127
134
|
value =~ data[key]
|
135
|
+
when Array
|
136
|
+
value.include?(data[key])
|
137
|
+
when Proc
|
138
|
+
value.call(data[key])
|
128
139
|
else
|
129
140
|
data[key] == value
|
130
141
|
end
|
@@ -187,6 +198,15 @@ module Poros
|
|
187
198
|
write_index_data if !@in_transaction && perist
|
188
199
|
end
|
189
200
|
|
201
|
+
def rebuild_indexes
|
202
|
+
transaction do
|
203
|
+
@data_changed = true
|
204
|
+
@index_data = {}
|
205
|
+
File.delete(index_file) if File.exist?(index_file)
|
206
|
+
all.each { |object| update_index(object) }
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
190
210
|
def transaction(&block)
|
191
211
|
@in_transaction = true
|
192
212
|
@data_changed = false
|