twitter-text 1.4.8 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,11 @@
1
1
  $TESTING=true
2
- $KCODE='u'
2
+
3
+ # Ruby 1.8 encoding check
4
+ major, minor, patch = RUBY_VERSION.split('.')
5
+ if major.to_i == 1 && minor.to_i < 9
6
+ $KCODE='u'
7
+ end
8
+
3
9
  $:.push File.join(File.dirname(__FILE__), '..', 'lib')
4
10
 
5
11
  require 'nokogiri'
@@ -32,16 +38,16 @@ RSpec::Matchers.define :match_autolink_expression_in do |text|
32
38
  end
33
39
  end
34
40
 
35
- RSpec::Matchers.define :have_autolinked_url do |url|
41
+ RSpec::Matchers.define :have_autolinked_url do |url, inner_text|
36
42
  match do |text|
37
43
  @link = Nokogiri::HTML(text).search("a[@href='#{url}']")
38
44
  @link &&
39
45
  @link.inner_text &&
40
- @link.inner_text == url
46
+ (inner_text && @link.inner_text == inner_text) || (!inner_text && @link.inner_text == url)
41
47
  end
42
48
 
43
49
  failure_message_for_should do |text|
44
- "Expected url '#{url}' to be autolinked in '#{text}'"
50
+ "Expected url '#{url}'#{", inner_text '#{inner_text}'" if inner_text} to be autolinked in '#{text}'"
45
51
  end
46
52
  end
47
53
 
@@ -1,7 +1,13 @@
1
1
  require 'test/unit'
2
2
  require 'yaml'
3
- $KCODE = 'UTF8'
4
- require File.dirname(__FILE__) + '/../lib/twitter-text'
3
+
4
+ # Ruby 1.8 encoding check
5
+ major, minor, patch = RUBY_VERSION.split('.')
6
+ if major.to_i == 1 && minor.to_i < 9
7
+ $KCODE='u'
8
+ end
9
+
10
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/twitter-text')
5
11
 
6
12
  class ConformanceTest < Test::Unit::TestCase
7
13
  include Twitter::Extractor
@@ -28,11 +34,18 @@ class ConformanceTest < Test::Unit::TestCase
28
34
 
29
35
  def test_mentions_with_indices_extractor_conformance
30
36
  run_conformance_test(File.join(@conformance_dir, 'extract.yml'), :mentions_with_indices) do |description, expected, input|
31
- expected = expected.map{|elem| elem.symbolize_keys }
37
+ expected = expected.map{|elem| elem.inject({}){|h, (k,v)| h[k.to_sym] = v; h} }
32
38
  assert_equal expected, extract_mentioned_screen_names_with_indices(input), description
33
39
  end
34
40
  end
35
41
 
42
+ def test_mentions_or_lists_with_indices_conformance
43
+ run_conformance_test(File.join(@conformance_dir, 'extract.yml'), :mentions_or_lists_with_indices) do |description, expected, input|
44
+ expected = expected.map{|elem| elem.inject({}){|h, (k,v)| h[k.to_sym] = v; h} }
45
+ assert_equal expected, extract_mentions_or_lists_with_indices(input), description
46
+ end
47
+ end
48
+
36
49
  def test_url_extractor_conformance
37
50
  run_conformance_test(File.join(@conformance_dir, 'extract.yml'), :urls) do |description, expected, input|
38
51
  assert_equal expected, extract_urls(input), description
@@ -44,7 +57,7 @@ class ConformanceTest < Test::Unit::TestCase
44
57
 
45
58
  def test_urls_with_indices_extractor_conformance
46
59
  run_conformance_test(File.join(@conformance_dir, 'extract.yml'), :urls_with_indices) do |description, expected, input|
47
- expected = expected.map{|elem| elem.symbolize_keys }
60
+ expected = expected.map{|elem| elem.inject({}){|h, (k,v)| h[k.to_sym] = v; h} }
48
61
  assert_equal expected, extract_urls_with_indices(input), description
49
62
  end
50
63
  end
@@ -57,7 +70,7 @@ class ConformanceTest < Test::Unit::TestCase
57
70
 
58
71
  def test_hashtags_with_indices_extractor_conformance
59
72
  run_conformance_test(File.join(@conformance_dir, 'extract.yml'), :hashtags_with_indices) do |description, expected, input|
60
- expected = expected.map{|elem| elem.symbolize_keys }
73
+ expected = expected.map{|elem| elem.inject({}){|h, (k,v)| h[k.to_sym] = v; h} }
61
74
  assert_equal expected, extract_hashtags_with_indices(input), description
62
75
  end
63
76
  end
data/twitter-text.gemspec CHANGED
@@ -1,8 +1,10 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = "twitter-text"
3
- s.version = "1.4.8"
4
- s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle", "Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa"]
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"]
3
+ s.version = "1.4.9"
4
+ s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle",
5
+ "Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa"]
6
+ s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com",
7
+ "raffi@twitter.com", "jcummins@twitter.com", "niw@niw.at"]
6
8
  s.homepage = "http://twitter.com"
7
9
  s.description = s.summary = "A gem that provides text handling for Twitter"
8
10
 
@@ -14,7 +16,7 @@ spec = Gem::Specification.new do |s|
14
16
  s.add_development_dependency "rake"
15
17
  s.add_development_dependency "rspec"
16
18
  s.add_development_dependency "simplecov"
17
- s.add_runtime_dependency "actionpack"
19
+ s.add_runtime_dependency "activesupport"
18
20
 
19
21
  s.files = `git ls-files`.split("\n")
20
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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: 23
5
- prerelease:
4
+ hash: 21
5
+ prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 8
10
- version: 1.4.8
9
+ - 9
10
+ version: 1.4.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Sanford
@@ -21,7 +21,8 @@ autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
23
 
24
- date: 2011-07-13 00:00:00 Z
24
+ date: 2011-08-05 00:00:00 -07:00
25
+ default_executable:
25
26
  dependencies:
26
27
  - !ruby/object:Gem::Dependency
27
28
  name: nokogiri
@@ -80,7 +81,7 @@ dependencies:
80
81
  type: :development
81
82
  version_requirements: *id004
82
83
  - !ruby/object:Gem::Dependency
83
- name: actionpack
84
+ name: activesupport
84
85
  prerelease: false
85
86
  requirement: &id005 !ruby/object:Gem::Requirement
86
87
  none: false
@@ -122,6 +123,7 @@ files:
122
123
  - lib/extractor.rb
123
124
  - lib/hithighlighter.rb
124
125
  - lib/regex.rb
126
+ - lib/rewriter.rb
125
127
  - lib/twitter-text.rb
126
128
  - lib/unicode.rb
127
129
  - lib/validation.rb
@@ -131,6 +133,7 @@ files:
131
133
  - spec/extractor_spec.rb
132
134
  - spec/hithighlighter_spec.rb
133
135
  - spec/regex_spec.rb
136
+ - spec/rewriter_spec.rb
134
137
  - spec/spec_helper.rb
135
138
  - spec/test_urls.rb
136
139
  - spec/twitter_text_spec.rb
@@ -138,6 +141,7 @@ files:
138
141
  - spec/validation_spec.rb
139
142
  - test/conformance_test.rb
140
143
  - twitter-text.gemspec
144
+ has_rdoc: true
141
145
  homepage: http://twitter.com
142
146
  licenses: []
143
147
 
@@ -167,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
171
  requirements: []
168
172
 
169
173
  rubyforge_project:
170
- rubygems_version: 1.8.5
174
+ rubygems_version: 1.3.7
171
175
  signing_key:
172
176
  specification_version: 3
173
177
  summary: Twitter text handling library
@@ -176,6 +180,7 @@ test_files:
176
180
  - spec/extractor_spec.rb
177
181
  - spec/hithighlighter_spec.rb
178
182
  - spec/regex_spec.rb
183
+ - spec/rewriter_spec.rb
179
184
  - spec/spec_helper.rb
180
185
  - spec/test_urls.rb
181
186
  - spec/twitter_text_spec.rb