loggable_activity 0.1.39 → 0.1.40
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 +4 -4
- data/.document +1 -0
- data/.nojekyll +1 -0
- data/.rubocop.yml +1 -1
- data/doc/.nojekyll +1 -0
- data/doc/CHANGELOG_md.html +125 -0
- data/doc/CODE_OF_CONDUCT_md.html +220 -0
- data/doc/CONSIDERTIONS_md.html +227 -0
- data/doc/CreateLoggableActivities.html +144 -0
- data/doc/CreateLoggableEncryptionKeys.html +140 -0
- data/doc/CreateLoggablePayloads.html +144 -0
- data/doc/GETTING-STARTED_md.html +186 -0
- data/doc/Gemfile.html +104 -0
- data/doc/Gemfile_lock.html +152 -0
- data/doc/LICENSE_txt.html +104 -0
- data/doc/LoggableActivity/CurrentUser.html +99 -0
- data/doc/LoggableActivity/Generators/InstallGenerator.html +178 -0
- data/doc/LoggableActivity/Generators.html +91 -0
- data/doc/README_md.html +138 -0
- data/doc/ROADMAP_md.html +151 -0
- data/doc/Rakefile.html +102 -0
- data/doc/bin/setup.html +100 -0
- data/doc/notes/CHEAT_SHEET_md.html +130 -0
- data/doc/sig/loggable_activity_rbs.html +101 -0
- data/docs/LoggableActivity/Activity.html +494 -0
- data/docs/LoggableActivity/Configuration.html +183 -0
- data/docs/LoggableActivity/Encryption.html +220 -0
- data/docs/LoggableActivity/EncryptionError.html +99 -0
- data/docs/LoggableActivity/EncryptionKey.html +327 -0
- data/docs/LoggableActivity/Error.html +97 -0
- data/docs/LoggableActivity/Hooks.html +172 -0
- data/docs/LoggableActivity/Payload.html +159 -0
- data/docs/LoggableActivity/PayloadsBuilder.html +154 -0
- data/docs/LoggableActivity/UpdatePayloadsBuilder.html +199 -0
- data/docs/LoggableActivity.html +100 -0
- data/docs/created.rid +10 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +687 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +91 -0
- data/docs/js/darkfish.js +97 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +184 -0
- data/lib/generators/loggable_activity/install_generator.rb +2 -1
- data/lib/generators/loggable_activity/templates/current_user.rb +1 -1
- data/lib/generators/loggable_activity/templates/loggable_activity.yml +29 -0
- data/lib/loggable_activity/activity.rb +208 -59
- data/lib/loggable_activity/configuration.rb +18 -0
- data/lib/loggable_activity/encryption.rb +20 -1
- data/lib/loggable_activity/encryption_key.rb +81 -14
- data/lib/loggable_activity/hooks.rb +10 -7
- data/lib/loggable_activity/payload.rb +45 -11
- data/lib/loggable_activity/payloads_builder.rb +50 -4
- data/lib/loggable_activity/update_payloads_builder.rb +64 -2
- data/lib/loggable_activity/version.rb +1 -1
- metadata +81 -9
- data/.DS_Store +0 -0
- data/loggable_activity-0.1.32.gem +0 -0
- data/loggable_activity-0.1.33.gem +0 -0
- data/loggable_activity-0.1.34.gem +0 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class LoggableActivity::Configuration - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">Object
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li ><a href="#method-c-for_class">::for_class</a>
|
76
|
+
<li ><a href="#method-c-load_config_file">::load_config_file</a>
|
77
|
+
</ul>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
</div>
|
81
|
+
</nav>
|
82
|
+
|
83
|
+
<main role="main" aria-labelledby="class-LoggableActivity::Configuration">
|
84
|
+
<h1 id="class-LoggableActivity::Configuration" class="class">
|
85
|
+
class LoggableActivity::Configuration
|
86
|
+
</h1>
|
87
|
+
|
88
|
+
<section class="description">
|
89
|
+
|
90
|
+
<p>This class is used to load the configuration file located at config/loggable_activity.yml</p>
|
91
|
+
|
92
|
+
</section>
|
93
|
+
|
94
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
101
|
+
<header>
|
102
|
+
<h3>Public Class Methods</h3>
|
103
|
+
</header>
|
104
|
+
|
105
|
+
<div id="method-c-for_class" class="method-detail ">
|
106
|
+
<div class="method-header">
|
107
|
+
<div class="method-heading">
|
108
|
+
<span class="method-name">for_class</span><span
|
109
|
+
class="method-args">(class_name)</span>
|
110
|
+
<span class="method-click-advice">click to toggle source</span>
|
111
|
+
</div>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
<div class="method-description">
|
115
|
+
<p>Returns the configuration data for the given class</p>
|
116
|
+
|
117
|
+
<p>Example:</p>
|
118
|
+
|
119
|
+
<pre class="ruby"><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">for_class</span>(<span class="ruby-string">'User'</span>)
|
120
|
+
</pre>
|
121
|
+
|
122
|
+
<p>Returns:</p>
|
123
|
+
|
124
|
+
<pre class="ruby">{
|
125
|
+
<span class="ruby-value">"record_display_name":</span> <span class="ruby-string">"full_name"</span>,
|
126
|
+
<span class="ruby-value">"loggable_attrs":</span> [
|
127
|
+
<span class="ruby-string">"first_name"</span>,
|
128
|
+
<span class="ruby-string">"last_name"</span>,
|
129
|
+
],
|
130
|
+
<span class="ruby-value">"auto_log":</span> [
|
131
|
+
<span class="ruby-string">"create"</span>,
|
132
|
+
<span class="ruby-string">"update"</span>,
|
133
|
+
<span class="ruby-string">"destroy"</span>
|
134
|
+
]
|
135
|
+
}
|
136
|
+
</pre>
|
137
|
+
|
138
|
+
<div class="method-source-code" id="for_class-source">
|
139
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 27</span>
|
140
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">for_class</span>(<span class="ruby-identifier">class_name</span>)
|
141
|
+
<span class="ruby-ivar">@config_data</span>[<span class="ruby-identifier">class_name</span>]
|
142
|
+
<span class="ruby-keyword">end</span></pre>
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<div id="method-c-load_config_file" class="method-detail ">
|
150
|
+
<div class="method-header">
|
151
|
+
<div class="method-heading">
|
152
|
+
<span class="method-name">load_config_file</span><span
|
153
|
+
class="method-args">(config_file_path)</span>
|
154
|
+
<span class="method-click-advice">click to toggle source</span>
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div class="method-description">
|
159
|
+
|
160
|
+
|
161
|
+
<div class="method-source-code" id="load_config_file-source">
|
162
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/configuration.rb, line 6</span>
|
163
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">load_config_file</span>(<span class="ruby-identifier">config_file_path</span>)
|
164
|
+
<span class="ruby-ivar">@config_data</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">config_file_path</span>)
|
165
|
+
<span class="ruby-keyword">end</span></pre>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
|
170
|
+
</div>
|
171
|
+
|
172
|
+
</section>
|
173
|
+
|
174
|
+
</section>
|
175
|
+
</main>
|
176
|
+
|
177
|
+
|
178
|
+
<footer id="validator-badges" role="contentinfo">
|
179
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
180
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
|
181
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
182
|
+
</footer>
|
183
|
+
|
@@ -0,0 +1,220 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module LoggableActivity::Encryption - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="module">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
<!-- Method Quickref -->
|
65
|
+
<div id="method-list-section" class="nav-section">
|
66
|
+
<h3>Methods</h3>
|
67
|
+
|
68
|
+
<ul class="link-list" role="directory">
|
69
|
+
<li ><a href="#method-c-blank-3F">::blank?</a>
|
70
|
+
<li ><a href="#method-c-decrypt">::decrypt</a>
|
71
|
+
<li ><a href="#method-c-encrypt">::encrypt</a>
|
72
|
+
</ul>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
</div>
|
76
|
+
</nav>
|
77
|
+
|
78
|
+
<main role="main" aria-labelledby="module-LoggableActivity::Encryption">
|
79
|
+
<h1 id="module-LoggableActivity::Encryption" class="module">
|
80
|
+
module LoggableActivity::Encryption
|
81
|
+
</h1>
|
82
|
+
|
83
|
+
<section class="description">
|
84
|
+
|
85
|
+
<p>This module is used to encrypt and decrypt attributes</p>
|
86
|
+
|
87
|
+
</section>
|
88
|
+
|
89
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
96
|
+
<header>
|
97
|
+
<h3>Public Class Methods</h3>
|
98
|
+
</header>
|
99
|
+
|
100
|
+
<div id="method-c-blank-3F" class="method-detail ">
|
101
|
+
<div class="method-header">
|
102
|
+
<div class="method-heading">
|
103
|
+
<span class="method-name">blank?</span><span
|
104
|
+
class="method-args">(value)</span>
|
105
|
+
<span class="method-click-advice">click to toggle source</span>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<div class="method-description">
|
110
|
+
|
111
|
+
|
112
|
+
<div class="method-source-code" id="blank-3F-source">
|
113
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 58</span>
|
114
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">blank?</span>(<span class="ruby-identifier">value</span>)
|
115
|
+
<span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">:</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>
|
116
|
+
<span class="ruby-keyword">end</span></pre>
|
117
|
+
</div>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div id="method-c-decrypt" class="method-detail ">
|
124
|
+
<div class="method-header">
|
125
|
+
<div class="method-heading">
|
126
|
+
<span class="method-name">decrypt</span><span
|
127
|
+
class="method-args">(data, encryption_key)</span>
|
128
|
+
<span class="method-click-advice">click to toggle source</span>
|
129
|
+
</div>
|
130
|
+
</div>
|
131
|
+
|
132
|
+
<div class="method-description">
|
133
|
+
<p>Decrypts the given data using the given encryption key</p>
|
134
|
+
|
135
|
+
<p>Example:</p>
|
136
|
+
|
137
|
+
<pre class="ruby"><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-string">'SOME_ENCRYPTED_STRING'</span>, <span class="ruby-string">'SECRET_KEY'</span>)
|
138
|
+
</pre>
|
139
|
+
|
140
|
+
<p>Returns:</p>
|
141
|
+
|
142
|
+
<pre class="ruby"><span class="ruby-string">"my secret data"</span>
|
143
|
+
</pre>
|
144
|
+
|
145
|
+
<div class="method-source-code" id="decrypt-source">
|
146
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 43</span>
|
147
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">encryption_key</span>)
|
148
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
|
149
|
+
<span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable.activity.deleted'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">nil?</span>
|
150
|
+
|
151
|
+
<span class="ruby-identifier">cipher</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'AES-128-CBC'</span>).<span class="ruby-identifier">decrypt</span>
|
152
|
+
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">encryption_key</span>)[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">15</span>]
|
153
|
+
<span class="ruby-identifier">decrypted_data</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">data</span>)
|
154
|
+
<span class="ruby-identifier">decrypted_output</span> = <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">decrypted_data</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">final</span>
|
155
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-string">'Decryption failed: Invalid UTF-8 output'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">decrypted_output</span>.<span class="ruby-identifier">valid_encoding?</span>
|
156
|
+
|
157
|
+
<span class="ruby-identifier">decrypted_output</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">'UTF-8'</span>)
|
158
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span><span class="ruby-operator">::</span><span class="ruby-constant">CipherError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
159
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
|
160
|
+
<span class="ruby-keyword">end</span></pre>
|
161
|
+
</div>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div id="method-c-encrypt" class="method-detail ">
|
168
|
+
<div class="method-header">
|
169
|
+
<div class="method-heading">
|
170
|
+
<span class="method-name">encrypt</span><span
|
171
|
+
class="method-args">(data, encryption_key)</span>
|
172
|
+
<span class="method-click-advice">click to toggle source</span>
|
173
|
+
</div>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
<div class="method-description">
|
177
|
+
<p>Encrypts the given data using the given encryption key</p>
|
178
|
+
|
179
|
+
<p>Example:</p>
|
180
|
+
|
181
|
+
<pre class="ruby"><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-string">'my secret data'</span>, <span class="ruby-string">'my secret key'</span>)
|
182
|
+
</pre>
|
183
|
+
|
184
|
+
<p>Returns:</p>
|
185
|
+
|
186
|
+
<pre class="ruby"><span class="ruby-string">"SOME_ENCRYPTED_STRING"</span>
|
187
|
+
</pre>
|
188
|
+
|
189
|
+
<div class="method-source-code" id="encrypt-source">
|
190
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 22</span>
|
191
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">encryption_key</span>)
|
192
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
|
193
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">nil?</span>
|
194
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-string">'Encryption failed: Invalid encryption key length'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
|
195
|
+
|
196
|
+
<span class="ruby-identifier">cipher</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'AES-128-CBC'</span>).<span class="ruby-identifier">encrypt</span>
|
197
|
+
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">encryption_key</span>)[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">15</span>]
|
198
|
+
<span class="ruby-identifier">encrypted</span> = <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">final</span>
|
199
|
+
<span class="ruby-constant">Base64</span>.<span class="ruby-identifier">encode64</span>(<span class="ruby-identifier">encrypted</span>)
|
200
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span><span class="ruby-operator">::</span><span class="ruby-constant">CipherError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
201
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">"Encryption failed: #{e.message} ***"</span>
|
202
|
+
<span class="ruby-keyword">end</span></pre>
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
|
207
|
+
</div>
|
208
|
+
|
209
|
+
</section>
|
210
|
+
|
211
|
+
</section>
|
212
|
+
</main>
|
213
|
+
|
214
|
+
|
215
|
+
<footer id="validator-badges" role="contentinfo">
|
216
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
217
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
|
218
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
219
|
+
</footer>
|
220
|
+
|
@@ -0,0 +1,99 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class LoggableActivity::EncryptionError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">StandardError
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</div>
|
71
|
+
</nav>
|
72
|
+
|
73
|
+
<main role="main" aria-labelledby="class-LoggableActivity::EncryptionError">
|
74
|
+
<h1 id="class-LoggableActivity::EncryptionError" class="class">
|
75
|
+
class LoggableActivity::EncryptionError
|
76
|
+
</h1>
|
77
|
+
|
78
|
+
<section class="description">
|
79
|
+
|
80
|
+
<p>This error is raised when encryption or decryption fails</p>
|
81
|
+
|
82
|
+
</section>
|
83
|
+
|
84
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
</section>
|
91
|
+
</main>
|
92
|
+
|
93
|
+
|
94
|
+
<footer id="validator-badges" role="contentinfo">
|
95
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
96
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
|
97
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
98
|
+
</footer>
|
99
|
+
|