Permalink
Browse files

Updated rake task for submodules. Updated regex for unicode (but not …

…puctuation) domains
  • Loading branch information...
1 parent ecc05ce commit 226049a113527d24e221e373e692716ec60a5b3d Matt Sanford committed Feb 3, 2010
Showing with 29 additions and 9 deletions.
  1. +11 −3 Rakefile
  2. +2 −2 lib/regex.rb
  3. +13 −3 spec/regex_spec.rb
  4. +2 −0 test/conformance_test.rb
  5. +1 −1 test/twitter-text-conformance
View
@@ -45,20 +45,28 @@ namespace :test do
namespace :conformance do
desc "Update conformance testing data"
task :update do
- dir = File.join(File.dirname(__FILE__), "test", "twitter-text-conformance")
puts "Updating conformance data ... "
- system("cd #{dir} && git pull origin master") || exit(1)
+ system("git submodule init") || raise("Failed to init submodule")
+ system("git submodule update") || raise("Failed to update submodule")
puts "Updating conformance data ... DONE"
end
+ desc "Change conformance test data to the lastest version"
+ task :latest => ['conformance:update'] do
+ current_dir = File.dirname(__FILE__)
+ submodule_dir = File.join(File.dirname(__FILE__), "test", "twitter-text-conformance")
+ system("cd #{submodule_dir} && git pull origin master") || raise("Failed to pull submodule version")
+ system("cd #{current_dir} && git commit -a -m \"Upgraded to the latest conformance version\"") || raise("Failed to commit version upgrade")
+ end
+
desc "Run conformance test suite"
task :run do
ruby "test/conformance_test.rb"
end
end
desc "Run conformance test suite"
- task :conformance => ['conformance:update', 'conformance:run'] do
+ task :conformance => ['conformance:latest', 'conformance:run'] do
end
end
View
@@ -43,7 +43,7 @@ class Regex
# URL related hash regex collection
REGEXEN[:valid_preceeding_chars] = /(?:[^\/"':!=]|^|\:)/
- REGEXEN[:valid_domain] = /[a-z0-9\.-]+\.[a-z]{2,}(?::[0-9]+)?/i
+ REGEXEN[:valid_domain] = /(?:[\.-]|[^[:punct:]])+\.[a-z]{2,}(?::[0-9]+)?/i
REGEXEN[:valid_url_path_chars] = /[a-z0-9!\*'\(\);:&=\+\$\/%#\[\]\-_\.,~]/i
# Valid end-of-path chracters (so /foo. does not gobble the period).
# 1. Allow ) for Wikipedia URLs.
@@ -71,4 +71,4 @@ def self.[](key)
REGEXEN[key]
end
end
-end
+end
View
@@ -15,7 +15,11 @@
"http://www.ams.org/bookstore-getitem/item=mbk-59",
"http://chilp.it/?77e8fd",
"www.foobar.com",
- "WWW.FOOBAR.COM"
+ "WWW.FOOBAR.COM",
+ "http://tell.me/why",
+ "http://longtlds.mobi",
+ "http://✪df.ws/ejp",
+ "http://日本.com"
]
@urls.each do |url|
@@ -31,14 +35,20 @@
end
describe "invalid URLS" do
- it "does not link urls with invalid_domains" do
+ it "does not link urls with invalid characters" do
[ "http://doman-dash_2314352345_dfasd.foo-cow_4352.com",
"http://no-tld",
"http://tld-too-short.x",
"http://x.com/,,,/.../@@@/;;;/:::/---/%%%x",
- "http://doman-dash_2314352345_dfasd.foo-cow_4352.com",
+ "http://doman_dash_2314352345_dfasd.foo-cow_4352.com",
].each {|url| url.should_not have_autolinked_url(url)}
end
+
+ it "does not link domains beginning with a hypen" do
+ pending
+ "http://-doman_dash_2314352345_dfasd.com".should_not match_autolink_expression
+ end
+
end
end
View
@@ -75,6 +75,8 @@ def test_all_autolink_conformance
def run_conformance_test(file, test_type, &block)
yaml = YAML.load_file(file)
+ assert yaml["tests"][test_type.to_s], "No such test suite: #{test_type.to_s}"
+
yaml["tests"][test_type.to_s].each do |test_info|
yield test_info['description'], test_info['expected'], test_info['text']
end

0 comments on commit 226049a

Please sign in to comment.