prismic.io 1.0.0.rc8 → 1.0.0.rc9

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: 5e8407198320a76fe68735f7adbab9c99caf2540
4
- data.tar.gz: ea27a831a0d80593f279ae187f0530a5094c6f3b
3
+ metadata.gz: efe6723ef7f29deff32c702fed5695aba28e93f6
4
+ data.tar.gz: a2a470960e7065d31ea4f416d07a738bdf3d467f
5
5
  SHA512:
6
- metadata.gz: 4dbc3131e382071d913859b15005f039c17323862c7da63d19ebabbfa766c0337c11aa462665985ed5714bbec4ad74820d6460640ff688bcf2ccbdc0d7b84fb9
7
- data.tar.gz: 322c49ea82af8afe85a487c6a4643be5ad68671b73deec72e0a802bb9505161b843c53c7f139c385f73a77b3a22be379dbfb030fcc6af1d9efc048267db6a9e2
6
+ metadata.gz: 05c234357c7f80ee100af6471632a5b8defa792ab7dd3def6db15442a0b3a115b0a8c38864f87e37ce755c7516f99e114db0fccb91ed2d1e592b70a7ea8ef655
7
+ data.tar.gz: 0b4d361e0a79ea6d86795133b16499e6e8c8a844e40be2f681be66269b2ee4c5518971e054bb7c820d029d5bfc0613211ca5db40538f7ebe350ab381398db9a4
data/lib/prismic/api.rb CHANGED
@@ -92,7 +92,7 @@ module Prismic
92
92
  data = {}
93
93
  data["access_token"] = access_token if access_token
94
94
  cache_key = url + (access_token ? ("#" + access_token) : "")
95
- api_cache.get_or_set(cache_key, expired_in:5) {
95
+ api_cache.get_or_set(cache_key, nil, 5) {
96
96
  res = http_client.get(url, data, 'Accept' => 'application/json')
97
97
  case res.code
98
98
  when '200'
@@ -39,7 +39,7 @@ module Prismic
39
39
  end
40
40
 
41
41
  def get_or_set(key, value = nil, expired_in = 0)
42
- return get(key) if include?(key)
42
+ return get(key) if include?(key) && !expired?(key)
43
43
  set(key, block_given? ? yield : value, expired_in)
44
44
  end
45
45
 
@@ -202,7 +202,7 @@ module Prismic
202
202
  linked_documents = json['linked_documents']
203
203
  if linked_documents
204
204
  linked_documents.map! do |linked_doc|
205
- LinkedDocument.new(linked_doc['id'], linked_doc['type'], linked_doc['tags'])
205
+ LinkedDocument.new(linked_doc['id'], linked_doc['slug'], linked_doc['type'], linked_doc['tags'])
206
206
  end
207
207
  else
208
208
  linked_documents = []
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Prismic
3
3
 
4
- VERSION = "1.0.0.rc8"
4
+ VERSION = "1.0.0.rc9"
5
5
 
6
6
  end
data/lib/prismic.rb CHANGED
@@ -352,10 +352,11 @@ module Prismic
352
352
  end
353
353
 
354
354
  class LinkedDocument
355
- attr_accessor :id, :type, :tags
355
+ attr_accessor :id, :slug, :type, :tags
356
356
 
357
- def initialize(id, type, tags)
357
+ def initialize(id, slug, type, tags)
358
358
  @id = id
359
+ @slug = slug
359
360
  @type = type
360
361
  @tags = tags
361
362
  end
data/spec/cache_spec.rb CHANGED
@@ -100,6 +100,14 @@ describe "Basic Cache's" do
100
100
  cache.get('key').should == nil
101
101
  end
102
102
 
103
+ it 'set with expiration and a block' do
104
+ cache = Prismic::BasicCache.new
105
+ cache.get_or_set('key', nil, 2){ 'value' }
106
+ cache.get_or_set('key', nil, 2){ 'othervalue' }.should == 'value'
107
+ sleep(3)
108
+ cache.get_or_set('key', nil, 2){ 'othervalue' }.should == 'othervalue'
109
+ end
110
+
103
111
  it 'set & test value' do
104
112
  cache = Prismic::BasicCache.new
105
113
  cache.set('key', 'value')
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.0.0.rc8
4
+ version: 1.0.0.rc9
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Étienne Vallette d'Osia"
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-19 00:00:00.000000000 Z
12
+ date: 2014-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler