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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjBlODNiYWZhMWJhOTgxNDljYzJkOWZlNDVmZThhNTg1YWQ4ZjI2Yg==
4
+ YTUwODdmZjljOWQwZmZiZGQzODdlMDMzMmMzNTQ0ZjAyNDhkNTFlNQ==
5
5
  data.tar.gz: !binary |-
6
- NWEzYTU3MTRmNjg1YWMwMDQzYWM5MWIzZmU4YTY1ZWE1MTNjOTVjZg==
6
+ ZmIyYjY3MDY4OWExYjYwMTZjM2MzNzMxZWViNTVmMTZkOWE5MmY3YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTIzZTM1YTIzZTM0NDcxM2U3Y2YzMmQxMzcxZTU1OTc3NTJjNGI2ZDIzOWUy
10
- ZTVhYTkzOTcyMWRmOGU3NDc0ZjQ0YWNlNmVmYjcwM2M5ZmM1ZTI2ZmNiYzQw
11
- OGQxMTRiNjM3NGQwNWVjOGQ2ZDQ2ODNhMDJkMGY2Y2I1MzBjYmI=
9
+ ZTY1ZGI1NDlhZDlkZjg3MWZjZmRjYWNkMzQyZmY0MDk1MmZkYjgzMDI1NWEy
10
+ MzRhZGE1NGNjZjdiZTVjNmM0ZGUyMjc5NTI5NjMyNDZjMTAwZTg2YzNjYTcx
11
+ MDg2NWU2OGU5NTllYzdlYjVlZjIyNjk4N2M0NWFhNTFiYzNjOGU=
12
12
  data.tar.gz: !binary |-
13
- YTM2NDYzODM3OTNiMWY3MWFhNzZiMjdiODZkNDZhMWUwYTA0Yzg5YzA3NTY4
14
- OGNiYTZkMjkyNWQ2NmQ1ZDY5ZjU1ODYzOGZjZDA1MTNhNjNmZjcwZTUxMDUx
15
- Njk0OTdmN2JiMzRmN2E2YTM5NTEzNzAwOTFiMWJmOTQ0NmE0MjM=
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 stream' arguments are optional.*
56
+ *The 'tags' and type' arguments are optional.*
57
57
 
58
58
  ```ruby
59
- site.build_collection_meta_token('title', 'article_id', 'url', 'tags', 'stream')
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='', stream=nil)
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 stream
83
- collection_meta[:type] = stream
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)
@@ -1,3 +1,3 @@
1
1
  module Livefyre
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -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', "siteKey")
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.2
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-10 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler