livefyre 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +2 -2
- data/lib/livefyre/core.rb +12 -3
- data/lib/livefyre/version.rb +1 -1
- data/spec/livefyre/core_spec.rb +18 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTUwODdmZjljOWQwZmZiZGQzODdlMDMzMmMzNTQ0ZjAyNDhkNTFlNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmIyYjY3MDY4OWExYjYwMTZjM2MzNzMxZWViNTVmMTZkOWE5MmY3YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTY1ZGI1NDlhZDlkZjg3MWZjZmRjYWNkMzQyZmY0MDk1MmZkYjgzMDI1NWEy
|
10
|
+
MzRhZGE1NGNjZjdiZTVjNmM0ZGUyMjc5NTI5NjMyNDZjMTAwZTg2YzNjYTcx
|
11
|
+
MDg2NWU2OGU5NTllYzdlYjVlZjIyNjk4N2M0NWFhNTFiYzNjOGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjEzMWM2Y2RjYTY5OWFkN2E1NzZmNTNkOGU4ODZmOTAyMjE0ZmUwZjRiMGMy
|
14
|
+
Nzc3NWRmMmU4MGUyYWIxNTYzZWVlZmQ5ZGU3ZDA4NTQ0ODYxYTE2YTlhNGM2
|
15
|
+
Nzg4YjgzOTQ5NDhhZThmODgzODIzODEzYjYwNjgxNjU5ZDYyMDU=
|
data/README.md
CHANGED
@@ -53,10 +53,10 @@ site = network.get_site('site_id', 'site_key')
|
|
53
53
|
```
|
54
54
|
|
55
55
|
Building a collection meta token:
|
56
|
-
*The 'tags' and
|
56
|
+
*The 'tags' and type' arguments are optional.*
|
57
57
|
|
58
58
|
```ruby
|
59
|
-
site.build_collection_meta_token('title', 'article_id', 'url', 'tags', '
|
59
|
+
site.build_collection_meta_token('title', 'article_id', 'url', 'tags', 'type')
|
60
60
|
```
|
61
61
|
|
62
62
|
Building a checksum:
|
data/lib/livefyre/core.rb
CHANGED
@@ -63,13 +63,16 @@ module Livefyre
|
|
63
63
|
end
|
64
64
|
|
65
65
|
class Site
|
66
|
+
TYPE = ['reviews', 'sidenotes']
|
67
|
+
STREAM_TYPE = ['liveblog', 'livechat', 'livecomments']
|
68
|
+
|
66
69
|
def initialize(network_name, site_id, site_key)
|
67
70
|
@network_name = network_name
|
68
71
|
@site_id = site_id
|
69
72
|
@site_key = site_key
|
70
73
|
end
|
71
74
|
|
72
|
-
def build_collection_meta_token(title, article_id, url, tags='',
|
75
|
+
def build_collection_meta_token(title, article_id, url, tags='', type=nil)
|
73
76
|
raise ArgumentError, 'provided url is not a valid url' if !uri?(url)
|
74
77
|
raise ArgumentError, 'title length should be under 255 char' if title.length > 255
|
75
78
|
|
@@ -79,8 +82,14 @@ module Livefyre
|
|
79
82
|
title: title,
|
80
83
|
articleId: article_id
|
81
84
|
}
|
82
|
-
if
|
83
|
-
|
85
|
+
if type
|
86
|
+
if TYPE.include? type
|
87
|
+
collection_meta[:type] = type
|
88
|
+
elsif STREAM_TYPE.include? type
|
89
|
+
collection_meta[:stream_type] = type
|
90
|
+
else
|
91
|
+
raise ArgumentError, 'type is not a recognized type. should be liveblog, livechat, livecomments, reviews, sidenotes, or an empty string'
|
92
|
+
end
|
84
93
|
end
|
85
94
|
|
86
95
|
JWT.encode(collection_meta, @site_key)
|
data/lib/livefyre/version.rb
CHANGED
data/spec/livefyre/core_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'livefyre'
|
4
|
+
require 'jwt'
|
4
5
|
|
5
6
|
describe Livefyre::Network do
|
6
7
|
before(:each) do
|
@@ -22,7 +23,7 @@ end
|
|
22
23
|
|
23
24
|
describe Livefyre::Network::Site do
|
24
25
|
before(:each) do
|
25
|
-
@site = Livefyre.get_network('networkName', 'networkKey').get_site('siteId',
|
26
|
+
@site = Livefyre.get_network('networkName', 'networkKey').get_site('siteId', 'siteKey')
|
26
27
|
end
|
27
28
|
|
28
29
|
it 'should raise ArgumentError if url is not a valid url for cmt' do
|
@@ -33,6 +34,22 @@ describe Livefyre::Network::Site do
|
|
33
34
|
expect{ @site.build_collection_meta_token('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456', 'test', 'http://test.com', 'test') }.to raise_error(ArgumentError)
|
34
35
|
end
|
35
36
|
|
37
|
+
it 'should raise ArgumentError if not a valid type is passed in when building a collection meta token' do
|
38
|
+
expect{ @site.build_collection_meta_token('', '', 'http://livefyre.com', '', 'bad type') }.to raise_error(ArgumentError)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should check type and assign them to the correct field in the collection meta token' do
|
42
|
+
@token = @site.build_collection_meta_token('', '', 'http://livefyre.com', '', 'reviews')
|
43
|
+
@decoded = JWT.decode(@token, 'siteKey')
|
44
|
+
|
45
|
+
expect(@decoded['type']).to eq('reviews')
|
46
|
+
|
47
|
+
@token = @site.build_collection_meta_token('', '', 'http://livefyre.com', '', 'liveblog')
|
48
|
+
@decoded = JWT.decode(@token, 'siteKey')
|
49
|
+
|
50
|
+
expect(@decoded['stream_type']).to eq('liveblog')
|
51
|
+
end
|
52
|
+
|
36
53
|
it 'should return a collection meta token' do
|
37
54
|
expect{ @site.build_collection_meta_token('title', 'article_id', 'https://www.url.com', 'tags') }.to be_true
|
38
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livefyre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Livefyre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|