redacted 0.0.2 → 0.0.3
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/Gemfile +4 -1
- data/README.md +25 -23
- data/Rakefile +0 -1
- data/circle.yml +3 -0
- data/lib/redacted.rb +1 -1
- data/lib/redacted/version.rb +1 -1
- data/redacted.gemspec +1 -1
- data/test/test_helper.rb +3 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 898b8576effd7e89eeb8eb860a759bac5d686697
|
4
|
+
data.tar.gz: f74e3c61e9c52b704fb43015f8823de025ce039c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bec6a5dbd663398a030755781daf8d0a2e6635fb8b2ce1bbaa862bace4d1b829d98746a38c82cc3aa052c5a06192a0fb86ad67dc0721bab59891a74ecfb97ed
|
7
|
+
data.tar.gz: a4054c2c4a49a5320c495becce7f2f8defc9213926c1aafbeb1894145ea3e3f4e89bdfa580312d2071560c97617907a9483695678596390f2281e128460fa316
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,51 +1,53 @@
|
|
1
1
|
# Redacted
|
2
|
+
[](https://circleci.com/gh/kurtfunai/redacted/tree/master) [](https://codeclimate.com/github/kurtfunai/redacted) [](https://codeclimate.com/github/kurtfunai/redacted)
|
2
3
|
|
3
|
-
The goal of Redacted is to take
|
4
|
+
The goal of Redacted is to take text like `My maple syrup was stolen by a moose!` and black it out, just like on a top secret document!
|
4
5
|
|
5
|
-
|
6
|
+
To keep the redacted information private, it turns the text into [Lorem ipsum](http://www.lipsum.com/). It tries its best to maintain the same size & shape of the text that is being redacted.
|
7
|
+
|
8
|
+
Redacted works with both plain text and HTML.
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'redacted'
|
15
|
+
```
|
12
16
|
|
13
17
|
And then execute:
|
14
|
-
|
15
|
-
|
18
|
+
```bash
|
19
|
+
$ bundle
|
20
|
+
```
|
16
21
|
|
17
22
|
In your application.css, include the css file:
|
18
|
-
```
|
23
|
+
```css
|
19
24
|
/*
|
20
25
|
*= require redacted
|
21
26
|
*/
|
22
27
|
```
|
23
|
-
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
## Usage
|
26
30
|
|
27
31
|
After installing the gem, you will have access to a couple new methods in your Rails Views.
|
28
32
|
|
29
|
-
**
|
33
|
+
**redact(str)**
|
30
34
|
```ruby
|
31
|
-
|
32
|
-
|
35
|
+
# Plain text (inline):
|
36
|
+
<%= redact("You know nothing Jon Snow") %>
|
37
|
+
#=> Iusto eos eligendi non iu
|
33
38
|
|
34
|
-
All of the maple syrup was stolen by <%= redact(
|
39
|
+
All of the maple syrup was stolen by <%= redact("aliens") %>.
|
35
40
|
#=> All of the maple syrup was stolen by ducimu
|
36
|
-
```
|
37
|
-
The plain text method can create inline redacted text, or write out paragraphs to maintain the size/shape of paragraphs.
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
#=> <p>Roses are red.</p><p>Violets are blue.</p><p>All our base</p><p>are belong to you.</p>
|
42
|
+
# Plain text (paragraphs):
|
43
|
+
<%= redact("Roses are red.\nViolets are blue.\n\nAll our base\r\n are belong to you.") %>
|
44
|
+
#=> <p>consequatur et</p><p>excepturi sed dol</p><p>maxime id su</p><p>at non quia nonotas</p>
|
43
45
|
```
|
44
|
-
The `#redact` method will try to guess if the text should be inline or not, but you can also explictly call `redact_text` or `redact_paragraphs`
|
46
|
+
The `#redact` method will try to guess if the text should be inline or not, but you can also explictly call `redact_text(str)` for inline rendering, or `redact_paragraphs(str)` for paragraphs wrapped in `<p>` tags.
|
45
47
|
|
46
|
-
**
|
48
|
+
**redact_html(html_str)**
|
47
49
|
```ruby
|
48
|
-
redact_html(
|
50
|
+
redact_html("<p>A mind needs books as a sword needs a whetstone<br>if it is to keep its edge.</p><div>- George R.R. Martin, A Game of Thrones</div>")
|
49
51
|
#=> <p>adipisci labore quae perferendis impedit autem <br>odit impedit dolorem rerum</p><div>et quibusdam qui quis accusantium ullam</div>
|
50
52
|
```
|
51
53
|
Redacted parses the HTML string and replaces the text with lorem ipsum while maintaining the original HTML structure.
|
@@ -55,7 +57,7 @@ Redacted takes text like `Winter is coming.` and replaces it with lorem ipsum of
|
|
55
57
|
|
56
58
|
It then returns the redacted text surrounded by `<span></span>` tags that have the class `.redacted-text`.
|
57
59
|
```ruby
|
58
|
-
redact(
|
60
|
+
redact("Winter is coming.")
|
59
61
|
```
|
60
62
|
Becomes:
|
61
63
|
```html
|
data/Rakefile
CHANGED
data/circle.yml
ADDED
data/lib/redacted.rb
CHANGED
data/lib/redacted/version.rb
CHANGED
data/redacted.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "
|
21
|
+
spec.add_dependency "ffaker", "~> 1.24.0"
|
22
22
|
spec.add_dependency "nokogiri", "~> 1.6.3"
|
23
23
|
spec.add_dependency "railties", ">= 3.2", "< 5.0"
|
24
24
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redacted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurt Funai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: ffaker
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.24.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.24.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- README.md
|
115
115
|
- Rakefile
|
116
116
|
- app/assets/stylesheets/redacted.css
|
117
|
+
- circle.yml
|
117
118
|
- lib/redacted.rb
|
118
119
|
- lib/redacted/action_view/helpers.rb
|
119
120
|
- lib/redacted/engine.rb
|
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
187
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.4.
|
188
|
+
rubygems_version: 2.4.8
|
188
189
|
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: Convert strings into redacted text.
|
@@ -233,3 +234,4 @@ test_files:
|
|
233
234
|
- test/redacted_helper_test.rb
|
234
235
|
- test/redacted_test.rb
|
235
236
|
- test/test_helper.rb
|
237
|
+
has_rdoc:
|