prismic.io 1.6.0 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
- data/.travis.yml +18 -20
- data/CONTRIBUTING.md +28 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +27 -27
- data/LICENSE.md +201 -0
- data/README.md +7 -7
- data/gulpfile.js +0 -2
- data/lib/prismic/api.rb +13 -0
- data/lib/prismic/fragments.rb +2 -0
- data/lib/prismic/fragments/boolean_field.rb +21 -0
- data/lib/prismic/fragments/integration_field.rb +19 -0
- data/lib/prismic/fragments/link.rb +4 -0
- data/lib/prismic/fragments/structured_text.rb +17 -1
- data/lib/prismic/json_parsers.rb +34 -24
- data/lib/prismic/version.rb +1 -1
- data/lib/prismic/with_fragments.rb +7 -0
- data/package-lock.json +2629 -0
- data/prismic.gemspec +2 -3
- data/spec/cache_spec.rb +3 -3
- data/spec/fragments_spec.rb +31 -10
- data/spec/json_parsers_spec.rb +18 -1
- data/spec/micro_spec.rb +1 -1
- data/spec/predicates_spec.rb +13 -0
- data/spec/prismic_spec.rb +4 -4
- data/spec/responses_mocks/document.json +4 -0
- data/spec/simple_search_spec.rb +9 -0
- data/spec/spec_helper.rb +0 -6
- metadata +16 -24
data/prismic.gemspec
CHANGED
@@ -11,16 +11,15 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.description = %q{The standard Prismic.io's API library.}
|
12
12
|
spec.summary = %q{Prismic.io development kit}
|
13
13
|
spec.homepage = 'http://prismic.io'
|
14
|
-
spec.license = 'Apache-2'
|
14
|
+
spec.license = 'Apache-2.0'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
21
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
22
|
+
spec.add_development_dependency 'rspec-core', '~> 2.14'
|
23
23
|
spec.add_development_dependency 'nokogiri', '~> 1.6'
|
24
|
-
spec.add_development_dependency 'simplecov', '~> 0.7'
|
25
24
|
spec.add_runtime_dependency 'hashery', '~> 2.1.1'
|
26
25
|
end
|
data/spec/cache_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe "Cache's" do
|
|
41
41
|
@cache['fake_key3'] = 3
|
42
42
|
end
|
43
43
|
it 'contains some keys' do
|
44
|
-
@cache.include?('fake_key1').should
|
44
|
+
@cache.include?('fake_key1').should be true
|
45
45
|
end
|
46
46
|
it 'contains all keys' do
|
47
47
|
@cache.intern.size.should == 3
|
@@ -52,8 +52,8 @@ describe "Cache's" do
|
|
52
52
|
it 'keeps readed keys alive' do
|
53
53
|
@cache['fake_key1']
|
54
54
|
@cache['fake_key4'] = 4
|
55
|
-
@cache.include?('fake_key1').should
|
56
|
-
@cache.include?('fake_key2').should
|
55
|
+
@cache.include?('fake_key1').should be true
|
56
|
+
@cache.include?('fake_key2').should be false
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
data/spec/fragments_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe 'WebLink' do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns a HTML element with an href attribute" do
|
22
|
-
Nokogiri::XML(@web_link.as_html).child.has_attribute?('href').should
|
22
|
+
Nokogiri::XML(@web_link.as_html).child.has_attribute?('href').should be true
|
23
23
|
end
|
24
24
|
|
25
25
|
it "returns a HTML element with an href attribute pointing to the url" do
|
@@ -31,7 +31,7 @@ describe 'WebLink' do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns an <a> HTML element with a target attribute" do
|
34
|
-
Nokogiri::XML(@target_blank.as_html).child.has_attribute?('target').should
|
34
|
+
Nokogiri::XML(@target_blank.as_html).child.has_attribute?('target').should be true
|
35
35
|
end
|
36
36
|
|
37
37
|
it "returns an <a> HTML element with an target blank attribute" do
|
@@ -40,8 +40,8 @@ describe 'WebLink' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
describe 'as_text' do
|
43
|
-
it '
|
44
|
-
|
43
|
+
it 'returns the url' do
|
44
|
+
@web_link.as_text.should == 'my_url'
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -88,7 +88,7 @@ describe 'ImageLink' do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it "returns a HTML element with an href attribute" do
|
91
|
-
Nokogiri::XML(@image_link.as_html).child.has_attribute?('href').should
|
91
|
+
Nokogiri::XML(@image_link.as_html).child.has_attribute?('href').should be true
|
92
92
|
end
|
93
93
|
|
94
94
|
it "returns a HTML element with an href attribute pointing to the url" do
|
@@ -369,11 +369,11 @@ describe 'Color' do
|
|
369
369
|
|
370
370
|
describe 'self.valid?' do
|
371
371
|
it "returns true if the color is valid" do
|
372
|
-
Prismic::Fragments::Color.valid?(@hex_value).should
|
372
|
+
Prismic::Fragments::Color.valid?(@hex_value).should be true
|
373
373
|
end
|
374
374
|
|
375
375
|
it "returns false if the color is not valid" do
|
376
|
-
Prismic::Fragments::Color.valid?("I'm a murloc").should
|
376
|
+
Prismic::Fragments::Color.valid?("I'm a murloc").should be false
|
377
377
|
end
|
378
378
|
end
|
379
379
|
end
|
@@ -395,7 +395,7 @@ describe 'Embed' do
|
|
395
395
|
end
|
396
396
|
|
397
397
|
it "returns an element with a data-oembed attribute" do
|
398
|
-
Nokogiri::XML(@embed.as_html).child.has_attribute?('data-oembed').should
|
398
|
+
Nokogiri::XML(@embed.as_html).child.has_attribute?('data-oembed').should be true
|
399
399
|
end
|
400
400
|
|
401
401
|
it "returns an element with a data-oembed attribute containing the url" do
|
@@ -403,7 +403,7 @@ describe 'Embed' do
|
|
403
403
|
end
|
404
404
|
|
405
405
|
it "returns an element with a data-oembed-type attribute" do
|
406
|
-
Nokogiri::XML(@embed.as_html).child.has_attribute?('data-oembed-type').should
|
406
|
+
Nokogiri::XML(@embed.as_html).child.has_attribute?('data-oembed-type').should be true
|
407
407
|
end
|
408
408
|
|
409
409
|
it "returns an element with a data-oembed-type attribute containing the type in lowercase" do
|
@@ -411,7 +411,7 @@ describe 'Embed' do
|
|
411
411
|
end
|
412
412
|
|
413
413
|
it "returns an element with a data-oembed-provider attribute" do
|
414
|
-
Nokogiri::XML(@embed.as_html).child.has_attribute?('data-oembed-provider').should
|
414
|
+
Nokogiri::XML(@embed.as_html).child.has_attribute?('data-oembed-provider').should be true
|
415
415
|
end
|
416
416
|
|
417
417
|
it "returns an element with a data-oembed-provider attribute containing the provider in lowercase" do
|
@@ -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
|
data/spec/json_parsers_spec.rb
CHANGED
@@ -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 ==
|
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
|
data/spec/micro_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe 'micro' do
|
|
11
11
|
describe 'embed block in structured text fragments' do
|
12
12
|
it 'is of the right Embed object, and serializes well' do
|
13
13
|
fragment = @api.form('everything').query(%w(at document.id UrjI1gEAALOCeO5i)).submit(@master_ref)[0]['article.body']
|
14
|
-
fragment.blocks[4].is_a?(Prismic::Fragments::Embed).should == true
|
14
|
+
fragment.blocks[4].is_a?(Prismic::Fragments::StructuredText::Block::Embed).should == true
|
15
15
|
fragment.as_html(@link_resolver).gsub(/[\n\r]+/, '').gsub(/ +/, ' ').gsub(/'/, "'").should == %(<h2>The meta-micro mailing-list</h2><p>This is where you go to give feedback, and discuss the future of micro. <a href="https://groups.google.com/forum/?hl=en#!forum/micro-meta-framework">Subscribe to the list now</a>!</p><h2>The micro GitHub repository</h2><p>This is where you get truly active, by forking the project's source code, and making it better. Please always feel free to send us pull requests.</p><div data-oembed="" data-oembed-type="link" data-oembed-provider="object"><div data-type="object"><a href="https://github.com/rudyrigot/meta-micro"><h1>rudyrigot/meta-micro</h1><img src="https://avatars2.githubusercontent.com/u/552279?s=400"><p>The meta-micro-framework you simply need</p></a></div></div><h2>Report bugs on micro</h2><p>If you think micro isn't working properly in one of its features, <a href="https://github.com/rudyrigot/meta-micro/issues">open a new issue in the micro GitHub repository</a>.</p><h2>Ask for help</h2><p>Feel free to ask a new question <a href="http://stackoverflow.com/questions/tagged/meta-micro">on StackOverflow</a>.</p>)
|
16
16
|
end
|
17
17
|
end
|
data/spec/predicates_spec.rb
CHANGED
@@ -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
|
data/spec/prismic_spec.rb
CHANGED
@@ -118,7 +118,7 @@ describe 'Api' do
|
|
118
118
|
|
119
119
|
describe 'master' do
|
120
120
|
it 'returns a master Ref' do
|
121
|
-
@api.master.master?.should
|
121
|
+
@api.master.master?.should be true
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -219,11 +219,11 @@ describe 'Api' do
|
|
219
219
|
end
|
220
220
|
|
221
221
|
it "create fields (other than 'q') as non repeatable" do
|
222
|
-
@parsed.forms['pies'].fields['ref'].repeatable.should
|
222
|
+
@parsed.forms['pies'].fields['ref'].repeatable.should be false
|
223
223
|
end
|
224
224
|
|
225
225
|
it "create 'q' fields as repeatable" do
|
226
|
-
@parsed.forms['pies'].fields['q'].repeatable.should
|
226
|
+
@parsed.forms['pies'].fields['q'].repeatable.should be true
|
227
227
|
end
|
228
228
|
|
229
229
|
end
|
@@ -341,7 +341,7 @@ describe 'Document' do
|
|
341
341
|
end
|
342
342
|
|
343
343
|
it "returns a HTML element with a 'data-field' attribute" do
|
344
|
-
Nokogiri::XML(@document.as_html(@link_resolver)).child.has_attribute?('data-field').should
|
344
|
+
Nokogiri::XML(@document.as_html(@link_resolver)).child.has_attribute?('data-field').should be true
|
345
345
|
end
|
346
346
|
|
347
347
|
it "returns a HTML element with a 'data-field' attribute containing the name of the field" do
|
data/spec/simple_search_spec.rb
CHANGED
@@ -53,6 +53,15 @@ describe Prismic::API do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
describe '#get_by_uids' do
|
57
|
+
it 'returns the right documents' do
|
58
|
+
docs = @api.get_by_uids('all', ['all1', 'all2'])
|
59
|
+
docs.size.should == 2
|
60
|
+
docs[0].id.should == 'WHyJqyYAAHgyXbcj'
|
61
|
+
docs[1].id.should == 'WH2PaioAALYBEgug'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
56
65
|
describe '#get_single' do
|
57
66
|
it 'returns the singleton document of a type' do
|
58
67
|
# 'single' is the type name
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'codeclimate-test-reporter'
|
3
|
-
CodeClimate::TestReporter.start
|
4
|
-
|
5
2
|
require 'nokogiri'
|
6
3
|
begin
|
7
4
|
require 'yajl/json_gem'
|
@@ -9,15 +6,12 @@ rescue LoadError
|
|
9
6
|
# ok not a big deal
|
10
7
|
require 'json'
|
11
8
|
end
|
12
|
-
require 'simplecov'
|
13
9
|
|
14
10
|
RSpec.configure do |c|
|
15
11
|
# Stop after the first failure
|
16
12
|
# c.fail_fast = true
|
17
13
|
end
|
18
14
|
|
19
|
-
SimpleCov.start
|
20
|
-
|
21
15
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
22
16
|
|
23
17
|
require 'prismic'
|
metadata
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prismic.io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Étienne Vallette d'Osia
|
8
8
|
- Erwan Loisant
|
9
9
|
- Samy Dindane
|
10
10
|
- Rudy Rigot
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-06-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: rspec
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '2.14'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2.14'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
31
|
+
name: rspec-core
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
@@ -55,20 +55,6 @@ dependencies:
|
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '1.6'
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: simplecov
|
60
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
-
requirements:
|
62
|
-
- - "~>"
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '0.7'
|
65
|
-
type: :development
|
66
|
-
prerelease: false
|
67
|
-
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - "~>"
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '0.7'
|
72
58
|
- !ruby/object:Gem::Dependency
|
73
59
|
name: hashery
|
74
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,11 +76,15 @@ executables: []
|
|
90
76
|
extensions: []
|
91
77
|
extra_rdoc_files: []
|
92
78
|
files:
|
79
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
80
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
93
81
|
- ".gitignore"
|
94
82
|
- ".travis.yml"
|
95
83
|
- ".yardopts"
|
84
|
+
- CONTRIBUTING.md
|
96
85
|
- Gemfile
|
97
86
|
- Gemfile.lock
|
87
|
+
- LICENSE.md
|
98
88
|
- README.md
|
99
89
|
- Rakefile
|
100
90
|
- docs/Prismic.html
|
@@ -187,6 +177,7 @@ files:
|
|
187
177
|
- lib/prismic/experiments.rb
|
188
178
|
- lib/prismic/form.rb
|
189
179
|
- lib/prismic/fragments.rb
|
180
|
+
- lib/prismic/fragments/boolean_field.rb
|
190
181
|
- lib/prismic/fragments/color.rb
|
191
182
|
- lib/prismic/fragments/date.rb
|
192
183
|
- lib/prismic/fragments/embed.rb
|
@@ -194,6 +185,7 @@ files:
|
|
194
185
|
- lib/prismic/fragments/geopoint.rb
|
195
186
|
- lib/prismic/fragments/group.rb
|
196
187
|
- lib/prismic/fragments/image.rb
|
188
|
+
- lib/prismic/fragments/integration_field.rb
|
197
189
|
- lib/prismic/fragments/link.rb
|
198
190
|
- lib/prismic/fragments/multiple.rb
|
199
191
|
- lib/prismic/fragments/number.rb
|
@@ -207,6 +199,7 @@ files:
|
|
207
199
|
- lib/prismic/predicates.rb
|
208
200
|
- lib/prismic/version.rb
|
209
201
|
- lib/prismic/with_fragments.rb
|
202
|
+
- package-lock.json
|
210
203
|
- package.json
|
211
204
|
- prismic.gemspec
|
212
205
|
- spec/cache_spec.rb
|
@@ -234,7 +227,7 @@ files:
|
|
234
227
|
- spec/spec_helper.rb
|
235
228
|
homepage: http://prismic.io
|
236
229
|
licenses:
|
237
|
-
- Apache-2
|
230
|
+
- Apache-2.0
|
238
231
|
metadata: {}
|
239
232
|
post_install_message:
|
240
233
|
rdoc_options: []
|
@@ -251,8 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
244
|
- !ruby/object:Gem::Version
|
252
245
|
version: '0'
|
253
246
|
requirements: []
|
254
|
-
|
255
|
-
rubygems_version: 2.2.2
|
247
|
+
rubygems_version: 3.0.8
|
256
248
|
signing_key:
|
257
249
|
specification_version: 4
|
258
250
|
summary: Prismic.io development kit
|