user_text 0.1.0 → 0.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/.rubocop.yml +20 -0
- data/README.md +18 -8
- data/Rakefile +7 -1
- data/lib/user_text/helper.rb +6 -6
- data/lib/user_text/version.rb +1 -3
- data/lib/user_text.rb +6 -0
- metadata +3 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '009d3afc2a1af0552dce447efd23a45f8174be44eecdb3fdecada622f538cd9b'
|
4
|
+
data.tar.gz: d670ee4f4553b670fedd252d8a64edf725bb1e987b8735a4ece7e17aa9cb90ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db8d66450a32052a80062aac26838cd6e65cd9922073d7f0914fd7c3661ee4570c723048eaf7b448967a4d3d1fb89d7ba50e9d0161844106f2bbc4a4c27197b4
|
7
|
+
data.tar.gz: b94db60ce4ecde96c4a50fc91f6fb8bb02c52bb77108b28c18c03e8975182e5482d04c11ef6599899734e8fc8e36e9335be0ff851d2b12f3423b40614014cc26
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 3.0
|
4
|
+
|
5
|
+
# String literals use double quotes.
|
6
|
+
Style/StringLiterals:
|
7
|
+
EnforcedStyle: double_quotes
|
8
|
+
|
9
|
+
# Do not use frozen_string_literal comment.
|
10
|
+
Style/FrozenStringLiteralComment:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/HashSyntax:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Layout/LineLength:
|
20
|
+
Max: 160
|
data/README.md
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
# UserText
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/user_text`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
`UserText` is a gem to format the input by user.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
7
|
Install the gem and add to the application's Gemfile by executing:
|
12
8
|
|
13
|
-
|
9
|
+
```
|
10
|
+
$ bundle add user_text
|
11
|
+
```
|
14
12
|
|
15
13
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
14
|
|
17
|
-
|
15
|
+
```
|
16
|
+
$ gem install user_text
|
17
|
+
```
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
text = <<EOS
|
23
|
+
Hello, World!
|
24
|
+
|
25
|
+
My email address is user@example.com
|
26
|
+
|
27
|
+
https://example.com/path/to/page
|
28
|
+
EOS
|
29
|
+
UserText.format(text)
|
30
|
+
# => "Hello, World!<br><br>My email address is <a href=\"mailto:user@example.com\">user@example.com</a><br><br><a href=\"https://example.com/path/to/page\" target=\"_blank\">https://example.com/path/to/page</a><br>"
|
31
|
+
```
|
22
32
|
|
23
33
|
## Development
|
24
34
|
|
data/Rakefile
CHANGED
data/lib/user_text/helper.rb
CHANGED
@@ -5,17 +5,17 @@ module UserText
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def nl2br(text)
|
8
|
-
text.gsub(/\R/) { %
|
8
|
+
text.gsub(/\R/) { %(<br>) }
|
9
9
|
end
|
10
10
|
|
11
11
|
def url2a(text)
|
12
|
-
text.gsub(URI::DEFAULT_PARSER.make_regexp(%w[http https]))
|
13
|
-
%
|
14
|
-
|
12
|
+
text.gsub(URI::DEFAULT_PARSER.make_regexp(%w[http https])) do
|
13
|
+
%(<a href="#{Regexp.last_match(0)}" target="_blank">#{Regexp.last_match(0)}</a>)
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def email2a(text)
|
18
|
-
text.gsub(/[\w+\-.]+@[a-z\d\-.]+\.[a-z]+/i) { %
|
18
|
+
text.gsub(/[\w+\-.]+@[a-z\d\-.]+\.[a-z]+/i) { %(<a href="mailto:#{Regexp.last_match(0)}">#{Regexp.last_match(0)}</a>) }
|
19
19
|
end
|
20
20
|
|
21
21
|
def user_text_sanitize(text)
|
@@ -26,4 +26,4 @@ module UserText
|
|
26
26
|
@user_text_sanitizer ||= Rails::HTML5::FullSanitizer.new
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/lib/user_text/version.rb
CHANGED
data/lib/user_text.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- i2bskn
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
description: user_text
|
56
42
|
email:
|
57
43
|
- i2bskn@gmail.com
|
@@ -59,6 +45,7 @@ executables: []
|
|
59
45
|
extensions: []
|
60
46
|
extra_rdoc_files: []
|
61
47
|
files:
|
48
|
+
- ".rubocop.yml"
|
62
49
|
- LICENSE.txt
|
63
50
|
- README.md
|
64
51
|
- Rakefile
|
@@ -73,6 +60,7 @@ metadata:
|
|
73
60
|
homepage_uri: https://github.com/i2bskn/user_text
|
74
61
|
source_code_uri: https://github.com/i2bskn/user_text
|
75
62
|
changelog_uri: https://github.com/i2bskn/user_text/blob/master/CHANGELOG.md
|
63
|
+
rubygems_mfa_required: 'true'
|
76
64
|
post_install_message:
|
77
65
|
rdoc_options: []
|
78
66
|
require_paths:
|