twitter-text 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.8.7
4
- - 1.9.3
4
+ - 1.9.3
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  require 'bundler'
3
2
  include Rake::DSL
4
3
  Bundler::GemHelper.install_tasks
@@ -8,10 +8,6 @@ else
8
8
  true
9
9
  end
10
10
 
11
- require 'active_support'
12
- require 'active_support/core_ext/string/multibyte.rb'
13
- require 'active_support/core_ext/hash/keys.rb'
14
-
15
11
  %w(
16
12
  deprecation
17
13
  regex
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'set'
4
+ require 'twitter-text/core_ext/hash'
4
5
 
5
6
  module Twitter
6
7
  # A module for including Tweet auto-linking in a class. The primary use of this is for helpers/views so they can auto-link
@@ -437,5 +438,6 @@ module Twitter
437
438
  attrs
438
439
  end
439
440
  end
441
+
440
442
  end
441
443
  end
@@ -0,0 +1,21 @@
1
+ class Hash
2
+
3
+ # Return a new hash with all keys converted to symbols, as long as
4
+ # they respond to +to_sym+.
5
+ #
6
+ # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys
7
+ # #=> { :name => "Rob", :years => "28" }
8
+ def symbolize_keys
9
+ dup.symbolize_keys!
10
+ end
11
+
12
+ # Destructively convert all keys to symbols, as long as they respond
13
+ # to +to_sym+. Same as +symbolize_keys+, but modifies +self+.
14
+ def symbolize_keys!
15
+ keys.each do |key|
16
+ self[(key.to_sym rescue key) || key] = delete(key)
17
+ end
18
+ self
19
+ end
20
+
21
+ end
@@ -195,7 +195,7 @@ module Twitter
195
195
  gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|
196
196
  lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|
197
197
  pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sy|sz|tc|td|tf|tg|th|
198
- tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)
198
+ tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw|sx)
199
199
  (?=[^0-9a-z]|$)
200
200
  )
201
201
  }ix
@@ -1,3 +1,5 @@
1
+ require 'unf'
2
+
1
3
  module Twitter
2
4
  module Validation extend self
3
5
  MAX_LENGTH = 140
@@ -23,7 +25,7 @@ module Twitter
23
25
  def tweet_length(text, options = {})
24
26
  options = DEFAULT_TCO_URL_LENGTHS.merge(options)
25
27
 
26
- length = ActiveSupport::Multibyte::Chars.new(text).normalize(:c).length
28
+ length = text.to_nfc.unpack("U*").length
27
29
 
28
30
  Twitter::Extractor.extract_urls_with_indices(text) do |url, start_position, end_position|
29
31
  length += start_position - end_position
@@ -47,7 +49,7 @@ module Twitter
47
49
  begin
48
50
  return :too_long if tweet_length(text) > MAX_LENGTH
49
51
  return :invalid_characters if Twitter::Regex::INVALID_CHARACTERS.any?{|invalid_char| text.include?(invalid_char) }
50
- rescue ArgumentError, ActiveSupport::Multibyte::EncodingError => e
52
+ rescue ArgumentError => e
51
53
  # non-Unicode value.
52
54
  return :invalid_characters
53
55
  end
@@ -1,6 +1,7 @@
1
+ require 'multi_json'
2
+ require 'nokogiri'
1
3
  require 'test/unit'
2
4
  require 'yaml'
3
- require 'nokogiri'
4
5
 
5
6
  # Ruby 1.8 encoding check
6
7
  major, minor, patch = RUBY_VERSION.split('.')
@@ -138,7 +139,7 @@ class ConformanceTest < Test::Unit::TestCase
138
139
  end
139
140
 
140
141
  def_conformance_test("autolink.yml", :json) do
141
- assert_equal_without_attribute_order expected, auto_link_with_json(text, ActiveSupport::JSON.decode(json), :suppress_no_follow => true), description
142
+ assert_equal_without_attribute_order expected, auto_link_with_json(text, MultiJson.load(json), :suppress_no_follow => true), description
142
143
  end
143
144
 
144
145
  # HitHighlighter Conformance
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "twitter-text"
5
- s.version = "1.6.0"
5
+ s.version = "1.6.1"
6
6
  s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle",
7
7
  "Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa", "Keita Fujii", "James Koval"]
8
8
  s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com",
@@ -14,12 +14,13 @@ Gem::Specification.new do |s|
14
14
  s.has_rdoc = true
15
15
  s.summary = "Twitter text handling library"
16
16
 
17
+ s.add_development_dependency "multi_json", "~> 1.3"
17
18
  s.add_development_dependency "nokogiri"
18
19
  s.add_development_dependency "rake"
19
20
  s.add_development_dependency "rdoc"
20
21
  s.add_development_dependency "rspec"
21
22
  s.add_development_dependency "simplecov"
22
- s.add_runtime_dependency "activesupport"
23
+ s.add_runtime_dependency "unf", "~> 0.0.5"
23
24
 
24
25
  s.files = `git ls-files`.split("\n")
25
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: twitter-text
3
- version: !ruby/object:Gem::Version
4
- hash: 15
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 6
9
- - 0
10
- version: 1.6.0
5
+ version: 1.6.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matt Sanford
14
9
  - Patrick Ewing
15
10
  - Ben Cherry
@@ -22,95 +17,122 @@ authors:
22
17
  autorequire:
23
18
  bindir: bin
24
19
  cert_chain: []
25
-
26
- date: 2013-03-01 00:00:00 Z
27
- dependencies:
28
- - !ruby/object:Gem::Dependency
29
- name: nokogiri
20
+ date: 2013-03-11 00:00:00.000000000 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ none: false
30
29
  prerelease: false
31
- requirement: &id001 !ruby/object:Gem::Requirement
30
+ name: multi_json
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '1.3'
32
36
  none: false
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- hash: 3
37
- segments:
38
- - 0
39
- version: "0"
40
37
  type: :development
41
- version_requirements: *id001
42
- - !ruby/object:Gem::Dependency
43
- name: rake
38
+ - !ruby/object:Gem::Dependency
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ none: false
44
45
  prerelease: false
45
- requirement: &id002 !ruby/object:Gem::Requirement
46
+ name: nokogiri
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
46
52
  none: false
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 0
53
- version: "0"
54
53
  type: :development
55
- version_requirements: *id002
56
- - !ruby/object:Gem::Dependency
57
- name: rdoc
54
+ - !ruby/object:Gem::Dependency
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ none: false
58
61
  prerelease: false
59
- requirement: &id003 !ruby/object:Gem::Requirement
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
60
68
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
68
69
  type: :development
69
- version_requirements: *id003
70
- - !ruby/object:Gem::Dependency
71
- name: rspec
70
+ - !ruby/object:Gem::Dependency
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ none: false
77
+ prerelease: false
78
+ name: rdoc
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ none: false
85
+ type: :development
86
+ - !ruby/object:Gem::Dependency
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ none: false
72
93
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
94
+ name: rspec
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
74
100
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- hash: 3
79
- segments:
80
- - 0
81
- version: "0"
82
101
  type: :development
83
- version_requirements: *id004
84
- - !ruby/object:Gem::Dependency
85
- name: simplecov
102
+ - !ruby/object:Gem::Dependency
103
+ version_requirements: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ none: false
86
109
  prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
110
+ name: simplecov
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
88
116
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
117
  type: :development
97
- version_requirements: *id005
98
- - !ruby/object:Gem::Dependency
99
- name: activesupport
118
+ - !ruby/object:Gem::Dependency
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ version: 0.0.5
124
+ none: false
100
125
  prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
126
+ name: unf
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.5
102
132
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
110
133
  type: :runtime
111
- version_requirements: *id006
112
134
  description: A gem that provides text handling for Twitter
113
- email:
135
+ email:
114
136
  - matt@twitter.com
115
137
  - patrick.henry.ewing@gmail.com
116
138
  - bcherry@gmail.com
@@ -121,12 +143,9 @@ email:
121
143
  - keita@twitter.com
122
144
  - jkoval@twitter.com
123
145
  executables: []
124
-
125
146
  extensions: []
126
-
127
147
  extra_rdoc_files: []
128
-
129
- files:
148
+ files:
130
149
  - .gemtest
131
150
  - .gitignore
132
151
  - .gitmodules
@@ -136,9 +155,9 @@ files:
136
155
  - LICENSE
137
156
  - README.rdoc
138
157
  - Rakefile
139
- - TODO
140
158
  - lib/twitter-text.rb
141
159
  - lib/twitter-text/autolink.rb
160
+ - lib/twitter-text/core_ext/hash.rb
142
161
  - lib/twitter-text/deprecation.rb
143
162
  - lib/twitter-text/extractor.rb
144
163
  - lib/twitter-text/hit_highlighter.rb
@@ -162,38 +181,35 @@ files:
162
181
  - twitter-text.gemspec
163
182
  homepage: http://twitter.com
164
183
  licenses: []
165
-
166
184
  post_install_message:
167
185
  rdoc_options: []
168
-
169
- require_paths:
186
+ require_paths:
170
187
  - lib
171
- required_ruby_version: !ruby/object:Gem::Requirement
172
- none: false
173
- requirements:
174
- - - ">="
175
- - !ruby/object:Gem::Version
176
- hash: 3
177
- segments:
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ segments:
178
194
  - 0
179
- version: "0"
180
- required_rubygems_version: !ruby/object:Gem::Requirement
195
+ hash: -209443876529914673
181
196
  none: false
182
- requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- hash: 3
186
- segments:
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ! '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ segments:
187
203
  - 0
188
- version: "0"
204
+ hash: -209443876529914673
205
+ none: false
189
206
  requirements: []
190
-
191
207
  rubyforge_project:
192
208
  rubygems_version: 1.8.24
193
209
  signing_key:
194
210
  specification_version: 3
195
211
  summary: Twitter text handling library
196
- test_files:
212
+ test_files:
197
213
  - spec/autolinking_spec.rb
198
214
  - spec/extractor_spec.rb
199
215
  - spec/hithighlighter_spec.rb
@@ -205,4 +221,3 @@ test_files:
205
221
  - spec/unicode_spec.rb
206
222
  - spec/validation_spec.rb
207
223
  - test/conformance_test.rb
208
- has_rdoc: true
data/TODO DELETED
@@ -1,3 +0,0 @@
1
- TODO:
2
-
3
- * @mentions preceded by a dash should work. "I am great -@greatguy"