prismic.io 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: 08719b7d27a244af6b9b57a68aee5980db6aeb25
4
- data.tar.gz: 7ba1a6bcb021a1fc6ba55cc15cd0ca196e440044
3
+ metadata.gz: 262cbc2bac7da40a5f91810b4b1e3d3325676f0b
4
+ data.tar.gz: fb939276c43de3b25a2f949119650035536afcd2
5
5
  SHA512:
6
- metadata.gz: c3b0b134abe08cc7a74e92fbf4ee9e2dd8ddc87795f36fa1cfcc0e2b20c4e4a0c5117f53ebc5b6cc601ff73ad8962d4863dd55ed04138e054eb2e24555fd506f
7
- data.tar.gz: 4366750b86e6a3d109aaf99b65fbe6c13de48764af245a0b6f53f09745ab1cfdf67d40e1cf49af397c9aced0e206f0d1ec3acacb21443c824d65f07904ce70da
6
+ metadata.gz: e87f7f3f8eb76161cf56b94dbf919215b85963d3dce8f67ff0383987abbcb67f18ab807b14834a2a810f4c5c87fc00ec7f29873b59558c2ddcde1dfddef7340b
7
+ data.tar.gz: 14f537c21d1ecee4c18204174e64236911a268f71b49412c4ca4190d984a3f08fab97a36556585329f42e2aa37f42e3a5aa80587a2938389fc1cc40cc5ce2028
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prismic.io (1.1.0)
4
+ prismic.io (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/prismic.rb CHANGED
@@ -157,7 +157,7 @@ module Prismic
157
157
 
158
158
  def q(*query)
159
159
  def serialize(field)
160
- if field.kind_of?(String) and not (field.start_with?('my.') or field.start_with?('document.'))
160
+ if field.kind_of?(String) and not (field.start_with?('my.') or field.start_with?('document'))
161
161
  %("#{field}")
162
162
  elsif field.kind_of?(Array)
163
163
  %([#{field.map{ |arg| serialize(arg) }.join(', ')}])
data/lib/prismic/api.rb CHANGED
@@ -58,7 +58,7 @@ module Prismic
58
58
 
59
59
  # Get a bookmark by its name
60
60
  # @api
61
- # @param name [String] The bookmark's name
61
+ # @param [String] The bookmark's name
62
62
  #
63
63
  # @return [String] The bookmark document id
64
64
  def bookmark(name)
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Prismic
3
3
 
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
 
6
6
  end
@@ -66,6 +66,13 @@ module Prismic
66
66
  end
67
67
  alias :size :length
68
68
 
69
+ # @return [Fragments::StructuredText]
70
+ def get_structured_text(field)
71
+ fragment = self[field]
72
+ return nil unless fragment.is_a? Prismic::Fragments::StructuredText
73
+ fragment
74
+ end
75
+
69
76
  # @return [Fragments::Text]
70
77
  def get_text(field)
71
78
  fragment = self[field]
data/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "url": "https://github.com/prismicio/ruby-kit",
5
5
  "devDependencies": {
6
6
  "gulp": "~3.8.8",
7
- "gulp-gist": "~1.0.3",
7
+ "gulp-gist": "~1.1.0",
8
8
  "gulp-gh-pages": "~0.3.4"
9
9
  }
10
10
  }
data/spec/doc_spec.rb CHANGED
@@ -6,7 +6,7 @@ describe 'Documentation' do
6
6
  describe 'api' do
7
7
 
8
8
  it 'api.get' do
9
- # startgist:31cf4b514778d5d9d9cc:prismic-api.rb
9
+ # startgist:983989438334c8bf7967:prismic-api.rb
10
10
  api = Prismic.api('https://lesbonneschoses.cdn.wroom.io/api')
11
11
  # endgist
12
12
  api.should_not be_nil
@@ -14,7 +14,7 @@ describe 'Documentation' do
14
14
 
15
15
  it 'apiPrivate' do
16
16
  expect {
17
- # startgist:10822fc1befeeea1191a:prismic-apiPrivate.rb
17
+ # startgist:efecc8f60b1f69bada81:prismic-apiPrivate.rb
18
18
  # This will fail because the token is invalid, but this is how to access a private API
19
19
  api = Prismic.api('https://lesbonneschoses.cdn.prismic.io/api', 'MC5-XXXXXXX-vRfvv70')
20
20
  # endgist
@@ -23,7 +23,7 @@ describe 'Documentation' do
23
23
  end
24
24
 
25
25
  it 'references' do
26
- # startgist:431e191cabf5e160c701:prismic-references.rb
26
+ # startgist:55a7ef6bc691bf3c4929:prismic-references.rb
27
27
  preview_token = 'MC5VbDdXQmtuTTB6Z0hNWHF3.c--_vVbvv73vv73vv73vv71EA--_vS_vv73vv70T77-9Ke-_ve-_vWfvv70ebO-_ve-_ve-_vQN377-9ce-_vRfvv70';
28
28
  api = Prismic.api('https://lesbonneschoses.cdn.prismic.io/api', preview_token)
29
29
  st_patrick_ref = api.ref('St-Patrick specials')
@@ -43,7 +43,7 @@ describe 'Documentation' do
43
43
  describe 'queries' do
44
44
 
45
45
  it 'simple query' do
46
- # startgist:8943931ba0cf2bb2c873:prismic-simplequery.rb
46
+ # startgist:f1007f1c4c4bc94f9fc6:prismic-simplequery.rb
47
47
  api = Prismic.api('https://lesbonneschoses.cdn.prismic.io/api')
48
48
  response = api
49
49
  .form('everything')
@@ -55,7 +55,7 @@ describe 'Documentation' do
55
55
  end
56
56
 
57
57
  it 'orderings' do
58
- # startgist:2866b2e2cae0221f2188:prismic-orderings.rb
58
+ # startgist:f987025745dbbf26e817:prismic-orderings.rb
59
59
  api = Prismic.api('https://lesbonneschoses.cdn.prismic.io/api')
60
60
  response = api.form('everything')
61
61
  .ref(api.master_ref)
@@ -70,7 +70,7 @@ describe 'Documentation' do
70
70
  end
71
71
 
72
72
  it 'predicates' do
73
- # startgist:e0501cce9a12fa4b83db:prismic-predicates.rb
73
+ # startgist:7b93db67fa25ac386603:prismic-predicates.rb
74
74
  api = Prismic.api('https://lesbonneschoses.cdn.prismic.io/api')
75
75
  response = api
76
76
  .form('everything')
@@ -83,7 +83,7 @@ describe 'Documentation' do
83
83
  end
84
84
 
85
85
  it 'all predicates' do
86
- # startgist:e4875d732426a7b9fd09:prismic-allPredicates.rb
86
+ # startgist:1efb7363a5f573627308:prismic-allPredicates.rb
87
87
  # 'at' predicate: equality of a fragment to a value.
88
88
  at = Predicates::at('document.type', 'article')
89
89
  # 'any' predicate: equality of a fragment to a value.
@@ -110,7 +110,7 @@ describe 'Documentation' do
110
110
  .ref(api.master_ref)
111
111
  .submit
112
112
  doc = response[0]
113
- # startgist:cd0d4559870f5f88b90f:prismic-getText.rb
113
+ # startgist:4cbc1abffe7cc1209f95:prismic-getText.rb
114
114
  author = doc.get_text('blog-post.author')
115
115
  if author == nil
116
116
  name = 'Anonymous'
@@ -128,7 +128,7 @@ describe 'Documentation' do
128
128
  .ref(api.master_ref)
129
129
  .submit
130
130
  doc = response[0]
131
- # startgist:c6783e9789d3ff446876:prismic-getNumber.rb
131
+ # startgist:4e263ac039e0b0cea0be:prismic-getNumber.rb
132
132
  # Number predicates
133
133
  gt = Predicates::gt('my.product.price', 10)
134
134
  lt = Predicates::lt('my.product.price', 20)
@@ -147,7 +147,7 @@ describe 'Documentation' do
147
147
  .ref(api.master_ref)
148
148
  .submit
149
149
  doc = response[0]
150
- # startgist:825fa25b66355ce758fe:prismic-images.rb
150
+ # startgist:154ba379a5000f14b3ea:prismic-images.rb
151
151
  # Accessing image fields
152
152
  image = doc.get_image('product.image')
153
153
  # Most of the time you will be using the "main" view
@@ -163,7 +163,7 @@ describe 'Documentation' do
163
163
  .ref(api.master_ref)
164
164
  .submit
165
165
  doc = response[0]
166
- # startgist:aa956ac3d7fb9c221011:prismic-dateTimestamp.rb
166
+ # startgist:4ac2db89bde0ca0c2b33:prismic-dateTimestamp.rb
167
167
  # Date and Timestamp predicates
168
168
  dateBefore = Predicates::date_before('my.product.releaseDate', Time.new(2014, 6, 1))
169
169
  dateAfter = Predicates::date_after('my.product.releaseDate', Time.new(2014, 1, 1))
@@ -195,7 +195,7 @@ describe 'Documentation' do
195
195
  json = '{"id":"abcd","type":"article","href":"","slugs":[],"tags":[],"data":{"article":{"documents":{"type":"Group","value":[{"linktodoc":{"type":"Link.document","value":{"document":{"id":"UrDejAEAAFwMyrW9","type":"doc","tags":[],"slug":"installing-meta-micro"},"isBroken":false}},"desc":{"type":"StructuredText","value":[{"type":"paragraph","text":"A detailed step by step point of view on how installing happens.","spans":[]}]}},{"linktodoc":{"type":"Link.document","value":{"document":{"id":"UrDmKgEAALwMyrXA","type":"doc","tags":[],"slug":"using-meta-micro"},"isBroken":false}}}]}}}}'
196
196
  document = Prismic::JsonParser.document_parser(JSON.load(json))
197
197
  resolver = Prismic.link_resolver('master') { |doc_link| "http://localhost/#{doc_link.id}" }
198
- # startgist:825cff092f082058520d:prismic-group.rb
198
+ # startgist:4c87bd640086b9094151:prismic-group.rb
199
199
  group = document.get_group('article.documents')
200
200
  docs = group ? group : []
201
201
  docs.each do |doc|
@@ -210,7 +210,7 @@ describe 'Documentation' do
210
210
  it 'link' do
211
211
  json = '{"id":"abcd","type":"article","href":"","slugs":[],"tags":[],"data":{"article":{"source":{"type":"Link.document","value":{"document":{"id":"UlfoxUnM0wkXYXbE","type":"product","tags":["Macaron"],"slug":"dark-chocolate-macaron"},"isBroken":false}}}}}'
212
212
  document = Prismic::JsonParser.document_parser(JSON.load(json))
213
- # startgist:6c7ae8d7ab6dc057a8b0:prismic-link.rb
213
+ # startgist:762dfce77d215e6c70b0:prismic-link.rb
214
214
  resolver = Prismic.link_resolver('master') { |doc_link| "http://localhost/#{doc_link.id}/#{doc_link.slug}" }
215
215
  source = document.get_link('article.source')
216
216
  url = source ? source.url(resolver) : nil
@@ -221,7 +221,7 @@ describe 'Documentation' do
221
221
  it 'embed' do
222
222
  json = '{"id":"abcd","type":"article","href":"","slugs":[],"tags":[],"data":{"article":{"video":{"type":"Embed","value":{"oembed":{"provider_url":"http://www.youtube.com/","type":"video","thumbnail_height":360,"height":270,"thumbnail_url":"http://i1.ytimg.com/vi/baGfM6dBzs8/hqdefault.jpg","width":480,"provider_name":"YouTube","html":"<iframe width=\\"480\\" height=\\"270\\" src=\\"http://www.youtube.com/embed/baGfM6dBzs8?feature=oembed\\" frameborder=\\"0\\" allowfullscreen></iframe>","author_name":"Siobhan Wilson","version":"1.0","author_url":"http://www.youtube.com/user/siobhanwilsonsongs","thumbnail_width":480,"title":"Siobhan Wilson - All Dressed Up","embed_url":"https://www.youtube.com/watch?v=baGfM6dBzs8"}}}}}}'
223
223
  document = Prismic::JsonParser.document_parser(JSON.load(json))
224
- # startgist:d5a6c0715c9a8df984e4:prismic-embed.rb
224
+ # startgist:86d937da7ba242ea981f:prismic-embed.rb
225
225
  video = document.get_embed('article.video')
226
226
  # Html is the code to include to embed the object, and depends on the embedded service
227
227
  html = video ? video.as_html : ''
@@ -232,7 +232,7 @@ describe 'Documentation' do
232
232
  it 'color' do
233
233
  json = '{"id":"abcd","type":"article","href":"","slugs":[],"tags":[],"data":{"article":{"background":{"type":"Color","value":"#000000"}}}}'
234
234
  document = Prismic::JsonParser.document_parser(JSON.load(json))
235
- # startgist:ccafcdcbcd6ef6f2fce8:prismic-color.rb
235
+ # startgist:2b41f3a75f129a0d6903:prismic-color.rb
236
236
  bgcolor = document.get_color('article.background')
237
237
  hex = '#' + (bgcolor ? bgcolor.value : 'FFFFFF')
238
238
  # endgist
@@ -242,7 +242,7 @@ describe 'Documentation' do
242
242
  it 'GeoPoint' do
243
243
  json = '{"id":"abcd","type":"article","href":"","slugs":[],"tags":[],"data":{"article":{"location":{"type":"GeoPoint","value":{"latitude":48.877108,"longitude":2.333879}}}}}'
244
244
  document = Prismic::JsonParser.document_parser(JSON.load(json))
245
- # startgist:c70626752d00669ee18f:prismic-geopoint.rb
245
+ # startgist:f221a2396c079a7d291f:prismic-geopoint.rb
246
246
  # "near" predicate for GeoPoint fragments
247
247
  near = Predicates::near('my.store.location', 48.8768767, 2.3338802, 10)
248
248
 
@@ -259,7 +259,7 @@ describe 'Documentation' do
259
259
  .form('everything')
260
260
  .query(Prismic::Predicates::at('document.id', 'UlfoxUnM0wkXYXbX'))
261
261
  .submit(api.master_ref)
262
- # startgist:7bc04d4690b74e4d4a39:prismic-asHtml.rb
262
+ # startgist:7b93db67fa25ac386603:prismic-asHtml.rb
263
263
  resolver = Prismic.link_resolver('master'){ |doc_link| "http:#localhost/#{doc_link.id}" }
264
264
  doc = response.results[0]
265
265
  html = doc['blog-post.body'].as_html(resolver)
@@ -273,7 +273,7 @@ describe 'Documentation' do
273
273
  .form('everything')
274
274
  .query(Prismic::Predicates::at('document.id', 'UlfoxUnM0wkXYXbX'))
275
275
  .submit(api.master_ref)
276
- # startgist:db34a3847be03315da55:prismic-htmlSerializer.rb
276
+ # startgist:e7944fe6ecdd8956b72:prismic-htmlSerializer.rb
277
277
  resolver = Prismic.link_resolver('master'){ |doc_link| "http:#localhost/#{doc_link.id}" }
278
278
  serializer = Prismic.html_serializer do |element, html|
279
279
  if element.is_a?(Prismic::Fragments::StructuredText::Block::Image)
@@ -284,13 +284,13 @@ describe 'Documentation' do
284
284
  end
285
285
  end
286
286
  doc = response.results[0]
287
- html = doc['blog-post.body'].as_html(resolver, serializer)
287
+ html = doc.get_structured_text('blog-post.body').as_html(resolver, serializer)
288
288
  # endgist
289
289
  html.should_not be_nil
290
290
  end
291
291
 
292
292
  it 'cache' do
293
- # startgist:a6b898cc3af15d7def0a:prismic-cache.rb
293
+ # startgist:388900d4e9e7a444e0a2:prismic-cache.rb
294
294
  # You can pass any object implementing the same methods as the BasicCache
295
295
  # https://github.com/prismicio/ruby-kit/blob/master/lib/prismic/cache/basic.rb
296
296
  cache = Prismic::BasicCache.new
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.1.0
4
+ version: 1.1.1
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: 2014-12-23 00:00:00.000000000 Z
14
+ date: 2015-04-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler