prismic.io 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e41dc7a4fb85a94a4ac56034a5565b068af27b5a8ac4e15fc4b77f7ca52b025e
4
- data.tar.gz: ee57f1d28b9050b0adb564de62b81149f6178cd38dca1e0bc4d07864b8765604
3
+ metadata.gz: 1f892385baa9ad4441d83552d88db0f1633aa97288324008e2e22dfd191b95b8
4
+ data.tar.gz: 74b6efa38bcb4c81be35a39af3ce6ae40448668babc2d1070724e47efdc09226
5
5
  SHA512:
6
- metadata.gz: 27ed02ec87bd731bec6a2df07eaf010013a23c3b971743dab0fc395113c23bfde6fca4858899e1c1027ceeec01938aa1a87dc6ae0de1b4a1d76e7c3c221af132
7
- data.tar.gz: 33e9de0fc144c00fd0851dbe8780fcc1487106480cab49458848eba6e5218026b0eec882995f68150a1600d83d30940927a76e79900387253eaf9d6f3df8ba20
6
+ metadata.gz: 74bc269db0e3c96f088196b27f506f9c73109507a857e1e81e7754cddd8721425e98834df7517cd10577e539b496bfad9ff5ead09a39134fd1172c0aecd1cbab
7
+ data.tar.gz: 2cb1ad33ac5befb98b6f31d674d2753f83c2992581616b9c8360f230973e44cf14e4e02023e42ff779587f10a6b587ca6f87e00f2408cabe0c9ee44bd41acad4
@@ -1,12 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-head
3
+ #- ruby-head
4
4
  - 2.6.3
5
5
  - 2.5.5
6
6
  - 2.4.6
7
7
  - jruby-head
8
8
  - jruby-9.1.9.0
9
- - jruby-1.7.26
9
+ #- jruby-1.7.26
10
10
 
11
11
  sudo: false
12
12
  cache: bundler
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prismic.io (1.6.2)
4
+ prismic.io (1.7.0)
5
5
  hashery (~> 2.1.1)
6
6
 
7
7
  GEM
@@ -46,4 +46,4 @@ DEPENDENCIES
46
46
  yajl-ruby
47
47
 
48
48
  BUNDLED WITH
49
- 1.16.0
49
+ 1.17.2
@@ -16,3 +16,4 @@ require 'prismic/fragments/timestamp'
16
16
  require 'prismic/fragments/slices'
17
17
  require 'prismic/fragments/separator'
18
18
  require 'prismic/fragments/integration_field'
19
+ require 'prismic/fragments/boolean_field'
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ module Prismic
3
+ module Fragments
4
+ class BooleanField < Fragment
5
+ attr_accessor :value
6
+
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ def as_html(link_resolver=nil)
12
+ if (@value === true)
13
+ %(<input type="checkbox" checked="checked" />)
14
+ else
15
+ %(<input type="checkbox" />)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -26,7 +26,8 @@ module Prismic
26
26
  'Group' => method(:group_parser),
27
27
  'SliceZone' => method(:slices_parser),
28
28
  'Separator' => method(:separator_parser),
29
- 'IntegrationFields' => method(:integration_fields_parser)
29
+ 'IntegrationFields' => method(:integration_fields_parser),
30
+ 'Boolean' => method(:boolean_field_parser)
30
31
  }
31
32
  end
32
33
 
@@ -34,6 +35,10 @@ module Prismic
34
35
  Prismic::Fragments::IntegrationField.new(json['value'])
35
36
  end
36
37
 
38
+ def boolean_field_parser(json)
39
+ Prismic::Fragments::BooleanField.new(json['value'])
40
+ end
41
+
37
42
  def document_link_parser(json)
38
43
  doc = json['value']['document']
39
44
  type = doc['type']
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Prismic
3
3
 
4
- VERSION = '1.7.0'
4
+ VERSION = '1.8.0'
5
5
 
6
6
  end
@@ -156,6 +156,13 @@ module Prismic
156
156
  fragment
157
157
  end
158
158
 
159
+ # @return [Fragments::BooleanField]
160
+ def get_boolean_field(field)
161
+ fragment = self[field]
162
+ return nil unless fragment.is_a? Prismic::Fragments::BooleanField
163
+ fragment
164
+ end
165
+
159
166
  # @return [Array<LinkedDocument>]
160
167
  def linked_documents
161
168
  self.fragments.map { |name, fragment|
@@ -779,3 +779,24 @@ describe 'Composite slice' do
779
779
  @slices.slices[0].repeat[0]['label'].as_text.should == 'Start from Scratch'
780
780
  end
781
781
  end
782
+
783
+ describe 'Boolean Field' do
784
+ it 'get html: true' do
785
+ expected_boolean_field = %[<input type="checkbox" checked="checked" />]
786
+ @booleanfield = Prismic::Fragments::BooleanField::new(true)
787
+ @booleanfield.as_html.should == expected_boolean_field
788
+ end
789
+
790
+ it 'get html: false' do
791
+ expected_boolean_field = %[<input type="checkbox" />]
792
+ @booleanfield = Prismic::Fragments::BooleanField::new(false)
793
+ @booleanfield.as_html.should == expected_boolean_field
794
+ end
795
+
796
+ it 'value' do
797
+ expected_value = true
798
+ @booleanfield = Prismic::Fragments::BooleanField::new(true)
799
+ @booleanfield.value.should == expected_value
800
+ end
801
+
802
+ end
@@ -381,7 +381,7 @@ describe 'document_parser' do
381
381
  end
382
382
 
383
383
  it "correctly parses the document's fragments" do
384
- @document.fragments.size.should == 14
384
+ @document.fragments.size.should == 15
385
385
  @document.fragments['name'].should be_a Prismic::Fragments::StructuredText
386
386
  end
387
387
  end
@@ -495,3 +495,20 @@ describe 'structured_text_label_parser' do
495
495
  end
496
496
 
497
497
  end
498
+
499
+ describe 'boolean_field_parser' do
500
+ before do
501
+ raw_json = <<json
502
+ {
503
+ "type": "Boolean",
504
+ "value": true
505
+ }
506
+ json
507
+ @json = JSON.load(raw_json)
508
+ end
509
+
510
+ it "correctly parses Boolean objects" do
511
+ bool = Prismic::JsonParser.boolean_field_parser(@json)
512
+ bool.value.should == true
513
+ end
514
+ end
@@ -8,6 +8,19 @@ describe 'predicates' do
8
8
  @api = Prismic.api('https://micro.prismic.io/api', nil)
9
9
  @master_ref = @api.master_ref
10
10
  @link_resolver = Prismic.link_resolver('master'){|doc_link| "http://localhost/#{doc_link.id}" }
11
+ @boolean_api = Prismic.api("https://a-bool.prismic.io/api", nil)
12
+ @boolean_api_master_ref = @boolean_api.master_ref
13
+ end
14
+
15
+ describe 'boolean query' do
16
+ it "can query a boolean field with value true" do
17
+ form = @boolean_api.form('everything').query(['at', 'my.bools.set_to_true', true])
18
+ form.data['q'].should == ['[[:d = at(my.bools.set_to_true, true)]]']
19
+ end
20
+ it "can query a boolean field with value false" do
21
+ form = @boolean_api.form('everything').query(['at', 'my.bools.set_to_true', false])
22
+ form.data['q'].should == ['[[:d = at(my.bools.set_to_true, false)]]']
23
+ end
11
24
  end
12
25
 
13
26
  describe 'at predicate' do
@@ -36,6 +36,10 @@
36
36
  }
37
37
  ]
38
38
  },
39
+ "checkbox": {
40
+ "type": "Boolean",
41
+ "value": true
42
+ },
39
43
  "short_lede": {
40
44
  "type": "StructuredText",
41
45
  "value": [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prismic.io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Étienne Vallette d'Osia
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-05-22 00:00:00.000000000 Z
14
+ date: 2020-07-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -187,6 +187,7 @@ files:
187
187
  - lib/prismic/experiments.rb
188
188
  - lib/prismic/form.rb
189
189
  - lib/prismic/fragments.rb
190
+ - lib/prismic/fragments/boolean_field.rb
190
191
  - lib/prismic/fragments/color.rb
191
192
  - lib/prismic/fragments/date.rb
192
193
  - lib/prismic/fragments/embed.rb
@@ -252,8 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
253
  - !ruby/object:Gem::Version
253
254
  version: '0'
254
255
  requirements: []
255
- rubyforge_project:
256
- rubygems_version: 2.7.7
256
+ rubygems_version: 3.1.2
257
257
  signing_key:
258
258
  specification_version: 4
259
259
  summary: Prismic.io development kit