prismic.io 1.0.0.rc9 → 1.0.0.rc10

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: efe6723ef7f29deff32c702fed5695aba28e93f6
4
- data.tar.gz: a2a470960e7065d31ea4f416d07a738bdf3d467f
3
+ metadata.gz: 4ea682bc3f2afcc4da972445dda3adb15eff1549
4
+ data.tar.gz: c47ad3c077959de4f29a90a52249163f69d784ce
5
5
  SHA512:
6
- metadata.gz: 05c234357c7f80ee100af6471632a5b8defa792ab7dd3def6db15442a0b3a115b0a8c38864f87e37ce755c7516f99e114db0fccb91ed2d1e592b70a7ea8ef655
7
- data.tar.gz: 0b4d361e0a79ea6d86795133b16499e6e8c8a844e40be2f681be66269b2ee4c5518971e054bb7c820d029d5bfc0613211ca5db40538f7ebe350ab381398db9a4
6
+ metadata.gz: 7067ccbd2b56755280c0fdc734adc14dee3c0a1ca9abe6e5462e0eeffef26dfb38f8fe32091a8de5e46b032a2c46d4037d93f48fd76fb82a9c81b942a3a1d7ea
7
+ data.tar.gz: a7436d00a195ebd14ce978e11b65c52b0bd43b60ab77637d20bd88ccecaa78871faccb49539c4bfb5db0d4b9ee36e898ebf13568121551cb3c2a6c3afadcff55
data/.travis.yml CHANGED
@@ -1,12 +1,20 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.1
4
- - 2.1.0
5
- - 2.0.0
6
- - 1.9.3
7
- - 1.9.2
8
- - jruby-19mode
3
+ - 2.1.1
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ - jruby-19mode
9
9
  script: bundle exec rspec spec
10
10
  notifications:
11
11
  email:
12
- - evo@zenexity.com
12
+ - evo@zenexity.com
13
+ deploy:
14
+ provider: rubygems
15
+ api_key:
16
+ secure: TBCtAi8FnlHzuiv86Me/YpMdGeAiG9d+J3ZpxWIY32jJv+t8dsW8Fej4jhGSW0aarPT7sarXan6cez0ssSDObUwWMYJfshmMsKykTi6TW4US2ZXtWxtglABYK2DJ/8N1fgkdXKO0NRMF7RVUoJNSw+91GX7ug/obNiCcmG/ms5I=
17
+ gemspec: prismic.gemspec
18
+ on:
19
+ tags: true
20
+ repo: prismicio/ruby-kit
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem "yajl-ruby", require: 'yajl', platforms: [:ruby_19, :ruby_20]
7
+ gem "yajl-ruby", require: 'yajl', platforms: [:ruby_19, :ruby_20, :ruby_21]
8
8
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prismic.io (1.0.0.rc8)
4
+ prismic.io (1.0.0.rc10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/prismic.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # encoding: utf-8
2
+ require 'cgi'
2
3
  require 'net/http'
3
4
  require 'uri'
4
5
 
6
+ require 'json' unless defined?(JSON)
7
+
5
8
  module Prismic
6
9
 
7
10
  # These exception can contains an error cause and is able to show them
@@ -231,6 +234,23 @@ module Prismic
231
234
  # @return [Response] The results (array of Document object + pagination
232
235
  # specifics)
233
236
  def submit(ref = nil)
237
+ Prismic::JsonParser.response_parser(JSON.load(submit_raw(ref)))
238
+ end
239
+
240
+ # Submit the form, returns a raw JSON string
241
+ # @api
242
+ #
243
+ # @note The reference MUST be defined, either by:
244
+ #
245
+ # - setting it at {API#create_search_form creation}
246
+ # - using the {#ref} method
247
+ # - providing the ref parameter.
248
+ #
249
+ # @param ref [Ref, String] The {Ref reference} to use (if not already
250
+ # defined)
251
+ #
252
+ # @return [string] The JSON string returned by the API
253
+ def submit_raw(ref = nil)
234
254
  self.ref(ref) if ref
235
255
  data['ref'] = @ref
236
256
  raise NoRefSetException unless @ref
@@ -246,9 +266,9 @@ module Prismic
246
266
  response = api.http_client.get(form_action, data, 'Accept' => 'application/json')
247
267
 
248
268
  if response.code.to_s == "200"
249
- Prismic::JsonParser.response_parser(JSON.parse(response.body))
269
+ response.body
250
270
  else
251
- body = JSON.parse(response.body) rescue nil
271
+ body = JSON.load(response.body) rescue nil
252
272
  error = body.is_a?(Hash) ? body['error'] : response.body
253
273
  raise AuthenticationException, error if response.code.to_s == "401"
254
274
  raise AuthorizationException, error if response.code.to_s == "403"
data/lib/prismic/api.rb CHANGED
@@ -230,7 +230,7 @@ module Prismic
230
230
  res = http_client.post(token, params)
231
231
  if res.code == '200'
232
232
  begin
233
- JSON.parse(res.body)['access_token']
233
+ JSON.load(res.body)['access_token']
234
234
  rescue Exception => e
235
235
  raise PrismicWSConnectionError.new(res, e)
236
236
  end
@@ -3,6 +3,7 @@ require 'prismic/fragments/fragment'
3
3
  require 'prismic/fragments/color'
4
4
  require 'prismic/fragments/date'
5
5
  require 'prismic/fragments/embed'
6
+ require 'prismic/fragments/geopoint'
6
7
  require 'prismic/fragments/group'
7
8
  require 'prismic/fragments/image'
8
9
  require 'prismic/fragments/link'
@@ -11,3 +12,4 @@ require 'prismic/fragments/number'
11
12
  require 'prismic/fragments/select'
12
13
  require 'prismic/fragments/structured_text'
13
14
  require 'prismic/fragments/text'
15
+ require 'prismic/fragments/timestamp'
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ module Prismic
3
+ module Fragments
4
+ class GeoPoint < Fragment
5
+ attr_accessor :longitude, :latitude
6
+
7
+ def initialize(longitude, latitude)
8
+ @longitude = longitude
9
+ @latitude = latitude
10
+ end
11
+
12
+ # Generate an HTML representation of the fragment
13
+ #
14
+ # @param link_resolver [LinkResolver] The LinkResolver used to build
15
+ # application's specific URL
16
+ #
17
+ # @return [String] the HTML representation
18
+ def as_html(link_resolver=nil)
19
+ %(<div class="geopoint"><span class="longitude">#@longitude</span><span class="latitude">#@latitude</span></div>)
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -26,14 +26,15 @@ module Prismic
26
26
  class ViewDoesNotExistException < Error ; end
27
27
 
28
28
  class View < Fragment
29
- attr_accessor :url, :width, :height, :alt, :copyright
29
+ attr_accessor :url, :width, :height, :alt, :copyright, :link_to
30
30
 
31
- def initialize(url, width, height, alt, copyright)
31
+ def initialize(url, width, height, alt, copyright, link_to)
32
32
  @url = url
33
33
  @width = width
34
34
  @height = height
35
35
  @alt = alt
36
36
  @copyright = copyright
37
+ @link_to = link_to
37
38
  end
38
39
 
39
40
  def ratio
@@ -41,7 +42,11 @@ module Prismic
41
42
  end
42
43
 
43
44
  def as_html(link_resolver=nil)
44
- %(<img src="#@url" alt="#@alt" width="#@width" height="#@height" />)
45
+ html = []
46
+ html << (link_to.nil? ? '' : link_to.start_html(link_resolver))
47
+ html << %(<img src="#@url" alt="#@alt" width="#@width" height="#@height" />)
48
+ html << (link_to.nil? ? '' : link_to.end_html)
49
+ html.join
45
50
  end
46
51
 
47
52
  end
@@ -113,7 +113,7 @@ module Prismic
113
113
  "</strong>"
114
114
  end
115
115
  end
116
-
116
+
117
117
  class Hyperlink < Span
118
118
  attr_accessor :link
119
119
  def initialize(start, finish, link)
@@ -156,12 +156,20 @@ module Prismic
156
156
  # Initializing the browsing of the string
157
157
  output = []
158
158
  cursor = 0
159
+ tags = [] # the seen tags
159
160
 
160
161
  # Taking each text cut and inserting the closing tags and the opening tags if needed
161
162
  all_cuts.each do |cut|
162
163
  output << CGI::escapeHTML(text[cursor, cut-cursor])
163
- output << end_spans[cut].map{|span| span.end_html} # this pushes an array into the array; we'll need to flatten later
164
- output << start_spans[cut].map{|span| span.start_html(link_resolver)} # this pushes an array into the array; we'll need to flatten later
164
+ end_tags = end_spans[cut]
165
+ # reorder endings tags using creating order
166
+ split = tags.group_by {|t| end_tags.include?(t) }
167
+ end_tags, tags = split[true]||[], split[false]||[]
168
+ output += end_tags.map{|span| span.end_html }
169
+ # store created tags (in the right order)
170
+ start_tags = start_spans[cut].sort_by{|s| s.end }.reverse
171
+ tags += start_tags.reverse
172
+ output += start_tags.map{|span| span.start_html(link_resolver) }
165
173
  cursor = cut # cursor is now where the cut was
166
174
  end
167
175
 
@@ -169,7 +177,7 @@ module Prismic
169
177
  output << text[cursor..-1]
170
178
 
171
179
  # Making the array into a string
172
- output.flatten.join
180
+ output.join
173
181
 
174
182
  end
175
183
 
@@ -264,6 +272,10 @@ module Prismic
264
272
  @view.copyright
265
273
  end
266
274
 
275
+ def link_to
276
+ @view.link_to
277
+ end
278
+
267
279
  def as_html(link_resolver)
268
280
  view.as_html(link_resolver)
269
281
  end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ module Prismic
3
+ module Fragments
4
+ class Timestamp < Fragment
5
+ attr_accessor :value
6
+
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ # Generate an HTML representation of the fragment
12
+ #
13
+ # @param link_resolver [LinkResolver] The LinkResolver used to build
14
+ # application's specific URL
15
+ #
16
+ # @return [String] the HTML representation
17
+ def as_html(link_resolver=nil)
18
+ %(<time>#{value.iso8601(3)}</time>)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -8,11 +8,13 @@ module Prismic
8
8
  'Link.document' => method(:document_link_parser),
9
9
  'Text' => method(:text_parser),
10
10
  'Link.web' => method(:web_link_parser),
11
- 'Link.image' => method(:image_link_parser),
12
- 'Link.file' => method(:file_link_parser),
11
+ 'Link.image' => method(:image_link_parser),
12
+ 'Link.file' => method(:file_link_parser),
13
13
  'Date' => method(:date_parser),
14
+ 'Timestamp' => method(:timestamp_parser),
14
15
  'Number' => method(:number_parser),
15
16
  'Embed' => method(:embed_parser),
17
+ 'GeoPoint' => method(:geo_point_parser),
16
18
  'Image' => method(:image_parser),
17
19
  'Color' => method(:color_parser),
18
20
  'StructuredText' => method(:structured_text_parser),
@@ -56,6 +58,10 @@ module Prismic
56
58
  Prismic::Fragments::Date.new(Time.parse(json['value']))
57
59
  end
58
60
 
61
+ def timestamp_parser(json)
62
+ Prismic::Fragments::Timestamp.new(Time.parse(json['value']))
63
+ end
64
+
59
65
  def number_parser(json)
60
66
  Prismic::Fragments::Number.new(json['value'])
61
67
  end
@@ -71,13 +77,21 @@ module Prismic
71
77
  )
72
78
  end
73
79
 
80
+ def geo_point_parser(json)
81
+ Prismic::Fragments::GeoPoint.new(
82
+ json['value']['longitude'],
83
+ json['value']['latitude']
84
+ )
85
+ end
86
+
74
87
  def image_parser(json)
75
88
  def self.view_parser(json)
76
89
  Prismic::Fragments::Image::View.new(json['url'],
77
90
  json['dimensions']['width'],
78
91
  json['dimensions']['height'],
79
92
  json['alt'],
80
- json['copyright'])
93
+ json['copyright'],
94
+ json['linkTo'] ? link_parser(json['linkTo']) : nil)
81
95
  end
82
96
 
83
97
  main = view_parser(json['value']['main'])
@@ -143,7 +157,8 @@ module Prismic
143
157
  block['dimensions']['width'],
144
158
  block['dimensions']['height'],
145
159
  block['alt'],
146
- block['copyright']
160
+ block['copyright'],
161
+ block['linkTo'] ? link_parser(block['linkTo']) : nil
147
162
  )
148
163
  Prismic::Fragments::StructuredText::Block::Image.new(view)
149
164
  when 'embed'
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Prismic
3
3
 
4
- VERSION = "1.0.0.rc9"
4
+ VERSION = "1.0.0.rc10"
5
5
 
6
6
  end
data/prismic.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'prismic/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "prismic.io"
8
8
  spec.version = Prismic::VERSION
9
- spec.authors = ["Étienne Vallette d'Osia", "Samy Dindane"]
9
+ spec.authors = ["Étienne Vallette d'Osia", "Samy Dindane", "Rudy Rigot"]
10
10
  spec.email = ["evo@zenexity.com"]
11
11
  spec.description = %q{The standard Prismic.io's API library.}
12
12
  spec.summary = %q{Prismic.io development kit}
@@ -1,6 +1,13 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
+ def em(start, stop)
5
+ Prismic::Fragments::StructuredText::Span::Em.new(start, stop)
6
+ end
7
+ def strong(start, stop)
8
+ Prismic::Fragments::StructuredText::Span::Strong.new(start, stop)
9
+ end
10
+
4
11
  describe 'WebLink' do
5
12
  before do
6
13
  @web_link = Prismic::Fragments::WebLink.new('my_url')
@@ -98,7 +105,7 @@ describe 'FileLink' do
98
105
  describe 'in structured texts' do
99
106
  before do
100
107
  @raw_json_structured_text = File.read("#{File.dirname(__FILE__)}/responses_mocks/structured_text_linkfile.json")
101
- @json_structured_text = JSON.parse(@raw_json_structured_text)
108
+ @json_structured_text = JSON.load(@raw_json_structured_text)
102
109
  @structured_text = Prismic::JsonParser.structured_text_parser(@json_structured_text)
103
110
  end
104
111
  it 'serializes well into HTML' do
@@ -111,7 +118,7 @@ describe 'Span' do
111
118
  describe 'in structured texts when end is at the end of line' do
112
119
  before do
113
120
  @raw_json_structured_text = File.read("#{File.dirname(__FILE__)}/responses_mocks/structured_text_with_tricky_spans.json")
114
- @json_structured_text = JSON.parse(@raw_json_structured_text)
121
+ @json_structured_text = JSON.load(@raw_json_structured_text)
115
122
  @structured_text = Prismic::JsonParser.structured_text_parser(@json_structured_text)
116
123
  end
117
124
  it 'serializes well into HTML' do
@@ -121,7 +128,7 @@ describe 'Span' do
121
128
  describe 'in structured texts when multiple spans' do
122
129
  before do
123
130
  @raw_json_structured_text = File.read("#{File.dirname(__FILE__)}/responses_mocks/structured_text_paragraph.json")
124
- @json_structured_text = JSON.parse(@raw_json_structured_text)
131
+ @json_structured_text = JSON.load(@raw_json_structured_text)
125
132
  @structured_text = Prismic::JsonParser.structured_text_parser(@json_structured_text)
126
133
  end
127
134
  it 'serializes well into HTML' do
@@ -394,7 +401,7 @@ describe 'Image::View' do
394
401
  @url = 'my_url'
395
402
  @width = 10
396
403
  @height = 2
397
- @view = Prismic::Fragments::Image::View.new(@url, @width, @height, "", "")
404
+ @view = Prismic::Fragments::Image::View.new(@url, @width, @height, "", "", nil)
398
405
  end
399
406
 
400
407
  describe 'ratio' do
@@ -440,8 +447,8 @@ end
440
447
 
441
448
  describe 'Image' do
442
449
  before do
443
- @main_view = Prismic::Fragments::Image::View.new('my_url', 10, 10, "Alternative", "CC-BY")
444
- @another_view = Prismic::Fragments::Image::View.new('my_url2', 20, 20, "", "")
450
+ @main_view = Prismic::Fragments::Image::View.new('my_url', 10, 10, "Alternative", "CC-BY", nil)
451
+ @another_view = Prismic::Fragments::Image::View.new('my_url2', 20, 20, "", "", nil)
445
452
  @image = Prismic::Fragments::Image.new(@main_view, { 'another_view' => @another_view })
446
453
  end
447
454
 
@@ -501,63 +508,75 @@ end
501
508
  describe 'StructuredText::Heading' do
502
509
  before do
503
510
  @text = "This is a simple test."
504
- @spans = [
505
- Prismic::Fragments::StructuredText::Span::Em.new(5, 7),
506
- Prismic::Fragments::StructuredText::Span::Strong.new(8, 9),
507
- ]
511
+ @spans = [em(5, 7), strong(8, 9)]
508
512
  end
513
+ let :block do Prismic::Fragments::StructuredText::Block::Heading.new(@text, @spans, @heading) end
509
514
  it 'generates valid h1 html' do
510
515
  @heading = 1
511
- @block = Prismic::Fragments::StructuredText::Block::Heading.new(@text, @spans, @heading)
512
- @block.as_html(nil).should == "<h1>This <em>is</em> <strong>a</strong> simple test.</h1>"
516
+ block.as_html(nil).should == "<h1>This <em>is</em> <strong>a</strong> simple test.</h1>"
513
517
  end
514
518
  it 'generates valid h2 html' do
515
519
  @heading = 2
516
- @block = Prismic::Fragments::StructuredText::Block::Heading.new(@text, @spans, @heading)
517
- @block.as_html(nil).should == "<h2>This <em>is</em> <strong>a</strong> simple test.</h2>"
520
+ block.as_html(nil).should == "<h2>This <em>is</em> <strong>a</strong> simple test.</h2>"
518
521
  end
519
522
  end
520
523
 
521
524
  describe 'StructuredText::Paragraph' do
522
- before do
523
- @text = "This is a simple test."
524
- @spans = [
525
- Prismic::Fragments::StructuredText::Span::Em.new(5, 7),
526
- Prismic::Fragments::StructuredText::Span::Strong.new(8, 9),
527
- ]
528
- @block = Prismic::Fragments::StructuredText::Block::Paragraph.new(@text, @spans)
529
- end
525
+ let :block do Prismic::Fragments::StructuredText::Block::Paragraph.new(@text, @spans) end
530
526
  it 'generates valid html' do
531
- @block.as_html(nil).should == "<p>This <em>is</em> <strong>a</strong> simple test.</p>"
527
+ @text = "This is a simple test."
528
+ @spans = [em(5, 7), strong(8, 9)]
529
+ block.as_html(nil).should == "<p>This <em>is</em> <strong>a</strong> simple test.</p>"
532
530
  end
533
531
  it "espaces HTML content" do
534
- @text = '&my <value> #abcde'
535
- @spans = [
536
- Prismic::Fragments::StructuredText::Span::Em.new(4, 11),
537
- Prismic::Fragments::StructuredText::Span::Strong.new(0, 1),
538
- ]
539
- @block = Prismic::Fragments::StructuredText::Block::Paragraph.new(@text, @spans)
540
- @block.as_html(nil).should =~ %r{^<[^>]+><strong>&amp;</strong>my <em>&lt;value&gt;</em> #abcde<[^>]+>$}
532
+ @text = '&my <value> #abcde'
533
+ @spans = [em(4, 11), strong(0, 1)]
534
+ block.as_html(nil).should =~ %r{^<[^>]+><strong>&amp;</strong>my <em>&lt;value&gt;</em> #abcde<[^>]+>$}
535
+ end
536
+ it "espaces HTML content (many spans)" do
537
+ @text = 'abcdefghijklmnopqrstuvwxyz'
538
+ @spans = [em(1, 3), strong(5, 7), em(9, 11), strong(13, 15)]
539
+ block.as_html(nil).should =~ %r{^<[^>]+>a<em>bc</em>de<strong>fg</strong>hi<em>jk</em>lm<strong>no</strong>pqrstuvwxyz<[^>]+>$}
540
+ end
541
+ it "espaces HTML content (empty spans)" do
542
+ @text = 'abcdefghijklmnopqrstuvwxyz'
543
+ @spans = [em(2, 2)]
544
+ block.as_html(nil).should =~ %r{^<[^>]+>abcdefghijklmnopqrstuvwxyz<[^>]+>$}
545
+ end
546
+ it "espaces HTML content (2 spans on the same text)" do
547
+ @text = 'abcdefghijklmnopqrstuvwxyz'
548
+ @spans = [em(2, 4), strong(2, 4)]
549
+ block.as_html(nil).should =~ %r{^<[^>]+>ab<strong><em>cd</em></strong>efghijklmnopqrstuvwxyz<[^>]+>$}
550
+ end
551
+ it "espaces HTML content (2 spans on the same text - one bigger 1)" do
552
+ @text = 'abcdefghijklmnopqrstuvwxyz'
553
+ @spans = [em(2, 6), strong(2, 4)]
554
+ block.as_html(nil).should =~ %r{^<[^>]+>ab<em><strong>cd</strong>ef</em>ghijklmnopqrstuvwxyz<[^>]+>$}
555
+ end
556
+ it "espaces HTML content (2 spans on the same text - one bigger 2)" do
557
+ @text = 'abcdefghijklmnopqrstuvwxyz'
558
+ @spans = [em(2, 4), strong(2, 6)]
559
+ block.as_html(nil).should =~ %r{^<[^>]+>ab<strong><em>cd</em>ef</strong>ghijklmnopqrstuvwxyz<[^>]+>$}
560
+ end
561
+ it "espaces HTML content (span next to span)" do
562
+ @text = 'abcdefghijklmnopqrstuvwxyz'
563
+ @spans = [em(2, 4), strong(4, 6)]
564
+ block.as_html(nil).should =~ %r{^<[^>]+>ab<em>cd</em><strong>ef</strong>ghijklmnopqrstuvwxyz<[^>]+>$}
541
565
  end
542
566
  end
543
567
 
544
568
  describe 'StructuredText::Preformatted' do
545
- before do
546
- @text = "This is a simple test."
547
- @spans = [
548
- Prismic::Fragments::StructuredText::Span::Em.new(5, 7),
549
- Prismic::Fragments::StructuredText::Span::Strong.new(8, 9),
550
- ]
551
- @block = Prismic::Fragments::StructuredText::Block::Preformatted.new(@text, @spans)
552
- end
569
+ let :block do Prismic::Fragments::StructuredText::Block::Preformatted.new(@text, @spans) end
553
570
  it 'generates valid html' do
554
- @block.as_html(nil).should == "<pre>This <em>is</em> <strong>a</strong> simple test.</pre>"
571
+ @text = "This is a simple test."
572
+ @spans = [em(5, 7), strong(8, 9)]
573
+ block.as_html(nil).should == "<pre>This <em>is</em> <strong>a</strong> simple test.</pre>"
555
574
  end
556
575
  end
557
576
 
558
577
  describe 'StructuredText::Image' do
559
578
  before do
560
- @view = Prismic::Fragments::Image::View.new('my_url', 10, 10, "Aternative", "CC-BY")
579
+ @view = Prismic::Fragments::Image::View.new('my_url', 10, 10, "Aternative", "CC-BY", nil)
561
580
  @image = Prismic::Fragments::StructuredText::Block::Image.new(@view)
562
581
  end
563
582
 
@@ -599,7 +618,7 @@ describe 'StructuredText::Hyperlink' do
599
618
  "product",
600
619
  ["Macaron"],
601
620
  "dark-chocolate-macaron",
602
- false # broken
621
+ false # not broken
603
622
  )
604
623
  @hyperlink = Prismic::Fragments::StructuredText::Span::Hyperlink.new(0, 0, @link)
605
624
  @link_resolver = Prismic.link_resolver("master"){|doc_link| "http://localhost/#{doc_link.id}" }
@@ -671,4 +690,4 @@ describe 'Group' do
671
690
  @docchapter['docchapter.docs'][0].size.should == 1
672
691
  end
673
692
 
674
- end
693
+ end
@@ -17,7 +17,7 @@ describe 'document_link_parser' do
17
17
  }
18
18
  }
19
19
  json
20
- @json = JSON.parse(raw_json)
20
+ @json = JSON.load(raw_json)
21
21
  end
22
22
 
23
23
  it "correctly parses DocumentLinks" do
@@ -38,7 +38,7 @@ describe 'text_parser' do
38
38
  "value": "New York City, NY"
39
39
  }
40
40
  json
41
- @json = JSON.parse(raw_json)
41
+ @json = JSON.load(raw_json)
42
42
  end
43
43
 
44
44
  it "correctly parses Text objects" do
@@ -57,7 +57,7 @@ describe 'web_link_parser' do
57
57
  }
58
58
  }
59
59
  json
60
- @json = JSON.parse(raw_json)
60
+ @json = JSON.load(raw_json)
61
61
  end
62
62
 
63
63
  it "correctly parses WebLinks objects" do
@@ -74,7 +74,7 @@ describe 'date_parser' do
74
74
  "value": "2013-09-19"
75
75
  }
76
76
  json
77
- @json = JSON.parse(raw_json)
77
+ @json = JSON.load(raw_json)
78
78
  end
79
79
 
80
80
  it "correctly parses Date objects" do
@@ -91,7 +91,7 @@ describe 'number_parser' do
91
91
  "value": 3.55
92
92
  }
93
93
  json
94
- @json = JSON.parse(raw_json)
94
+ @json = JSON.load(raw_json)
95
95
  end
96
96
 
97
97
  it "correctly parses Number objects" do
@@ -123,7 +123,7 @@ describe 'embed_parser' do
123
123
  }
124
124
  }
125
125
  json
126
- @json = JSON.parse(raw_json)
126
+ @json = JSON.load(raw_json)
127
127
  end
128
128
 
129
129
  it "correctly parses Embed objects" do
@@ -164,7 +164,7 @@ describe 'image_parser' do
164
164
  }
165
165
  }
166
166
  json
167
- @json = JSON.parse(raw_json)
167
+ @json = JSON.load(raw_json)
168
168
  end
169
169
 
170
170
  it "correctly parses Image objects" do
@@ -182,6 +182,59 @@ json
182
182
  end
183
183
  end
184
184
 
185
+ describe 'geo_point_parser' do
186
+ before do
187
+ raw_json = File.read("#{File.dirname(__FILE__)}/responses_mocks/document.json")
188
+ json = JSON.load(raw_json)
189
+ @document = Prismic::JsonParser.document_parser(json)
190
+ end
191
+
192
+ it 'correctly parses GeoPoint objects' do
193
+ @document['product.location'].latitude.should == 48.877108
194
+ @document['product.location'].longitude.should == -2.333879
195
+ end
196
+
197
+ it 'correctly serializes GeoPoint objects into HTML' do
198
+ @document['product.location'].as_html.should == "<div class=\"geopoint\"><span class=\"longitude\">-2.333879</span><span class=\"latitude\">48.877108</span></div>"
199
+ end
200
+ end
201
+
202
+ describe 'image_parser in StructuredText' do
203
+ before do
204
+ raw_json = File.read("#{File.dirname(__FILE__)}/responses_mocks/document.json")
205
+ json = JSON.load(raw_json)
206
+ @document = Prismic::JsonParser.document_parser(json)
207
+ @image_st = @document['product.linked_images']
208
+ end
209
+
210
+ it 'parses properly with links' do
211
+ @image_st.blocks[2].link_to.url.should == 'http://google.com/'
212
+ end
213
+
214
+ it 'parses properly without links' do
215
+ @image_st.blocks[5].link_to.should be_nil
216
+ end
217
+
218
+ it 'serializes properly as HTML' do
219
+ expected = <<expected
220
+ <p>Here is some introductory text.</p>
221
+
222
+ <p>The following image is linked.</p>
223
+
224
+ <a href="http://google.com/"><img src="http://fpoimg.com/129x260" alt="" width="260" height="129" /></a>
225
+
226
+ <p><strong>More important stuff</strong></p>
227
+
228
+ <p>One more image, this one is not linked:</p>
229
+
230
+ <img src="http://fpoimg.com/199x300" alt="" width="300" height="199" />
231
+ expected
232
+ expected.chomp!
233
+ link_resolver = Prismic.link_resolver("master"){|doc_link| "http://localhost/#{doc_link.id}" }
234
+ @image_st.as_html(link_resolver).should == expected
235
+ end
236
+ end
237
+
185
238
  describe 'color_parser' do
186
239
  before do
187
240
  raw_json = <<json
@@ -190,7 +243,7 @@ describe 'color_parser' do
190
243
  "value": "#ffeacd"
191
244
  }
192
245
  json
193
- @json = JSON.parse(raw_json)
246
+ @json = JSON.load(raw_json)
194
247
  end
195
248
 
196
249
  it "correctly parses Color objects" do
@@ -214,7 +267,7 @@ describe 'file_link_parser' do
214
267
  }
215
268
  }
216
269
  json
217
- @json = JSON.parse(raw_json)
270
+ @json = JSON.load(raw_json)
218
271
  @link_file = Prismic::JsonParser.file_link_parser(@json)
219
272
  end
220
273
 
@@ -230,11 +283,11 @@ end
230
283
  describe 'structured_text_parser' do
231
284
  before do
232
285
  raw_json_paragraph = File.read("#{File.dirname(__FILE__)}/responses_mocks/structured_text_paragraph.json")
233
- json_paragraph = JSON.parse(raw_json_paragraph)
286
+ json_paragraph = JSON.load(raw_json_paragraph)
234
287
  @structured_text_paragraph = Prismic::JsonParser.structured_text_parser(json_paragraph)
235
288
 
236
289
  raw_json_heading = File.read("#{File.dirname(__FILE__)}/responses_mocks/structured_text_heading.json")
237
- json_heading = JSON.parse(raw_json_heading)
290
+ json_heading = JSON.load(raw_json_heading)
238
291
  @structured_text_heading = Prismic::JsonParser.structured_text_parser(json_heading)
239
292
  end
240
293
 
@@ -246,7 +299,7 @@ describe 'structured_text_parser' do
246
299
  end
247
300
 
248
301
  it "correctly parses >h9 heading" do
249
- json_heading = JSON.parse(<<-JSON)
302
+ json_heading = JSON.load(<<-JSON)
250
303
  {
251
304
  "type": "StructuredText",
252
305
  "value": [{
@@ -298,7 +351,7 @@ end
298
351
  describe 'document_parser' do
299
352
  before do
300
353
  raw_json = File.read("#{File.dirname(__FILE__)}/responses_mocks/document.json")
301
- json = JSON.parse(raw_json)
354
+ json = JSON.load(raw_json)
302
355
  @document = Prismic::JsonParser.document_parser(json)
303
356
  end
304
357
 
@@ -311,7 +364,7 @@ describe 'document_parser' do
311
364
  end
312
365
 
313
366
  it "correctly parses the document's fragments" do
314
- @document.fragments.size.should == 11
367
+ @document.fragments.size.should == 14
315
368
  @document.fragments['name'].should be_a Prismic::Fragments::StructuredText
316
369
  end
317
370
  end
@@ -319,7 +372,7 @@ end
319
372
  describe 'response_parser' do
320
373
 
321
374
  it "accepts basic documents response" do
322
- @json = JSON.parse('{ "page": 1,
375
+ @json = JSON.load('{ "page": 1,
323
376
  "results_per_page": 20,
324
377
  "results_size": 20,
325
378
  "total_results_size": 40,
@@ -354,7 +407,7 @@ describe 'multiple_parser' do
354
407
  }
355
408
  ]
356
409
  json
357
- @json = JSON.parse(raw_json)
410
+ @json = JSON.load(raw_json)
358
411
  end
359
412
 
360
413
  it "correctly parses the Multiple object's elements" do
@@ -365,14 +418,32 @@ json
365
418
  end
366
419
  end
367
420
 
421
+ describe 'timestamp_parser' do
422
+ before do
423
+ raw_json = File.read("#{File.dirname(__FILE__)}/responses_mocks/document.json")
424
+ json = JSON.load(raw_json)
425
+ @document = Prismic::JsonParser.document_parser(json)
426
+ @timestamp_fragment = @document['product.some_timestamp']
427
+ end
428
+
429
+ it 'correctly parses and stores a Time object' do
430
+ @timestamp_fragment.value.utc.wednesday?.should == true
431
+ @timestamp_fragment.value.min.should == 30
432
+ end
433
+
434
+ it 'outputs correctly as HTML' do
435
+ @timestamp_fragment.as_html.should match /<time>2014-06-1\dT\d{2}:30:00\.000[-+]\d{2}:00<\/time>/
436
+ end
437
+ end
438
+
368
439
  describe 'unknown_parser' do
369
440
  before do
370
441
  @raw_json = File.read("#{File.dirname(__FILE__)}/responses_mocks/document_with_unknown_fragment.json")
371
- @json = JSON.parse(@raw_json)
442
+ @json = JSON.load(@raw_json)
372
443
  end
373
444
 
374
445
  it "raises the proper error" do
375
446
  Prismic::JsonParser.should_receive(:warn).with("Type blabla is unknown, fragment was skipped; perhaps you should update your prismic.io gem?")
376
447
  Prismic::JsonParser.document_parser(@json).fragments.size.should == 2
377
448
  end
378
- end
449
+ end
@@ -51,7 +51,7 @@ describe 'LesBonnesChoses' do
51
51
  documents.results_size.should == 20
52
52
  documents.total_results_size.should == 40
53
53
  documents.total_pages.should == 2
54
- documents.next_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UkL0hcuvzYUANCrm&page=2&pageSize=20"
54
+ documents.next_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UlfoxUnM08QWYXdl&page=2&pageSize=20"
55
55
  documents.prev_page.should == nil
56
56
  end
57
57
  it "works on page 2" do
@@ -62,7 +62,7 @@ describe 'LesBonnesChoses' do
62
62
  documents.total_results_size.should == 40
63
63
  documents.total_pages.should == 2
64
64
  documents.next_page.should == nil
65
- documents.prev_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UkL0hcuvzYUANCrm&page=1&pageSize=20"
65
+ documents.prev_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UlfoxUnM08QWYXdl&page=1&pageSize=20"
66
66
  end
67
67
  it "works on page 2 with a pagination step of 10" do
68
68
  documents = @api.form("everything").page("2").page_size("10").submit(@master_ref)
@@ -71,14 +71,14 @@ describe 'LesBonnesChoses' do
71
71
  documents.results_size.should == 10
72
72
  documents.total_results_size.should == 40
73
73
  documents.total_pages.should == 4
74
- documents.next_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UkL0hcuvzYUANCrm&page=3&pageSize=10"
75
- documents.prev_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UkL0hcuvzYUANCrm&page=1&pageSize=10"
74
+ documents.next_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UlfoxUnM08QWYXdl&page=3&pageSize=10"
75
+ documents.prev_page.should == "https://lesbonneschoses.prismic.io/api/documents/search?ref=UlfoxUnM08QWYXdl&page=1&pageSize=10"
76
76
  end
77
77
  end
78
78
 
79
79
  describe 'API::Document' do
80
80
  before do
81
- @document = @api.form('everything').query(%([[:d = at(document.id, "UkL0gMuvzYUANCpf")]])).submit(@master_ref)[0]
81
+ @document = @api.form('everything').query(%([[:d = at(document.id, "UlfoxUnM0wkXYXbh")]])).submit(@master_ref)[0]
82
82
  end
83
83
 
84
84
  it 'Operator [] works on document' do
@@ -111,10 +111,10 @@ describe 'LesBonnesChoses' do
111
111
  it 'has a proper each method' do
112
112
  array = []
113
113
  @documents.each {|document| array << document.slug }
114
- array.join(' ').should == 'pastry-dresser exotic-kiwi-pie apricot-pie sweet-strawberry-pie woodland-cherry-pie cool-coconut-macaron salted-caramel-macaron the-end-of-a-chapter-the-beginning-of-a-new-one get-the-right-approach-to-ganache one-day-in-the-life-of-a-les-bonnes-choses-pastry les-bonnes-chosess-internship-a-testimony our-world-famous-pastry-art-brainstorm-event tips-to-dress-a-pastry triple-chocolate-cupcake dont-be-a-stranger about-us wedding-gift-box art-director store-intern content-director'
114
+ array.join(' ').should == 'art-director store-intern content-director ganache-specialist community-manager oven-instrumentist paris-saint-lazare tokyo-roppongi-hills london-covent-garden paris-champ-elysees new-york-fifth-avenue pastry-dresser exotic-kiwi-pie apricot-pie sweet-strawberry-pie woodland-cherry-pie cool-coconut-macaron salted-caramel-macaron the-end-of-a-chapter-the-beginning-of-a-new-one get-the-right-approach-to-ganache'
115
115
  end
116
116
  it 'is a proper Enumerable' do
117
- @documents.map {|document| document.slug }.join(' ').should == 'pastry-dresser exotic-kiwi-pie apricot-pie sweet-strawberry-pie woodland-cherry-pie cool-coconut-macaron salted-caramel-macaron the-end-of-a-chapter-the-beginning-of-a-new-one get-the-right-approach-to-ganache one-day-in-the-life-of-a-les-bonnes-choses-pastry les-bonnes-chosess-internship-a-testimony our-world-famous-pastry-art-brainstorm-event tips-to-dress-a-pastry triple-chocolate-cupcake dont-be-a-stranger about-us wedding-gift-box art-director store-intern content-director'
117
+ @documents.map {|document| document.slug }.join(' ').should == 'art-director store-intern content-director ganache-specialist community-manager oven-instrumentist paris-saint-lazare tokyo-roppongi-hills london-covent-garden paris-champ-elysees new-york-fifth-avenue pastry-dresser exotic-kiwi-pie apricot-pie sweet-strawberry-pie woodland-cherry-pie cool-coconut-macaron salted-caramel-macaron the-end-of-a-chapter-the-beginning-of-a-new-one get-the-right-approach-to-ganache'
118
118
  end
119
119
  end
120
120
 
@@ -125,23 +125,23 @@ describe 'LesBonnesChoses' do
125
125
  describe 'API::Fragments::StructuredText' do
126
126
  it "returns a correct as_html on a StructuredText with list, span, embed and image" do
127
127
  @api.form("everything")
128
- .query(%([[:d = at(document.id, "UkL0gMuvzYUANCpr")]]))
128
+ .query(%([[:d = at(document.id, "UlfoxUnM0wkXYXbX")]]))
129
129
  .submit(@master_ref)[0]['blog-post.body'].as_html(@link_resolver).gsub("&#39;", "'").should == "<h1>Get the right approach to ganache</h1>\n\n<p>A lot of people touch base with us to know about one of our key ingredients, and the essential role it plays in our creations: ganache.</p>\n\n<p>Indeed, ganache is the macaron's softener, or else, macarons would be but tough biscuits; it is the cupcake's wrapper, or else, cupcakes would be but plain old cake. We even sometimes use ganache within our cupcakes, to soften the cake itself, or as a support to our pies' content.</p>\n\n<h2>How to approach ganache</h2>\n\n<img src=\"https://prismic-io.s3.amazonaws.com/lesbonneschoses/ee7b984b98db4516aba2eabd54ab498293913c6c.jpg\" alt=\"\" width=\"640\" height=\"425\" />\n\n<p>Apart from the taste balance, which is always a challenge when it comes to pastry, the tough part about ganache is about thickness. It is even harder to predict through all the phases the ganache gets to meet (how long will it get melted? how long will it remain in the fridge?). Things get a hell of a lot easier to get once you consider that there are two main ways to get the perfect ganache:</p>\n\n<ul><li><strong>working from the top down</strong>: start with a thick, almost hard material, and soften it by manipulating it, or by mixing it with a more liquid ingredient (like milk)</li><li><strong>working from the bottom up</strong>: start from a liquid-ish state, and harden it by miwing it with thicker ingredients, or by leaving it in the fridge longer.</li></ul>\n\n<p>We do hope this advice will empower you in your ganache-making skills. Let us know how you did with it!</p>\n\n<h2>Ganache at <em>Les Bonnes Choses</em></h2>\n\n<p>We have a saying at Les Bonnes Choses: \"Once you can make ganache, you can make anything.\"</p>\n\n<p>As you may know, we like to give our workshop artists the ability to master their art to the top; that is why our Preparation Experts always start off as being Ganache Specialists for Les Bonnes Choses. That way, they're given an opportunity to focus on one exercise before moving on. Once they master their ganache, and are able to provide the most optimal delight to our customers, we consider they'll thrive as they work on other kinds of preparations.</p>\n\n<h2>About the chocolate in our ganache</h2>\n\n<p>Now, we've also had a lot of questions about how our chocolate gets made. It's true, as you might know, that we make it ourselves, from Columbian cocoa and French cow milk, with a process that much resembles the one in the following Discovery Channel documentary.</p>\n\n <div data-oembed=\"http://www.youtube.com/\"\n data-oembed-type=\"video\"\n data-oembed-provider=\"youtube\"><iframe width=\"459\" height=\"344\" src=\"http://www.youtube.com/embed/Ye78F3-CuXY?feature=oembed\" frameborder=\"0\" allowfullscreen></iframe></div>\n"
130
130
  end
131
131
  it "returns a correct as_html on a StructuredText with links" do
132
132
  @api.form("everything")
133
133
  .query(%([[:d = at(document.id, "#{@api.bookmark('about')}")]]))
134
- .submit(@master_ref)[0]['article.content'].as_html(@link_resolver).gsub("&#39;", "'").should == "<h2>A tale of pastry and passion</h2>\n\n<p>As a child, Jean-Michel Pastranova learned the art of fine cuisine from his grand-father, Jacques Pastranova, who was the creator of the \"taste-design\" art current, and still today an unmissable reference of forward-thinking in cuisine. At first an assistant in his grand-father's kitchen, Jean-Michel soon found himself fascinated by sweet flavors and the tougher art of pastry, drawing his own path in the ever-changing cuisine world.</p>\n\n<p>In 1992, the first Les Bonnes Choses store opened on rue Saint-Lazare, in Paris (<a href=\"http://localhost/UkL0gMuvzYUANCpa\">we're still there!</a>), much to everyone's surprise; indeed, back then, it was very surprising for a highly promising young man with a preordained career as a restaurant chef, to open a pastry shop instead. But soon enough, contemporary chefs understood that Jean-Michel had the drive to redefine a new nobility to pastry, the same way many other kinds of cuisine were being qualified as \"fine\".</p>\n\n<p>In 1996, meeting an overwhelming demand, Jean-Michel Pastranova opened <a href=\"http://localhost/UkL0gMuvzYUANCpX\">a second shop on Paris's Champs-Élysées</a>, and <a href=\"http://localhost/UkL0gMuvzYUANCpY\">a third one in London</a>, the same week! Eventually, Les Bonnes Choses gained an international reputation as &quot;a perfection so familiar and new at the same time, that it will feel like a taste travel&quot; (New York Gazette), &quot;the finest balance between surprise and comfort, enveloped in sweetness&quot; (The Tokyo Tribune), &quot;a renewal of the pastry genre (...), the kind that changed the way pastry is approached globally&quot; (The San Francisco Gourmet News). Therefore, it was only a matter of time before Les Bonnes Choses opened shops in <a href=\"http://localhost/UkL0gMuvzYUANCpW\">New York</a> (2000) and <a href=\"http://localhost/UkL0gMuvzYUANCpZ\">Tokyo</a> (2004).</p>\n\n<p>In 2013, Jean-Michel Pastranova stepped down as the CEO and Director of Workshops, remaining a senior advisor to the board and to the workshop artists; he passed the light on to Selena, his daugther, who initially learned the art of pastry from him. Passion for great food runs in the Pastranova family...</p>\n\n<img src=\"https://prismic-io.s3.amazonaws.com/lesbonneschoses/df6c1d87258a5bfadf3479b163fd85c829a5c0b8.jpg\" alt=\"\" width=\"800\" height=\"533\" />\n\n<h2>Our main value: our customers' delight</h2>\n\n<p>Our every action is driven by the firm belief that there is art in pastry, and that this art is one of the dearest pleasures one can experience.</p>\n\n<p>At Les Bonnes Choses, people preparing your macarons are not simply &quot;pastry chefs&quot;: they are &quot;<a href=\"http://localhost/UkL0gMuvzYUANCpe\">ganache specialists</a>&quot;, &quot;<a href=\"http://localhost/UkL0gMuvzYUANCpc\">fruit experts</a>&quot;, or &quot;<a href=\"http://localhost/UkL0gMuvzYUANCpb\">oven instrumentalists</a>\". They are the best people out there to perform the tasks they perform to create your pastry, giving it the greatest value. And they just love to make their specialized pastry skill better and better until perfection.</p>\n\n<p>Of course, there is a workshop in each <em>Les Bonnes Choses</em> store, and every pastry you buy was made today, by the best pastry specialists in your country.</p>\n\n<p>However, the very difficult art of creating new concepts, juggling with tastes and creating brand new, powerful experiences, is performed every few months, during our &quot;<a href=\"http://localhost/UkL0gMuvzYUANCpo\">Pastry Art Brainstorms</a>&quot;. During the event, the best pastry artists in the world (some working for <em>Les Bonnes Choses</em>, some not) gather in Paris, and showcase the experiments they've been working on; then, the other present artists comment on the piece, and iterate on it together, in order to make it the best possible masterchief!</p>\n\n<p>The session is presided by Jean-Michel Pastranova, who then selects the most delightful experiences, to add it to <em>Les Bonnes Choses</em>'s catalogue.</p>"
134
+ .submit(@master_ref)[0]['article.content'].as_html(@link_resolver).gsub("&#39;", "'").should == "<h2>A tale of pastry and passion</h2>\n\n<p>As a child, Jean-Michel Pastranova learned the art of fine cuisine from his grand-father, Jacques Pastranova, who was the creator of the \"taste-design\" art current, and still today an unmissable reference of forward-thinking in cuisine. At first an assistant in his grand-father's kitchen, Jean-Michel soon found himself fascinated by sweet flavors and the tougher art of pastry, drawing his own path in the ever-changing cuisine world.</p>\n\n<p>In 1992, the first Les Bonnes Choses store opened on rue Saint-Lazare, in Paris (<a href=\"http://localhost/UlfoxUnM0wkXYXbb\">we're still there!</a>), much to everyone's surprise; indeed, back then, it was very surprising for a highly promising young man with a preordained career as a restaurant chef, to open a pastry shop instead. But soon enough, contemporary chefs understood that Jean-Michel had the drive to redefine a new nobility to pastry, the same way many other kinds of cuisine were being qualified as \"fine\".</p>\n\n<p>In 1996, meeting an overwhelming demand, Jean-Michel Pastranova opened <a href=\"http://localhost/UlfoxUnM0wkXYXbP\">a second shop on Paris's Champs-Élysées</a>, and <a href=\"http://localhost/UlfoxUnM0wkXYXbr\">a third one in London</a>, the same week! Eventually, Les Bonnes Choses gained an international reputation as &quot;a perfection so familiar and new at the same time, that it will feel like a taste travel&quot; (New York Gazette), &quot;the finest balance between surprise and comfort, enveloped in sweetness&quot; (The Tokyo Tribune), &quot;a renewal of the pastry genre (...), the kind that changed the way pastry is approached globally&quot; (The San Francisco Gourmet News). Therefore, it was only a matter of time before Les Bonnes Choses opened shops in <a href=\"http://localhost/UlfoxUnM0wkXYXbc\">New York</a> (2000) and <a href=\"http://localhost/UlfoxUnM0wkXYXbU\">Tokyo</a> (2004).</p>\n\n<p>In 2013, Jean-Michel Pastranova stepped down as the CEO and Director of Workshops, remaining a senior advisor to the board and to the workshop artists; he passed the light on to Selena, his daugther, who initially learned the art of pastry from him. Passion for great food runs in the Pastranova family...</p>\n\n<img src=\"https://prismic-io.s3.amazonaws.com/lesbonneschoses/df6c1d87258a5bfadf3479b163fd85c829a5c0b8.jpg\" alt=\"\" width=\"800\" height=\"533\" />\n\n<h2>Our main value: our customers' delight</h2>\n\n<p>Our every action is driven by the firm belief that there is art in pastry, and that this art is one of the dearest pleasures one can experience.</p>\n\n<p>At Les Bonnes Choses, people preparing your macarons are not simply &quot;pastry chefs&quot;: they are &quot;<a href=\"http://localhost/UlfoxUnM0wkXYXba\">ganache specialists</a>&quot;, &quot;<a href=\"http://localhost/UlfoxUnM0wkXYXbQ\">fruit experts</a>&quot;, or &quot;<a href=\"http://localhost/UlfoxUnM0wkXYXbn\">oven instrumentalists</a>\". They are the best people out there to perform the tasks they perform to create your pastry, giving it the greatest value. And they just love to make their specialized pastry skill better and better until perfection.</p>\n\n<p>Of course, there is a workshop in each <em>Les Bonnes Choses</em> store, and every pastry you buy was made today, by the best pastry specialists in your country.</p>\n\n<p>However, the very difficult art of creating new concepts, juggling with tastes and creating brand new, powerful experiences, is performed every few months, during our &quot;<a href=\"http://localhost/UlfoxUnM0wkXYXbl\">Pastry Art Brainstorms</a>&quot;. During the event, the best pastry artists in the world (some working for <em>Les Bonnes Choses</em>, some not) gather in Paris, and showcase the experiments they've been working on; then, the other present artists comment on the piece, and iterate on it together, in order to make it the best possible masterchief!</p>\n\n<p>The session is presided by Jean-Michel Pastranova, who then selects the most delightful experiences, to add it to <em>Les Bonnes Choses</em>'s catalogue.</p>"
135
135
  end
136
136
  it "returns a correct as_text on a StructuredText" do
137
137
  @api.form("everything")
138
- .query(%([[:d = at(document.id, "UkL0gMuvzYUANCps")]]))
138
+ .query(%([[:d = at(document.id, "UlfoxUnM0wkXYXbt")]]))
139
139
  .submit(@master_ref)[0]['blog-post.body'].as_text.should == "The end of a chapter the beginning of a new one Jean-Michel Pastranova, the founder of Les Bonnes Choses, and creator of the whole concept of modern fine pastry, has decided to step down as the CEO and the Director of Workshops of Les Bonnes Choses, to focus on other projects, among which his now best-selling pastry cook books, but also to take on a primary role in a culinary television show to be announced later this year. \"I believe I've taken the Les Bonnes Choses concept as far as it can go. Les Bonnes Choses is already an entity that is driven by its people, thanks to a strong internal culture, so I don't feel like they need me as much as they used to. I'm sure they are greater ways to come, to innovate in pastry, and I'm sure Les Bonnes Choses's coming innovation will be even more mind-blowing than if I had stayed longer.\" He will remain as a senior advisor to the board, and to the workshop artists, as his daughter Selena, who has been working with him for several years, will fulfill the CEO role from now on. \"My father was able not only to create a revolutionary concept, but also a company culture that puts everyone in charge of driving the company's innovation and quality. That gives us years, maybe decades of revolutionary ideas to come, and there's still a long, wonderful path to walk in the fine pastry world.\""
140
140
  end
141
141
 
142
142
  it "returns a correct as_text on a StructuredText with a separator" do
143
143
  @api.form("everything")
144
- .query(%([[:d = at(document.id, "UkL0gMuvzYUANCps")]]))
144
+ .query(%([[:d = at(document.id, "UlfoxUnM0wkXYXbt")]]))
145
145
  .submit(@master_ref)[0]['blog-post.body'].as_text(' #### ').should == "The end of a chapter the beginning of a new one #### Jean-Michel Pastranova, the founder of Les Bonnes Choses, and creator of the whole concept of modern fine pastry, has decided to step down as the CEO and the Director of Workshops of Les Bonnes Choses, to focus on other projects, among which his now best-selling pastry cook books, but also to take on a primary role in a culinary television show to be announced later this year. #### \"I believe I've taken the Les Bonnes Choses concept as far as it can go. Les Bonnes Choses is already an entity that is driven by its people, thanks to a strong internal culture, so I don't feel like they need me as much as they used to. I'm sure they are greater ways to come, to innovate in pastry, and I'm sure Les Bonnes Choses's coming innovation will be even more mind-blowing than if I had stayed longer.\" #### He will remain as a senior advisor to the board, and to the workshop artists, as his daughter Selena, who has been working with him for several years, will fulfill the CEO role from now on. #### \"My father was able not only to create a revolutionary concept, but also a company culture that puts everyone in charge of driving the company's innovation and quality. That gives us years, maybe decades of revolutionary ideas to come, and there's still a long, wonderful path to walk in the fine pastry world.\""
146
146
  end
147
147
  end
data/spec/prismic_spec.rb CHANGED
@@ -116,7 +116,7 @@ describe 'Api' do
116
116
  describe 'parse_api_response' do
117
117
  before do
118
118
  @data = File.read("#{File.dirname(__FILE__)}/responses_mocks/api.json")
119
- @json = JSON.parse(@data)
119
+ @json = JSON.load(@data)
120
120
  @parsed = Prismic::API.parse_api_response(@json, nil, Prismic::DefaultHTTPClient, false)
121
121
  end
122
122
 
@@ -225,11 +225,11 @@ describe 'Api' do
225
225
  end
226
226
 
227
227
  it "returns the json representation of the api" do
228
- JSON.parse(@json)['foo'].should == 'bar'
228
+ JSON.load(@json)['foo'].should == 'bar'
229
229
  end
230
230
 
231
231
  it "returns the json representation of the api containing one single element" do
232
- JSON.parse(@json).size.should == 1
232
+ JSON.load(@json).size.should == 1
233
233
  end
234
234
  end
235
235
 
@@ -446,4 +446,82 @@ describe 'SearchForm' do
446
446
  expect { @form.submit }.to raise_error Prismic::SearchForm::NoRefSetException
447
447
  end
448
448
  end
449
+
450
+ describe 'submit_raw' do
451
+ before do
452
+ @api = Prismic.api("https://lesbonneschoses.prismic.io/api")
453
+ @master_ref = @api.master_ref
454
+ end
455
+ it "returns a proper JSON string if all ok" do
456
+ data = <<-DATA.gsub(/\n */, '').strip
457
+ {
458
+ "page":1,
459
+ "results_per_page":1,
460
+ "results_size":1,
461
+ "total_results_size":40,
462
+ "total_pages":40,
463
+ "next_page":"https://lesbonneschoses.prismic.io/api/documents/search?ref=UlfoxUnM08QWYXdl&page=2&pageSize=1",
464
+ "prev_page":null,
465
+ "results":[{
466
+ "id":"UlfoxUnM0wkXYXbV",
467
+ "type":"job-offer",
468
+ "href":"https://lesbonneschoses.prismic.io/api/documents/search?ref=UlfoxUnM08QWYXdl&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22UlfoxUnM0wkXYXbV%22%29+%5D%5D",
469
+ "tags":[],
470
+ "slugs":["art-director"],
471
+ "linked_documents":[{
472
+ "id":"UlfoxUnM0wkXYXbb",
473
+ "tags":[],
474
+ "type":"store",
475
+ "slug":"paris-saint-lazare"
476
+ }],
477
+ "data":{
478
+ "job-offer":{
479
+ "name":{
480
+ "type":"StructuredText",
481
+ "value":[{"type":"heading1","text":"Art Director","spans":[]}]
482
+ },
483
+ "location":[{
484
+ "type":"Link.document",
485
+ "value":{
486
+ "document":{
487
+ "id":"UlfoxUnM0wkXYXbb",
488
+ "type":"store",
489
+ "tags":[],
490
+ "slug":"paris-saint-lazare"
491
+ },
492
+ "isBroken":false
493
+ }
494
+ }],
495
+ "contract_type":{"type":"Select","value":"Permanent"},
496
+ "service":{"type":"Select","value":"Office"},
497
+ "profile":{
498
+ "type":"StructuredText",
499
+ "value":[{
500
+ "type":"paragraph",
501
+ "text":"Brand visual identity must be vital to you, and you must have a thorough experience with working for/with great visual brands. We will ask you to present your previous work, and explain your choices, so be prepared. Previous work with luxury brands is a plus.",
502
+ "spans":[]
503
+ }]
504
+ },
505
+ "job_description":{
506
+ "type":"StructuredText",
507
+ "value":[{
508
+ "type":"paragraph",
509
+ "text":"As our only Art director, you will be the one in charge of every design aspect of Les Bonnes Choses, from the design of our pastry boxes, of our shop fronts, of our website, ... You will lead a team of more specialized people, and you will be expected to be able to travel from time to time.",
510
+ "spans":[]
511
+ },{
512
+ "type":"paragraph",
513
+ "text":"You will be the vessel that will bring emotions to our clientbase, before they tasted our pastries. We are aware the responsibility is huge, and we hope that you are too.",
514
+ "spans":[]
515
+ }]
516
+ }
517
+ }
518
+ }
519
+ }],
520
+ "version":"61d96e9",
521
+ "license":"All Rights Reserved"
522
+ }
523
+ DATA
524
+ @api.form("everything").page_size('1').submit_raw(@master_ref).should == data
525
+ end
526
+ end
449
527
  end
@@ -51,6 +51,13 @@
51
51
  }
52
52
  ]
53
53
  },
54
+ "location" : {
55
+ "type": "GeoPoint",
56
+ "value": {
57
+ "latitude": 48.877108,
58
+ "longitude": -2.3338790
59
+ }
60
+ },
54
61
  "image": {
55
62
  "type": "Image",
56
63
  "value": {
@@ -168,7 +175,68 @@
168
175
  }
169
176
  ]
170
177
  }
171
- ]
178
+ ],
179
+ "some_timestamp" : {
180
+ "type" : "Timestamp",
181
+ "value" : "2014-06-18T15:30:00+0000"
182
+ },
183
+ "linked_images": {
184
+ "type": "StructuredText",
185
+ "value": [
186
+ {
187
+ "spans": [],
188
+ "text": "Here is some introductory text.",
189
+ "type": "paragraph"
190
+ },
191
+ {
192
+ "spans": [],
193
+ "text": "The following image is linked.",
194
+ "type": "paragraph"
195
+ },
196
+ {
197
+ "alt": "",
198
+ "copyright": "",
199
+ "dimensions": {
200
+ "height": 129,
201
+ "width": 260
202
+ },
203
+ "linkTo": {
204
+ "type": "Link.web",
205
+ "value": {
206
+ "url": "http://google.com/"
207
+ }
208
+ },
209
+ "type": "image",
210
+ "url": "http://fpoimg.com/129x260"
211
+ },
212
+ {
213
+ "spans": [
214
+ {
215
+ "end": 20,
216
+ "start": 0,
217
+ "type": "strong"
218
+ }
219
+ ],
220
+ "text": "More important stuff",
221
+ "type": "paragraph"
222
+ },
223
+ {
224
+ "spans": [],
225
+ "text": "One more image, this one is not linked:",
226
+ "type": "paragraph"
227
+ },
228
+ {
229
+ "alt": "",
230
+ "copyright": "",
231
+ "dimensions": {
232
+ "height": 199,
233
+ "width": 300
234
+ },
235
+ "type": "image",
236
+ "url": "http://fpoimg.com/199x300"
237
+ }
238
+ ]
239
+ }
172
240
  }
173
241
  }
174
242
  }
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # encoding: utf-8
2
2
  require 'nokogiri'
3
3
  begin
4
- require 'yajl'
4
+ require 'yajl/json_gem'
5
5
  rescue LoadError
6
6
  # ok not a big deal
7
+ require 'json'
7
8
  end
8
- require 'json'
9
9
  require 'simplecov'
10
10
 
11
11
  SimpleCov.start
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prismic.io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc9
4
+ version: 1.0.0.rc10
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Étienne Vallette d'Osia"
8
8
  - Samy Dindane
9
+ - Rudy Rigot
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-06-21 00:00:00.000000000 Z
13
+ date: 2014-09-10 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: bundler
@@ -91,6 +92,7 @@ files:
91
92
  - lib/prismic/fragments/date.rb
92
93
  - lib/prismic/fragments/embed.rb
93
94
  - lib/prismic/fragments/fragment.rb
95
+ - lib/prismic/fragments/geopoint.rb
94
96
  - lib/prismic/fragments/group.rb
95
97
  - lib/prismic/fragments/image.rb
96
98
  - lib/prismic/fragments/link.rb
@@ -99,6 +101,7 @@ files:
99
101
  - lib/prismic/fragments/select.rb
100
102
  - lib/prismic/fragments/structured_text.rb
101
103
  - lib/prismic/fragments/text.rb
104
+ - lib/prismic/fragments/timestamp.rb
102
105
  - lib/prismic/json_parsers.rb
103
106
  - lib/prismic/version.rb
104
107
  - prismic.gemspec
@@ -138,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
141
  version: 1.3.1
139
142
  requirements: []
140
143
  rubyforge_project:
141
- rubygems_version: 2.3.0
144
+ rubygems_version: 2.2.2
142
145
  signing_key:
143
146
  specification_version: 4
144
147
  summary: Prismic.io development kit