strip-tags 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +85 -0
- data/LICENSE +21 -0
- data/README.md +265 -0
- data/Rakefile +6 -0
- data/gemfiles/activemodel-5.2.gemfile +5 -0
- data/gemfiles/activemodel-6.1.gemfile +5 -0
- data/gemfiles/activemodel-7.0.gemfile +5 -0
- data/lib/strip-tags/matchers.rb +61 -0
- data/lib/strip-tags/version.rb +3 -0
- data/lib/strip-tags.rb +70 -0
- data/strip_tags.gemspec +34 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: af2346bfaf613d78a8cb0451d6913ae788b5a629fff5d72466de3be531370265
|
4
|
+
data.tar.gz: daff9b49baf2be82e9a7846c96e71d0bcab2999a425e4cff3f8816c228745956
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abc5ec6a88ceab556c9ac892e4fe43d409ead3047efb2cadb7f88e602ac70ef2f45a3e6405019dff004f1cd4263b1761e0d14fac9b6ea9da6ff494c10edb92fa
|
7
|
+
data.tar.gz: 046170e57a5a5b993a92265adc4a0624d8201b6257fd331aafdc0324869497f1348d0ea1789e3184a08c52fe14195a58498ca87da37c21038ce04ab710285704
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
strip-tags (1.0.5)
|
5
|
+
activemodel (>= 5.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (7.0.6)
|
11
|
+
actionview (= 7.0.6)
|
12
|
+
activesupport (= 7.0.6)
|
13
|
+
rack (~> 2.0, >= 2.2.4)
|
14
|
+
rack-test (>= 0.6.3)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
17
|
+
actionview (7.0.6)
|
18
|
+
activesupport (= 7.0.6)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubi (~> 1.4)
|
21
|
+
rails-dom-testing (~> 2.0)
|
22
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
23
|
+
active_attr (0.15.4)
|
24
|
+
actionpack (>= 3.0.2, < 7.1)
|
25
|
+
activemodel (>= 3.0.2, < 7.1)
|
26
|
+
activesupport (>= 3.0.2, < 7.1)
|
27
|
+
activemodel (7.0.6)
|
28
|
+
activesupport (= 7.0.6)
|
29
|
+
activesupport (7.0.6)
|
30
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
31
|
+
i18n (>= 1.6, < 2)
|
32
|
+
minitest (>= 5.1)
|
33
|
+
tzinfo (~> 2.0)
|
34
|
+
builder (3.2.4)
|
35
|
+
concurrent-ruby (1.2.2)
|
36
|
+
crass (1.0.6)
|
37
|
+
diff-lcs (1.5.0)
|
38
|
+
erubi (1.12.0)
|
39
|
+
i18n (1.14.1)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
loofah (2.21.3)
|
42
|
+
crass (~> 1.0.2)
|
43
|
+
nokogiri (>= 1.12.0)
|
44
|
+
minitest (5.18.1)
|
45
|
+
nokogiri (1.15.3-arm64-darwin)
|
46
|
+
racc (~> 1.4)
|
47
|
+
racc (1.7.1)
|
48
|
+
rack (2.2.7)
|
49
|
+
rack-test (2.1.0)
|
50
|
+
rack (>= 1.3)
|
51
|
+
rails-dom-testing (2.1.1)
|
52
|
+
activesupport (>= 5.0.0)
|
53
|
+
minitest
|
54
|
+
nokogiri (>= 1.6)
|
55
|
+
rails-html-sanitizer (1.6.0)
|
56
|
+
loofah (~> 2.21)
|
57
|
+
nokogiri (~> 1.14)
|
58
|
+
rake (13.0.6)
|
59
|
+
rspec (3.12.0)
|
60
|
+
rspec-core (~> 3.12.0)
|
61
|
+
rspec-expectations (~> 3.12.0)
|
62
|
+
rspec-mocks (~> 3.12.0)
|
63
|
+
rspec-core (3.12.2)
|
64
|
+
rspec-support (~> 3.12.0)
|
65
|
+
rspec-expectations (3.12.3)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.12.0)
|
68
|
+
rspec-mocks (3.12.6)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.12.0)
|
71
|
+
rspec-support (3.12.1)
|
72
|
+
tzinfo (2.0.6)
|
73
|
+
concurrent-ruby (~> 1.0)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
arm64-darwin-22
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
active_attr (~> 0.15)
|
80
|
+
rake
|
81
|
+
rspec (>= 3.12.0)
|
82
|
+
strip-tags!
|
83
|
+
|
84
|
+
BUNDLED WITH
|
85
|
+
2.4.10
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Martin Moen Wulffeld
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
# strip-tags
|
2
|
+
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/strip-tags.svg)](https://rubygems.org/gems/strip-tags)
|
4
|
+
[![Build Status](https://github.com/wulffeld/strip-tags/workflows/CI/badge.svg?branch=main)](https://github.com/wulffeld/strip-tags/actions?query=workflow%3ACI)
|
5
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/strip-tags.svg)](https://rubygems.org/gems/strip-tags)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/7b3c646f87ca2d6d691c/maintainability)](https://codeclimate.com/github/wulffeld/strip-tags)
|
7
|
+
|
8
|
+
An ActiveModel extension that strips tags from attributes before validation using the strip-tags helper.
|
9
|
+
|
10
|
+
It preserves '&', '<' and '>' characters.
|
11
|
+
|
12
|
+
It works by adding a before_validation hook to the record. By default, all
|
13
|
+
attributes are stripped of tags, but `:only` and `:except` options can be
|
14
|
+
used to limit which attributes are stripped. Both options accept a single
|
15
|
+
attribute (`only: :field`) or arrays of attributes (`except: [:field1,
|
16
|
+
:field2, :field3]`).
|
17
|
+
|
18
|
+
It's also possible to skip stripping the attributes altogether per model using the `:if` and `:unless` options.
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Include the gem in your Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem "strip-tags"
|
26
|
+
```
|
27
|
+
|
28
|
+
## Examples
|
29
|
+
|
30
|
+
### Default Behavior
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class DrunkPokerPlayer < ActiveRecord::Base
|
34
|
+
strip-tags
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
### Using `except`
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# all attributes will be stripped except :boxers
|
42
|
+
class SoberPokerPlayer < ActiveRecord::Base
|
43
|
+
strip-tags except: :boxers
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
### Using `only`
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# only :shoe, :sock, and :glove attributes will be stripped
|
51
|
+
class ConservativePokerPlayer < ActiveRecord::Base
|
52
|
+
strip-tags only: [:shoe, :sock, :glove]
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
### Using `if`
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# Only records with odd ids will be stripped
|
60
|
+
class OddPokerPlayer < ActiveRecord::Base
|
61
|
+
strip-tags if: :strip_me?
|
62
|
+
|
63
|
+
def strip_me?
|
64
|
+
id.odd?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
### Using `unless`
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
# strip-tags will be applied randomly
|
73
|
+
class RandomPokerPlayer < ActiveRecord::Base
|
74
|
+
strip-tags unless: :strip_me?
|
75
|
+
|
76
|
+
def strip_me?
|
77
|
+
[true, false].sample
|
78
|
+
end
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
### Using `allow_empty`
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
# Empty attributes will not be converted to nil
|
86
|
+
class BrokePokerPlayer < ActiveRecord::Base
|
87
|
+
strip-tags allow_empty: true
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
## Usage Patterns
|
92
|
+
|
93
|
+
### Other ORMs implementing `ActiveModel`
|
94
|
+
|
95
|
+
It also works on other ActiveModel classes, such as [Mongoid](http://mongoid.org/) documents:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
class User
|
99
|
+
include Mongoid::Document
|
100
|
+
|
101
|
+
strip-tags only: :email
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
### Using it with [`ActiveAttr`](https://github.com/cgriego/active_attr)
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
class Person
|
109
|
+
include ActiveAttr::Model
|
110
|
+
include ActiveModel::Validations::Callbacks
|
111
|
+
|
112
|
+
attribute :name
|
113
|
+
attribute :email
|
114
|
+
|
115
|
+
strip-tags
|
116
|
+
end
|
117
|
+
|
118
|
+
```
|
119
|
+
|
120
|
+
### Using it directly
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
# where record is an ActiveModel instance
|
124
|
+
StripTags.strip(record,: true)
|
125
|
+
|
126
|
+
# works directly on Strings too
|
127
|
+
StripTags.strip(" foo \t") #=> "foo"
|
128
|
+
StripTags.strip(" foo bar",: true) #=> "foo bar"
|
129
|
+
```
|
130
|
+
|
131
|
+
## Testing
|
132
|
+
|
133
|
+
StripTags provides an RSpec/Shoulda-compatible matcher for easier
|
134
|
+
testing of attribute assignment. You can use this with
|
135
|
+
[RSpec](http://rspec.info/), [Shoulda](https://github.com/thoughtbot/shoulda),
|
136
|
+
[Minitest-MatchersVaccine](https://github.com/rmm5t/minitest-matchers_vaccine)
|
137
|
+
(preferred), or
|
138
|
+
[Minitest-Matchers](https://github.com/wojtekmach/minitest-matchers).
|
139
|
+
|
140
|
+
### Setup `spec_helper.rb` or `test_helper.rb`
|
141
|
+
|
142
|
+
#### To initialize **RSpec**, add this to your `spec_helper.rb`:
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
require "strip-tags/matchers"
|
146
|
+
|
147
|
+
RSpec.configure do |config|
|
148
|
+
config.include StripTags::Matchers
|
149
|
+
end
|
150
|
+
```
|
151
|
+
|
152
|
+
#### To initialize **Shoulda (with test-unit)**, add this to your `test_helper.rb`:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
require "strip-tags/matchers"
|
156
|
+
|
157
|
+
class Test::Unit::TestCase
|
158
|
+
extend StripTags::Matchers
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
162
|
+
OR if in a Rails environment, you might prefer this:
|
163
|
+
|
164
|
+
``` ruby
|
165
|
+
require "strip-tags/matchers"
|
166
|
+
|
167
|
+
class ActiveSupport::TestCase
|
168
|
+
extend StripTags::Matchers
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
#### To initialize **Minitest-MatchersVaccine**, add this to your `test_helper.rb`:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
require "strip-tags/matchers"
|
176
|
+
|
177
|
+
class MiniTest::Spec
|
178
|
+
include StripTags::Matchers
|
179
|
+
end
|
180
|
+
```
|
181
|
+
|
182
|
+
OR if in a Rails environment, you might prefer this:
|
183
|
+
|
184
|
+
``` ruby
|
185
|
+
require "strip-tags/matchers"
|
186
|
+
|
187
|
+
class ActiveSupport::TestCase
|
188
|
+
include StripTags::Matchers
|
189
|
+
end
|
190
|
+
```
|
191
|
+
|
192
|
+
#### To initialize **Minitest-Matchers**, add this to your `test_helper.rb`:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
require "strip-tags/matchers"
|
196
|
+
|
197
|
+
class MiniTest::Spec
|
198
|
+
include StripTags::Matchers
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
202
|
+
### Writing Tests
|
203
|
+
|
204
|
+
**RSpec**:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
describe User do
|
208
|
+
it { is_expected.to strip_tag(:name) }
|
209
|
+
it { is_expected.not_to strip_tag(:password) }
|
210
|
+
end
|
211
|
+
```
|
212
|
+
|
213
|
+
**Shoulda (with test-unit)**:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
class UserTest < ActiveSupport::TestCase
|
217
|
+
should strip_tag(:name)
|
218
|
+
should strip-tags(:name, :email)
|
219
|
+
should_not strip_tag(:password)
|
220
|
+
should_not strip-tags(:password, :encrypted_password)
|
221
|
+
end
|
222
|
+
```
|
223
|
+
|
224
|
+
**Minitest-MatchersVaccine**:
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
describe User do
|
228
|
+
subject { User.new }
|
229
|
+
|
230
|
+
it "strips attributes" do
|
231
|
+
must strip_tag(:name)
|
232
|
+
must strip-tags(:name, :email)
|
233
|
+
wont strip_tag(:password)
|
234
|
+
wont strip-tags(:password, :encrypted_password)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
```
|
238
|
+
|
239
|
+
**Minitest-Matchers**:
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
describe User do
|
243
|
+
subject { User.new }
|
244
|
+
|
245
|
+
must { strip_tag(:name) }
|
246
|
+
must { strip-tags(:name, :email) }
|
247
|
+
wont { strip_tag(:password) }
|
248
|
+
wont { strip-tags(:password, :encrypted_password) }
|
249
|
+
end
|
250
|
+
```
|
251
|
+
|
252
|
+
## Support
|
253
|
+
|
254
|
+
Submit suggestions or feature requests as a GitHub Issue or Pull
|
255
|
+
Request (preferred). If you send a pull request, remember to update the
|
256
|
+
corresponding unit tests. In fact, I prefer new features to be submitted in the
|
257
|
+
form of new unit tests.
|
258
|
+
|
259
|
+
## Credits
|
260
|
+
|
261
|
+
Original code 99% from the [strip_attributes](https://github.com/rmm5t/strip_attributes) gem.
|
262
|
+
|
263
|
+
## Versioning
|
264
|
+
|
265
|
+
Semantic Versioning 2.0 as defined at <http://semver.org>.
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module StripTags
|
2
|
+
module Matchers
|
3
|
+
# RSpec Examples:
|
4
|
+
#
|
5
|
+
# it { is_expected.to strip_tag(:first_name) }
|
6
|
+
# it { is_expected.to strip_tags(:first_name, :last_name) }
|
7
|
+
# it { is_expected.not_to strip_tag(:password) }
|
8
|
+
# it { is_expected.not_to strip_tags(:password, :encrypted_password) }
|
9
|
+
#
|
10
|
+
# Minitest Matchers Examples:
|
11
|
+
#
|
12
|
+
# must { strip_tag(:first_name) }
|
13
|
+
# must { strip_tags(:first_name, :last_name) }
|
14
|
+
# wont { strip_tag(:password) }
|
15
|
+
# wont { strip_tags(:password, :encrypted_password) }
|
16
|
+
def strip_tag(*attributes)
|
17
|
+
StripTagsMatcher.new(attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :strip_tags, :strip_tag
|
21
|
+
|
22
|
+
class StripTagsMatcher
|
23
|
+
def initialize(attributes)
|
24
|
+
@attributes = attributes
|
25
|
+
@options = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def matches?(subject)
|
29
|
+
@attributes.all? do |attribute|
|
30
|
+
@attribute = attribute
|
31
|
+
subject.send("#{@attribute}=", "foo> & <<script>alert('xss')</script>")
|
32
|
+
subject.valid?
|
33
|
+
subject.send(@attribute) == "foo> & <"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def failure_message # RSpec 3.x
|
38
|
+
"Expected tags to be #{expectation} from ##{@attribute}, but it was not"
|
39
|
+
end
|
40
|
+
alias_method :failure_message_for_should, :failure_message # RSpec 1.2, 2.x, and minitest-matchers
|
41
|
+
|
42
|
+
def failure_message_when_negated # RSpec 3.x
|
43
|
+
"Expected tags to remain on ##{@attribute}, but it was #{expectation}"
|
44
|
+
end
|
45
|
+
alias_method :failure_message_for_should_not, :failure_message_when_negated # RSpec 1.2, 2.x, and minitest-matchers
|
46
|
+
alias_method :negative_failure_message, :failure_message_when_negated # RSpec 1.1
|
47
|
+
|
48
|
+
def description
|
49
|
+
"#{expectation(false)} tags from #{@attributes.map {|el| "##{el}" }.to_sentence}"
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def expectation(past = true)
|
55
|
+
expectation = past ? "stripped" : "strip"
|
56
|
+
expectation += past ? " and replaced" : " and replace"
|
57
|
+
expectation
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/strip-tags.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "active_model"
|
2
|
+
require "action_controller"
|
3
|
+
|
4
|
+
module ActiveModel::Validations::HelperMethods
|
5
|
+
# Strips tags from model fields.
|
6
|
+
def strip_tags(options = {})
|
7
|
+
StripTags.validate_options(options)
|
8
|
+
|
9
|
+
before_validation(options.slice(:if, :unless)) do |record|
|
10
|
+
StripTags.strip(record, options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module StripTags
|
16
|
+
VALID_OPTIONS = [:only, :except, :allow_empty, :regex, :if, :unless].freeze
|
17
|
+
|
18
|
+
def self.strip(record_or_string, options = {})
|
19
|
+
if record_or_string.respond_to?(:attributes)
|
20
|
+
strip_record(record_or_string, options)
|
21
|
+
else
|
22
|
+
strip_string(record_or_string, options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.strip_record(record, options = {})
|
27
|
+
attributes = narrow(record.attributes, options)
|
28
|
+
|
29
|
+
attributes.each do |attr, value|
|
30
|
+
original_value = value
|
31
|
+
value = strip_string(value, options)
|
32
|
+
record[attr] = value if original_value != value
|
33
|
+
end
|
34
|
+
|
35
|
+
record
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.strip_string(value, options = {})
|
39
|
+
return value unless value.is_a?(String)
|
40
|
+
return value if value.frozen?
|
41
|
+
|
42
|
+
allow_empty = options[:allow_empty]
|
43
|
+
|
44
|
+
value = ActionController::Base.helpers.strip_tags(value).gsub("&", "&").gsub(">", ">").gsub("<", "<")
|
45
|
+
|
46
|
+
(value.blank? && !allow_empty) ? nil : value
|
47
|
+
end
|
48
|
+
|
49
|
+
# Necessary because Rails has removed the narrowing of attributes using :only
|
50
|
+
# and :except on Base#attributes
|
51
|
+
def self.narrow(attributes, options = {})
|
52
|
+
if except = options[:except]
|
53
|
+
except = Array(except).collect { |attribute| attribute.to_s }
|
54
|
+
attributes.except(*except)
|
55
|
+
elsif only = options[:only]
|
56
|
+
only = Array(only).collect { |attribute| attribute.to_s }
|
57
|
+
attributes.slice(*only)
|
58
|
+
else
|
59
|
+
attributes
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.validate_options(options)
|
64
|
+
if keys = options.keys
|
65
|
+
unless (keys - VALID_OPTIONS).empty?
|
66
|
+
raise ArgumentError, "Options does not specify #{VALID_OPTIONS} (#{options.keys.inspect})"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/strip_tags.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "lib/strip-tags/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "strip-tags"
|
5
|
+
spec.version = StripTags::VERSION
|
6
|
+
spec.authors = ["Martin Moen Wulffeld"]
|
7
|
+
spec.email = ["martin@wulffeld.dk"]
|
8
|
+
|
9
|
+
spec.summary = "Strip tags from fields in your models."
|
10
|
+
spec.description = "An ActiveModel extension that strips tags from attributes before validation using the strip-tags helper."
|
11
|
+
spec.homepage = "https://github.com/wulffeld/strip-tags"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = ">= 2.5"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/wulffeld/strip-tags"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/wulffeld/strip-tags/CHANGELOG.md"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_runtime_dependency "activemodel", ">= 5.2"
|
31
|
+
spec.add_development_dependency "active_attr", "~> 0.15"
|
32
|
+
spec.add_development_dependency "rspec", ">= 3.12.0"
|
33
|
+
spec.add_development_dependency "rake"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: strip-tags
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Moen Wulffeld
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: active_attr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.12.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.12.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: An ActiveModel extension that strips tags from attributes before validation
|
70
|
+
using the strip-tags helper.
|
71
|
+
email:
|
72
|
+
- martin@wulffeld.dk
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".rspec"
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- gemfiles/activemodel-5.2.gemfile
|
85
|
+
- gemfiles/activemodel-6.1.gemfile
|
86
|
+
- gemfiles/activemodel-7.0.gemfile
|
87
|
+
- lib/strip-tags.rb
|
88
|
+
- lib/strip-tags/matchers.rb
|
89
|
+
- lib/strip-tags/version.rb
|
90
|
+
- strip_tags.gemspec
|
91
|
+
homepage: https://github.com/wulffeld/strip-tags
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata:
|
95
|
+
homepage_uri: https://github.com/wulffeld/strip-tags
|
96
|
+
source_code_uri: https://github.com/wulffeld/strip-tags
|
97
|
+
changelog_uri: https://github.com/wulffeld/strip-tags/CHANGELOG.md
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '2.5'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubygems_version: 3.4.10
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Strip tags from fields in your models.
|
117
|
+
test_files: []
|