twitter-text 1.4.2 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/LICENSE +184 -9
- data/README.rdoc +23 -6
- data/lib/autolink.rb +6 -0
- data/lib/extractor.rb +7 -0
- data/lib/regex.rb +41 -7
- data/spec/extractor_spec.rb +0 -23
- data/twitter-text.gemspec +1 -1
- metadata +6 -6
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
@@ -1,13 +1,188 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2011 Twitter, Inc.
|
2
2
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
use this
|
5
|
-
the License at
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this work except in compliance with the License.
|
5
|
+
You may obtain a copy of the License below, or at:
|
6
6
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
|
9
9
|
Unless required by applicable law or agreed to in writing, software
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
License for the specific language governing permissions and
|
13
|
-
the License.
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
15
|
+
Apache License
|
16
|
+
Version 2.0, January 2004
|
17
|
+
http://www.apache.org/licenses/
|
18
|
+
|
19
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
20
|
+
|
21
|
+
1. Definitions.
|
22
|
+
|
23
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
24
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
25
|
+
|
26
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
27
|
+
the copyright owner that is granting the License.
|
28
|
+
|
29
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
30
|
+
other entities that control, are controlled by, or are under common
|
31
|
+
control with that entity. For the purposes of this definition,
|
32
|
+
"control" means (i) the power, direct or indirect, to cause the
|
33
|
+
direction or management of such entity, whether by contract or
|
34
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
35
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
36
|
+
|
37
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
38
|
+
exercising permissions granted by this License.
|
39
|
+
|
40
|
+
"Source" form shall mean the preferred form for making modifications,
|
41
|
+
including but not limited to software source code, documentation
|
42
|
+
source, and configuration files.
|
43
|
+
|
44
|
+
"Object" form shall mean any form resulting from mechanical
|
45
|
+
transformation or translation of a Source form, including but
|
46
|
+
not limited to compiled object code, generated documentation,
|
47
|
+
and conversions to other media types.
|
48
|
+
|
49
|
+
"Work" shall mean the work of authorship, whether in Source or
|
50
|
+
Object form, made available under the License, as indicated by a
|
51
|
+
copyright notice that is included in or attached to the work
|
52
|
+
(an example is provided in the Appendix below).
|
53
|
+
|
54
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
55
|
+
form, that is based on (or derived from) the Work and for which the
|
56
|
+
editorial revisions, annotations, elaborations, or other modifications
|
57
|
+
represent, as a whole, an original work of authorship. For the purposes
|
58
|
+
of this License, Derivative Works shall not include works that remain
|
59
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
60
|
+
the Work and Derivative Works thereof.
|
61
|
+
|
62
|
+
"Contribution" shall mean any work of authorship, including
|
63
|
+
the original version of the Work and any modifications or additions
|
64
|
+
to that Work or Derivative Works thereof, that is intentionally
|
65
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
66
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
67
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
68
|
+
means any form of electronic, verbal, or written communication sent
|
69
|
+
to the Licensor or its representatives, including but not limited to
|
70
|
+
communication on electronic mailing lists, source code control systems,
|
71
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
72
|
+
Licensor for the purpose of discussing and improving the Work, but
|
73
|
+
excluding communication that is conspicuously marked or otherwise
|
74
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
75
|
+
|
76
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
77
|
+
on behalf of whom a Contribution has been received by Licensor and
|
78
|
+
subsequently incorporated within the Work.
|
79
|
+
|
80
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
81
|
+
this License, each Contributor hereby grants to You a perpetual,
|
82
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
83
|
+
copyright license to reproduce, prepare Derivative Works of,
|
84
|
+
publicly display, publicly perform, sublicense, and distribute the
|
85
|
+
Work and such Derivative Works in Source or Object form.
|
86
|
+
|
87
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
88
|
+
this License, each Contributor hereby grants to You a perpetual,
|
89
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
90
|
+
(except as stated in this section) patent license to make, have made,
|
91
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
92
|
+
where such license applies only to those patent claims licensable
|
93
|
+
by such Contributor that are necessarily infringed by their
|
94
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
95
|
+
with the Work to which such Contribution(s) was submitted. If You
|
96
|
+
institute patent litigation against any entity (including a
|
97
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
98
|
+
or a Contribution incorporated within the Work constitutes direct
|
99
|
+
or contributory patent infringement, then any patent licenses
|
100
|
+
granted to You under this License for that Work shall terminate
|
101
|
+
as of the date such litigation is filed.
|
102
|
+
|
103
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
104
|
+
Work or Derivative Works thereof in any medium, with or without
|
105
|
+
modifications, and in Source or Object form, provided that You
|
106
|
+
meet the following conditions:
|
107
|
+
|
108
|
+
(a) You must give any other recipients of the Work or
|
109
|
+
Derivative Works a copy of this License; and
|
110
|
+
|
111
|
+
(b) You must cause any modified files to carry prominent notices
|
112
|
+
stating that You changed the files; and
|
113
|
+
|
114
|
+
(c) You must retain, in the Source form of any Derivative Works
|
115
|
+
that You distribute, all copyright, patent, trademark, and
|
116
|
+
attribution notices from the Source form of the Work,
|
117
|
+
excluding those notices that do not pertain to any part of
|
118
|
+
the Derivative Works; and
|
119
|
+
|
120
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
121
|
+
distribution, then any Derivative Works that You distribute must
|
122
|
+
include a readable copy of the attribution notices contained
|
123
|
+
within such NOTICE file, excluding those notices that do not
|
124
|
+
pertain to any part of the Derivative Works, in at least one
|
125
|
+
of the following places: within a NOTICE text file distributed
|
126
|
+
as part of the Derivative Works; within the Source form or
|
127
|
+
documentation, if provided along with the Derivative Works; or,
|
128
|
+
within a display generated by the Derivative Works, if and
|
129
|
+
wherever such third-party notices normally appear. The contents
|
130
|
+
of the NOTICE file are for informational purposes only and
|
131
|
+
do not modify the License. You may add Your own attribution
|
132
|
+
notices within Derivative Works that You distribute, alongside
|
133
|
+
or as an addendum to the NOTICE text from the Work, provided
|
134
|
+
that such additional attribution notices cannot be construed
|
135
|
+
as modifying the License.
|
136
|
+
|
137
|
+
You may add Your own copyright statement to Your modifications and
|
138
|
+
may provide additional or different license terms and conditions
|
139
|
+
for use, reproduction, or distribution of Your modifications, or
|
140
|
+
for any such Derivative Works as a whole, provided Your use,
|
141
|
+
reproduction, and distribution of the Work otherwise complies with
|
142
|
+
the conditions stated in this License.
|
143
|
+
|
144
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
145
|
+
any Contribution intentionally submitted for inclusion in the Work
|
146
|
+
by You to the Licensor shall be under the terms and conditions of
|
147
|
+
this License, without any additional terms or conditions.
|
148
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
149
|
+
the terms of any separate license agreement you may have executed
|
150
|
+
with Licensor regarding such Contributions.
|
151
|
+
|
152
|
+
6. Trademarks. This License does not grant permission to use the trade
|
153
|
+
names, trademarks, service marks, or product names of the Licensor,
|
154
|
+
except as required for reasonable and customary use in describing the
|
155
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
156
|
+
|
157
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
158
|
+
agreed to in writing, Licensor provides the Work (and each
|
159
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
160
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
161
|
+
implied, including, without limitation, any warranties or conditions
|
162
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
163
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
164
|
+
appropriateness of using or redistributing the Work and assume any
|
165
|
+
risks associated with Your exercise of permissions under this License.
|
166
|
+
|
167
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
168
|
+
whether in tort (including negligence), contract, or otherwise,
|
169
|
+
unless required by applicable law (such as deliberate and grossly
|
170
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
171
|
+
liable to You for damages, including any direct, indirect, special,
|
172
|
+
incidental, or consequential damages of any character arising as a
|
173
|
+
result of this License or out of the use or inability to use the
|
174
|
+
Work (including but not limited to damages for loss of goodwill,
|
175
|
+
work stoppage, computer failure or malfunction, or any and all
|
176
|
+
other commercial damages or losses), even if such Contributor
|
177
|
+
has been advised of the possibility of such damages.
|
178
|
+
|
179
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
180
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
181
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
182
|
+
or other liability obligations and/or rights consistent with this
|
183
|
+
License. However, in accepting such obligations, You may act only
|
184
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
185
|
+
of any other Contributor, and only if You agree to indemnify,
|
186
|
+
defend, and hold each Contributor harmless for any liability
|
187
|
+
incurred by, or claims asserted against, such Contributor by reason
|
188
|
+
of your accepting any such warranty or additional liability.
|
data/README.rdoc
CHANGED
@@ -29,15 +29,15 @@ usernames, lists, hashtags and URLs.
|
|
29
29
|
|
30
30
|
html = auto_link("link @user, please #request")
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
# For Ruby on Rails you want to add this to app/helpers/application_helper.rb
|
34
34
|
module ApplicationHelper
|
35
35
|
include Twitter::Autolink
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Now the auto_link function is available in every view. So in index.html.erb:
|
39
39
|
<%= auto_link("link @user, please #request") %>
|
40
|
-
|
40
|
+
|
41
41
|
=== Usernames
|
42
42
|
|
43
43
|
Username extraction and linking matches all valid Twitter usernames but does
|
@@ -50,8 +50,8 @@ format.
|
|
50
50
|
|
51
51
|
=== Hashtags
|
52
52
|
|
53
|
-
Auto-link and extract hashtags, where a hashtag
|
54
|
-
|
53
|
+
Auto-link and extract hashtags, where a hashtag can contain most letters or
|
54
|
+
numbers but cannot be solely numbers and cannot contain punctuation.
|
55
55
|
|
56
56
|
=== URLs
|
57
57
|
|
@@ -74,7 +74,7 @@ to work against text that has been auto-linked already.
|
|
74
74
|
|
75
75
|
To run the Conformance suite, you'll need to add that project as a git submodule. From the root twitter-text-rb directory, run:
|
76
76
|
|
77
|
-
git submodule add git@github.com:
|
77
|
+
git submodule add git@github.com:twitter/twitter-text-conformance.git test/twitter-text-conformance/
|
78
78
|
git submodule init
|
79
79
|
git submodule update
|
80
80
|
|
@@ -83,6 +83,7 @@ To run the Conformance suite, you'll need to add that project as a git submodule
|
|
83
83
|
Thanks to everybody who has filed issues, provided feedback or contributed patches. Patches courtesy of:
|
84
84
|
|
85
85
|
* At Twitter …
|
86
|
+
* Matt Sanford - http://github.com/mzsanford
|
86
87
|
* Raffi Krikorian - http://github.com/r
|
87
88
|
* Ben Cherry - http://github.com/bcherry
|
88
89
|
* Patrick Ewing - http://github.com/hoverbird
|
@@ -93,3 +94,19 @@ Thanks to everybody who has filed issues, provided feedback or contributed patch
|
|
93
94
|
* Jean-Philippe Bougie - http://github.com/jpbougie
|
94
95
|
|
95
96
|
* Anyone who has filed an issue. It helps. Really.
|
97
|
+
|
98
|
+
=== Copyright and License
|
99
|
+
|
100
|
+
Copyright 2011 Twitter, Inc.
|
101
|
+
|
102
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
103
|
+
you may not use this work except in compliance with the License.
|
104
|
+
You may obtain a copy of the License in the LICENSE file, or at:
|
105
|
+
|
106
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
107
|
+
|
108
|
+
Unless required by applicable law or agreed to in writing, software
|
109
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
110
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
111
|
+
See the License for the specific language governing permissions and
|
112
|
+
limitations under the License.
|
data/lib/autolink.rb
CHANGED
@@ -137,6 +137,12 @@ module Twitter
|
|
137
137
|
text = $3
|
138
138
|
text = yield(text) if block_given?
|
139
139
|
"#{before}<a href=\"#{options[:hashtag_url_base]}#{html_escape(text)}\" title=\"##{html_escape(text)}\" #{target_tag(options)}class=\"#{options[:url_class]} #{options[:hashtag_class]}\"#{extra_html}>#{html_escape(hash)}#{html_escape(text)}</a>"
|
140
|
+
end.gsub(Twitter::Regex[:auto_link_cj_hashtags]) do
|
141
|
+
before = $1
|
142
|
+
hash = $2
|
143
|
+
text = $3
|
144
|
+
text = yield(text) if block_given?
|
145
|
+
"#{before}<a href=\"#{options[:hashtag_url_base]}#{html_escape(text)}\" title=\"##{html_escape(text)}\" #{target_tag(options)}class=\"#{options[:url_class]} #{options[:hashtag_class]}\"#{extra_html}>#{html_escape(hash)}#{html_escape(text)}</a>"
|
140
146
|
end
|
141
147
|
end
|
142
148
|
|
data/lib/extractor.rb
CHANGED
@@ -165,6 +165,13 @@ module Twitter
|
|
165
165
|
:hashtag => hash_text,
|
166
166
|
:indices => [start_position, end_position]
|
167
167
|
}
|
168
|
+
end.scan(Twitter::Regex[:auto_link_cj_hashtags]) do |before, hash, hash_text|
|
169
|
+
start_position = $~.char_begin(2)
|
170
|
+
end_position = $~.char_end(3)
|
171
|
+
tags << {
|
172
|
+
:hashtag => hash_text,
|
173
|
+
:indices => [start_position, end_position]
|
174
|
+
}
|
168
175
|
end
|
169
176
|
tags.each{|tag| yield tag[:hashtag], tag[:indices].first, tag[:indices].last } if block_given?
|
170
177
|
tags
|
data/lib/regex.rb
CHANGED
@@ -24,6 +24,7 @@ module Twitter
|
|
24
24
|
0x205F, # White_Space # Zs MEDIUM MATHEMATICAL SPACE
|
25
25
|
0x3000, # White_Space # Zs IDEOGRAPHIC SPACE
|
26
26
|
].flatten.freeze
|
27
|
+
SPACE_CHAR_CLASS_VALUE = Regexp.new(UNICODE_SPACES.collect{ |e| [e].pack 'U*' }.join(''))
|
27
28
|
REGEXEN[:spaces] = Regexp.new(UNICODE_SPACES.collect{ |e| [e].pack 'U*' }.join('|'))
|
28
29
|
|
29
30
|
REGEXEN[:at_signs] = /[@@]/
|
@@ -42,25 +43,58 @@ module Twitter
|
|
42
43
|
# Excludes 0xd7 from the range (the multiplication sign, confusable with "x").
|
43
44
|
# Also excludes 0xf7, the division sign
|
44
45
|
LATIN_ACCENTS = [(0xc0..0xd6).to_a, (0xd8..0xf6).to_a, (0xf8..0xff).to_a].flatten.pack('U*').freeze
|
46
|
+
NON_LATIN_HASHTAG_CHARS = [
|
47
|
+
# Cyrillic (Russian, Ukrainian, etc.)
|
48
|
+
(0x0400..0x04ff).to_a, # Cyrillic
|
49
|
+
(0x0500..0x0527).to_a, # Cyrillic Supplement
|
50
|
+
# Hangul (Korean)
|
51
|
+
(0x1100..0x11ff).to_a, # Hangul Jamo
|
52
|
+
(0x3130..0x3185).to_a, # Hangul Compatibility Jamo
|
53
|
+
(0xA960..0xA97F).to_a, # Hangul Jamo Extended-A
|
54
|
+
(0xAC00..0xD7AF).to_a, # Hangul Syllables
|
55
|
+
(0xD7B0..0xD7FF).to_a # Hangul Jamo Extended-B
|
56
|
+
].flatten.pack('U*').freeze
|
45
57
|
REGEXEN[:latin_accents] = /[#{LATIN_ACCENTS}]+/o
|
46
58
|
|
47
59
|
REGEXEN[:end_screen_name_match] = /^(?:#{REGEXEN[:at_signs]}|#{REGEXEN[:latin_accents]}|:\/\/)/o
|
48
60
|
|
61
|
+
CJ_HASHTAG_CHARACTERS = [
|
62
|
+
(0x30A1..0x30FA).to_a, # Katakana (full-width)
|
63
|
+
(0xFF66..0xFF9D).to_a, # Katakana (half-width)
|
64
|
+
(0xFF10..0xFF19).to_a, (0xFF21..0xFF3A).to_a, (0xFF41..0xFF5A).to_a, # Latin (full-width)
|
65
|
+
(0x3041..0x3096).to_a, # Hiragana
|
66
|
+
(0x3400..0x4DBF).to_a, # Kanji (CJK Extension A)
|
67
|
+
(0x4E00..0x9FFF).to_a, # Kanji (Unified)
|
68
|
+
(0x20000..0x2A6DF).to_a, # Kanji (CJK Extension B)
|
69
|
+
(0x2A700..0x2B73F).to_a, # Kanji (CJK Extension C)
|
70
|
+
(0x2B740..0x2B81F).to_a, # Kanji (CJK Extension D)
|
71
|
+
(0x2F800..0x2FA1F).to_a # Kanji (CJK supplement)
|
72
|
+
].flatten.pack('U*').freeze
|
73
|
+
|
74
|
+
CJ_BOUNDARY = /(?:\A|\z|#{REGEXEN[:spaces]}|「|」|。|\.)/
|
75
|
+
|
49
76
|
# A hashtag must contain latin characters, numbers and underscores, but not all numbers.
|
50
|
-
HASHTAG_ALPHA = /[a-z_#{LATIN_ACCENTS}]/io
|
51
|
-
HASHTAG_ALPHANUMERIC = /[a-z0-9_#{LATIN_ACCENTS}]/io
|
52
|
-
|
77
|
+
HASHTAG_ALPHA = /[a-z_#{LATIN_ACCENTS}#{NON_LATIN_HASHTAG_CHARS}]/io
|
78
|
+
HASHTAG_ALPHANUMERIC = /[a-z0-9_#{LATIN_ACCENTS}#{NON_LATIN_HASHTAG_CHARS}]/io
|
79
|
+
|
80
|
+
CJ_HASHTAG = /(#{CJ_BOUNDARY})(#|#)([#{CJ_HASHTAG_CHARACTERS}]+)(?=#{CJ_BOUNDARY})/o
|
81
|
+
NON_CJ_HASHTAG = /(^|[^0-9A-Z&\/\?]+)(#|#)(#{HASHTAG_ALPHANUMERIC}*#{HASHTAG_ALPHA}#{HASHTAG_ALPHANUMERIC}*)/io
|
82
|
+
|
83
|
+
REGEXEN[:auto_link_hashtags] = /#{NON_CJ_HASHTAG}/io
|
84
|
+
REGEXEN[:auto_link_cj_hashtags] = /#{CJ_HASHTAG}/io
|
85
|
+
|
53
86
|
REGEXEN[:auto_link_usernames_or_lists] = /([^a-zA-Z0-9_]|^|RT:?)([@@]+)([a-zA-Z0-9_]{1,20})(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?/o
|
54
87
|
REGEXEN[:auto_link_emoticon] = /(8\-\#|8\-E|\+\-\(|\`\@|\`O|\<\|:~\(|\}:o\{|:\-\[|\>o\<|X\-\/|\[:-\]\-I\-|\/\/\/\/Ö\\\\\\\\|\(\|:\|\/\)|∑:\*\)|\( \| \))/
|
55
88
|
|
56
89
|
# URL related hash regex collection
|
57
90
|
REGEXEN[:valid_preceding_chars] = /(?:[^-\/"':!=A-Z0-9_@@]|^|\:)/i
|
58
91
|
|
59
|
-
|
60
|
-
REGEXEN[:
|
61
|
-
REGEXEN[:
|
92
|
+
DOMAIN_EXCLUDE_PART = "[:punct:][:space:][:blank:]#{[0x00A0].pack('U')}"
|
93
|
+
REGEXEN[:valid_subdomain] = /(?:[^#{DOMAIN_EXCLUDE_PART}](?:[_-]|[^#{DOMAIN_EXCLUDE_PART}])*)?[^#{DOMAIN_EXCLUDE_PART}]\./
|
94
|
+
REGEXEN[:valid_domain_name] = /(?:[^#{DOMAIN_EXCLUDE_PART}](?:[-]|[^#{DOMAIN_EXCLUDE_PART}])*)?[^#{DOMAIN_EXCLUDE_PART}]/
|
95
|
+
REGEXEN[:valid_domain] = /#{REGEXEN[:valid_subdomain]}*#{REGEXEN[:valid_domain_name]}\.(?:xn--[a-z0-9]{2,}|[a-z]{2,})(?::[0-9]+)?/i
|
62
96
|
|
63
|
-
REGEXEN[:valid_general_url_path_chars] = /[a-z0-9!\*';:=\+\,\$\/%#\[\]\-_
|
97
|
+
REGEXEN[:valid_general_url_path_chars] = /[a-z0-9!\*';:=\+\,\$\/%#\[\]\-_~|\.]/i
|
64
98
|
# Allow URL paths to contain balanced parens
|
65
99
|
# 1. Used in Wikipedia URLs like /Primer_(film)
|
66
100
|
# 2. Used in IIS sessions like /S(dfd346)/
|
data/spec/extractor_spec.rb
CHANGED
@@ -236,17 +236,6 @@ describe Twitter::Extractor do
|
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
239
|
-
context "should NOT allow Japanese" do
|
240
|
-
%w(会議中 ハッシュ).each do |hashtag|
|
241
|
-
it "should NOT extract ##{hashtag}" do
|
242
|
-
@extractor.extract_hashtags("##{hashtag}").should == []
|
243
|
-
end
|
244
|
-
|
245
|
-
it "should NOT extract ##{hashtag} within text" do
|
246
|
-
@extractor.extract_hashtags("pre-text ##{hashtag} post-text").should == []
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
239
|
end
|
251
240
|
|
252
241
|
it "should not extract numeric hashtags" do
|
@@ -301,18 +290,6 @@ describe Twitter::Extractor do
|
|
301
290
|
match_hashtag_in_text('pre', "#pre#{[0xf7].pack('U')}post")
|
302
291
|
end
|
303
292
|
end
|
304
|
-
|
305
|
-
context "should NOT allow Japanese" do
|
306
|
-
%w(会議中 ハッシュ).each do |hashtag|
|
307
|
-
it "should NOT extract ##{hashtag}" do
|
308
|
-
no_match_hashtag_in_text("##{hashtag}")
|
309
|
-
end
|
310
|
-
|
311
|
-
it "should NOT extract ##{hashtag} within text" do
|
312
|
-
no_match_hashtag_in_text("pre-text ##{hashtag} post-text")
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
316
293
|
end
|
317
294
|
|
318
295
|
it "should not extract numeric hashtags" do
|
data/twitter-text.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "twitter-text"
|
3
|
-
s.version = "1.4.
|
3
|
+
s.version = "1.4.5"
|
4
4
|
s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle", "Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa"]
|
5
5
|
s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com", "raffi@twitter.com", "jcummins@twitter.com", "niw@niw.at"]
|
6
6
|
s.homepage = "http://twitter.com"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 13
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 5
|
10
|
+
version: 1.4.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Sanford
|
@@ -21,7 +21,7 @@ autorequire:
|
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
23
|
|
24
|
-
date: 2011-
|
24
|
+
date: 2011-06-22 00:00:00 -07:00
|
25
25
|
default_executable:
|
26
26
|
dependencies:
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
requirements: []
|
170
170
|
|
171
171
|
rubyforge_project:
|
172
|
-
rubygems_version: 1.
|
172
|
+
rubygems_version: 1.3.7
|
173
173
|
signing_key:
|
174
174
|
specification_version: 3
|
175
175
|
summary: Twitter text handling library
|