livefyre 1.1.0 → 1.1.1

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWNjYjgzNjFhMWJlNjc4YWY1MjQ5OTcwYzlkNTBjMjdlMjc0ZjM5OA==
4
+ MjkyNWUzNzE3OGFhNTJiNTc1ZjBmN2I4ZDY5OGVlYjkyOGVjMzE1Mg==
5
5
  data.tar.gz: !binary |-
6
- MGNhN2I5NjY5NjVjMTczYWNiNjEwNmViOWZhOGIxMjNhNDkzNGQzMg==
6
+ ZjBjMTkyMTIxMmRlMjQ2YWI4NGVmYmRhODZmZjQxNzk5M2Q1NDVhMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTk5NDRmYzE2NzhmMTkzZTZlZTlmMTIzYzdhZDUxZTllZTFhZGM1ZDVjZWZj
10
- MzhmYmI2ODZmNzA5YWRlYzQ3ZWZhZGYyZWQ4YmY1Njk3MmNkOWFjMThkM2Uw
11
- YWJmMGFhOTY3NGUxNzYxZWMyYTRjYjRiMGY1ZDJiYmJhMzY5M2Q=
9
+ Y2VhZGI2MmMyOTZkOGZhN2UzMTY2YWYzNmE4NGRhYTJiMzZjYWE2YzdlZmE4
10
+ YWMwZjA5NGVjMTQ1NmVkNjNlZTMyN2ViMjBiYWU2MTNhNWNhNWI1Y2E5MDQ2
11
+ MDIyZTExNTY0ZTQ2NTYwMWNkM2JiOTVjN2RhMDQ3MjZkZWU1MzI=
12
12
  data.tar.gz: !binary |-
13
- MmRhNDlhN2UwNDc2MDI4MjFjYjRhZGNiM2UzYmFlMWIzOTNkZmEyMGE3Yjkw
14
- Njc1MGYwNGZkZjQ1NThkZjg2OWViNTFlYmU3NzgwNjI1ZWU5OGM4ZjExYjg3
15
- Y2NmYTgxYzZmM2JlM2E4ZjljMDY0MzE0ZTE0MTdmYjhmMTRlOGY=
13
+ NDBhMWRjMDA3MWMxODA0MDY5MjIzYmU5ZTAzZjVmMGQyNDlhNGJlNmFjOTBh
14
+ MGUzMDhkNGExZDkzM2ZiMDFjMGM4MTlkNDg4NjRkOTEwYjhiNjUzODQ4NGY5
15
+ Yjg5NWI5MWRhZjhiZDg3NDg3ZDgzY2M0YTkxMGIyYmRkZDE3NjU=
data/README.md CHANGED
@@ -59,6 +59,13 @@ Building a collection meta token:
59
59
  site.build_collection_meta_token('title', 'article_id', 'url', 'tags', 'stream')
60
60
  ```
61
61
 
62
+ Building a checksum:
63
+ *The 'tags' argument is optional.*
64
+
65
+ ```ruby
66
+ site.build_checksum('title', 'url', 'tags')
67
+ ```
68
+
62
69
  To retrieve content collection data:
63
70
 
64
71
  ```ruby
data/lib/livefyre/core.rb CHANGED
@@ -73,18 +73,26 @@ module Livefyre
73
73
  raise ArgumentError, 'provided url is not a valid url' if !uri?(url)
74
74
  raise ArgumentError, 'title length should be under 255 char' if title.length > 255
75
75
 
76
- collection_meta = { url: url, tags: tags, title: title }
77
- checksum = Digest::MD5.new.update(collection_meta.to_json).hexdigest
78
-
79
- collection_meta[:articleId] = article_id
80
- collection_meta[:checksum] = checksum
81
-
76
+ collection_meta = {
77
+ url: url,
78
+ tags: tags,
79
+ title: title,
80
+ articleId: article_id
81
+ }
82
82
  if stream
83
83
  collection_meta[:type] = stream
84
84
  end
85
85
 
86
86
  JWT.encode(collection_meta, @site_key)
87
87
  end
88
+
89
+ def build_checksum(title, url, tags='')
90
+ raise ArgumentError, 'provided url is not a valid url' if !uri?(url)
91
+ raise ArgumentError, 'title length should be under 255 char' if title.length > 255
92
+
93
+ collection_meta = { url: url, tags: tags, title: title }
94
+ Digest::MD5.new.update(collection_meta.to_json).hexdigest
95
+ end
88
96
 
89
97
  def get_collection_content(article_id)
90
98
  response =
@@ -1,3 +1,3 @@
1
1
  module Livefyre
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -23,15 +23,27 @@ describe Livefyre::Network::Site do
23
23
  @site = Livefyre.get_network('networkName', 'networkKey').get_site('siteId', "siteKey")
24
24
  end
25
25
 
26
- it 'should raise ArgumentError if url is not a valid url' do
26
+ it 'should raise ArgumentError if url is not a valid url for cmt' do
27
27
  expect{ @site.build_collection_meta_token('test', 'test', 'blah.com/', 'test') }.to raise_error(ArgumentError)
28
28
  end
29
29
 
30
- it 'should raise ArgumentError if title is more than 255 characters' do
30
+ it 'should raise ArgumentError if title is more than 255 characters for cmt' do
31
31
  expect{ @site.build_collection_meta_token('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456', 'test', 'http://test.com', 'test') }.to raise_error(ArgumentError)
32
32
  end
33
33
 
34
34
  it 'should return a collection meta token' do
35
35
  expect{ @site.build_collection_meta_token('title', 'article_id', 'https://www.url.com', 'tags') }.to be_true
36
36
  end
37
+
38
+ it 'should raise ArgumentError if url is not a valid url for checksum' do
39
+ expect{ @site.build_checksum('test', 'blah.com/', 'test') }.to raise_error(ArgumentError)
40
+ end
41
+
42
+ it 'should raise ArgumentError if title is more than 255 characters for checksum' do
43
+ expect{ @site.build_checksum('1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456', 'http://test.com', 'test') }.to raise_error(ArgumentError)
44
+ end
45
+
46
+ it 'should return a valid checksum' do
47
+ expect(@site.build_checksum('title', 'https://www.url.com', 'tags')).to eq('6e2e4faf7b95f896260fe695eafb34ba')
48
+ end
37
49
  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.0
4
+ version: 1.1.1
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-07 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler