prismic.io 1.3.0 → 1.3.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: 7ddebf7e0c8efd6eb548e0c2311e5021611320ef
4
- data.tar.gz: 396c64eadc4b74c2355a70cc60723c9a1a7252af
3
+ metadata.gz: d224afd3ee32524169fdee262f95d3f2893749af
4
+ data.tar.gz: 2c3d874f6c67bff9022a9cf789d3b832c72cd786
5
5
  SHA512:
6
- metadata.gz: 9781e89122d946b0ee9d4c1a11869ec6887e00e8b5c9921e996c537607ce483d9723c27cf789e258ce99cf7f5c837b46956d5a3309883d11b2eefaadad472787
7
- data.tar.gz: 97402b3c5ffad257575f73f2583d615028646dcf7d106093e4ecdeb38c2897b7d27022c0d815432c0177370077d189e99d6c41a1115d495c5f45a3269ab48e40
6
+ metadata.gz: cfcd6341947039e5e6999fa8bfcd360d6d57c6384dee9eed32440913a20e29325cb9e988555760310eaaad8021089643db0e064cef543db422ead2d4c1b30c9d
7
+ data.tar.gz: 6cde1dedf707faaf56c737e3169f4b420f3698f210585dec7b33a1cb004bf9ce92687f77e9777abe2e1d0af4ba24cdaf6c5a522acf08276d52016d565e2b2071
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prismic.io (1.3.0)
4
+ prismic.io (1.3.1)
5
5
  hashery (~> 2.1.1)
6
6
 
7
7
  GEM
@@ -5,10 +5,12 @@ module Prismic
5
5
  # A fragment of type Slice, an item in a SliceZone
6
6
  class Slice < Fragment
7
7
  attr_accessor :slice_type
8
+ attr_accessor :label
8
9
  attr_accessor :value
9
10
 
10
- def initialize(slice_type, value)
11
+ def initialize(slice_type, label, value)
11
12
  @slice_type = slice_type
13
+ @label = label
12
14
  @value = value
13
15
  end
14
16
 
@@ -26,7 +28,11 @@ module Prismic
26
28
  #
27
29
  # @return [String] the HTML representation
28
30
  def as_html(link_resolver=nil)
29
- @value.as_html(link_resolver)
31
+ classes = ['slice']
32
+ unless (@label.nil?)
33
+ classes.push(@label)
34
+ end
35
+ %[<div data-slicetype="#{@slice_type}" class="#{classes.join(' ')}">#{@value.as_html(link_resolver)}</div>]
30
36
  end
31
37
  end
32
38
 
@@ -203,9 +203,7 @@ module Prismic
203
203
  def slices_parser(json)
204
204
  slices = []
205
205
  json['value'].each do |data|
206
- slice_type = data['slice_type']
207
- fragment = data['value']
208
- slices << Prismic::Fragments::Slice.new(slice_type, fragment_parser(fragment))
206
+ slices << Prismic::Fragments::Slice.new(data['slice_type'], data['label'], fragment_parser(data['value']))
209
207
  end
210
208
  Prismic::Fragments::SliceZone.new(slices)
211
209
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Prismic
3
3
 
4
- VERSION = '1.3.0'
4
+ VERSION = '1.3.1'
5
5
 
6
6
  end
@@ -713,7 +713,7 @@ describe 'Slices' do
713
713
 
714
714
  it 'parses correctly' do
715
715
  @slices.as_text.should == "\nc'est un bloc features\nC'est un bloc content"
716
- @slices.as_html(@link_resolver).should == %[<section data-field="illustration"><img src="https://wroomdev.s3.amazonaws.com/toto/db3775edb44f9818c54baa72bbfc8d3d6394b6ef_hsf_evilsquall.jpg" alt="" width="4285" height="709" /></section>\n<section data-field="title"><span class="text">c&#39;est un bloc features</span></section>\n<p>C&#39;est un bloc content</p>]
716
+ @slices.as_html(@link_resolver).gsub('&#39;', "'").should == %[<div data-slicetype="features" class="slice"><section data-field="illustration"><img src="https://wroomdev.s3.amazonaws.com/toto/db3775edb44f9818c54baa72bbfc8d3d6394b6ef_hsf_evilsquall.jpg" alt="" width="4285" height="709" /></section>\n<section data-field="title"><span class="text">c'est un bloc features</span></section></div>\n<div data-slicetype="text" class="slice"><p>C'est un bloc content</p></div>]
717
717
  end
718
718
 
719
719
  end
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.3.0
4
+ version: 1.3.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: 2015-07-09 00:00:00.000000000 Z
14
+ date: 2015-07-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler