cookiesalert 0.1.1 → 0.1.2

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 967d3c2577ab16cdb328d7effd113a3598581dcab304056e3dc1e70fbe7dfabd
4
- data.tar.gz: 4f347183c2da130154a5490f4fb25d9edc07ea830268e7f553dc30cda3fce29c
3
+ metadata.gz: 6af23f235b2cb6e9a3a86fbb357d2d49185b85fb6c69d9637cf7798133f5d482
4
+ data.tar.gz: 319c2c81ccbf0bacd29aee8605e803dfde99977fb52ceb55cd60f17fad96298c
5
5
  SHA512:
6
- metadata.gz: 48b94cd6d1890e70830676de8b7e4c52993b795d4af8116fa8acfe2512eb8cb21ef25e17c41645f244a248c91860e3a4c38796a13dfb6c73da89d6effec6caf8
7
- data.tar.gz: 7db23f9221584e9bb1625916f1379e36af33b0d6ac1e553099ff9a8520d02ab59c64d2dd4d84845a6875fd1c569c19adc9812ce2f81cf7dcc9b795a3614cf8a4
6
+ metadata.gz: d9fa8455245fad2e2854b4fe574481f91c5908853a1142ee4d8b0ec8549e8600fb694502d77489d5c534a56523b4cfc78fb770bb6a49ad99b7d23104a65244de
7
+ data.tar.gz: 72846ac61604fd5aef471ee4c6ef1075843d24a15496737e66c7d3017808f0a51653441a1a7f7bc6a57cf16564b7b849c3f6c7c61db92fb85527a9010cd9cb3a
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Cookies alert
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/ct_table_for.svg)](https://badge.fury.io/rb/cookiesalert)
3
+ [![Gem Version](https://badge.fury.io/rb/cookiesalert.svg)](https://badge.fury.io/rb/cookiesalert)
4
+
5
+ Easily add a Cookie consent banner, upon the user’s first visit to the site, to alert the users about the cookies and get consent for setting them.
4
6
 
5
7
  ## Installation
6
8
 
@@ -29,7 +31,7 @@ $( document ).ready(function() {
29
31
  });
30
32
  ```
31
33
 
32
- Javascript optional parameters for select "#text_div" and add listener in "#button_confirm" for accept cookies:
34
+ Javascript optional parameters to select "#text_div" and add listener in "#button_confirm" to accept cookies:
33
35
  ```js
34
36
  cookies.check({
35
37
  div : '#div',
@@ -47,12 +49,12 @@ Add optional styles in "application.css":
47
49
 
48
50
  Import optional view layout:
49
51
  ```erb
50
- <%= render "cookies/alert", :advice => "Cookies Text", :link => "Link Advice", :button => "Button" %>
52
+ <%= render "cookies/alert", advice: "Cookies Text", link: "Link Advice", button: "Button" %>
51
53
  ```
52
54
 
53
55
  Render optional parameters:
54
56
  ```erb
55
- <%= render "cookies/alert", :advice => "Cookies Text", :link => link_to('Link Advice', root_path, target: '_blank'), :button => image_tag('cross_cookies.svg') %>
57
+ <%= render "cookies/alert", advice: "Cookies Text", link: link_to('Link Advice', root_path, target: '_blank'), button: image_tag('cross_cookies.svg') %>
56
58
  ```
57
59
 
58
60
  ## Used Javascript Linter
@@ -87,7 +89,7 @@ module.exports = {
87
89
  ```
88
90
 
89
91
  ## Dependences included:
90
- -[JavaScript Cookie v2.1.3](https://github.com/js-cookie/js-cookie)
92
+ - [JavaScript Cookie v2.2.0](https://github.com/js-cookie/js-cookie)
91
93
 
92
94
  # Contributing
93
95
 
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * JavaScript Cookie v2.1.3
2
+ * JavaScript Cookie v2.2.0
3
3
  * https://github.com/js-cookie/js-cookie
4
4
  *
5
5
  * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
6
6
  * Released under the MIT license
7
7
  */
8
8
  ;(function (factory) {
9
- var registeredInModuleLoader = false;
9
+ var registeredInModuleLoader;
10
10
  if (typeof define === 'function' && define.amd) {
11
11
  define(factory);
12
12
  registeredInModuleLoader = true;
@@ -36,117 +36,124 @@
36
36
  return result;
37
37
  }
38
38
 
39
+ function decode (s) {
40
+ return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
41
+ }
42
+
39
43
  function init (converter) {
40
- function api (key, value, attributes) {
41
- var result;
44
+ function api() {}
45
+
46
+ function set (key, value, attributes) {
42
47
  if (typeof document === 'undefined') {
43
48
  return;
44
49
  }
45
50
 
46
- // Write
51
+ attributes = extend({
52
+ path: '/'
53
+ }, api.defaults, attributes);
54
+
55
+ if (typeof attributes.expires === 'number') {
56
+ attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
57
+ }
47
58
 
48
- if (arguments.length > 1) {
49
- attributes = extend({
50
- path: '/'
51
- }, api.defaults, attributes);
59
+ // We're using "expires" because "max-age" is not supported by IE
60
+ attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
52
61
 
53
- if (typeof attributes.expires === 'number') {
54
- var expires = new Date();
55
- expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
56
- attributes.expires = expires;
62
+ try {
63
+ var result = JSON.stringify(value);
64
+ if (/^[\{\[]/.test(result)) {
65
+ value = result;
57
66
  }
67
+ } catch (e) {}
58
68
 
59
- try {
60
- result = JSON.stringify(value);
61
- if (/^[\{\[]/.test(result)) {
62
- value = result;
63
- }
64
- } catch (e) {}
69
+ value = converter.write ?
70
+ converter.write(value, key) :
71
+ encodeURIComponent(String(value))
72
+ .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
65
73
 
66
- if (!converter.write) {
67
- value = encodeURIComponent(String(value))
68
- .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
69
- } else {
70
- value = converter.write(value, key);
74
+ key = encodeURIComponent(String(key))
75
+ .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
76
+ .replace(/[\(\)]/g, escape);
77
+
78
+ var stringifiedAttributes = '';
79
+ for (var attributeName in attributes) {
80
+ if (!attributes[attributeName]) {
81
+ continue;
82
+ }
83
+ stringifiedAttributes += '; ' + attributeName;
84
+ if (attributes[attributeName] === true) {
85
+ continue;
71
86
  }
72
87
 
73
- key = encodeURIComponent(String(key));
74
- key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
75
- key = key.replace(/[\(\)]/g, escape);
76
-
77
- return (document.cookie = [
78
- key, '=', value,
79
- attributes.expires ? '; expires=' + attributes.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
80
- attributes.path ? '; path=' + attributes.path : '',
81
- attributes.domain ? '; domain=' + attributes.domain : '',
82
- attributes.secure ? '; secure' : ''
83
- ].join(''));
88
+ // Considers RFC 6265 section 5.2:
89
+ // ...
90
+ // 3. If the remaining unparsed-attributes contains a %x3B (";")
91
+ // character:
92
+ // Consume the characters of the unparsed-attributes up to,
93
+ // not including, the first %x3B (";") character.
94
+ // ...
95
+ stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
84
96
  }
85
97
 
86
- // Read
98
+ return (document.cookie = key + '=' + value + stringifiedAttributes);
99
+ }
87
100
 
88
- if (!key) {
89
- result = {};
101
+ function get (key, json) {
102
+ if (typeof document === 'undefined') {
103
+ return;
90
104
  }
91
105
 
106
+ var jar = {};
92
107
  // To prevent the for loop in the first place assign an empty array
93
- // in case there are no cookies at all. Also prevents odd result when
94
- // calling "get()"
108
+ // in case there are no cookies at all.
95
109
  var cookies = document.cookie ? document.cookie.split('; ') : [];
96
- var rdecode = /(%[0-9A-Z]{2})+/g;
97
110
  var i = 0;
98
111
 
99
112
  for (; i < cookies.length; i++) {
100
113
  var parts = cookies[i].split('=');
101
114
  var cookie = parts.slice(1).join('=');
102
115
 
103
- if (cookie.charAt(0) === '"') {
116
+ if (!json && cookie.charAt(0) === '"') {
104
117
  cookie = cookie.slice(1, -1);
105
118
  }
106
119
 
107
120
  try {
108
- var name = parts[0].replace(rdecode, decodeURIComponent);
109
- cookie = converter.read ?
110
- converter.read(cookie, name) : converter(cookie, name) ||
111
- cookie.replace(rdecode, decodeURIComponent);
121
+ var name = decode(parts[0]);
122
+ cookie = (converter.read || converter)(cookie, name) ||
123
+ decode(cookie);
112
124
 
113
- if (this.json) {
125
+ if (json) {
114
126
  try {
115
127
  cookie = JSON.parse(cookie);
116
128
  } catch (e) {}
117
129
  }
118
130
 
131
+ jar[name] = cookie;
132
+
119
133
  if (key === name) {
120
- result = cookie;
121
134
  break;
122
135
  }
123
-
124
- if (!key) {
125
- result[name] = cookie;
126
- }
127
136
  } catch (e) {}
128
137
  }
129
138
 
130
- return result;
139
+ return key ? jar[key] : jar;
131
140
  }
132
141
 
133
- api.set = api;
142
+ api.set = set;
134
143
  api.get = function (key) {
135
- return api.call(api, key);
144
+ return get(key, false /* read as raw */);
136
145
  };
137
- api.getJSON = function () {
138
- return api.apply({
139
- json: true
140
- }, [].slice.call(arguments));
146
+ api.getJSON = function (key) {
147
+ return get(key, true /* read as json */);
141
148
  };
142
- api.defaults = {};
143
-
144
149
  api.remove = function (key, attributes) {
145
- api(key, '', extend(attributes, {
150
+ set(key, '', extend(attributes, {
146
151
  expires: -1
147
152
  }));
148
153
  };
149
154
 
155
+ api.defaults = {};
156
+
150
157
  api.withConverter = init;
151
158
 
152
159
  return api;
@@ -1,3 +1,3 @@
1
1
  module Cookiesalert
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookiesalert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Subils
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-10-19 00:00:00.000000000 Z
13
+ date: 2019-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -77,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubyforge_project:
81
- rubygems_version: 2.7.6
80
+ rubygems_version: 3.0.2
82
81
  signing_key:
83
82
  specification_version: 4
84
83
  summary: Cookie's Alert generator