prismic.io 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/docs/Prismic/API/BadPrismicResponseError.html +44 -43
- data/docs/Prismic/API/OAuth.html +99 -98
- data/docs/Prismic/API/PrismicWSAuthError.html +67 -66
- data/docs/Prismic/API/PrismicWSConnectionError.html +51 -50
- data/docs/Prismic/API.html +434 -280
- data/docs/Prismic/BasicNullCache.html +49 -48
- data/docs/Prismic/DefaultHTTPClient.html +85 -79
- data/docs/Prismic/Document.html +279 -83
- data/docs/Prismic/Error.html +52 -51
- data/docs/Prismic/Experiment.html +60 -59
- data/docs/Prismic/Experiments.html +61 -60
- data/docs/Prismic/Field.html +54 -53
- data/docs/Prismic/Form.html +70 -69
- data/docs/Prismic/Fragments/Color.html +60 -59
- data/docs/Prismic/Fragments/Date.html +52 -51
- data/docs/Prismic/Fragments/DocumentLink.html +78 -76
- data/docs/Prismic/Fragments/Embed.html +60 -59
- data/docs/Prismic/Fragments/FileLink.html +58 -57
- data/docs/Prismic/Fragments/Fragment.html +49 -48
- data/docs/Prismic/Fragments/GeoPoint.html +54 -53
- data/docs/Prismic/Fragments/Group.html +65 -63
- data/docs/Prismic/Fragments/GroupDocument.html +57 -55
- data/docs/Prismic/Fragments/Image/View.html +64 -63
- data/docs/Prismic/Fragments/Image/ViewDoesNotExistException.html +44 -43
- data/docs/Prismic/Fragments/Image.html +69 -68
- data/docs/Prismic/Fragments/ImageLink.html +50 -49
- data/docs/Prismic/Fragments/Link.html +53 -52
- data/docs/Prismic/Fragments/Multiple.html +58 -57
- data/docs/Prismic/Fragments/Number.html +54 -53
- data/docs/Prismic/Fragments/Select.html +52 -51
- data/docs/Prismic/Fragments/Separator.html +54 -53
- data/docs/Prismic/Fragments/Slice.html +58 -57
- data/docs/Prismic/Fragments/SliceZone.html +54 -53
- data/docs/Prismic/Fragments/StructuredText/Block/Embed.html +52 -51
- data/docs/Prismic/Fragments/StructuredText/Block/Heading.html +52 -51
- data/docs/Prismic/Fragments/StructuredText/Block/Image.html +66 -65
- data/docs/Prismic/Fragments/StructuredText/Block/ListItem.html +52 -51
- data/docs/Prismic/Fragments/StructuredText/Block/Paragraph.html +47 -46
- data/docs/Prismic/Fragments/StructuredText/Block/Preformatted.html +47 -46
- data/docs/Prismic/Fragments/StructuredText/Block/Text.html +68 -64
- data/docs/Prismic/Fragments/StructuredText/Block.html +47 -46
- data/docs/Prismic/Fragments/StructuredText/BlockGroup.html +54 -53
- data/docs/Prismic/Fragments/StructuredText/Span/Em.html +47 -46
- data/docs/Prismic/Fragments/StructuredText/Span/Hyperlink.html +53 -52
- data/docs/Prismic/Fragments/StructuredText/Span/Label.html +52 -51
- data/docs/Prismic/Fragments/StructuredText/Span/Strong.html +47 -46
- data/docs/Prismic/Fragments/StructuredText/Span.html +52 -51
- data/docs/Prismic/Fragments/StructuredText.html +59 -58
- data/docs/Prismic/Fragments/Text.html +54 -53
- data/docs/Prismic/Fragments/Timestamp.html +52 -51
- data/docs/Prismic/Fragments/WebLink.html +50 -49
- data/docs/Prismic/Fragments.html +39 -39
- data/docs/Prismic/HtmlSerializer.html +57 -56
- data/docs/Prismic/JsonParser.html +145 -143
- data/docs/Prismic/LinkResolver.html +73 -72
- data/docs/Prismic/LruCache.html +70 -69
- data/docs/Prismic/Predicates.html +261 -209
- data/docs/Prismic/Ref.html +86 -85
- data/docs/Prismic/Response.html +75 -73
- data/docs/Prismic/SearchForm/AuthenticationException.html +44 -43
- data/docs/Prismic/SearchForm/AuthorizationException.html +44 -43
- data/docs/Prismic/SearchForm/FormSearchException.html +44 -43
- data/docs/Prismic/SearchForm/NoRefSetException.html +44 -43
- data/docs/Prismic/SearchForm/RefNotFoundException.html +44 -43
- data/docs/Prismic/SearchForm/UnsupportedFormKind.html +44 -43
- data/docs/Prismic/SearchForm.html +97 -96
- data/docs/Prismic/Variation.html +57 -56
- data/docs/Prismic/WithFragments.html +115 -113
- data/docs/Prismic.html +91 -93
- data/docs/_index.html +32 -35
- data/docs/class_list.html +24 -27
- data/docs/css/full_list.css +32 -31
- data/docs/css/style.css +244 -91
- data/docs/file.README.html +39 -74
- data/docs/file_list.html +26 -26
- data/docs/frames.html +7 -16
- data/docs/index.html +39 -74
- data/docs/js/app.js +101 -77
- data/docs/js/full_list.js +170 -132
- data/docs/method_list.html +1995 -1189
- data/docs/top-level-namespace.html +34 -36
- data/lib/prismic/api.rb +10 -1
- data/lib/prismic/fragments/link.rb +3 -2
- data/lib/prismic/json_parsers.rb +14 -0
- data/lib/prismic/version.rb +1 -1
- data/lib/prismic.rb +47 -5
- data/spec/cache_spec.rb +2 -2
- data/spec/fragments_spec.rb +8 -1
- data/spec/json_parsers_spec.rb +13 -1
- data/spec/prismic_spec.rb +14 -7
- data/spec/responses_mocks/document.json +13 -0
- data/spec/simple_search_spec.rb +9 -0
- metadata +2 -2
@@ -1,12 +1,12 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
4
3
|
<head>
|
5
|
-
<meta
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>
|
7
7
|
Top Level Namespace
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8
|
9
|
+
— Documentation by YARD 0.9.8
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -15,9 +15,8 @@
|
|
15
15
|
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
16
|
|
17
17
|
<script type="text/javascript" charset="utf-8">
|
18
|
-
|
18
|
+
pathId = "";
|
19
19
|
relpath = '';
|
20
|
-
framesUrl = "frames.html#!top-level-namespace.html";
|
21
20
|
</script>
|
22
21
|
|
23
22
|
|
@@ -28,58 +27,56 @@
|
|
28
27
|
|
29
28
|
</head>
|
30
29
|
<body>
|
31
|
-
<div
|
32
|
-
<
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
33
38
|
|
34
39
|
<a href="_index.html">Index</a> »
|
35
40
|
|
36
41
|
|
37
42
|
<span class="title">Top Level Namespace</span>
|
38
43
|
|
39
|
-
|
40
|
-
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
44
|
</div>
|
42
45
|
|
43
|
-
|
46
|
+
<div id="search">
|
44
47
|
|
45
48
|
<a class="full_list_link" id="class_list_link"
|
46
49
|
href="class_list.html">
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
</a>
|
54
|
-
|
55
|
-
<a class="full_list_link" id="file_list_link"
|
56
|
-
href="file_list.html">
|
57
|
-
File List
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
58
56
|
</a>
|
59
57
|
|
60
58
|
</div>
|
61
|
-
|
62
|
-
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
<div id="content"><h1>Top Level Namespace
|
62
|
+
<div id="content"><h1>Top Level Namespace
|
67
63
|
|
68
64
|
|
69
65
|
|
70
66
|
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
71
69
|
|
72
|
-
<dl class="box">
|
73
70
|
|
74
71
|
|
75
|
-
|
76
72
|
|
77
|
-
|
78
73
|
|
79
74
|
|
75
|
+
|
80
76
|
|
81
|
-
|
82
|
-
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
83
80
|
|
84
81
|
<h2>Defined Under Namespace</h2>
|
85
82
|
<p class="children">
|
@@ -102,11 +99,12 @@
|
|
102
99
|
|
103
100
|
</div>
|
104
101
|
|
105
|
-
|
106
|
-
Generated on
|
102
|
+
<div id="footer">
|
103
|
+
Generated on Mon Jan 16 16:05:08 2017 by
|
107
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
|
-
0.8
|
105
|
+
0.9.8 (ruby-2.3.1).
|
109
106
|
</div>
|
110
107
|
|
108
|
+
</div>
|
111
109
|
</body>
|
112
110
|
</html>
|
data/lib/prismic/api.rb
CHANGED
@@ -103,6 +103,9 @@ module Prismic
|
|
103
103
|
# @param opts [Hash] query options (page, pageSize, ref, etc.)
|
104
104
|
# @return the document, or nil if not found
|
105
105
|
def get_by_id(id, opts={})
|
106
|
+
unless opts.key?("lang")
|
107
|
+
opts["lang"] = '*'
|
108
|
+
end
|
106
109
|
query(Prismic::Predicates::at('document.id', id), opts)[0]
|
107
110
|
end
|
108
111
|
alias :getByID :get_by_id
|
@@ -113,6 +116,9 @@ module Prismic
|
|
113
116
|
# @param opts [Hash] query options (ref, etc.)
|
114
117
|
# @return the document, or nil if not found
|
115
118
|
def get_by_uid(typ, uid, opts={})
|
119
|
+
unless opts.key?("lang")
|
120
|
+
opts["lang"] = '*'
|
121
|
+
end
|
116
122
|
query(Prismic::Predicates::at('my.'+typ+'.uid', uid), opts)[0]
|
117
123
|
end
|
118
124
|
alias :getByUID :get_by_uid
|
@@ -122,6 +128,9 @@ module Prismic
|
|
122
128
|
# @param opts [Hash] query options (page, pageSize, ref, etc.)
|
123
129
|
# @return the document, or nil if not found
|
124
130
|
def get_by_ids(ids, opts={})
|
131
|
+
unless opts.key?("lang")
|
132
|
+
opts["lang"] = '*'
|
133
|
+
end
|
125
134
|
query(Prismic::Predicates::in('document.id', ids), opts)
|
126
135
|
end
|
127
136
|
alias :getByIDs :get_by_ids
|
@@ -148,7 +157,7 @@ module Prismic
|
|
148
157
|
return default_url
|
149
158
|
end
|
150
159
|
json = JSON.load(response.body)
|
151
|
-
documents = self.form('everything').query(Prismic::Predicates.at('document.id', json['mainDocument'])).submit(token)
|
160
|
+
documents = self.form('everything').query(Prismic::Predicates.at('document.id', json['mainDocument'])).lang("*").submit(token)
|
152
161
|
if documents.results.size > 0
|
153
162
|
link_resolver.link_to(documents.results[0])
|
154
163
|
else
|
@@ -96,14 +96,15 @@ module Prismic
|
|
96
96
|
|
97
97
|
class DocumentLink < Link
|
98
98
|
include Prismic::WithFragments
|
99
|
-
attr_accessor :id, :uid, :type, :tags, :slug, :fragments, :broken
|
99
|
+
attr_accessor :id, :uid, :type, :tags, :slug, :lang, :fragments, :broken
|
100
100
|
|
101
|
-
def initialize(id, uid, type, tags, slug, fragments, broken)
|
101
|
+
def initialize(id, uid, type, tags, slug, lang, fragments, broken)
|
102
102
|
@id = id
|
103
103
|
@uid = uid
|
104
104
|
@type = type
|
105
105
|
@tags = tags
|
106
106
|
@slug = slug
|
107
|
+
@lang = lang
|
107
108
|
@fragments = fragments
|
108
109
|
@broken = broken
|
109
110
|
end
|
data/lib/prismic/json_parsers.rb
CHANGED
@@ -48,6 +48,7 @@ module Prismic
|
|
48
48
|
type,
|
49
49
|
doc['tags'],
|
50
50
|
URI.unescape(doc['slug']),
|
51
|
+
doc['lang'],
|
51
52
|
fragments,
|
52
53
|
json['value']['isBroken'])
|
53
54
|
end
|
@@ -221,6 +222,10 @@ module Prismic
|
|
221
222
|
end
|
222
223
|
end
|
223
224
|
|
225
|
+
def alternate_language_parser(alternate_language)
|
226
|
+
Prismic::AlternateLanguage.new(alternate_language)
|
227
|
+
end
|
228
|
+
|
224
229
|
def document_parser(json)
|
225
230
|
data_json = json['data'].values.first # {"doc_type": data}
|
226
231
|
|
@@ -234,6 +239,13 @@ module Prismic
|
|
234
239
|
known_type
|
235
240
|
}
|
236
241
|
|
242
|
+
alternate_languages = nil
|
243
|
+
if json.key?('alternate_languages')
|
244
|
+
alternate_languages = Hash[json['alternate_languages'].map { |doc|
|
245
|
+
[doc['lang'], alternate_language_parser(doc)]
|
246
|
+
}]
|
247
|
+
end
|
248
|
+
|
237
249
|
fragments = Hash[data_json.map { |name, fragment|
|
238
250
|
[name, fragment_parser(fragment)]
|
239
251
|
}]
|
@@ -247,6 +259,8 @@ module Prismic
|
|
247
259
|
json['slugs'].map { |slug| URI.unescape(slug) },
|
248
260
|
json['first_publication_date'] && Time.parse(json['first_publication_date']),
|
249
261
|
json['last_publication_date'] && Time.parse(json['last_publication_date']),
|
262
|
+
json['lang'],
|
263
|
+
alternate_languages,
|
250
264
|
fragments)
|
251
265
|
end
|
252
266
|
|
data/lib/prismic/version.rb
CHANGED
data/lib/prismic.rb
CHANGED
@@ -171,9 +171,14 @@ module Prismic
|
|
171
171
|
if query[0].kind_of?(String)
|
172
172
|
set('q', query[0])
|
173
173
|
else
|
174
|
-
|
175
|
-
|
176
|
-
|
174
|
+
unless query[0][0].kind_of?(Array)
|
175
|
+
query = [query]
|
176
|
+
end
|
177
|
+
predicates = query.map { |predicate|
|
178
|
+
predicate.map { |q|
|
179
|
+
op = q.shift
|
180
|
+
"[:d = #{op}(#{q.map { |arg| serialize(arg) }.join(', ')})]"
|
181
|
+
}.join('')
|
177
182
|
}
|
178
183
|
set('q', "[#{predicates * ''}]")
|
179
184
|
end
|
@@ -204,6 +209,11 @@ module Prismic
|
|
204
209
|
# @param fields [String] The fields separated by commas (,)
|
205
210
|
# @return [SearchForm] self
|
206
211
|
|
212
|
+
# @!method lang(lang)
|
213
|
+
# Specify a language for this form.
|
214
|
+
# @param lang [String] The document language
|
215
|
+
# @return [SearchForm] self
|
216
|
+
|
207
217
|
# Create the fields'helper methods
|
208
218
|
def create_field_helper_method(name)
|
209
219
|
return if name == 'ref'
|
@@ -333,7 +343,9 @@ module Prismic
|
|
333
343
|
def set(field_name, value)
|
334
344
|
field = @form.fields[field_name]
|
335
345
|
unless value == nil
|
336
|
-
if
|
346
|
+
if value == ""
|
347
|
+
data[field_name] = nil
|
348
|
+
elsif field && field.repeatable?
|
337
349
|
data[field_name] = [] unless data.include? field_name
|
338
350
|
data[field_name] << value.to_s
|
339
351
|
else
|
@@ -454,6 +466,10 @@ module Prismic
|
|
454
466
|
attr_accessor :first_publication_date
|
455
467
|
# @return Time
|
456
468
|
attr_accessor :last_publication_date
|
469
|
+
# @return [String]
|
470
|
+
attr_accessor :lang
|
471
|
+
# @return [Array<AlternateLanguage>]
|
472
|
+
attr_accessor :alternate_languages
|
457
473
|
# @return [Array<Fragment>]
|
458
474
|
attr_accessor :fragments
|
459
475
|
|
@@ -466,6 +482,8 @@ module Prismic
|
|
466
482
|
slugs,
|
467
483
|
first_publication_date,
|
468
484
|
last_publication_date,
|
485
|
+
lang,
|
486
|
+
alternate_languages,
|
469
487
|
fragments
|
470
488
|
)
|
471
489
|
@id = id
|
@@ -476,6 +494,8 @@ module Prismic
|
|
476
494
|
@slugs = slugs
|
477
495
|
@first_publication_date = first_publication_date
|
478
496
|
@last_publication_date = last_publication_date
|
497
|
+
@lang = lang
|
498
|
+
@alternate_languages = alternate_languages
|
479
499
|
@fragments = fragments
|
480
500
|
end
|
481
501
|
|
@@ -549,7 +569,7 @@ module Prismic
|
|
549
569
|
if doc.is_a? Prismic::Fragments::DocumentLink
|
550
570
|
@blk.call(doc)
|
551
571
|
elsif doc.is_a? Prismic::Document
|
552
|
-
doc_link = Prismic::Fragments::DocumentLink.new(doc.id, doc.uid, doc.type, doc.tags, doc.slug, doc.fragments, false)
|
572
|
+
doc_link = Prismic::Fragments::DocumentLink.new(doc.id, doc.uid, doc.type, doc.tags, doc.slug, doc.lang, doc.fragments, false)
|
553
573
|
@blk.call(doc_link)
|
554
574
|
end
|
555
575
|
end
|
@@ -567,6 +587,28 @@ module Prismic
|
|
567
587
|
@blk.call(element, content)
|
568
588
|
end
|
569
589
|
end
|
590
|
+
|
591
|
+
|
592
|
+
# A class for the alternate language versions of a document
|
593
|
+
#
|
594
|
+
# The {Prismic.alternate_language} function is the recommended way to create an AlternateLanguage.
|
595
|
+
class AlternateLanguage
|
596
|
+
# @return [String]
|
597
|
+
attr_accessor :id
|
598
|
+
# @return [String]
|
599
|
+
attr_accessor :uid
|
600
|
+
# @return [String]
|
601
|
+
attr_accessor :type
|
602
|
+
# @return [String]
|
603
|
+
attr_accessor :lang
|
604
|
+
|
605
|
+
def initialize(json)
|
606
|
+
@id = json['id']
|
607
|
+
@uid = json['uid']
|
608
|
+
@type = json['type']
|
609
|
+
@lang = json['lang']
|
610
|
+
end
|
611
|
+
end
|
570
612
|
|
571
613
|
# Default HTTP client implementation, using the standard Net::HTTP library.
|
572
614
|
module DefaultHTTPClient
|
data/spec/cache_spec.rb
CHANGED
@@ -65,8 +65,8 @@ describe "Cache's" do
|
|
65
65
|
@other_ref = @api.refs['adding jason']
|
66
66
|
end
|
67
67
|
it 'works on different refs' do
|
68
|
-
@api.form('everything').submit(@master_ref).total_results_size.should ==
|
69
|
-
@api.form('everything').submit(@other_ref).total_results_size.should ==
|
68
|
+
@api.form('everything').submit(@master_ref).total_results_size.should == 24
|
69
|
+
@api.form('everything').submit(@other_ref).total_results_size.should == 25
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
data/spec/fragments_spec.rb
CHANGED
@@ -48,7 +48,7 @@ end
|
|
48
48
|
|
49
49
|
describe 'DocumentLink' do
|
50
50
|
before do
|
51
|
-
@document_link = Prismic::Fragments::DocumentLink.new("UdUjvt_mqVNObPeO", nil, "product", ["Macaron"], "dark-chocolate-macaron", {}, false)
|
51
|
+
@document_link = Prismic::Fragments::DocumentLink.new("UdUjvt_mqVNObPeO", nil, "product", ["Macaron"], "dark-chocolate-macaron", "en-us", {}, false)
|
52
52
|
end
|
53
53
|
|
54
54
|
describe 'url' do
|
@@ -59,6 +59,12 @@ describe 'DocumentLink' do
|
|
59
59
|
@document_link.url(@link_resolver).should == 'http://localhost/UdUjvt_mqVNObPeO'
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
describe 'lang' do
|
64
|
+
it 'is available' do
|
65
|
+
@document_link.lang.should == 'en-us'
|
66
|
+
end
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
describe 'ImageLink' do
|
@@ -638,6 +644,7 @@ describe 'StructuredText::Hyperlink' do
|
|
638
644
|
"product",
|
639
645
|
["Macaron"],
|
640
646
|
"dark-chocolate-macaron",
|
647
|
+
"fr-fr",
|
641
648
|
{},
|
642
649
|
false # not broken
|
643
650
|
)
|
data/spec/json_parsers_spec.rb
CHANGED
@@ -11,7 +11,8 @@ describe 'document_link_parser' do
|
|
11
11
|
"id": "UdUjvt_mqVNObPeO",
|
12
12
|
"type": "product",
|
13
13
|
"tags": ["Macaron"],
|
14
|
-
"slug": "dark-chocolate-macaron"
|
14
|
+
"slug": "dark-chocolate-macaron",
|
15
|
+
"lang": "en-us"
|
15
16
|
},
|
16
17
|
"isBroken": false
|
17
18
|
}
|
@@ -26,6 +27,7 @@ json
|
|
26
27
|
document_link.type.should == "product"
|
27
28
|
document_link.tags.should == ['Macaron']
|
28
29
|
document_link.slug.should == "dark-chocolate-macaron"
|
30
|
+
document_link.lang.should == "en-us"
|
29
31
|
document_link.broken?.should == false
|
30
32
|
end
|
31
33
|
end
|
@@ -361,6 +363,7 @@ describe 'document_parser' do
|
|
361
363
|
@document.href.should == 'doc-url'
|
362
364
|
@document.tags.should == ['Macaron']
|
363
365
|
@document.slugs.should == ['vanilla-macaron', '南大沢']
|
366
|
+
@document.lang.should == 'en-us'
|
364
367
|
end
|
365
368
|
|
366
369
|
it "correctly parses the document's publication dates" do
|
@@ -368,6 +371,15 @@ describe 'document_parser' do
|
|
368
371
|
@document.last_publication_date.should == Time.at(1476846111)
|
369
372
|
end
|
370
373
|
|
374
|
+
it "correctly parses the document's alternate languages" do
|
375
|
+
@document.alternate_languages.size.should == 2
|
376
|
+
@document.alternate_languages['fr-fr'].should be_a Prismic::AlternateLanguage
|
377
|
+
@document.alternate_languages['fr-fr'].id.should == "WL2IziIAACIAem32"
|
378
|
+
@document.alternate_languages['fr-fr'].type.should == "product"
|
379
|
+
@document.alternate_languages['fr-fr'].lang.should == "fr-fr"
|
380
|
+
@document.alternate_languages['fr-fr'].uid.should == nil
|
381
|
+
end
|
382
|
+
|
371
383
|
it "correctly parses the document's fragments" do
|
372
384
|
@document.fragments.size.should == 14
|
373
385
|
@document.fragments['name'].should be_a Prismic::Fragments::StructuredText
|
data/spec/prismic_spec.rb
CHANGED
@@ -267,30 +267,30 @@ end
|
|
267
267
|
|
268
268
|
describe 'LinkResolver' do
|
269
269
|
before do
|
270
|
-
@doc_link = Prismic::Fragments::DocumentLink.new('id', nil, 'blog-post', ['tag1', 'tag2'], 'my-slug', {}, false)
|
271
|
-
@document = Prismic::Document.new('id', nil, 'blog-post', nil, ['tag1', 'tag2'], ['my-slug', 'my-other-slug'], nil, nil, nil)
|
270
|
+
@doc_link = Prismic::Fragments::DocumentLink.new('id', nil, 'blog-post', ['tag1', 'tag2'], 'my-slug', "fr-fr", {}, false)
|
271
|
+
@document = Prismic::Document.new('id', nil, 'blog-post', nil, ['tag1', 'tag2'], ['my-slug', 'my-other-slug'], nil, nil, "en-us", nil, nil)
|
272
272
|
|
273
273
|
@link_resolver = Prismic::LinkResolver.new(nil) do |doc|
|
274
|
-
'/'+doc.type+'/'+doc.id+'/'+doc.slug
|
274
|
+
'/'+doc.lang+'/'+doc.type+'/'+doc.id+'/'+doc.slug
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
278
|
it 'builds the right URL from a DocumentLink' do
|
279
|
-
@link_resolver.link_to(@doc_link).should == '/blog-post/id/my-slug'
|
279
|
+
@link_resolver.link_to(@doc_link).should == '/fr-fr/blog-post/id/my-slug'
|
280
280
|
end
|
281
281
|
|
282
282
|
it 'builds the right URL from a Document' do
|
283
|
-
@link_resolver.link_to(@document).should == '/blog-post/id/my-slug'
|
283
|
+
@link_resolver.link_to(@document).should == '/en-us/blog-post/id/my-slug'
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
287
287
|
describe 'Document' do
|
288
288
|
before do
|
289
289
|
fragments = {
|
290
|
-
'field1' => Prismic::Fragments::DocumentLink.new(nil, nil, nil, nil, nil, {}, nil),
|
290
|
+
'field1' => Prismic::Fragments::DocumentLink.new(nil, nil, nil, nil, nil, "fr-fr", {}, nil),
|
291
291
|
'field2' => Prismic::Fragments::WebLink.new('weburl')
|
292
292
|
}
|
293
|
-
@document = Prismic::Document.new(nil, nil, nil, nil, nil, ['my-slug'], nil, nil, fragments)
|
293
|
+
@document = Prismic::Document.new(nil, nil, nil, nil, nil, ['my-slug'], nil, nil, "fr-fr", nil, fragments)
|
294
294
|
@link_resolver = Prismic::LinkResolver.new('master'){|doc_link|
|
295
295
|
"http://host/#{doc_link.id}"
|
296
296
|
}
|
@@ -423,6 +423,13 @@ describe 'SearchForm' do
|
|
423
423
|
@form.data.should == { 'q' => 'baz' } # test an other
|
424
424
|
end
|
425
425
|
|
426
|
+
it 'replace empty string value with nil' do
|
427
|
+
@field = Prismic::Field.new('String', nil, true)
|
428
|
+
@form = create_form('q' => @field)
|
429
|
+
@form.set('q', '')
|
430
|
+
@form.data.should == { 'q' => nil }
|
431
|
+
end
|
432
|
+
|
426
433
|
it 'create value array for repeatable fields without value' do
|
427
434
|
@field = Prismic::Field.new('String', nil, true)
|
428
435
|
@form = create_form('q' => @field)
|
@@ -11,6 +11,19 @@
|
|
11
11
|
"vanilla-macaron",
|
12
12
|
"%E5%8D%97%E5%A4%A7%E6%B2%A2"
|
13
13
|
],
|
14
|
+
"lang": "en-us",
|
15
|
+
"alternate_languages": [
|
16
|
+
{
|
17
|
+
"id": "WL6VySoAACwA_H9r",
|
18
|
+
"type": "product",
|
19
|
+
"lang": "es-es"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"id": "WL2IziIAACIAem32",
|
23
|
+
"type": "product",
|
24
|
+
"lang": "fr-fr"
|
25
|
+
}
|
26
|
+
],
|
14
27
|
"data": {
|
15
28
|
"product": {
|
16
29
|
"name": {
|
data/spec/simple_search_spec.rb
CHANGED
@@ -12,6 +12,15 @@ describe Prismic::API do
|
|
12
12
|
docs.size.should == 1
|
13
13
|
docs[0].id.should == 'UrDejAEAAFwMyrW9'
|
14
14
|
end
|
15
|
+
|
16
|
+
it 'handles multiple predicates' do
|
17
|
+
docs = @api.query([
|
18
|
+
Prismic::Predicates::at('document.type', 'all'),
|
19
|
+
Prismic::Predicates::at('my.all.uid', 'all')
|
20
|
+
])
|
21
|
+
docs.size.should == 1
|
22
|
+
docs[0].id.should == 'WHx-gSYAAMkyXYX_'
|
23
|
+
end
|
15
24
|
end
|
16
25
|
|
17
26
|
describe '#all' do
|
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.4.
|
4
|
+
version: 1.4.4
|
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: 2017-
|
14
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|