threepwood 0.7.0
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.
- data/README.rdoc +41 -0
- data/lib/threepwood.rb +6 -0
- data/lib/threepwood/cookie_filter.rb +13 -0
- data/lib/threepwood/railtie.rb +38 -0
- data/lib/threepwood/version.rb +13 -0
- metadata +69 -0
data/README.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= Threepwood
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
Allows cookies to be set and unset with simple command.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
gem install threepwood
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
Add gem 'threepwood' to your Gemfile.
|
14
|
+
This will remove all cookies from your site.
|
15
|
+
To allow cookies through, simply call accept_cookies in your controller.
|
16
|
+
instance variable available @accepted_cookies is set when consent needs to be got
|
17
|
+
|
18
|
+
== License
|
19
|
+
|
20
|
+
Copyright (c) 2012 AHC
|
21
|
+
|
22
|
+
Permission is hereby granted, free of charge, to any person
|
23
|
+
obtaining a copy of this software and associated documentation
|
24
|
+
files (the "Software"), to deal in the Software without
|
25
|
+
restriction, including without limitation the rights to use,
|
26
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
27
|
+
copies of the Software, and to permit persons to whom the
|
28
|
+
Software is furnished to do so, subject to the following
|
29
|
+
conditions:
|
30
|
+
|
31
|
+
The above copyright notice and this permission notice shall be
|
32
|
+
included in all copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
35
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
36
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
37
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
38
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
39
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
40
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
41
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/threepwood.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Threepwood
|
2
|
+
|
3
|
+
module ControllerExtensions
|
4
|
+
def self.included(base)
|
5
|
+
base.send(:include, InstanceMethods)
|
6
|
+
base.before_filter(:check_cookies)
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
def check_cookies
|
11
|
+
if cookies[:threepwood_accepted]
|
12
|
+
@accepted_cookies = true
|
13
|
+
else
|
14
|
+
headers["no-threepwood"] = "true"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def accept_cookies
|
18
|
+
cookies.permanent[:threepwood_accepted] = true
|
19
|
+
headers.delete "no-threepwood" #need this if the cookies have been accepeted after the header has been set
|
20
|
+
end
|
21
|
+
def reject_cookies
|
22
|
+
cookies.delete :threepwood_accepted
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
class Railtie < Rails::Railtie
|
29
|
+
initializer "threepwood.insert_middleware" do |app|
|
30
|
+
app.config.middleware.insert_before ::ActionDispatch::Cookies, ::CookieFilter
|
31
|
+
end
|
32
|
+
|
33
|
+
config.to_prepare do
|
34
|
+
ApplicationController.send(:include, Threepwood::ControllerExtensions)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: threepwood
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 0
|
10
|
+
version: 0.7.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Yule
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-21 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: By including threepwood in your gemfile, all cookies will be blocked on your site until accept_cookies is called
|
22
|
+
email: user@example.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.rdoc
|
29
|
+
files:
|
30
|
+
- lib/threepwood/cookie_filter.rb
|
31
|
+
- lib/threepwood/railtie.rb
|
32
|
+
- lib/threepwood/version.rb
|
33
|
+
- lib/threepwood.rb
|
34
|
+
- README.rdoc
|
35
|
+
homepage: http://www.ahc.uk.com
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.10
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Allows websites to easily comply with Eu cookie law
|
68
|
+
test_files: []
|
69
|
+
|