yaml_b_sides 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/yaml_b_sides.rb +6 -0
- data/lib/yaml_b_sides/base.rb +6 -1
- data/lib/yaml_b_sides/cacheable.rb +1 -1
- data/lib/yaml_b_sides/indexable.rb +2 -2
- data/lib/yaml_b_sides/queriable.rb +4 -4
- data/lib/yaml_b_sides/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45adeca9c08395b043daad3db4e33e0b94795901
|
4
|
+
data.tar.gz: 1086182181619ef1eca880e287f36f304a60fc7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a735ae884e248753f0a3db63c9e25632d094ba46694c0dcbbaf6d9ef810ad20b1d2c68800b9369bc671bac8cc8e8828dd9e8935791a33bf26d97cdf26bc844ff
|
7
|
+
data.tar.gz: f369847c980b4af239d1cbdd9c735b07f73da28b64b79d21e49a8bd10596a706c1cad21b60421ef3e00273e1dcae2c2d70b51e3472ea2d4aeaa9a4e8c57117ff
|
data/README.md
CHANGED
@@ -198,6 +198,11 @@ The setup is pretty straightforward. Yaml B-Sides wants a logger and a base dir
|
|
198
198
|
```ruby
|
199
199
|
YamlBSides::Base.logger = Rails.logger
|
200
200
|
YamlBSides::Base.root_path = Rails.root.join 'db', 'fixtures'
|
201
|
+
|
202
|
+
# in development.rb
|
203
|
+
|
204
|
+
# eanble reload of the data files to avoid having to restart the server for every change
|
205
|
+
YamlBSides.live_reload = true
|
201
206
|
```
|
202
207
|
|
203
208
|
## Development
|
data/lib/yaml_b_sides.rb
CHANGED
@@ -18,4 +18,10 @@ module YamlBSides
|
|
18
18
|
autoload :Indexable, 'yaml_b_sides/indexable'
|
19
19
|
autoload :Propertiable, 'yaml_b_sides/propertiable'
|
20
20
|
autoload :Queriable, 'yaml_b_sides/queriable'
|
21
|
+
|
22
|
+
class << self
|
23
|
+
attr_accessor :live_reload
|
24
|
+
end
|
25
|
+
|
26
|
+
self.live_reload = false
|
21
27
|
end
|
data/lib/yaml_b_sides/base.rb
CHANGED
@@ -18,7 +18,7 @@ module YamlBSides
|
|
18
18
|
idify_data!
|
19
19
|
logger.info "#{self} successfully loaded data"
|
20
20
|
# let's preemptively index by id so that when we do a find_by id:, or a where id: it won't table scan
|
21
|
-
index :id
|
21
|
+
index :id unless YamlBSides.live_reload
|
22
22
|
rescue => e
|
23
23
|
logger.error "#{self} failed to load data: #{e}"
|
24
24
|
end
|
@@ -38,6 +38,11 @@ module YamlBSides
|
|
38
38
|
v[:id] = k
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
def data
|
43
|
+
load! if YamlBSides.live_reload
|
44
|
+
@data
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -8,14 +8,14 @@ module YamlBSides
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def index(field)
|
11
|
-
self.__indices = __indices.merge( { field => Index.new(field,
|
11
|
+
self.__indices = __indices.merge( { field => Index.new(field, data) } )
|
12
12
|
end
|
13
13
|
|
14
14
|
def find_in_index(field, values)
|
15
15
|
keys = Array(index_for(field).find(values))
|
16
16
|
|
17
17
|
keys.map do |id|
|
18
|
-
|
18
|
+
data[id]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -5,7 +5,7 @@ module YamlBSides
|
|
5
5
|
included do
|
6
6
|
class << self
|
7
7
|
def find(id)
|
8
|
-
record =
|
8
|
+
record = data[id]
|
9
9
|
raise Errors::RecordNotFound, "#{self}: Record not found: #{id}" unless record
|
10
10
|
new record
|
11
11
|
end
|
@@ -17,13 +17,13 @@ module YamlBSides
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def all
|
20
|
-
|
20
|
+
data.values.map do |obj|
|
21
21
|
new obj
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def first
|
26
|
-
new
|
26
|
+
new data.values.first
|
27
27
|
end
|
28
28
|
|
29
29
|
# TODO: move this into scopes
|
@@ -41,7 +41,7 @@ module YamlBSides
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def find_by_scan(params)
|
44
|
-
|
44
|
+
data.values.select do |datum|
|
45
45
|
params.all? do |param, expected_value|
|
46
46
|
val = Array(expected_value).include? datum[param]
|
47
47
|
end
|
data/lib/yaml_b_sides/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml_b_sides
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Orlov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|