Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

lang/javascript/jsdeferred/trunk/Rakefile

lang/javascript/jsdeferred/trunk/makedoc.rb
lang/javascript/jsdeferred/trunk/test-jsdeferred.js
lang/javascript/jsdeferred/trunk/test-rhino.js
lang/javascript/jsdeferred/trunk/jsdeferred.js
lang/javascript/jsdeferred/trunk/binding/userscript.js:
 * 正規表現などの雑多な調整です。
  • Loading branch information...
commit 8217b5204d83364eff2b78e466523b8642e7f94d 1 parent 56ce9e0
@drry drry authored
View
2  Rakefile
@@ -66,7 +66,7 @@ task :release => [:update, :clean, :test] do
end
require "uri"
- url = URI(info[/URL: ([^\s]+)/, 1]) + "."
+ url = URI(info[/URL: (\S+)/, 1]) + "."
puts url
com = %{svn cp #{url + "trunk"} #{url + "tags/release-#{ver}"}}
puts com
View
8 binding/userscript.js
@@ -21,8 +21,8 @@ function xhttp (opts) {
GM_xmlhttpRequest(opts);
return d;
}
-xhttp.get = function (url) { return xhttp({method:"get", url:url}) }
-xhttp.post = function (url, data) { return xhttp({method:"post", url:url, data:data, headers:{"Content-Type":"application/x-www-form-urlencoded"}}) }
+xhttp.get = function (url) { return xhttp({method:"get", url:url}) };
+xhttp.post = function (url, data) { return xhttp({method:"post", url:url, data:data, headers:{"Content-Type":"application/x-www-form-urlencoded"}}) };
/* function http (opts) //=> Deferred
@@ -55,8 +55,8 @@ function http (opts) {
d.xhr = req;
return d;
}
-http.get = function (url) { return http({method:"get", url:url}) }
-http.post = function (url, data) { return http({method:"post", url:url, data:data, headers:{"Content-Type":"application/x-www-form-urlencoded"}}) }
+http.get = function (url) { return http({method:"get", url:url}) };
+http.post = function (url, data) { return http({method:"post", url:url, data:data, headers:{"Content-Type":"application/x-www-form-urlencoded"}}) };
Deferred.Deferred = Deferred;
Deferred.http = http;
View
14 jsdeferred.js
@@ -35,14 +35,14 @@
*
* parallel([$.get("foo.html"), $.get("bar.html")]).next(function (values) {
* log($.map(values, function (v) { return v.length }));
- * if (values[1].match(/nextUrl:\s*([^\s]+)/)) {
+ * if (values[1].match(/nextUrl:\s*(\S+)/)) {
* return $.get(RegExp.$1).next(function (d) {
* return d;
* });
* }
* }).
* next(function (d) {
- * log(d.length)
+ * log(d.length);
* });
*
*/
@@ -191,8 +191,8 @@ Deferred.wait = function (n) {
var id = setTimeout(function () {
clearTimeout(id);
d.call((new Date).getTime() - t.getTime());
- }, n * 1000)
- d.canceller = function () { try { clearTimeout(id) } catch (e) {} };
+ }, n * 1000);
+ d.canceller = function () { try { clearTimeout(id) } catch (e) {} };
return d;
};
@@ -205,7 +205,7 @@ Deferred.next = function (fun) {
var d = new Deferred();
var id = setTimeout(function () { clearTimeout(id); d.call() }, 0);
if (fun) d.callback.ok = fun;
- d.canceller = function () { try { clearTimeout(id) } catch (e) {} };
+ d.canceller = function () { try { clearTimeout(id) } catch (e) {} };
return d;
};
@@ -227,7 +227,7 @@ Deferred.next = function (fun) {
* }).
* next(function (r) {
* print([r, "end"]);
- * })
+ * });
*
*/
Deferred.call = function (f, args) {
@@ -245,7 +245,7 @@ Deferred.call = function (f, args) {
*
* Sample:
* //=> loop 1 to 100
- * loop({begin:1, end:100,step:10}, function (n, o) {
+ * loop({begin:1, end:100, step:10}, function (n, o) {
* for (var i = 0; i < o.step; i++) {
* log(n+i);
* }
View
6 makedoc.rb
@@ -19,7 +19,7 @@ def parse
js.scan(%r{/\* (function[^\n]+|[^:]+::)(.+?)\*/}im) do |header, body|
body.gsub!(/^ \* ?/, "")
p header
- _, name, arg, retv = *%r{^function\s+([^\s]+)\s+\((.*)\)\s+//=>\s+(.+)}.match(header)
+ _, name, arg, retv = *%r{^function\s*(\S+)\s*\(([^)]*)\)\s*//\s*=>\s*(.+)}.match(header)
if _
#p [name, args, retv]
_, req, opt = */([^\[\]]+)(?:\[, ([^\[\]]+)\])?/.match(arg)
@@ -62,7 +62,7 @@ def parse_section(section)
str.gsub!(/[<&]/) {|m|
"&#{r[m]};"
}
- str.gsub!(/`([^`]+)`/) {|m|
+ str.gsub!(/`((?:\\`|[^`])+)`/) {|m|
name = Regexp.last_match[1]
case
when fun[:args].include?(name)
@@ -101,7 +101,7 @@ def parse_section(section)
when :pre
"<pre>#{b}</pre>"
else
- "<p>#{parse_inline[b].gsub(/\n\n/, "</p>\n<p>")}</p>"
+ "<p>#{parse_inline[b].gsub(/(?:\r?\n|\r){2}/, "</p>\n<p>")}</p>"
end
}.join("\n")
end
View
2  test-jsdeferred.js
@@ -1,7 +1,7 @@
$(function () { $.get("test-jsdeferred.js", {}, function (data) {
// get tests number.
-data = data.match(/\/\/ ::Test::Start::((?:\s|[^\s])+)::Test::End::/)[1];
+data = data.match(/\/\/ ::Test::Start::([\s\S]+)::Test::End::/)[1];
var testfuns = []; data.replace(/(ok|expect)\(.+/g, function (m) {
if (window.console) console.log(m);
testfuns.push(m);
View
2  test-rhino.js
@@ -5,7 +5,7 @@ load(Global.arguments[0] || "jsdeferred.js");
var data;
data = readFile("./test-jsdeferred.js");
-data = data.match(/\/\/ ::Test::Start::((?:\s|[^\s])+)::Test::End::/)[1];
+data = data.match(/\/\/ ::Test::Start::([\s\S]+)::Test::End::/)[1];
var testfuns = []; data.replace(/(ok|expect)\(.+/g, function (m) {
// if (window.console) console.log(m);
testfuns.push(m);
Please sign in to comment.
Something went wrong with that request. Please try again.