swagr 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/swagr +15 -0
- data/examples/examples01/app.rb +6 -2
- data/examples/examples01/coffee/data_port.coffee +2 -0
- data/examples/examples01/static/css/codemirror.css +1247 -0
- data/examples/examples01/static/js/codemirror-compressed-3-0.js +5 -0
- data/examples/examples01/static/js/codemirror/keymap/emacs.js +30 -0
- data/examples/examples01/static/js/codemirror/keymap/vim.js +2298 -0
- data/examples/examples01/static/js/codemirror/lib/codemirror.css +239 -0
- data/examples/examples01/static/js/codemirror/lib/codemirror.js +4553 -0
- data/examples/examples01/static/js/codemirror/lib/util/closetag.js +85 -0
- data/examples/examples01/static/js/codemirror/lib/util/colorize.js +29 -0
- data/examples/examples01/static/js/codemirror/lib/util/continuecomment.js +36 -0
- data/examples/examples01/static/js/codemirror/lib/util/continuelist.js +28 -0
- data/examples/examples01/static/js/codemirror/lib/util/dialog.css +32 -0
- data/examples/examples01/static/js/codemirror/lib/util/dialog.js +75 -0
- data/examples/examples01/static/js/codemirror/lib/util/foldcode.js +182 -0
- data/examples/examples01/static/js/codemirror/lib/util/formatting.js +108 -0
- data/examples/examples01/static/js/codemirror/lib/util/javascript-hint.js +137 -0
- data/examples/examples01/static/js/codemirror/lib/util/loadmode.js +51 -0
- data/examples/examples01/static/js/codemirror/lib/util/match-highlighter.js +46 -0
- data/examples/examples01/static/js/codemirror/lib/util/matchbrackets.js +63 -0
- data/examples/examples01/static/js/codemirror/lib/util/multiplex.js +95 -0
- data/examples/examples01/static/js/codemirror/lib/util/overlay.js +59 -0
- data/examples/examples01/static/js/codemirror/lib/util/pig-hint.js +117 -0
- data/examples/examples01/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
- data/examples/examples01/static/js/codemirror/lib/util/runmode.js +52 -0
- data/examples/examples01/static/js/codemirror/lib/util/search.js +119 -0
- data/examples/examples01/static/js/codemirror/lib/util/searchcursor.js +119 -0
- data/examples/examples01/static/js/codemirror/lib/util/simple-hint.css +16 -0
- data/examples/examples01/static/js/codemirror/lib/util/simple-hint.js +102 -0
- data/examples/examples01/static/js/codemirror/lib/util/xml-hint.js +131 -0
- data/examples/examples01/static/js/codemirror/mode/clike/clike.js +300 -0
- data/examples/examples01/static/js/codemirror/mode/clike/index.html +103 -0
- data/examples/examples01/static/js/codemirror/mode/clike/scala.html +767 -0
- data/examples/examples01/static/js/codemirror/mode/clojure/clojure.js +206 -0
- data/examples/examples01/static/js/codemirror/mode/clojure/index.html +67 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/index.html +728 -0
- data/examples/examples01/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/examples/examples01/static/js/codemirror/mode/commonlisp/index.html +165 -0
- data/examples/examples01/static/js/codemirror/mode/css/css.js +465 -0
- data/examples/examples01/static/js/codemirror/mode/css/index.html +58 -0
- data/examples/examples01/static/js/codemirror/mode/css/test.js +501 -0
- data/examples/examples01/static/js/codemirror/mode/diff/diff.js +32 -0
- data/examples/examples01/static/js/codemirror/mode/diff/index.html +105 -0
- data/examples/examples01/static/js/codemirror/mode/ecl/ecl.js +192 -0
- data/examples/examples01/static/js/codemirror/mode/ecl/index.html +39 -0
- data/examples/examples01/static/js/codemirror/mode/erlang/erlang.js +463 -0
- data/examples/examples01/static/js/codemirror/mode/erlang/index.html +64 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/gfm.js +94 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/index.html +70 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/test.js +225 -0
- data/examples/examples01/static/js/codemirror/mode/go/go.js +165 -0
- data/examples/examples01/static/js/codemirror/mode/go/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/groovy/groovy.js +210 -0
- data/examples/examples01/static/js/codemirror/mode/groovy/index.html +73 -0
- data/examples/examples01/static/js/codemirror/mode/haskell/haskell.js +242 -0
- data/examples/examples01/static/js/codemirror/mode/haskell/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/haxe/haxe.js +429 -0
- data/examples/examples01/static/js/codemirror/mode/haxe/index.html +90 -0
- data/examples/examples01/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/examples/examples01/static/js/codemirror/mode/htmlembedded/index.html +49 -0
- data/examples/examples01/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
- data/examples/examples01/static/js/codemirror/mode/htmlmixed/index.html +52 -0
- data/examples/examples01/static/js/codemirror/mode/http/http.js +98 -0
- data/examples/examples01/static/js/codemirror/mode/http/index.html +32 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/index.html +88 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/javascript.js +411 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/typescript.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/jinja2/index.html +38 -0
- data/examples/examples01/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
- data/examples/examples01/static/js/codemirror/mode/less/index.html +741 -0
- data/examples/examples01/static/js/codemirror/mode/less/less.js +266 -0
- data/examples/examples01/static/js/codemirror/mode/lua/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/lua/lua.js +140 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/index.html +344 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/markdown.js +474 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/test.js +1266 -0
- data/examples/examples01/static/js/codemirror/mode/mysql/index.html +41 -0
- data/examples/examples01/static/js/codemirror/mode/mysql/mysql.js +203 -0
- data/examples/examples01/static/js/codemirror/mode/ntriples/index.html +33 -0
- data/examples/examples01/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
- data/examples/examples01/static/js/codemirror/mode/ocaml/index.html +131 -0
- data/examples/examples01/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/LICENSE +7 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/index.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/pascal.js +94 -0
- data/examples/examples01/static/js/codemirror/mode/perl/LICENSE +19 -0
- data/examples/examples01/static/js/codemirror/mode/perl/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/perl/perl.js +816 -0
- data/examples/examples01/static/js/codemirror/mode/php/index.html +51 -0
- data/examples/examples01/static/js/codemirror/mode/php/php.js +129 -0
- data/examples/examples01/static/js/codemirror/mode/pig/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/pig/pig.js +171 -0
- data/examples/examples01/static/js/codemirror/mode/plsql/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/plsql/plsql.js +216 -0
- data/examples/examples01/static/js/codemirror/mode/properties/index.html +41 -0
- data/examples/examples01/static/js/codemirror/mode/properties/properties.js +63 -0
- data/examples/examples01/static/js/codemirror/mode/python/LICENSE.txt +21 -0
- data/examples/examples01/static/js/codemirror/mode/python/index.html +124 -0
- data/examples/examples01/static/js/codemirror/mode/python/python.js +340 -0
- data/examples/examples01/static/js/codemirror/mode/r/LICENSE +24 -0
- data/examples/examples01/static/js/codemirror/mode/r/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/r/r.js +141 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/changes/index.html +53 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/index.html +99 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
- data/examples/examples01/static/js/codemirror/mode/rst/index.html +526 -0
- data/examples/examples01/static/js/codemirror/mode/rst/rst.js +314 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/LICENSE +24 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/index.html +173 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/ruby.js +195 -0
- data/examples/examples01/static/js/codemirror/mode/rust/index.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/rust/rust.js +432 -0
- data/examples/examples01/static/js/codemirror/mode/scheme/index.html +65 -0
- data/examples/examples01/static/js/codemirror/mode/scheme/scheme.js +230 -0
- data/examples/examples01/static/js/codemirror/mode/shell/index.html +51 -0
- data/examples/examples01/static/js/codemirror/mode/shell/shell.js +118 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/LICENSE +23 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/index.html +81 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/sieve.js +156 -0
- data/examples/examples01/static/js/codemirror/mode/smalltalk/index.html +57 -0
- data/examples/examples01/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/examples/examples01/static/js/codemirror/mode/smarty/index.html +83 -0
- data/examples/examples01/static/js/codemirror/mode/smarty/smarty.js +148 -0
- data/examples/examples01/static/js/codemirror/mode/sparql/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/sparql/sparql.js +143 -0
- data/examples/examples01/static/js/codemirror/mode/stex/index.html +98 -0
- data/examples/examples01/static/js/codemirror/mode/stex/stex.js +175 -0
- data/examples/examples01/static/js/codemirror/mode/stex/test.js +343 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/index.html +81 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/tiki.css +26 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/tiki.js +309 -0
- data/examples/examples01/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
- data/examples/examples01/static/js/codemirror/mode/vb/index.html +88 -0
- data/examples/examples01/static/js/codemirror/mode/vb/vb.js +260 -0
- data/examples/examples01/static/js/codemirror/mode/vbscript/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
- data/examples/examples01/static/js/codemirror/mode/velocity/index.html +103 -0
- data/examples/examples01/static/js/codemirror/mode/velocity/velocity.js +144 -0
- data/examples/examples01/static/js/codemirror/mode/verilog/index.html +210 -0
- data/examples/examples01/static/js/codemirror/mode/verilog/verilog.js +182 -0
- data/examples/examples01/static/js/codemirror/mode/xml/index.html +45 -0
- data/examples/examples01/static/js/codemirror/mode/xml/xml.js +324 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/LICENSE +20 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/index.html +221 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/test.js +77 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/xquery.js +450 -0
- data/examples/examples01/static/js/codemirror/mode/yaml/index.html +68 -0
- data/examples/examples01/static/js/codemirror/mode/yaml/yaml.js +95 -0
- data/examples/examples01/static/js/codemirror/mode/z80/index.html +39 -0
- data/examples/examples01/static/js/codemirror/mode/z80/z80.js +113 -0
- data/examples/examples01/static/js/codemirror/theme/ambiance-mobile.css +6 -0
- data/examples/examples01/static/js/codemirror/theme/ambiance.css +76 -0
- data/examples/examples01/static/js/codemirror/theme/blackboard.css +25 -0
- data/examples/examples01/static/js/codemirror/theme/cobalt.css +18 -0
- data/examples/examples01/static/js/codemirror/theme/eclipse.css +25 -0
- data/examples/examples01/static/js/codemirror/theme/elegant.css +10 -0
- data/examples/examples01/static/js/codemirror/theme/erlang-dark.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/lesser-dark.css +44 -0
- data/examples/examples01/static/js/codemirror/theme/monokai.css +28 -0
- data/examples/examples01/static/js/codemirror/theme/neat.css +9 -0
- data/examples/examples01/static/js/codemirror/theme/night.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/rubyblue.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/solarized.css +207 -0
- data/examples/examples01/static/js/codemirror/theme/twilight.css +26 -0
- data/examples/examples01/static/js/codemirror/theme/vibrant-ink.css +27 -0
- data/examples/examples01/static/js/codemirror/theme/xq-dark.css +46 -0
- data/examples/examples01/static/js/d3.v3.min.js +2 -2
- data/examples/examples01/static/test/cm.html +33 -0
- data/examples/examples01/views/about.slim +15 -0
- data/examples/examples01/views/index.slim +1 -1
- data/examples/examples01/views/layout.slim +1 -0
- data/examples/examples01/views/layout_cm.slim +17 -0
- data/examples/examples01/views/navbar.slim +4 -4
- data/lib/swagr/version.rb +1 -1
- data/templates/app.rb +4 -0
- data/templates/static/js/codemirror/keymap/emacs.js +30 -0
- data/templates/static/js/codemirror/keymap/vim.js +2298 -0
- data/templates/static/js/codemirror/lib/codemirror.css +239 -0
- data/templates/static/js/codemirror/lib/codemirror.js +4553 -0
- data/templates/static/js/codemirror/lib/util/closetag.js +85 -0
- data/templates/static/js/codemirror/lib/util/colorize.js +29 -0
- data/templates/static/js/codemirror/lib/util/continuecomment.js +36 -0
- data/templates/static/js/codemirror/lib/util/continuelist.js +28 -0
- data/templates/static/js/codemirror/lib/util/dialog.css +32 -0
- data/templates/static/js/codemirror/lib/util/dialog.js +75 -0
- data/templates/static/js/codemirror/lib/util/foldcode.js +182 -0
- data/templates/static/js/codemirror/lib/util/formatting.js +108 -0
- data/templates/static/js/codemirror/lib/util/javascript-hint.js +137 -0
- data/templates/static/js/codemirror/lib/util/loadmode.js +51 -0
- data/templates/static/js/codemirror/lib/util/match-highlighter.js +46 -0
- data/templates/static/js/codemirror/lib/util/matchbrackets.js +63 -0
- data/templates/static/js/codemirror/lib/util/multiplex.js +95 -0
- data/templates/static/js/codemirror/lib/util/overlay.js +59 -0
- data/templates/static/js/codemirror/lib/util/pig-hint.js +117 -0
- data/templates/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
- data/templates/static/js/codemirror/lib/util/runmode.js +52 -0
- data/templates/static/js/codemirror/lib/util/search.js +119 -0
- data/templates/static/js/codemirror/lib/util/searchcursor.js +119 -0
- data/templates/static/js/codemirror/lib/util/simple-hint.css +16 -0
- data/templates/static/js/codemirror/lib/util/simple-hint.js +102 -0
- data/templates/static/js/codemirror/lib/util/xml-hint.js +131 -0
- data/templates/static/js/codemirror/mode/clike/clike.js +300 -0
- data/templates/static/js/codemirror/mode/clike/index.html +103 -0
- data/templates/static/js/codemirror/mode/clike/scala.html +767 -0
- data/templates/static/js/codemirror/mode/clojure/clojure.js +206 -0
- data/templates/static/js/codemirror/mode/clojure/index.html +67 -0
- data/templates/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
- data/templates/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/templates/static/js/codemirror/mode/coffeescript/index.html +728 -0
- data/templates/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/templates/static/js/codemirror/mode/commonlisp/index.html +165 -0
- data/templates/static/js/codemirror/mode/css/css.js +465 -0
- data/templates/static/js/codemirror/mode/css/index.html +58 -0
- data/templates/static/js/codemirror/mode/css/test.js +501 -0
- data/templates/static/js/codemirror/mode/diff/diff.js +32 -0
- data/templates/static/js/codemirror/mode/diff/index.html +105 -0
- data/templates/static/js/codemirror/mode/ecl/ecl.js +192 -0
- data/templates/static/js/codemirror/mode/ecl/index.html +39 -0
- data/templates/static/js/codemirror/mode/erlang/erlang.js +463 -0
- data/templates/static/js/codemirror/mode/erlang/index.html +64 -0
- data/templates/static/js/codemirror/mode/gfm/gfm.js +94 -0
- data/templates/static/js/codemirror/mode/gfm/index.html +70 -0
- data/templates/static/js/codemirror/mode/gfm/test.js +225 -0
- data/templates/static/js/codemirror/mode/go/go.js +165 -0
- data/templates/static/js/codemirror/mode/go/index.html +74 -0
- data/templates/static/js/codemirror/mode/groovy/groovy.js +210 -0
- data/templates/static/js/codemirror/mode/groovy/index.html +73 -0
- data/templates/static/js/codemirror/mode/haskell/haskell.js +242 -0
- data/templates/static/js/codemirror/mode/haskell/index.html +62 -0
- data/templates/static/js/codemirror/mode/haxe/haxe.js +429 -0
- data/templates/static/js/codemirror/mode/haxe/index.html +90 -0
- data/templates/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/templates/static/js/codemirror/mode/htmlembedded/index.html +49 -0
- data/templates/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
- data/templates/static/js/codemirror/mode/htmlmixed/index.html +52 -0
- data/templates/static/js/codemirror/mode/http/http.js +98 -0
- data/templates/static/js/codemirror/mode/http/index.html +32 -0
- data/templates/static/js/codemirror/mode/javascript/index.html +88 -0
- data/templates/static/js/codemirror/mode/javascript/javascript.js +411 -0
- data/templates/static/js/codemirror/mode/javascript/typescript.html +48 -0
- data/templates/static/js/codemirror/mode/jinja2/index.html +38 -0
- data/templates/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
- data/templates/static/js/codemirror/mode/less/index.html +741 -0
- data/templates/static/js/codemirror/mode/less/less.js +266 -0
- data/templates/static/js/codemirror/mode/lua/index.html +74 -0
- data/templates/static/js/codemirror/mode/lua/lua.js +140 -0
- data/templates/static/js/codemirror/mode/markdown/index.html +344 -0
- data/templates/static/js/codemirror/mode/markdown/markdown.js +474 -0
- data/templates/static/js/codemirror/mode/markdown/test.js +1266 -0
- data/templates/static/js/codemirror/mode/mysql/index.html +41 -0
- data/templates/static/js/codemirror/mode/mysql/mysql.js +203 -0
- data/templates/static/js/codemirror/mode/ntriples/index.html +33 -0
- data/templates/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
- data/templates/static/js/codemirror/mode/ocaml/index.html +131 -0
- data/templates/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
- data/templates/static/js/codemirror/mode/pascal/LICENSE +7 -0
- data/templates/static/js/codemirror/mode/pascal/index.html +48 -0
- data/templates/static/js/codemirror/mode/pascal/pascal.js +94 -0
- data/templates/static/js/codemirror/mode/perl/LICENSE +19 -0
- data/templates/static/js/codemirror/mode/perl/index.html +62 -0
- data/templates/static/js/codemirror/mode/perl/perl.js +816 -0
- data/templates/static/js/codemirror/mode/php/index.html +51 -0
- data/templates/static/js/codemirror/mode/php/php.js +129 -0
- data/templates/static/js/codemirror/mode/pig/index.html +42 -0
- data/templates/static/js/codemirror/mode/pig/pig.js +171 -0
- data/templates/static/js/codemirror/mode/plsql/index.html +62 -0
- data/templates/static/js/codemirror/mode/plsql/plsql.js +216 -0
- data/templates/static/js/codemirror/mode/properties/index.html +41 -0
- data/templates/static/js/codemirror/mode/properties/properties.js +63 -0
- data/templates/static/js/codemirror/mode/python/LICENSE.txt +21 -0
- data/templates/static/js/codemirror/mode/python/index.html +124 -0
- data/templates/static/js/codemirror/mode/python/python.js +340 -0
- data/templates/static/js/codemirror/mode/r/LICENSE +24 -0
- data/templates/static/js/codemirror/mode/r/index.html +74 -0
- data/templates/static/js/codemirror/mode/r/r.js +141 -0
- data/templates/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
- data/templates/static/js/codemirror/mode/rpm/changes/index.html +53 -0
- data/templates/static/js/codemirror/mode/rpm/spec/index.html +99 -0
- data/templates/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
- data/templates/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
- data/templates/static/js/codemirror/mode/rst/index.html +526 -0
- data/templates/static/js/codemirror/mode/rst/rst.js +314 -0
- data/templates/static/js/codemirror/mode/ruby/LICENSE +24 -0
- data/templates/static/js/codemirror/mode/ruby/index.html +173 -0
- data/templates/static/js/codemirror/mode/ruby/ruby.js +195 -0
- data/templates/static/js/codemirror/mode/rust/index.html +48 -0
- data/templates/static/js/codemirror/mode/rust/rust.js +432 -0
- data/templates/static/js/codemirror/mode/scheme/index.html +65 -0
- data/templates/static/js/codemirror/mode/scheme/scheme.js +230 -0
- data/templates/static/js/codemirror/mode/shell/index.html +51 -0
- data/templates/static/js/codemirror/mode/shell/shell.js +118 -0
- data/templates/static/js/codemirror/mode/sieve/LICENSE +23 -0
- data/templates/static/js/codemirror/mode/sieve/index.html +81 -0
- data/templates/static/js/codemirror/mode/sieve/sieve.js +156 -0
- data/templates/static/js/codemirror/mode/smalltalk/index.html +57 -0
- data/templates/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/templates/static/js/codemirror/mode/smarty/index.html +83 -0
- data/templates/static/js/codemirror/mode/smarty/smarty.js +148 -0
- data/templates/static/js/codemirror/mode/sparql/index.html +42 -0
- data/templates/static/js/codemirror/mode/sparql/sparql.js +143 -0
- data/templates/static/js/codemirror/mode/stex/index.html +98 -0
- data/templates/static/js/codemirror/mode/stex/stex.js +175 -0
- data/templates/static/js/codemirror/mode/stex/test.js +343 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/templates/static/js/codemirror/mode/tiki/index.html +81 -0
- data/templates/static/js/codemirror/mode/tiki/tiki.css +26 -0
- data/templates/static/js/codemirror/mode/tiki/tiki.js +309 -0
- data/templates/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
- data/templates/static/js/codemirror/mode/vb/index.html +88 -0
- data/templates/static/js/codemirror/mode/vb/vb.js +260 -0
- data/templates/static/js/codemirror/mode/vbscript/index.html +42 -0
- data/templates/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
- data/templates/static/js/codemirror/mode/velocity/index.html +103 -0
- data/templates/static/js/codemirror/mode/velocity/velocity.js +144 -0
- data/templates/static/js/codemirror/mode/verilog/index.html +210 -0
- data/templates/static/js/codemirror/mode/verilog/verilog.js +182 -0
- data/templates/static/js/codemirror/mode/xml/index.html +45 -0
- data/templates/static/js/codemirror/mode/xml/xml.js +324 -0
- data/templates/static/js/codemirror/mode/xquery/LICENSE +20 -0
- data/templates/static/js/codemirror/mode/xquery/index.html +221 -0
- data/templates/static/js/codemirror/mode/xquery/test.js +77 -0
- data/templates/static/js/codemirror/mode/xquery/xquery.js +450 -0
- data/templates/static/js/codemirror/mode/yaml/index.html +68 -0
- data/templates/static/js/codemirror/mode/yaml/yaml.js +95 -0
- data/templates/static/js/codemirror/mode/z80/index.html +39 -0
- data/templates/static/js/codemirror/mode/z80/z80.js +113 -0
- data/templates/static/js/codemirror/theme/ambiance-mobile.css +6 -0
- data/templates/static/js/codemirror/theme/ambiance.css +76 -0
- data/templates/static/js/codemirror/theme/blackboard.css +25 -0
- data/templates/static/js/codemirror/theme/cobalt.css +18 -0
- data/templates/static/js/codemirror/theme/eclipse.css +25 -0
- data/templates/static/js/codemirror/theme/elegant.css +10 -0
- data/templates/static/js/codemirror/theme/erlang-dark.css +21 -0
- data/templates/static/js/codemirror/theme/lesser-dark.css +44 -0
- data/templates/static/js/codemirror/theme/monokai.css +28 -0
- data/templates/static/js/codemirror/theme/neat.css +9 -0
- data/templates/static/js/codemirror/theme/night.css +21 -0
- data/templates/static/js/codemirror/theme/rubyblue.css +21 -0
- data/templates/static/js/codemirror/theme/solarized.css +207 -0
- data/templates/static/js/codemirror/theme/twilight.css +26 -0
- data/templates/static/js/codemirror/theme/vibrant-ink.css +27 -0
- data/templates/static/js/codemirror/theme/xq-dark.css +46 -0
- data/templates/static/js/d3.v3.min.js +2 -2
- data/templates/static/test/cm.html +33 -0
- data/templates/views/about.slim +15 -0
- data/templates/views/index.slim +1 -1
- data/templates/views/layout.slim +1 -0
- data/templates/views/navbar.slim +4 -4
- metadata +347 -2
@@ -0,0 +1,103 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>CodeMirror: C-like mode</title>
|
6
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
+
<script src="../../lib/codemirror.js"></script>
|
8
|
+
<script src="../../lib/util/matchbrackets.js"></script>
|
9
|
+
<script src="clike.js"></script>
|
10
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
11
|
+
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
12
|
+
</head>
|
13
|
+
<body>
|
14
|
+
<h1>CodeMirror: C-like mode</h1>
|
15
|
+
|
16
|
+
<form><textarea id="code" name="code">
|
17
|
+
/* C demo code */
|
18
|
+
|
19
|
+
#include <zmq.h>
|
20
|
+
#include <pthread.h>
|
21
|
+
#include <semaphore.h>
|
22
|
+
#include <time.h>
|
23
|
+
#include <stdio.h>
|
24
|
+
#include <fcntl.h>
|
25
|
+
#include <malloc.h>
|
26
|
+
|
27
|
+
typedef struct {
|
28
|
+
void* arg_socket;
|
29
|
+
zmq_msg_t* arg_msg;
|
30
|
+
char* arg_string;
|
31
|
+
unsigned long arg_len;
|
32
|
+
int arg_int, arg_command;
|
33
|
+
|
34
|
+
int signal_fd;
|
35
|
+
int pad;
|
36
|
+
void* context;
|
37
|
+
sem_t sem;
|
38
|
+
} acl_zmq_context;
|
39
|
+
|
40
|
+
#define p(X) (context->arg_##X)
|
41
|
+
|
42
|
+
void* zmq_thread(void* context_pointer) {
|
43
|
+
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
44
|
+
char ok = 'K', err = 'X';
|
45
|
+
int res;
|
46
|
+
|
47
|
+
while (1) {
|
48
|
+
while ((res = sem_wait(&context->sem)) == EINTR);
|
49
|
+
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
50
|
+
switch(p(command)) {
|
51
|
+
case 0: goto cleanup;
|
52
|
+
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
53
|
+
case 2: p(int) = zmq_close(p(socket)); break;
|
54
|
+
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
55
|
+
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
56
|
+
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
57
|
+
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
58
|
+
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
59
|
+
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
60
|
+
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
61
|
+
}
|
62
|
+
p(command) = errno;
|
63
|
+
write(context->signal_fd, &ok, 1);
|
64
|
+
}
|
65
|
+
cleanup:
|
66
|
+
close(context->signal_fd);
|
67
|
+
free(context_pointer);
|
68
|
+
return 0;
|
69
|
+
}
|
70
|
+
|
71
|
+
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
72
|
+
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
73
|
+
pthread_t thread;
|
74
|
+
|
75
|
+
context->context = zmq_context;
|
76
|
+
context->signal_fd = signal_fd;
|
77
|
+
sem_init(&context->sem, 1, 0);
|
78
|
+
pthread_create(&thread, 0, &zmq_thread, context);
|
79
|
+
pthread_detach(thread);
|
80
|
+
return context;
|
81
|
+
}
|
82
|
+
</textarea></form>
|
83
|
+
|
84
|
+
<script>
|
85
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
86
|
+
lineNumbers: true,
|
87
|
+
matchBrackets: true,
|
88
|
+
mode: "text/x-csrc"
|
89
|
+
});
|
90
|
+
</script>
|
91
|
+
|
92
|
+
<p>Simple mode that tries to handle C-like languages as well as it
|
93
|
+
can. Takes two configuration parameters: <code>keywords</code>, an
|
94
|
+
object whose property names are the keywords in the language,
|
95
|
+
and <code>useCPP</code>, which determines whether C preprocessor
|
96
|
+
directives are recognized.</p>
|
97
|
+
|
98
|
+
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
99
|
+
(C code), <code>text/x-c++src</code> (C++
|
100
|
+
code), <code>text/x-java</code> (Java
|
101
|
+
code), <code>text/x-csharp</code> (C#).</p>
|
102
|
+
</body>
|
103
|
+
</html>
|
@@ -0,0 +1,767 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>CodeMirror: C-like mode</title>
|
6
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
+
<link rel="stylesheet" href="../../theme/ambiance.css">
|
8
|
+
<script src="../../lib/codemirror.js"></script>
|
9
|
+
<script src="../../lib/util/matchbrackets.js"></script>
|
10
|
+
<script src="clike.js"></script>
|
11
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
12
|
+
<style>
|
13
|
+
body
|
14
|
+
{
|
15
|
+
margin: 0;
|
16
|
+
padding: 0;
|
17
|
+
max-width:inherit;
|
18
|
+
height: 100%;
|
19
|
+
}
|
20
|
+
html, form, .CodeMirror, .CodeMirror-scroll
|
21
|
+
{
|
22
|
+
height: 100%;
|
23
|
+
}
|
24
|
+
</style>
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
<form>
|
28
|
+
<textarea id="code" name="code">
|
29
|
+
|
30
|
+
/* __ *\
|
31
|
+
** ________ ___ / / ___ Scala API **
|
32
|
+
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
33
|
+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
34
|
+
** /____/\___/_/ |_/____/_/ | | **
|
35
|
+
** |/ **
|
36
|
+
\* */
|
37
|
+
|
38
|
+
package scala.collection
|
39
|
+
|
40
|
+
import generic._
|
41
|
+
import mutable.{ Builder, ListBuffer }
|
42
|
+
import annotation.{tailrec, migration, bridge}
|
43
|
+
import annotation.unchecked.{ uncheckedVariance => uV }
|
44
|
+
import parallel.ParIterable
|
45
|
+
|
46
|
+
/** A template trait for traversable collections of type `Traversable[A]`.
|
47
|
+
*
|
48
|
+
* $traversableInfo
|
49
|
+
* @define mutability
|
50
|
+
* @define traversableInfo
|
51
|
+
* This is a base trait of all kinds of $mutability Scala collections. It
|
52
|
+
* implements the behavior common to all collections, in terms of a method
|
53
|
+
* `foreach` with signature:
|
54
|
+
* {{{
|
55
|
+
* def foreach[U](f: Elem => U): Unit
|
56
|
+
* }}}
|
57
|
+
* Collection classes mixing in this trait provide a concrete
|
58
|
+
* `foreach` method which traverses all the
|
59
|
+
* elements contained in the collection, applying a given function to each.
|
60
|
+
* They also need to provide a method `newBuilder`
|
61
|
+
* which creates a builder for collections of the same kind.
|
62
|
+
*
|
63
|
+
* A traversable class might or might not have two properties: strictness
|
64
|
+
* and orderedness. Neither is represented as a type.
|
65
|
+
*
|
66
|
+
* The instances of a strict collection class have all their elements
|
67
|
+
* computed before they can be used as values. By contrast, instances of
|
68
|
+
* a non-strict collection class may defer computation of some of their
|
69
|
+
* elements until after the instance is available as a value.
|
70
|
+
* A typical example of a non-strict collection class is a
|
71
|
+
* <a href="../immutable/Stream.html" target="ContentFrame">
|
72
|
+
* `scala.collection.immutable.Stream`</a>.
|
73
|
+
* A more general class of examples are `TraversableViews`.
|
74
|
+
*
|
75
|
+
* If a collection is an instance of an ordered collection class, traversing
|
76
|
+
* its elements with `foreach` will always visit elements in the
|
77
|
+
* same order, even for different runs of the program. If the class is not
|
78
|
+
* ordered, `foreach` can visit elements in different orders for
|
79
|
+
* different runs (but it will keep the same order in the same run).'
|
80
|
+
*
|
81
|
+
* A typical example of a collection class which is not ordered is a
|
82
|
+
* `HashMap` of objects. The traversal order for hash maps will
|
83
|
+
* depend on the hash codes of its elements, and these hash codes might
|
84
|
+
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
85
|
+
* is ordered because it's `foreach` method visits elements in the
|
86
|
+
* order they were inserted into the `HashMap`.
|
87
|
+
*
|
88
|
+
* @author Martin Odersky
|
89
|
+
* @version 2.8
|
90
|
+
* @since 2.8
|
91
|
+
* @tparam A the element type of the collection
|
92
|
+
* @tparam Repr the type of the actual collection containing the elements.
|
93
|
+
*
|
94
|
+
* @define Coll Traversable
|
95
|
+
* @define coll traversable collection
|
96
|
+
*/
|
97
|
+
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
98
|
+
with FilterMonadic[A, Repr]
|
99
|
+
with TraversableOnce[A]
|
100
|
+
with GenTraversableLike[A, Repr]
|
101
|
+
with Parallelizable[A, ParIterable[A]]
|
102
|
+
{
|
103
|
+
self =>
|
104
|
+
|
105
|
+
import Traversable.breaks._
|
106
|
+
|
107
|
+
/** The type implementing this traversable */
|
108
|
+
protected type Self = Repr
|
109
|
+
|
110
|
+
/** The collection of type $coll underlying this `TraversableLike` object.
|
111
|
+
* By default this is implemented as the `TraversableLike` object itself,
|
112
|
+
* but this can be overridden.
|
113
|
+
*/
|
114
|
+
def repr: Repr = this.asInstanceOf[Repr]
|
115
|
+
|
116
|
+
/** The underlying collection seen as an instance of `$Coll`.
|
117
|
+
* By default this is implemented as the current collection object itself,
|
118
|
+
* but this can be overridden.
|
119
|
+
*/
|
120
|
+
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
121
|
+
|
122
|
+
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
123
|
+
* By default this is implemented as just a cast, but this can be overridden.
|
124
|
+
*/
|
125
|
+
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
126
|
+
|
127
|
+
/** Creates a new builder for this collection type.
|
128
|
+
*/
|
129
|
+
protected[this] def newBuilder: Builder[A, Repr]
|
130
|
+
|
131
|
+
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
132
|
+
|
133
|
+
/** Applies a function `f` to all elements of this $coll.
|
134
|
+
*
|
135
|
+
* Note: this method underlies the implementation of most other bulk operations.
|
136
|
+
* It's important to implement this method in an efficient way.
|
137
|
+
*
|
138
|
+
*
|
139
|
+
* @param f the function that is applied for its side-effect to every element.
|
140
|
+
* The result of function `f` is discarded.
|
141
|
+
*
|
142
|
+
* @tparam U the type parameter describing the result of function `f`.
|
143
|
+
* This result will always be ignored. Typically `U` is `Unit`,
|
144
|
+
* but this is not necessary.
|
145
|
+
*
|
146
|
+
* @usecase def foreach(f: A => Unit): Unit
|
147
|
+
*/
|
148
|
+
def foreach[U](f: A => U): Unit
|
149
|
+
|
150
|
+
/** Tests whether this $coll is empty.
|
151
|
+
*
|
152
|
+
* @return `true` if the $coll contain no elements, `false` otherwise.
|
153
|
+
*/
|
154
|
+
def isEmpty: Boolean = {
|
155
|
+
var result = true
|
156
|
+
breakable {
|
157
|
+
for (x <- this) {
|
158
|
+
result = false
|
159
|
+
break
|
160
|
+
}
|
161
|
+
}
|
162
|
+
result
|
163
|
+
}
|
164
|
+
|
165
|
+
/** Tests whether this $coll is known to have a finite size.
|
166
|
+
* All strict collections are known to have finite size. For a non-strict collection
|
167
|
+
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
168
|
+
* It returns `false` if the stream is not yet evaluated to the end.
|
169
|
+
*
|
170
|
+
* Note: many collection methods will not work on collections of infinite sizes.
|
171
|
+
*
|
172
|
+
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
173
|
+
*/
|
174
|
+
def hasDefiniteSize = true
|
175
|
+
|
176
|
+
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
177
|
+
val b = bf(repr)
|
178
|
+
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
179
|
+
b ++= thisCollection
|
180
|
+
b ++= that.seq
|
181
|
+
b.result
|
182
|
+
}
|
183
|
+
|
184
|
+
@bridge
|
185
|
+
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
186
|
+
++(that: GenTraversableOnce[B])(bf)
|
187
|
+
|
188
|
+
/** Concatenates this $coll with the elements of a traversable collection.
|
189
|
+
* It differs from ++ in that the right operand determines the type of the
|
190
|
+
* resulting collection rather than the left one.
|
191
|
+
*
|
192
|
+
* @param that the traversable to append.
|
193
|
+
* @tparam B the element type of the returned collection.
|
194
|
+
* @tparam That $thatinfo
|
195
|
+
* @param bf $bfinfo
|
196
|
+
* @return a new collection of type `That` which contains all elements
|
197
|
+
* of this $coll followed by all elements of `that`.
|
198
|
+
*
|
199
|
+
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
200
|
+
*
|
201
|
+
* @return a new $coll which contains all elements of this $coll
|
202
|
+
* followed by all elements of `that`.
|
203
|
+
*/
|
204
|
+
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
205
|
+
val b = bf(repr)
|
206
|
+
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
207
|
+
b ++= that
|
208
|
+
b ++= thisCollection
|
209
|
+
b.result
|
210
|
+
}
|
211
|
+
|
212
|
+
/** This overload exists because: for the implementation of ++: we should reuse
|
213
|
+
* that of ++ because many collections override it with more efficient versions.
|
214
|
+
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
215
|
+
* but Traversable and down can use the overload.
|
216
|
+
*/
|
217
|
+
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
218
|
+
(that ++ seq)(breakOut)
|
219
|
+
|
220
|
+
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
221
|
+
val b = bf(repr)
|
222
|
+
b.sizeHint(this)
|
223
|
+
for (x <- this) b += f(x)
|
224
|
+
b.result
|
225
|
+
}
|
226
|
+
|
227
|
+
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
228
|
+
val b = bf(repr)
|
229
|
+
for (x <- this) b ++= f(x).seq
|
230
|
+
b.result
|
231
|
+
}
|
232
|
+
|
233
|
+
/** Selects all elements of this $coll which satisfy a predicate.
|
234
|
+
*
|
235
|
+
* @param p the predicate used to test elements.
|
236
|
+
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
237
|
+
* predicate `p`. The order of the elements is preserved.
|
238
|
+
*/
|
239
|
+
def filter(p: A => Boolean): Repr = {
|
240
|
+
val b = newBuilder
|
241
|
+
for (x <- this)
|
242
|
+
if (p(x)) b += x
|
243
|
+
b.result
|
244
|
+
}
|
245
|
+
|
246
|
+
/** Selects all elements of this $coll which do not satisfy a predicate.
|
247
|
+
*
|
248
|
+
* @param p the predicate used to test elements.
|
249
|
+
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
250
|
+
* predicate `p`. The order of the elements is preserved.
|
251
|
+
*/
|
252
|
+
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
253
|
+
|
254
|
+
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
255
|
+
val b = bf(repr)
|
256
|
+
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
257
|
+
b.result
|
258
|
+
}
|
259
|
+
|
260
|
+
/** Builds a new collection by applying an option-valued function to all
|
261
|
+
* elements of this $coll on which the function is defined.
|
262
|
+
*
|
263
|
+
* @param f the option-valued function which filters and maps the $coll.
|
264
|
+
* @tparam B the element type of the returned collection.
|
265
|
+
* @tparam That $thatinfo
|
266
|
+
* @param bf $bfinfo
|
267
|
+
* @return a new collection of type `That` resulting from applying the option-valued function
|
268
|
+
* `f` to each element and collecting all defined results.
|
269
|
+
* The order of the elements is preserved.
|
270
|
+
*
|
271
|
+
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
272
|
+
*
|
273
|
+
* @param pf the partial function which filters and maps the $coll.
|
274
|
+
* @return a new $coll resulting from applying the given option-valued function
|
275
|
+
* `f` to each element and collecting all defined results.
|
276
|
+
* The order of the elements is preserved.
|
277
|
+
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
278
|
+
val b = bf(repr)
|
279
|
+
for (x <- this)
|
280
|
+
f(x) match {
|
281
|
+
case Some(y) => b += y
|
282
|
+
case _ =>
|
283
|
+
}
|
284
|
+
b.result
|
285
|
+
}
|
286
|
+
*/
|
287
|
+
|
288
|
+
/** Partitions this $coll in two ${coll}s according to a predicate.
|
289
|
+
*
|
290
|
+
* @param p the predicate on which to partition.
|
291
|
+
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
292
|
+
* satisfy the predicate `p` and the second $coll consists of all elements
|
293
|
+
* that don't. The relative order of the elements in the resulting ${coll}s
|
294
|
+
* is the same as in the original $coll.
|
295
|
+
*/
|
296
|
+
def partition(p: A => Boolean): (Repr, Repr) = {
|
297
|
+
val l, r = newBuilder
|
298
|
+
for (x <- this) (if (p(x)) l else r) += x
|
299
|
+
(l.result, r.result)
|
300
|
+
}
|
301
|
+
|
302
|
+
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
303
|
+
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
304
|
+
for (elem <- this) {
|
305
|
+
val key = f(elem)
|
306
|
+
val bldr = m.getOrElseUpdate(key, newBuilder)
|
307
|
+
bldr += elem
|
308
|
+
}
|
309
|
+
val b = immutable.Map.newBuilder[K, Repr]
|
310
|
+
for ((k, v) <- m)
|
311
|
+
b += ((k, v.result))
|
312
|
+
|
313
|
+
b.result
|
314
|
+
}
|
315
|
+
|
316
|
+
/** Tests whether a predicate holds for all elements of this $coll.
|
317
|
+
*
|
318
|
+
* $mayNotTerminateInf
|
319
|
+
*
|
320
|
+
* @param p the predicate used to test elements.
|
321
|
+
* @return `true` if the given predicate `p` holds for all elements
|
322
|
+
* of this $coll, otherwise `false`.
|
323
|
+
*/
|
324
|
+
def forall(p: A => Boolean): Boolean = {
|
325
|
+
var result = true
|
326
|
+
breakable {
|
327
|
+
for (x <- this)
|
328
|
+
if (!p(x)) { result = false; break }
|
329
|
+
}
|
330
|
+
result
|
331
|
+
}
|
332
|
+
|
333
|
+
/** Tests whether a predicate holds for some of the elements of this $coll.
|
334
|
+
*
|
335
|
+
* $mayNotTerminateInf
|
336
|
+
*
|
337
|
+
* @param p the predicate used to test elements.
|
338
|
+
* @return `true` if the given predicate `p` holds for some of the
|
339
|
+
* elements of this $coll, otherwise `false`.
|
340
|
+
*/
|
341
|
+
def exists(p: A => Boolean): Boolean = {
|
342
|
+
var result = false
|
343
|
+
breakable {
|
344
|
+
for (x <- this)
|
345
|
+
if (p(x)) { result = true; break }
|
346
|
+
}
|
347
|
+
result
|
348
|
+
}
|
349
|
+
|
350
|
+
/** Finds the first element of the $coll satisfying a predicate, if any.
|
351
|
+
*
|
352
|
+
* $mayNotTerminateInf
|
353
|
+
* $orderDependent
|
354
|
+
*
|
355
|
+
* @param p the predicate used to test elements.
|
356
|
+
* @return an option value containing the first element in the $coll
|
357
|
+
* that satisfies `p`, or `None` if none exists.
|
358
|
+
*/
|
359
|
+
def find(p: A => Boolean): Option[A] = {
|
360
|
+
var result: Option[A] = None
|
361
|
+
breakable {
|
362
|
+
for (x <- this)
|
363
|
+
if (p(x)) { result = Some(x); break }
|
364
|
+
}
|
365
|
+
result
|
366
|
+
}
|
367
|
+
|
368
|
+
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
369
|
+
|
370
|
+
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
371
|
+
val b = bf(repr)
|
372
|
+
b.sizeHint(this, 1)
|
373
|
+
var acc = z
|
374
|
+
b += acc
|
375
|
+
for (x <- this) { acc = op(acc, x); b += acc }
|
376
|
+
b.result
|
377
|
+
}
|
378
|
+
|
379
|
+
@migration(2, 9,
|
380
|
+
"This scanRight definition has changed in 2.9.\n" +
|
381
|
+
"The previous behavior can be reproduced with scanRight.reverse."
|
382
|
+
)
|
383
|
+
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
384
|
+
var scanned = List(z)
|
385
|
+
var acc = z
|
386
|
+
for (x <- reversed) {
|
387
|
+
acc = op(x, acc)
|
388
|
+
scanned ::= acc
|
389
|
+
}
|
390
|
+
val b = bf(repr)
|
391
|
+
for (elem <- scanned) b += elem
|
392
|
+
b.result
|
393
|
+
}
|
394
|
+
|
395
|
+
/** Selects the first element of this $coll.
|
396
|
+
* $orderDependent
|
397
|
+
* @return the first element of this $coll.
|
398
|
+
* @throws `NoSuchElementException` if the $coll is empty.
|
399
|
+
*/
|
400
|
+
def head: A = {
|
401
|
+
var result: () => A = () => throw new NoSuchElementException
|
402
|
+
breakable {
|
403
|
+
for (x <- this) {
|
404
|
+
result = () => x
|
405
|
+
break
|
406
|
+
}
|
407
|
+
}
|
408
|
+
result()
|
409
|
+
}
|
410
|
+
|
411
|
+
/** Optionally selects the first element.
|
412
|
+
* $orderDependent
|
413
|
+
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
414
|
+
*/
|
415
|
+
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
416
|
+
|
417
|
+
/** Selects all elements except the first.
|
418
|
+
* $orderDependent
|
419
|
+
* @return a $coll consisting of all elements of this $coll
|
420
|
+
* except the first one.
|
421
|
+
* @throws `UnsupportedOperationException` if the $coll is empty.
|
422
|
+
*/
|
423
|
+
override def tail: Repr = {
|
424
|
+
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
425
|
+
drop(1)
|
426
|
+
}
|
427
|
+
|
428
|
+
/** Selects the last element.
|
429
|
+
* $orderDependent
|
430
|
+
* @return The last element of this $coll.
|
431
|
+
* @throws NoSuchElementException If the $coll is empty.
|
432
|
+
*/
|
433
|
+
def last: A = {
|
434
|
+
var lst = head
|
435
|
+
for (x <- this)
|
436
|
+
lst = x
|
437
|
+
lst
|
438
|
+
}
|
439
|
+
|
440
|
+
/** Optionally selects the last element.
|
441
|
+
* $orderDependent
|
442
|
+
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
443
|
+
*/
|
444
|
+
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
445
|
+
|
446
|
+
/** Selects all elements except the last.
|
447
|
+
* $orderDependent
|
448
|
+
* @return a $coll consisting of all elements of this $coll
|
449
|
+
* except the last one.
|
450
|
+
* @throws `UnsupportedOperationException` if the $coll is empty.
|
451
|
+
*/
|
452
|
+
def init: Repr = {
|
453
|
+
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
454
|
+
var lst = head
|
455
|
+
var follow = false
|
456
|
+
val b = newBuilder
|
457
|
+
b.sizeHint(this, -1)
|
458
|
+
for (x <- this.seq) {
|
459
|
+
if (follow) b += lst
|
460
|
+
else follow = true
|
461
|
+
lst = x
|
462
|
+
}
|
463
|
+
b.result
|
464
|
+
}
|
465
|
+
|
466
|
+
def take(n: Int): Repr = slice(0, n)
|
467
|
+
|
468
|
+
def drop(n: Int): Repr =
|
469
|
+
if (n <= 0) {
|
470
|
+
val b = newBuilder
|
471
|
+
b.sizeHint(this)
|
472
|
+
b ++= thisCollection result
|
473
|
+
}
|
474
|
+
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
475
|
+
|
476
|
+
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
477
|
+
|
478
|
+
// Precondition: from >= 0, until > 0, builder already configured for building.
|
479
|
+
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
480
|
+
var i = 0
|
481
|
+
breakable {
|
482
|
+
for (x <- this.seq) {
|
483
|
+
if (i >= from) b += x
|
484
|
+
i += 1
|
485
|
+
if (i >= until) break
|
486
|
+
}
|
487
|
+
}
|
488
|
+
b.result
|
489
|
+
}
|
490
|
+
// Precondition: from >= 0
|
491
|
+
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
492
|
+
val b = newBuilder
|
493
|
+
if (until <= from) b.result
|
494
|
+
else {
|
495
|
+
b.sizeHint(this, delta)
|
496
|
+
sliceInternal(from, until, b)
|
497
|
+
}
|
498
|
+
}
|
499
|
+
// Precondition: from >= 0
|
500
|
+
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
501
|
+
val b = newBuilder
|
502
|
+
if (until <= from) b.result
|
503
|
+
else {
|
504
|
+
b.sizeHintBounded(until - from, this)
|
505
|
+
sliceInternal(from, until, b)
|
506
|
+
}
|
507
|
+
}
|
508
|
+
|
509
|
+
def takeWhile(p: A => Boolean): Repr = {
|
510
|
+
val b = newBuilder
|
511
|
+
breakable {
|
512
|
+
for (x <- this) {
|
513
|
+
if (!p(x)) break
|
514
|
+
b += x
|
515
|
+
}
|
516
|
+
}
|
517
|
+
b.result
|
518
|
+
}
|
519
|
+
|
520
|
+
def dropWhile(p: A => Boolean): Repr = {
|
521
|
+
val b = newBuilder
|
522
|
+
var go = false
|
523
|
+
for (x <- this) {
|
524
|
+
if (!p(x)) go = true
|
525
|
+
if (go) b += x
|
526
|
+
}
|
527
|
+
b.result
|
528
|
+
}
|
529
|
+
|
530
|
+
def span(p: A => Boolean): (Repr, Repr) = {
|
531
|
+
val l, r = newBuilder
|
532
|
+
var toLeft = true
|
533
|
+
for (x <- this) {
|
534
|
+
toLeft = toLeft && p(x)
|
535
|
+
(if (toLeft) l else r) += x
|
536
|
+
}
|
537
|
+
(l.result, r.result)
|
538
|
+
}
|
539
|
+
|
540
|
+
def splitAt(n: Int): (Repr, Repr) = {
|
541
|
+
val l, r = newBuilder
|
542
|
+
l.sizeHintBounded(n, this)
|
543
|
+
if (n >= 0) r.sizeHint(this, -n)
|
544
|
+
var i = 0
|
545
|
+
for (x <- this) {
|
546
|
+
(if (i < n) l else r) += x
|
547
|
+
i += 1
|
548
|
+
}
|
549
|
+
(l.result, r.result)
|
550
|
+
}
|
551
|
+
|
552
|
+
/** Iterates over the tails of this $coll. The first value will be this
|
553
|
+
* $coll and the final one will be an empty $coll, with the intervening
|
554
|
+
* values the results of successive applications of `tail`.
|
555
|
+
*
|
556
|
+
* @return an iterator over all the tails of this $coll
|
557
|
+
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
558
|
+
*/
|
559
|
+
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
560
|
+
|
561
|
+
/** Iterates over the inits of this $coll. The first value will be this
|
562
|
+
* $coll and the final one will be an empty $coll, with the intervening
|
563
|
+
* values the results of successive applications of `init`.
|
564
|
+
*
|
565
|
+
* @return an iterator over all the inits of this $coll
|
566
|
+
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
567
|
+
*/
|
568
|
+
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
569
|
+
|
570
|
+
/** Copies elements of this $coll to an array.
|
571
|
+
* Fills the given array `xs` with at most `len` elements of
|
572
|
+
* this $coll, starting at position `start`.
|
573
|
+
* Copying will stop once either the end of the current $coll is reached,
|
574
|
+
* or the end of the array is reached, or `len` elements have been copied.
|
575
|
+
*
|
576
|
+
* $willNotTerminateInf
|
577
|
+
*
|
578
|
+
* @param xs the array to fill.
|
579
|
+
* @param start the starting index.
|
580
|
+
* @param len the maximal number of elements to copy.
|
581
|
+
* @tparam B the type of the elements of the array.
|
582
|
+
*
|
583
|
+
*
|
584
|
+
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
585
|
+
*/
|
586
|
+
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
587
|
+
var i = start
|
588
|
+
val end = (start + len) min xs.length
|
589
|
+
breakable {
|
590
|
+
for (x <- this) {
|
591
|
+
if (i >= end) break
|
592
|
+
xs(i) = x
|
593
|
+
i += 1
|
594
|
+
}
|
595
|
+
}
|
596
|
+
}
|
597
|
+
|
598
|
+
def toTraversable: Traversable[A] = thisCollection
|
599
|
+
def toIterator: Iterator[A] = toStream.iterator
|
600
|
+
def toStream: Stream[A] = toBuffer.toStream
|
601
|
+
|
602
|
+
/** Converts this $coll to a string.
|
603
|
+
*
|
604
|
+
* @return a string representation of this collection. By default this
|
605
|
+
* string consists of the `stringPrefix` of this $coll,
|
606
|
+
* followed by all elements separated by commas and enclosed in parentheses.
|
607
|
+
*/
|
608
|
+
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
609
|
+
|
610
|
+
/** Defines the prefix of this object's `toString` representation.
|
611
|
+
*
|
612
|
+
* @return a string representation which starts the result of `toString`
|
613
|
+
* applied to this $coll. By default the string prefix is the
|
614
|
+
* simple name of the collection class $coll.
|
615
|
+
*/
|
616
|
+
def stringPrefix : String = {
|
617
|
+
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
618
|
+
val idx1 = string.lastIndexOf('.' : Int)
|
619
|
+
if (idx1 != -1) string = string.substring(idx1 + 1)
|
620
|
+
val idx2 = string.indexOf('$')
|
621
|
+
if (idx2 != -1) string = string.substring(0, idx2)
|
622
|
+
string
|
623
|
+
}
|
624
|
+
|
625
|
+
/** Creates a non-strict view of this $coll.
|
626
|
+
*
|
627
|
+
* @return a non-strict view of this $coll.
|
628
|
+
*/
|
629
|
+
def view = new TraversableView[A, Repr] {
|
630
|
+
protected lazy val underlying = self.repr
|
631
|
+
override def foreach[U](f: A => U) = self foreach f
|
632
|
+
}
|
633
|
+
|
634
|
+
/** Creates a non-strict view of a slice of this $coll.
|
635
|
+
*
|
636
|
+
* Note: the difference between `view` and `slice` is that `view` produces
|
637
|
+
* a view of the current $coll, whereas `slice` produces a new $coll.
|
638
|
+
*
|
639
|
+
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
640
|
+
* $orderDependent
|
641
|
+
*
|
642
|
+
* @param from the index of the first element of the view
|
643
|
+
* @param until the index of the element following the view
|
644
|
+
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
645
|
+
* and extending up to (but not including) index `until`.
|
646
|
+
*/
|
647
|
+
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
648
|
+
|
649
|
+
/** Creates a non-strict filter of this $coll.
|
650
|
+
*
|
651
|
+
* Note: the difference between `c filter p` and `c withFilter p` is that
|
652
|
+
* the former creates a new collection, whereas the latter only
|
653
|
+
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
654
|
+
* and `withFilter` operations.
|
655
|
+
* $orderDependent
|
656
|
+
*
|
657
|
+
* @param p the predicate used to test elements.
|
658
|
+
* @return an object of class `WithFilter`, which supports
|
659
|
+
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
660
|
+
* All these operations apply to those elements of this $coll which
|
661
|
+
* satisfy the predicate `p`.
|
662
|
+
*/
|
663
|
+
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
664
|
+
|
665
|
+
/** A class supporting filtered operations. Instances of this class are
|
666
|
+
* returned by method `withFilter`.
|
667
|
+
*/
|
668
|
+
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
669
|
+
|
670
|
+
/** Builds a new collection by applying a function to all elements of the
|
671
|
+
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
672
|
+
*
|
673
|
+
* @param f the function to apply to each element.
|
674
|
+
* @tparam B the element type of the returned collection.
|
675
|
+
* @tparam That $thatinfo
|
676
|
+
* @param bf $bfinfo
|
677
|
+
* @return a new collection of type `That` resulting from applying
|
678
|
+
* the given function `f` to each element of the outer $coll
|
679
|
+
* that satisfies predicate `p` and collecting the results.
|
680
|
+
*
|
681
|
+
* @usecase def map[B](f: A => B): $Coll[B]
|
682
|
+
*
|
683
|
+
* @return a new $coll resulting from applying the given function
|
684
|
+
* `f` to each element of the outer $coll that satisfies
|
685
|
+
* predicate `p` and collecting the results.
|
686
|
+
*/
|
687
|
+
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
688
|
+
val b = bf(repr)
|
689
|
+
for (x <- self)
|
690
|
+
if (p(x)) b += f(x)
|
691
|
+
b.result
|
692
|
+
}
|
693
|
+
|
694
|
+
/** Builds a new collection by applying a function to all elements of the
|
695
|
+
* outer $coll containing this `WithFilter` instance that satisfy
|
696
|
+
* predicate `p` and concatenating the results.
|
697
|
+
*
|
698
|
+
* @param f the function to apply to each element.
|
699
|
+
* @tparam B the element type of the returned collection.
|
700
|
+
* @tparam That $thatinfo
|
701
|
+
* @param bf $bfinfo
|
702
|
+
* @return a new collection of type `That` resulting from applying
|
703
|
+
* the given collection-valued function `f` to each element
|
704
|
+
* of the outer $coll that satisfies predicate `p` and
|
705
|
+
* concatenating the results.
|
706
|
+
*
|
707
|
+
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
708
|
+
*
|
709
|
+
* @return a new $coll resulting from applying the given collection-valued function
|
710
|
+
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
711
|
+
*/
|
712
|
+
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
713
|
+
val b = bf(repr)
|
714
|
+
for (x <- self)
|
715
|
+
if (p(x)) b ++= f(x).seq
|
716
|
+
b.result
|
717
|
+
}
|
718
|
+
|
719
|
+
/** Applies a function `f` to all elements of the outer $coll containing
|
720
|
+
* this `WithFilter` instance that satisfy predicate `p`.
|
721
|
+
*
|
722
|
+
* @param f the function that is applied for its side-effect to every element.
|
723
|
+
* The result of function `f` is discarded.
|
724
|
+
*
|
725
|
+
* @tparam U the type parameter describing the result of function `f`.
|
726
|
+
* This result will always be ignored. Typically `U` is `Unit`,
|
727
|
+
* but this is not necessary.
|
728
|
+
*
|
729
|
+
* @usecase def foreach(f: A => Unit): Unit
|
730
|
+
*/
|
731
|
+
def foreach[U](f: A => U): Unit =
|
732
|
+
for (x <- self)
|
733
|
+
if (p(x)) f(x)
|
734
|
+
|
735
|
+
/** Further refines the filter for this $coll.
|
736
|
+
*
|
737
|
+
* @param q the predicate used to test elements.
|
738
|
+
* @return an object of class `WithFilter`, which supports
|
739
|
+
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
740
|
+
* All these operations apply to those elements of this $coll which
|
741
|
+
* satisfy the predicate `q` in addition to the predicate `p`.
|
742
|
+
*/
|
743
|
+
def withFilter(q: A => Boolean): WithFilter =
|
744
|
+
new WithFilter(x => p(x) && q(x))
|
745
|
+
}
|
746
|
+
|
747
|
+
// A helper for tails and inits.
|
748
|
+
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
749
|
+
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
750
|
+
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
751
|
+
}
|
752
|
+
}
|
753
|
+
|
754
|
+
|
755
|
+
</textarea>
|
756
|
+
</form>
|
757
|
+
|
758
|
+
<script>
|
759
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
760
|
+
lineNumbers: true,
|
761
|
+
matchBrackets: true,
|
762
|
+
theme: "ambiance",
|
763
|
+
mode: "text/x-scala"
|
764
|
+
});
|
765
|
+
</script>
|
766
|
+
</body>
|
767
|
+
</html>
|