beret 0.3.0 → 0.4.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 +21 -5
- data/lib/beret/block.rb +4 -0
- data/lib/beret/block_set.rb +1 -1
- data/lib/beret/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: 1273b083d974c464f726e6510178f8eaeddcf1cc
|
4
|
+
data.tar.gz: f35313f862feeaa8f5e1cffa5a034c8cc419a854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399c3832571dd080b208d3fcdf610dbfbe530e5d089ad33a35580707cb0ff6bb1fb66e2778c1dbde0135e4fc17ecc74c161b4cbbb5cf70a726b99416a19d789f
|
7
|
+
data.tar.gz: 55eca025ae4b0bc64034eebec3be716b30b18dd9718100fd90792321656c98e682d0a61a8c664c9af9c57bf57e77d399dc79c46e61aa159ce45a1d2cc99cd40b
|
data/README.md
CHANGED
@@ -31,17 +31,33 @@ ck_json = "[{\"content\":{\"text\":\"This is some text.\"},\"type\":\"redactor\"
|
|
31
31
|
beret = Beret.new(ck_json)
|
32
32
|
|
33
33
|
# Finding values
|
34
|
-
beret.find(:photo_id) # => [<Beret::
|
35
|
-
beret.find(:photo_id, in: [:image]) # => [<Beret::
|
36
|
-
beret.find(:photo_id, in: [:avatar]) # => [<Beret::
|
34
|
+
beret.find(:photo_id) # => [<Beret::SearchResult value="42">, <Beret::SearchResult value="144">]
|
35
|
+
beret.find(:photo_id, in: [:image]) # => [<Beret::SearchResult value="42">]
|
36
|
+
beret.find(:photo_id, in: [:avatar]) # => [<Beret::SearchResult value="144">]
|
37
37
|
beret.find(:photo_id, in: [:some_other_block_type]) # => []
|
38
38
|
|
39
|
+
# Using SearchResult objects
|
40
|
+
result = beret.find(:photo_id).first
|
41
|
+
result.value # => "42"
|
42
|
+
result.field_name # => "photo_id"
|
43
|
+
result.block # => <Beret::Block>
|
44
|
+
result.block.attributes # => { "photo_id" => "42" }
|
45
|
+
result.block.type # => "image"
|
46
|
+
result.block.parent # => <Beret::Block>
|
47
|
+
|
39
48
|
# In-place updating
|
40
|
-
beret.update(:photo_id, in: [:image]) do |value|
|
49
|
+
beret.update(:photo_id, in: [:image]) do |value, block|
|
41
50
|
# Transform the value any way you'd like here.
|
42
51
|
# In this example, we convert a plain old ID to a SGID
|
43
52
|
Image.find(value).to_sgid
|
44
53
|
end
|
45
54
|
|
46
|
-
|
55
|
+
beret.update(:photo_id, in: [:image]) do |value, block|
|
56
|
+
# You can also replace the contents of an entire block with
|
57
|
+
# Beret::Block#update_content
|
58
|
+
image = Image.find(value)
|
59
|
+
block.update_content(image.to_json)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Retrieving JSON (useful for saving or returning the net result of an in-place update)
|
47
63
|
beret.to_json
|
data/lib/beret/block.rb
CHANGED
data/lib/beret/block_set.rb
CHANGED
data/lib/beret/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lawson Kurtz (Viget)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Easily work with Colonel Kurtz-generated JSON data in your Ruby application
|
14
14
|
email:
|