prismic.io 1.0.0.rc7 → 1.0.0.rc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -0
- data/lib/prismic/api.rb +23 -20
- data/lib/prismic/cache/basic.rb +66 -0
- data/lib/prismic/{cache.rb → cache/lru.rb} +2 -2
- data/lib/prismic/json_parsers.rb +12 -3
- data/lib/prismic/version.rb +1 -1
- data/lib/prismic.rb +29 -7
- data/spec/cache_spec.rb +57 -2
- data/spec/json_parsers_spec.rb +2 -2
- data/spec/micro_spec.rb +9 -0
- data/spec/prismic_spec.rb +12 -6
- data/spec/responses_mocks/api.json +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e8407198320a76fe68735f7adbab9c99caf2540
|
4
|
+
data.tar.gz: ea27a831a0d80593f279ae187f0530a5094c6f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dbc3131e382071d913859b15005f039c17323862c7da63d19ebabbfa766c0337c11aa462665985ed5714bbec4ad74820d6460640ff688bcf2ccbdc0d7b84fb9
|
7
|
+
data.tar.gz: 322c49ea82af8afe85a487c6a4643be5ad68671b73deec72e0a802bb9505161b843c53c7f139c385f73a77b3a22be379dbfb030fcc6af1d9efc048267db6a9e2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,14 +37,28 @@ Also on our [prismic.io developer's portal](https://developers.prismic.io/), on
|
|
37
37
|
* get a thorough introduction of [how to use prismic.io kits](https://developers.prismic.io/documentation/UjBe8bGIJ3EKtgBZ/api-documentation#kits-and-helpers), including this one.
|
38
38
|
* see [what else is available for Ruby](https://developers.prismic.io/technologies/UjBh6MuvzeMJvE4m/ruby): starter projects, examples, ...
|
39
39
|
|
40
|
+
### Using the kit
|
41
|
+
|
40
42
|
#### Kit's detailed documentation
|
41
43
|
|
42
44
|
To get a detailed documentation of the Ruby kit's variables and methods, please check out the [prismic.io Ruby kit's documentation](http://rubydoc.info/github/prismicio/ruby-kit/master/frames).
|
43
45
|
|
46
|
+
#### Specific Ruby kit syntax
|
47
|
+
|
44
48
|
Thanks to Ruby's syntax, this kit contains some mild differences and syntastic sugar over [the "Kits and helpers" section of our API documentation](https://developers.prismic.io/documentation/UjBe8bGIJ3EKtgBZ/api-documentation#kits-and-helpers) in general (which you should read first). They are listed here:
|
49
|
+
|
45
50
|
* When calling the API, a faster way to pass the `ref`: directly as a parameter of the `submit` method (no need to use the `ref` method then): `api.form("everything").submit(@ref)`.
|
46
51
|
* Accessing type-dependent fields from a `document` is done through the `[]` operator (rather than a `get()` method). Printing the HTML version of a field therefore looks like `document["title_user_friendly"].as_html(link_resolver(@ref))`.
|
47
52
|
* Two of the fields in the `DocumentLink` object (the one used to write your `link_resolver` method, for instance) were renamed to fit Ruby's best practice: `doc.type` is in fact `doc.link_type`, and `doc.isBroken` is in fact `doc.broken?`.
|
53
|
+
* You don't need to pass a `ctx` object in `as_html()`, you can use the `Prismic.link_resolver` static method to build a link resolver object that takes the `ref` into account, like this: `@link_resolver = Prismic.link_resolver(@ref) { |doc| ... }`. Then you can simply go: `fragment.as_html(@link_resolver)`. Note: the Rails starter kit provides you with a helper allowing you to pass the ref each time you call the link resolver, like this: `fragment.as_html(link_resolver(@ref))`.
|
54
|
+
* the `Response` class is fit to work with the [Kaminari](https://github.com/amatsuda/kaminari) gem. So if you have a `@response` object in your controller, you can display a whole pagination for it in your view like this: `<%= paginate @response %>` (this works with any Rails 3 or 4 app with the Kaminari gem installed).
|
55
|
+
|
56
|
+
Knowing all that, here is typical code written with the Ruby kit:
|
57
|
+
|
58
|
+
* A typical API object instantiation looks like this: `Prismic.api(url, opts)`
|
59
|
+
* A typical querying looks like this: `api.form('everything').query('[[:d = at(document.type, "product")]]').submit(@ref)`
|
60
|
+
* A typical fragment manipulation looks like this: `doc['article.image'].get_view('icon').url`
|
61
|
+
* A typical fragment serialization to HTML looks like this: `doc['article.body'].as_html(@link_resolver)`
|
48
62
|
|
49
63
|
### Changelog
|
50
64
|
|
data/lib/prismic/api.rb
CHANGED
@@ -88,28 +88,31 @@ module Prismic
|
|
88
88
|
@json
|
89
89
|
end
|
90
90
|
|
91
|
-
def self.get(url, access_token=nil, http_client=Prismic::DefaultHTTPClient)
|
91
|
+
def self.get(url, access_token=nil, http_client=Prismic::DefaultHTTPClient, api_cache=Prismic::DefaultApiCache)
|
92
92
|
data = {}
|
93
93
|
data["access_token"] = access_token if access_token
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
res
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
json
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
94
|
+
cache_key = url + (access_token ? ("#" + access_token) : "")
|
95
|
+
api_cache.get_or_set(cache_key, expired_in:5) {
|
96
|
+
res = http_client.get(url, data, 'Accept' => 'application/json')
|
97
|
+
case res.code
|
98
|
+
when '200'
|
99
|
+
res
|
100
|
+
when '401', '403'
|
101
|
+
begin
|
102
|
+
json = JSON.load(res.body)
|
103
|
+
raise PrismicWSAuthError.new(
|
104
|
+
json['error'],
|
105
|
+
json['oauth_initiate'],
|
106
|
+
json['oauth_token'],
|
107
|
+
http_client
|
108
|
+
)
|
109
|
+
rescue => e
|
110
|
+
raise PrismicWSConnectionError.new(res, e)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
raise PrismicWSConnectionError, res
|
109
114
|
end
|
110
|
-
|
111
|
-
raise PrismicWSConnectionError, res
|
112
|
-
end
|
115
|
+
}
|
113
116
|
end
|
114
117
|
|
115
118
|
def self.start(url, opts={})
|
@@ -142,7 +145,7 @@ module Prismic
|
|
142
145
|
}]
|
143
146
|
api.refs = Hash[data_refs.map { |ref|
|
144
147
|
scheduled_at = ref['scheduledAt']
|
145
|
-
[ref['label'].downcase, Ref.new(ref['ref'], ref['label'], ref['isMasterRef'], scheduled_at && Time.at(scheduled_at / 1000.0))]
|
148
|
+
[ref['label'].downcase, Ref.new(ref['id'], ref['ref'], ref['label'], ref['isMasterRef'], scheduled_at && Time.at(scheduled_at / 1000.0))]
|
146
149
|
}]
|
147
150
|
api.tags = data['tags']
|
148
151
|
api.types = data['types']
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Prismic
|
3
|
+
|
4
|
+
class BasicCacheEntry
|
5
|
+
|
6
|
+
attr_reader :expired_in
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize(data, expired_in = 0)
|
10
|
+
@data = data
|
11
|
+
@expired_in = expired_in
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class BasicCache
|
16
|
+
|
17
|
+
attr_reader :cache
|
18
|
+
attr_reader :expirations
|
19
|
+
|
20
|
+
def initialize(data = {})
|
21
|
+
@cache = {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(key)
|
25
|
+
return delete(key) if expired?(key)
|
26
|
+
include?(key) ? @cache[key].data : nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def set(key, value = nil, expired_in = 0)
|
30
|
+
data = block_given? ? yield : value
|
31
|
+
expired_in = (expired_in == 0) ? 0 : Time.now.getutc.to_i + expired_in
|
32
|
+
entry = BasicCacheEntry.new(data, expired_in)
|
33
|
+
@cache[key] = entry
|
34
|
+
entry.data
|
35
|
+
end
|
36
|
+
|
37
|
+
def include?(key)
|
38
|
+
@cache.keys.include?(key)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_or_set(key, value = nil, expired_in = 0)
|
42
|
+
return get(key) if include?(key)
|
43
|
+
set(key, block_given? ? yield : value, expired_in)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete(key)
|
47
|
+
@cache.delete(key)
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def expired?(key)
|
52
|
+
if include?(key)
|
53
|
+
expired_in = @cache[key].expired_in
|
54
|
+
(expired_in != 0) && expired_in < Time.now.getutc.to_i
|
55
|
+
else
|
56
|
+
false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def clear()
|
61
|
+
@cache = {}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
DefaultApiCache = BasicCache.new
|
66
|
+
end
|
@@ -16,7 +16,7 @@ module Prismic
|
|
16
16
|
# class you created as a :cache option. Therefore, to use this simple cache,
|
17
17
|
# you can create your API object like this: `Prismic.api(url, cache:
|
18
18
|
# Prismic::DefaultCache)`
|
19
|
-
class
|
19
|
+
class LruCache
|
20
20
|
|
21
21
|
# Based on http://stackoverflow.com/questions/1933866/efficient-ruby-lru-cache
|
22
22
|
# The Hash are sorted, so the age is represented by the key order
|
@@ -127,5 +127,5 @@ module Prismic
|
|
127
127
|
|
128
128
|
# This default instance is used by the API to avoid creating a new instance
|
129
129
|
# per request (which would make the cache useless).
|
130
|
-
DefaultCache =
|
130
|
+
DefaultCache = LruCache.new
|
131
131
|
end
|
data/lib/prismic/json_parsers.rb
CHANGED
@@ -199,8 +199,17 @@ module Prismic
|
|
199
199
|
end
|
200
200
|
}]
|
201
201
|
|
202
|
+
linked_documents = json['linked_documents']
|
203
|
+
if linked_documents
|
204
|
+
linked_documents.map! do |linked_doc|
|
205
|
+
LinkedDocument.new(linked_doc['id'], linked_doc['type'], linked_doc['tags'])
|
206
|
+
end
|
207
|
+
else
|
208
|
+
linked_documents = []
|
209
|
+
end
|
210
|
+
|
202
211
|
Prismic::Document.new(json['id'], json['type'], json['href'], json['tags'],
|
203
|
-
json['slugs'], fragments)
|
212
|
+
json['slugs'], linked_documents, fragments)
|
204
213
|
end
|
205
214
|
|
206
215
|
def results_parser(results)
|
@@ -209,9 +218,9 @@ module Prismic
|
|
209
218
|
end
|
210
219
|
end
|
211
220
|
|
212
|
-
def
|
221
|
+
def response_parser(documents)
|
213
222
|
raise FormSearchException, "Error : #{documents['error']}" if documents['error']
|
214
|
-
Prismic::
|
223
|
+
Prismic::Response.new(
|
215
224
|
documents['page'],
|
216
225
|
documents['results_per_page'],
|
217
226
|
documents['results_size'],
|
data/lib/prismic/version.rb
CHANGED
data/lib/prismic.rb
CHANGED
@@ -228,7 +228,7 @@ module Prismic
|
|
228
228
|
# @param ref [Ref, String] The {Ref reference} to use (if not already
|
229
229
|
# defined)
|
230
230
|
#
|
231
|
-
# @return [
|
231
|
+
# @return [Response] The results (array of Document object + pagination
|
232
232
|
# specifics)
|
233
233
|
def submit(ref = nil)
|
234
234
|
self.ref(ref) if ref
|
@@ -246,7 +246,7 @@ module Prismic
|
|
246
246
|
response = api.http_client.get(form_action, data, 'Accept' => 'application/json')
|
247
247
|
|
248
248
|
if response.code.to_s == "200"
|
249
|
-
Prismic::JsonParser.
|
249
|
+
Prismic::JsonParser.response_parser(JSON.parse(response.body))
|
250
250
|
else
|
251
251
|
body = JSON.parse(response.body) rescue nil
|
252
252
|
error = body.is_a?(Hash) ? body['error'] : response.body
|
@@ -307,9 +307,13 @@ module Prismic
|
|
307
307
|
alias :repeatable? :repeatable
|
308
308
|
end
|
309
309
|
|
310
|
-
class
|
310
|
+
class Response
|
311
311
|
attr_accessor :page, :results_per_page, :results_size, :total_results_size, :total_pages, :next_page, :prev_page, :results
|
312
312
|
|
313
|
+
# To be able to use Kaminari as a paginator in Rails out of the box
|
314
|
+
alias :current_page :page
|
315
|
+
alias :limit_value :results_per_page
|
316
|
+
|
313
317
|
def initialize(page, results_per_page, results_size, total_results_size, total_pages, next_page, prev_page, results)
|
314
318
|
@page = page
|
315
319
|
@results_per_page = results_per_page
|
@@ -347,15 +351,26 @@ module Prismic
|
|
347
351
|
alias :size :length
|
348
352
|
end
|
349
353
|
|
354
|
+
class LinkedDocument
|
355
|
+
attr_accessor :id, :type, :tags
|
356
|
+
|
357
|
+
def initialize(id, type, tags)
|
358
|
+
@id = id
|
359
|
+
@type = type
|
360
|
+
@tags = tags
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
350
364
|
class Document
|
351
|
-
attr_accessor :id, :type, :href, :tags, :slugs, :fragments
|
365
|
+
attr_accessor :id, :type, :href, :tags, :slugs, :linked_documents, :fragments
|
352
366
|
|
353
|
-
def initialize(id, type, href, tags, slugs, fragments)
|
367
|
+
def initialize(id, type, href, tags, slugs, linked_documents, fragments)
|
354
368
|
@id = id
|
355
369
|
@type = type
|
356
370
|
@href = href
|
357
371
|
@tags = tags
|
358
372
|
@slugs = slugs
|
373
|
+
@linked_documents = linked_documents
|
359
374
|
@fragments = (fragments.is_a? Hash) ? parse_fragments(fragments) : fragments
|
360
375
|
end
|
361
376
|
|
@@ -427,6 +442,11 @@ module Prismic
|
|
427
442
|
# returns the same results.
|
428
443
|
class Ref
|
429
444
|
|
445
|
+
# Returns the value of attribute id.
|
446
|
+
#
|
447
|
+
# @return [String]
|
448
|
+
attr_accessor :id
|
449
|
+
|
430
450
|
# Returns the value of attribute ref.
|
431
451
|
#
|
432
452
|
# @return [String]
|
@@ -447,7 +467,8 @@ module Prismic
|
|
447
467
|
# @return [Time]
|
448
468
|
attr_accessor :scheduled_at
|
449
469
|
|
450
|
-
def initialize(ref, label, is_master = false, scheduled_at = nil)
|
470
|
+
def initialize(id, ref, label, is_master = false, scheduled_at = nil)
|
471
|
+
@id = id
|
451
472
|
@ref = ref
|
452
473
|
@label = label
|
453
474
|
@is_master = is_master
|
@@ -550,4 +571,5 @@ require 'prismic/api'
|
|
550
571
|
require 'prismic/form'
|
551
572
|
require 'prismic/fragments'
|
552
573
|
require 'prismic/json_parsers'
|
553
|
-
require 'prismic/cache'
|
574
|
+
require 'prismic/cache/lru'
|
575
|
+
require 'prismic/cache/basic'
|
data/spec/cache_spec.rb
CHANGED
@@ -5,14 +5,14 @@ describe "Cache's" do
|
|
5
5
|
|
6
6
|
describe 'on/off switch' do
|
7
7
|
before do
|
8
|
-
@api = Prismic.api("https://lesbonneschoses.prismic.io/api", cache: Prismic::
|
8
|
+
@api = Prismic.api("https://lesbonneschoses.prismic.io/api", cache: Prismic::LruCache.new(3))
|
9
9
|
@cache = @api.cache
|
10
10
|
@master_ref = @api.master_ref
|
11
11
|
end
|
12
12
|
|
13
13
|
it "is properly on" do
|
14
14
|
@api.has_cache?.should == true
|
15
|
-
@cache.is_a?(Prismic::
|
15
|
+
@cache.is_a?(Prismic::LruCache).should == true
|
16
16
|
end
|
17
17
|
|
18
18
|
it "is properly off" do
|
@@ -84,3 +84,58 @@ describe "Cache's" do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
describe "Basic Cache's" do
|
89
|
+
|
90
|
+
it 'set & get value' do
|
91
|
+
cache = Prismic::BasicCache.new
|
92
|
+
cache.set('key', 'value')
|
93
|
+
cache.get('key').should == 'value'
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'set with expiration value & get value' do
|
97
|
+
cache = Prismic::BasicCache.new
|
98
|
+
cache.set('key', 'value', 2)
|
99
|
+
sleep(3)
|
100
|
+
cache.get('key').should == nil
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'set & test value' do
|
104
|
+
cache = Prismic::BasicCache.new
|
105
|
+
cache.set('key', 'value')
|
106
|
+
cache.include?('key').should == true
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'get or set value' do
|
110
|
+
cache = Prismic::BasicCache.new
|
111
|
+
cache.set('key', 'value')
|
112
|
+
cache.get('key').should == 'value'
|
113
|
+
cache.get_or_set('key', 'value1')
|
114
|
+
cache.get('key').should == 'value'
|
115
|
+
cache.get_or_set('key1', 'value2')
|
116
|
+
cache.get('key1').should == 'value2'
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'set, delete & get value' do
|
120
|
+
cache = Prismic::BasicCache.new
|
121
|
+
cache.set('key', 'value')
|
122
|
+
cache.get('key').should == 'value'
|
123
|
+
cache.delete('key')
|
124
|
+
cache.get('key').should == nil
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'set, clear & get value' do
|
128
|
+
cache = Prismic::BasicCache.new
|
129
|
+
cache.expired?('key')
|
130
|
+
cache.set('key', 'value')
|
131
|
+
cache.set('key1', 'value1')
|
132
|
+
cache.set('key2', 'value2')
|
133
|
+
cache.get('key').should == 'value'
|
134
|
+
cache.get('key1').should == 'value1'
|
135
|
+
cache.get('key2').should == 'value2'
|
136
|
+
cache.clear()
|
137
|
+
cache.get('key').should == nil
|
138
|
+
cache.get('key1').should == nil
|
139
|
+
cache.get('key2').should == nil
|
140
|
+
end
|
141
|
+
end
|
data/spec/json_parsers_spec.rb
CHANGED
@@ -316,7 +316,7 @@ describe 'document_parser' do
|
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
|
-
describe '
|
319
|
+
describe 'response_parser' do
|
320
320
|
|
321
321
|
it "accepts basic documents response" do
|
322
322
|
@json = JSON.parse('{ "page": 1,
|
@@ -327,7 +327,7 @@ describe 'documents_parser' do
|
|
327
327
|
"next_page": "https://lesbonneschoses.prismic.io/api/documents/search?ref=UkL0hcuvzYUANCrm&page=2&pageSize=20",
|
328
328
|
"prev_page": null,
|
329
329
|
"results":[]}')
|
330
|
-
@documents = Prismic::JsonParser.
|
330
|
+
@documents = Prismic::JsonParser.response_parser(@json)
|
331
331
|
@documents.results.should == []
|
332
332
|
@documents.page.should == 1
|
333
333
|
@documents.results_per_page.should == 20
|
data/spec/micro_spec.rb
CHANGED
@@ -15,4 +15,13 @@ describe 'micro' do
|
|
15
15
|
fragment.as_html(@link_resolver).gsub(/[\n\r]+/, '').gsub(/ +/, ' ').gsub(/'/, "'").should == %(<h2>The meta-micro mailing-list</h2><p>This is where you go to give feedback, and discuss the future of micro. <a href="https://groups.google.com/forum/?hl=en#!forum/micro-meta-framework">Subscribe to the list now</a>!</p><h2>The micro GitHub repository</h2><p>This is where you get truly active, by forking the project's source code, and making it better. Please always feel free to send us pull requests.</p> <div data-oembed="" data-oembed-type="link" data-oembed-provider="object"><div data-type="object"><a href="https://github.com/rudyrigot/meta-micro"><h1>rudyrigot/meta-micro</h1><img src="https://avatars2.githubusercontent.com/u/552279?s=400"><p>The meta-micro-framework you simply need</p></a></div></div><h2>Report bugs on micro</h2><p>If you think micro isn't working properly in one of its features, <a href="https://github.com/rudyrigot/meta-micro/issues">open a new issue in the micro GitHub repository</a>.</p><h2>Ask for help</h2><p>Feel free to ask a new question <a href="http://stackoverflow.com/questions/tagged/meta-micro">on StackOverflow</a>.</p>)
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
describe 'linked documents' do
|
20
|
+
it 'should have linked documents' do
|
21
|
+
response = @api.form("everything").query(%([[:d = any(document.type, ["doc","docchapter"])]])).submit(@master_ref)
|
22
|
+
linked_documents = response.results[0].linked_documents
|
23
|
+
linked_documents.count.should == 1
|
24
|
+
linked_documents[0].id.should == "U0w8OwEAACoAQEvB"
|
25
|
+
end
|
26
|
+
end
|
18
27
|
end
|
data/spec/prismic_spec.rb
CHANGED
@@ -10,10 +10,10 @@ describe 'Api' do
|
|
10
10
|
api.tags = {}
|
11
11
|
api.types = {}
|
12
12
|
api.refs = {
|
13
|
-
'key1' => Prismic::Ref.new('ref1', 'label1'),
|
14
|
-
'key2' => Prismic::Ref.new('ref2', 'label2'),
|
15
|
-
'key3' => Prismic::Ref.new('ref3', 'label3', true),
|
16
|
-
'key4' => Prismic::Ref.new('ref4', 'label4'),
|
13
|
+
'key1' => Prismic::Ref.new('id1', 'ref1', 'label1'),
|
14
|
+
'key2' => Prismic::Ref.new('id2', 'ref2', 'label2'),
|
15
|
+
'key3' => Prismic::Ref.new('id3', 'ref3', 'label3', true),
|
16
|
+
'key4' => Prismic::Ref.new('id4', 'ref4', 'label4'),
|
17
17
|
}
|
18
18
|
api.forms = {
|
19
19
|
'form1' => Prismic::Form.new(@api, 'form1', {}, nil, nil, nil, nil),
|
@@ -28,6 +28,12 @@ describe 'Api' do
|
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
|
+
describe 'id' do
|
32
|
+
it "returns the right id" do
|
33
|
+
@api.ref('key1').id.should == 'id1'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
31
37
|
describe 'ref' do
|
32
38
|
it "returns the right Ref" do
|
33
39
|
@api.ref('key2').label.should == 'label2'
|
@@ -253,7 +259,7 @@ end
|
|
253
259
|
describe 'LinkResolver' do
|
254
260
|
before do
|
255
261
|
@doc_link = Prismic::Fragments::DocumentLink.new('id', 'blog-post', ['tag1', 'tag2'], 'my-slug', false)
|
256
|
-
@document = Prismic::Document.new('id', 'blog-post', nil, ['tag1', 'tag2'], ['my-slug', 'my-other-slug'], nil)
|
262
|
+
@document = Prismic::Document.new('id', 'blog-post', nil, ['tag1', 'tag2'], ['my-slug', 'my-other-slug'], nil, nil)
|
257
263
|
|
258
264
|
@link_resolver = Prismic::LinkResolver.new(nil) do |doc|
|
259
265
|
'/'+doc.link_type+'/'+doc.id+'/'+doc.slug
|
@@ -275,7 +281,7 @@ describe 'Document' do
|
|
275
281
|
'field1' => Prismic::Fragments::DocumentLink.new(nil, nil, nil, nil, nil),
|
276
282
|
'field2' => Prismic::Fragments::WebLink.new('weburl')
|
277
283
|
}
|
278
|
-
@document = Prismic::Document.new(nil, nil, nil, nil, ['my-slug'], fragments)
|
284
|
+
@document = Prismic::Document.new(nil, nil, nil, nil, ['my-slug'], nil, fragments)
|
279
285
|
@link_resolver = Prismic::LinkResolver.new('master'){|doc_link|
|
280
286
|
"http://host/#{doc_link.id}"
|
281
287
|
}
|
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.
|
4
|
+
version: 1.0.0.rc8
|
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-
|
12
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -83,7 +83,8 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- lib/prismic.rb
|
85
85
|
- lib/prismic/api.rb
|
86
|
-
- lib/prismic/cache.rb
|
86
|
+
- lib/prismic/cache/basic.rb
|
87
|
+
- lib/prismic/cache/lru.rb
|
87
88
|
- lib/prismic/form.rb
|
88
89
|
- lib/prismic/fragments.rb
|
89
90
|
- lib/prismic/fragments/color.rb
|
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
138
|
version: 1.3.1
|
138
139
|
requirements: []
|
139
140
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.3.0
|
141
142
|
signing_key:
|
142
143
|
specification_version: 4
|
143
144
|
summary: Prismic.io development kit
|