sanitization 1.1.0 → 1.1.1
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/.github/workflows/main.yml +35 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -10
- data/lib/sanitization/active_record_extension.rb +2 -1
- data/lib/sanitization/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa296e29509cc55b27d9e5e5881b6e2eb470efa9d2b3b587aed8512853576a9a
|
4
|
+
data.tar.gz: 2fda3af9d53f634997e8b1146a536212d43bc5cc3d0d8034867704d63f045427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c39ba9c58abe38d12fbddefd0b1724e1845bcffd9786c7569374de9eb6ec615c13ff2e030e001bf9d66c92bacc42051070d0be6c812ae315dbe0ecdbe7022d5
|
7
|
+
data.tar.gz: 94d13c49f4383d5c517285db93f02d853859fa0f3d300131a0ac3280be042ac22daae72d584a3ff70cbf9c7ab6de4fa3d3a0346888f9279153bab2c7eb060a8e
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ main ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ main ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# 1.1.1
|
2
|
+
* Changed `sanitization` method to `sanitizes` as the new preferred way. `sanitization` still works and is an alias of `sanitizes`.
|
3
|
+
|
1
4
|
# 1.1.0
|
2
5
|
* **BREAKING CHANGE:** By default, Sanitization now does nothing. A configuration block should be used to set your desired defaults. Add `Sanitization.simple_defaults!` to `config/initializers/sanitization.rb` for version 1.0.x defaults.
|
3
6
|
* Added support for configuration block.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,41 +63,41 @@ end
|
|
63
63
|
|
64
64
|
# Default settings for all strings
|
65
65
|
class Person < ApplicationModel
|
66
|
-
|
66
|
+
sanitizes
|
67
67
|
# is equivalent to:
|
68
|
-
|
68
|
+
sanitizes strip: true, collapse: true, include_text_type: false
|
69
69
|
end
|
70
70
|
|
71
71
|
# Default settings for all strings, except a specific column
|
72
72
|
class Person < ApplicationModel
|
73
|
-
|
73
|
+
sanitizes except: :alias
|
74
74
|
end
|
75
75
|
|
76
76
|
# Default settings + titlecase for specific columns
|
77
77
|
class Person < ApplicationModel
|
78
|
-
|
78
|
+
sanitizes only: [:first_name, :last_name], case: :title
|
79
79
|
end
|
80
80
|
|
81
81
|
# Complex example. All these lines could be used in combination.
|
82
82
|
class Person
|
83
83
|
# Apply default settings and `titlecase` to all string columns, except `description`.
|
84
|
-
|
84
|
+
sanitizes case: :title, except: :description
|
85
85
|
|
86
86
|
# Keep previous settings, but specify `upcase` for 2 columns.
|
87
|
-
|
87
|
+
sanitizes only: [:first_name, :last_name], case: :up
|
88
88
|
|
89
89
|
# Keep previous settings, but specify `downcase` for a single column.
|
90
|
-
|
90
|
+
sanitizes only: :email, case: :downcase
|
91
91
|
|
92
92
|
# Apply default settings to column `description`, of type `text`. By default, `text` type is NOT sanitized.
|
93
|
-
|
93
|
+
sanitizes only: :description, include_text_type: true
|
94
94
|
|
95
95
|
# Disable collapsing for `do_not_collapse`.
|
96
|
-
|
96
|
+
sanitizes only: :do_not_collapse, collapse: false
|
97
97
|
|
98
98
|
# Sanitize with a custom casing method named `leetcase` for the `133t` column.
|
99
99
|
# Don't nullify empty strings.
|
100
|
-
|
100
|
+
sanitizes only: '1337', case: :leet, nullify: false
|
101
101
|
end
|
102
102
|
|
103
103
|
```
|
@@ -9,7 +9,7 @@ module Sanitization
|
|
9
9
|
attr_accessor :sanitization__store
|
10
10
|
|
11
11
|
private
|
12
|
-
def
|
12
|
+
def sanitizes(options = {})
|
13
13
|
# Skip initialization if table is not yet created. For example, during migrations.
|
14
14
|
return unless ActiveRecord::Base.connection.data_source_exists?(self.table_name)
|
15
15
|
|
@@ -53,6 +53,7 @@ module Sanitization
|
|
53
53
|
before_save :sanitization__format_strings
|
54
54
|
EOV
|
55
55
|
end
|
56
|
+
alias sanitization sanitizes
|
56
57
|
|
57
58
|
def valid_case_methods
|
58
59
|
String.new.methods.map { |m|
|
data/lib/sanitization/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanitization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Mercier
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/main.yml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
51
|
- CHANGELOG.md
|