acts_as_mentionable 0.2.0 → 0.2.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/README.md +3 -3
- data/lib/acts_as_mentionable/mentioner_parser.rb +1 -1
- data/lib/acts_as_mentionable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9044c1db8eb718ee2f4493ad2457f2528436fa715abf545936c8888f001e600
|
4
|
+
data.tar.gz: 95cdbfb74522f66963143296e0469be2c9ba7a9ce4b4822f162d2371114fc297
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20e1b3c472ecce5c273e7c11d78195091bf74dee4e106e2b46fb368494522798357cfab124d62657c606ffde8aaefa633fa3d2561b6bb094212d20914c58ca88
|
7
|
+
data.tar.gz: 64a955a69a73bb655ace131d279e2895de739495ba0b1ef770ade7cc6eea4e06c39592acc5efc357602014ed51bd017c26ddc18ad52b929e8b703be4fb23ba07
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ end
|
|
58
58
|
```
|
59
59
|
|
60
60
|
Mentioner (`Comment`) model is expected to have two fields:
|
61
|
-
1. The field, which contains, let's say, plain version of the comment - in the example above it's `body`. This field, by default, is rewritten by the parser and contains all the mentions as the plain text, e.g. `Hello,
|
61
|
+
1. The field, which contains, let's say, plain version of the comment - in the example above it's `body`. This field, by default, is rewritten by the parser and contains all the mentions as the plain text, e.g. `Hello, *U+2063*@john*U+2063*!`. The character `*U+2063*` is used to show the beginning and end of a mention
|
62
62
|
2. The field, which contains comment with the mentions. It's named as the `parsed_*`, where `*` is meant to be the field, which contains plain version of the comment. In the example above it's named `parsed_body`. Mentions are recognized by the following template - `{#|RECORD_ID|RECORD_MODEL_NAME}`, where `RECORD_ID` is the ID of record being mentioned, for instance, user ID, and, `RECORD_MODEL_NAME` is the name of the model being mentioned, for instance, for `User` model it is `user`. According to this, `parsed_body` field may have the following value - `Hello, {#|42|user}!`.
|
63
63
|
|
64
64
|
So, as you may have already noticed, the argument provided to the `#acts_as_mentioner` method is the name of the field, which is a plain version of the comment - `body`, and the name of the field, which contains mentions is generated automatically - `parsed_body`.
|
@@ -83,9 +83,9 @@ The argument `username` provided to `#acts_as_mentionable` method, is a field on
|
|
83
83
|
user = User.create! id: 42, username: 'john'
|
84
84
|
comment = Comment.create! parsed_body: 'Hello, {#|42|user}!'
|
85
85
|
puts comment.body
|
86
|
-
# => Hello,
|
86
|
+
# => Hello, *U+2063*@john*U+2063*!
|
87
87
|
```
|
88
|
-
As you can see, it this case `{#|42|user}` in `parsed_body` is replaced by `@` + `username` field of the user in comment's `body`.
|
88
|
+
As you can see, it this case `{#|42|user}` in `parsed_body` is replaced by `*U+2063*` + `@` + `username` + `*U+2063*` field of the user in comment's `body`.
|
89
89
|
|
90
90
|
### Retrieving mentions
|
91
91
|
|
@@ -32,7 +32,7 @@ module ActsAsMentionable
|
|
32
32
|
|
33
33
|
def metionable_template mentionable, template
|
34
34
|
if mentionable.respond_to?(:mentionable?) && mentionable.mentionable?
|
35
|
-
"
|
35
|
+
"*U+2063*@#{mentionable.send(mentionable.class.mentionable_field)}*U+2063*"
|
36
36
|
else
|
37
37
|
template
|
38
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_mentionable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Baron Bloomer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-06-
|
13
|
+
date: 2019-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|