datagram 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. data/.env.sample +7 -0
  2. data/.gitignore +20 -0
  3. data/.rbenv-version +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +22 -0
  6. data/Procfile +1 -0
  7. data/README.md +29 -0
  8. data/Rakefile +1 -0
  9. data/config.ru +5 -0
  10. data/datagram.gemspec +23 -0
  11. data/db/migrate/1_create_queries.rb +9 -0
  12. data/db/migrate/2_add_name_to_queries.rb +5 -0
  13. data/lib/datagram/version.rb +3 -0
  14. data/lib/datagram.rb +135 -0
  15. data/lib/views/application.coffee +222 -0
  16. data/lib/views/index.haml +47 -0
  17. data/lib/views/layout.haml +17 -0
  18. data/lib/views/style.sass +179 -0
  19. data/public/ace/ace.js +15209 -0
  20. data/public/ace/ext-elastic_tabstops_lite.js +301 -0
  21. data/public/ace/ext-emmet.js +253 -0
  22. data/public/ace/ext-searchbox.js +441 -0
  23. data/public/ace/ext-spellcheck.js +67 -0
  24. data/public/ace/ext-static_highlight.js +96 -0
  25. data/public/ace/ext-textarea.js +492 -0
  26. data/public/ace/ext-whitespace.js +204 -0
  27. data/public/ace/keybinding-emacs.js +962 -0
  28. data/public/ace/keybinding-vim.js +1704 -0
  29. data/public/ace/mode-abap.js +260 -0
  30. data/public/ace/mode-asciidoc.js +372 -0
  31. data/public/ace/mode-c9search.js +182 -0
  32. data/public/ace/mode-c_cpp.js +737 -0
  33. data/public/ace/mode-clojure.js +299 -0
  34. data/public/ace/mode-coffee.js +426 -0
  35. data/public/ace/mode-coldfusion.js +1753 -0
  36. data/public/ace/mode-csharp.js +612 -0
  37. data/public/ace/mode-css.js +773 -0
  38. data/public/ace/mode-curly.js +1950 -0
  39. data/public/ace/mode-dart.js +945 -0
  40. data/public/ace/mode-diff.js +166 -0
  41. data/public/ace/mode-django.js +1969 -0
  42. data/public/ace/mode-dot.js +320 -0
  43. data/public/ace/mode-ftl.js +907 -0
  44. data/public/ace/mode-glsl.js +810 -0
  45. data/public/ace/mode-golang.js +632 -0
  46. data/public/ace/mode-groovy.js +1037 -0
  47. data/public/ace/mode-haml.js +487 -0
  48. data/public/ace/mode-haxe.js +609 -0
  49. data/public/ace/mode-html.js +1881 -0
  50. data/public/ace/mode-jade.js +1951 -0
  51. data/public/ace/mode-java.js +996 -0
  52. data/public/ace/mode-javascript.js +876 -0
  53. data/public/ace/mode-json.js +578 -0
  54. data/public/ace/mode-jsp.js +1351 -0
  55. data/public/ace/mode-jsx.js +635 -0
  56. data/public/ace/mode-latex.js +189 -0
  57. data/public/ace/mode-less.js +807 -0
  58. data/public/ace/mode-liquid.js +862 -0
  59. data/public/ace/mode-lisp.js +138 -0
  60. data/public/ace/mode-livescript.js +288 -0
  61. data/public/ace/mode-logiql.js +664 -0
  62. data/public/ace/mode-lsl.js +828 -0
  63. data/public/ace/mode-lua.js +455 -0
  64. data/public/ace/mode-luapage.js +2340 -0
  65. data/public/ace/mode-lucene.js +64 -0
  66. data/public/ace/mode-makefile.js +313 -0
  67. data/public/ace/mode-markdown.js +2280 -0
  68. data/public/ace/mode-mushcode.js +704 -0
  69. data/public/ace/mode-mushcode_high_rules.js +569 -0
  70. data/public/ace/mode-objectivec.js +659 -0
  71. data/public/ace/mode-ocaml.js +443 -0
  72. data/public/ace/mode-pascal.js +233 -0
  73. data/public/ace/mode-perl.js +316 -0
  74. data/public/ace/mode-pgsql.js +908 -0
  75. data/public/ace/mode-php.js +2291 -0
  76. data/public/ace/mode-powershell.js +618 -0
  77. data/public/ace/mode-python.js +264 -0
  78. data/public/ace/mode-r.js +404 -0
  79. data/public/ace/mode-rdoc.js +184 -0
  80. data/public/ace/mode-rhtml.js +2168 -0
  81. data/public/ace/mode-ruby.js +431 -0
  82. data/public/ace/mode-sass.js +442 -0
  83. data/public/ace/mode-scad.js +670 -0
  84. data/public/ace/mode-scala.js +1025 -0
  85. data/public/ace/mode-scheme.js +144 -0
  86. data/public/ace/mode-scss.js +832 -0
  87. data/public/ace/mode-sh.js +204 -0
  88. data/public/ace/mode-sql.js +118 -0
  89. data/public/ace/mode-stylus.js +483 -0
  90. data/public/ace/mode-svg.js +1442 -0
  91. data/public/ace/mode-tcl.js +319 -0
  92. data/public/ace/mode-tex.js +166 -0
  93. data/public/ace/mode-text.js +0 -0
  94. data/public/ace/mode-textile.js +170 -0
  95. data/public/ace/mode-tmsnippet.js +200 -0
  96. data/public/ace/mode-toml.js +180 -0
  97. data/public/ace/mode-typescript.js +961 -0
  98. data/public/ace/mode-vbscript.js +281 -0
  99. data/public/ace/mode-velocity.js +962 -0
  100. data/public/ace/mode-xml.js +789 -0
  101. data/public/ace/mode-xquery.js +2750 -0
  102. data/public/ace/mode-yaml.js +289 -0
  103. data/public/ace/theme-ambiance.js +202 -0
  104. data/public/ace/theme-chaos.js +182 -0
  105. data/public/ace/theme-chrome.js +161 -0
  106. data/public/ace/theme-clouds.js +135 -0
  107. data/public/ace/theme-clouds_midnight.js +136 -0
  108. data/public/ace/theme-cobalt.js +150 -0
  109. data/public/ace/theme-crimson_editor.js +154 -0
  110. data/public/ace/theme-dawn.js +146 -0
  111. data/public/ace/theme-dreamweaver.js +173 -0
  112. data/public/ace/theme-eclipse.js +122 -0
  113. data/public/ace/theme-github.js +136 -0
  114. data/public/ace/theme-idle_fingers.js +136 -0
  115. data/public/ace/theme-kr.js +143 -0
  116. data/public/ace/theme-merbivore.js +135 -0
  117. data/public/ace/theme-merbivore_soft.js +136 -0
  118. data/public/ace/theme-mono_industrial.js +148 -0
  119. data/public/ace/theme-monokai.js +140 -0
  120. data/public/ace/theme-pastel_on_dark.js +148 -0
  121. data/public/ace/theme-solarized_dark.js +128 -0
  122. data/public/ace/theme-solarized_light.js +131 -0
  123. data/public/ace/theme-terminal.js +154 -0
  124. data/public/ace/theme-textmate.js +0 -0
  125. data/public/ace/theme-tomorrow.js +147 -0
  126. data/public/ace/theme-tomorrow_night.js +147 -0
  127. data/public/ace/theme-tomorrow_night_blue.js +145 -0
  128. data/public/ace/theme-tomorrow_night_bright.js +147 -0
  129. data/public/ace/theme-tomorrow_night_eighties.js +144 -0
  130. data/public/ace/theme-twilight.js +147 -0
  131. data/public/ace/theme-vibrant_ink.js +131 -0
  132. data/public/ace/theme-xcode.js +125 -0
  133. data/public/ace/worker-coffee.js +7091 -0
  134. data/public/ace/worker-css.js +8289 -0
  135. data/public/ace/worker-javascript.js +6496 -0
  136. data/public/ace/worker-json.js +2305 -0
  137. data/public/ace/worker-lua.js +3313 -0
  138. data/public/ace/worker-php.js +6743 -0
  139. data/public/ace/worker-xquery.js +21897 -0
  140. data/public/font/FontAwesome.otf +0 -0
  141. data/public/font/fontawesome-webfont.eot +0 -0
  142. data/public/font/fontawesome-webfont.svg +284 -0
  143. data/public/font/fontawesome-webfont.ttf +0 -0
  144. data/public/font/fontawesome-webfont.woff +0 -0
  145. data/public/font-awesome.css +540 -0
  146. data/public/jquery.js +9597 -0
  147. data/script/migrate.sh +2 -0
  148. metadata +242 -0
@@ -0,0 +1,431 @@
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Distributed under the BSD license:
3
+ *
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *
29
+ * ***** END LICENSE BLOCK ***** */
30
+
31
+ define('ace/mode/ruby', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/ruby_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/folding/coffee'], function(require, exports, module) {
32
+
33
+
34
+ var oop = require("../lib/oop");
35
+ var TextMode = require("./text").Mode;
36
+ var Tokenizer = require("../tokenizer").Tokenizer;
37
+ var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
38
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
39
+ var Range = require("../range").Range;
40
+ var FoldMode = require("./folding/coffee").FoldMode;
41
+
42
+ var Mode = function() {
43
+ this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules());
44
+ this.$outdent = new MatchingBraceOutdent();
45
+ this.foldingRules = new FoldMode();
46
+ };
47
+ oop.inherits(Mode, TextMode);
48
+
49
+ (function() {
50
+
51
+
52
+ this.lineCommentStart = "#";
53
+
54
+ this.getNextLineIndent = function(state, line, tab) {
55
+ var indent = this.$getIndent(line);
56
+
57
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
58
+ var tokens = tokenizedLine.tokens;
59
+
60
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
61
+ return indent;
62
+ }
63
+
64
+ if (state == "start") {
65
+ var match = line.match(/^.*[\{\(\[]\s*$/);
66
+ var startingClassOrMethod = line.match(/^\s*(class|def)\s.*$/);
67
+ var startingDoBlock = line.match(/.*do(\s*|\s+\|.*\|\s*)$/);
68
+ var startingConditional = line.match(/^\s*(if|else)\s*/)
69
+ if (match || startingClassOrMethod || startingDoBlock || startingConditional) {
70
+ indent += tab;
71
+ }
72
+ }
73
+
74
+ return indent;
75
+ };
76
+
77
+ this.checkOutdent = function(state, line, input) {
78
+ return /\s+end$/.test(line + input) || /\s+}$/.test(line + input) || /\s+else$/.test(line + input);
79
+ };
80
+
81
+ this.autoOutdent = function(state, doc, row) {
82
+ var indent = this.$getIndent(doc.getLine(row));
83
+ var tab = doc.getTabString();
84
+ if (indent.slice(-tab.length) == tab)
85
+ doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
86
+ };
87
+
88
+ }).call(Mode.prototype);
89
+
90
+ exports.Mode = Mode;
91
+ });
92
+
93
+ define('ace/mode/ruby_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
94
+
95
+
96
+ var oop = require("../lib/oop");
97
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
98
+ var constantOtherSymbol = exports.constantOtherSymbol = {
99
+ token : "constant.other.symbol.ruby", // symbol
100
+ regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
101
+ };
102
+
103
+ var qString = exports.qString = {
104
+ token : "string", // single line
105
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
106
+ };
107
+
108
+ var qqString = exports.qqString = {
109
+ token : "string", // single line
110
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
111
+ };
112
+
113
+ var tString = exports.tString = {
114
+ token : "string", // backtick string
115
+ regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]"
116
+ };
117
+
118
+ var constantNumericHex = exports.constantNumericHex = {
119
+ token : "constant.numeric", // hex
120
+ regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b"
121
+ };
122
+
123
+ var constantNumericFloat = exports.constantNumericFloat = {
124
+ token : "constant.numeric", // float
125
+ regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b"
126
+ };
127
+
128
+ var RubyHighlightRules = function() {
129
+
130
+ var builtinFunctions = (
131
+ "abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" +
132
+ "assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" +
133
+ "assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" +
134
+ "assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" +
135
+ "assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" +
136
+ "assert_select_email|assert_select_rjs|assert_select_encoded|css_select|at_exit|" +
137
+ "attr|attr_writer|attr_reader|attr_accessor|attr_accessible|autoload|binding|block_given?|callcc|" +
138
+ "caller|catch|chomp|chomp!|chop|chop!|defined?|delete_via_redirect|eval|exec|exit|" +
139
+ "exit!|fail|Float|flunk|follow_redirect!|fork|form_for|form_tag|format|gets|global_variables|gsub|" +
140
+ "gsub!|get_via_redirect|host!|https?|https!|include|Integer|lambda|link_to|" +
141
+ "link_to_unless_current|link_to_function|link_to_remote|load|local_variables|loop|open|open_session|" +
142
+ "p|print|printf|proc|putc|puts|post_via_redirect|put_via_redirect|raise|rand|" +
143
+ "raw|readline|readlines|redirect?|request_via_redirect|require|scan|select|" +
144
+ "set_trace_func|sleep|split|sprintf|srand|String|stylesheet_link_tag|syscall|system|sub|sub!|test|" +
145
+ "throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan|" +
146
+ "render|javascript_include_tag|csrf_meta_tag|label_tag|text_field_tag|submit_tag|check_box_tag|" +
147
+ "content_tag|radio_button_tag|text_area_tag|password_field_tag|hidden_field_tag|" +
148
+ "fields_for|select_tag|options_for_select|options_from_collection_for_select|collection_select|" +
149
+ "time_zone_select|select_date|select_time|select_datetime|date_select|time_select|datetime_select|" +
150
+ "select_year|select_month|select_day|select_hour|select_minute|select_second|file_field_tag|" +
151
+ "file_field|respond_to|skip_before_filter|around_filter|after_filter|verify|" +
152
+ "protect_from_forgery|rescue_from|helper_method|redirect_to|before_filter|" +
153
+ "send_data|send_file|validates_presence_of|validates_uniqueness_of|validates_length_of|" +
154
+ "validates_format_of|validates_acceptance_of|validates_associated|validates_exclusion_of|" +
155
+ "validates_inclusion_of|validates_numericality_of|validates_with|validates_each|" +
156
+ "authenticate_or_request_with_http_basic|authenticate_or_request_with_http_digest|" +
157
+ "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" +
158
+ "translate|localize|extract_locale_from_tld|caches_page|expire_page|caches_action|expire_action|" +
159
+ "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" +
160
+ "has_many|has_one|belongs_to|has_and_belongs_to_many"
161
+ );
162
+
163
+ var keywords = (
164
+ "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" +
165
+ "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" +
166
+ "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield"
167
+ );
168
+
169
+ var buildinConstants = (
170
+ "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" +
171
+ "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING"
172
+ );
173
+
174
+ var builtinVariables = (
175
+ "\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" +
176
+ "$!|root_url|flash|session|cookies|params|request|response|logger|self"
177
+ );
178
+
179
+ var keywordMapper = this.$keywords = this.createKeywordMapper({
180
+ "keyword": keywords,
181
+ "constant.language": buildinConstants,
182
+ "variable.language": builtinVariables,
183
+ "support.function": builtinFunctions,
184
+ "invalid.deprecated": "debugger" // TODO is this a remnant from js mode?
185
+ }, "identifier");
186
+
187
+ this.$rules = {
188
+ "start" : [
189
+ {
190
+ token : "comment",
191
+ regex : "#.*$"
192
+ }, {
193
+ token : "comment", // multi line comment
194
+ regex : "^=begin(?:$|\\s.*$)",
195
+ next : "comment"
196
+ }, {
197
+ token : "string.regexp",
198
+ regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
199
+ },
200
+
201
+ qString,
202
+ qqString,
203
+ tString,
204
+
205
+ {
206
+ token : "text", // namespaces aren't symbols
207
+ regex : "::"
208
+ }, {
209
+ token : "variable.instance", // instance variable
210
+ regex : "@{1,2}[a-zA-Z_\\d]+"
211
+ }, {
212
+ token : "support.class", // class name
213
+ regex : "[A-Z][a-zA-Z_\\d]+"
214
+ },
215
+
216
+ constantOtherSymbol,
217
+ constantNumericHex,
218
+ constantNumericFloat,
219
+
220
+ {
221
+ token : "constant.language.boolean",
222
+ regex : "(?:true|false)\\b"
223
+ }, {
224
+ token : keywordMapper,
225
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
226
+ }, {
227
+ token : "punctuation.separator.key-value",
228
+ regex : "=>"
229
+ }, {
230
+ stateName: "heredoc",
231
+ onMatch : function(value, currentState, stack) {
232
+ var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
233
+ var tokens = value.split(this.splitRegex);
234
+ stack.push(next, tokens[3]);
235
+ return [
236
+ {type:"constant", value: tokens[1]},
237
+ {type:"string", value: tokens[2]},
238
+ {type:"support.class", value: tokens[3]},
239
+ {type:"string", value: tokens[4]}
240
+ ];
241
+ },
242
+ regex : "(<<-?)(['\"`]?)([\\w]+)(['\"`]?)",
243
+ rules: {
244
+ heredoc: [{
245
+ onMatch: function(value, currentState, stack) {
246
+ if (value == stack[1]) {
247
+ stack.shift();
248
+ stack.shift();
249
+ return "support.class";
250
+ }
251
+ return "string";
252
+ },
253
+ regex: ".*$",
254
+ next: "start"
255
+ }],
256
+ indentedHeredoc: [{
257
+ token: "string",
258
+ regex: "^ +"
259
+ }, {
260
+ onMatch: function(value, currentState, stack) {
261
+ if (value == stack[1]) {
262
+ stack.shift();
263
+ stack.shift();
264
+ return "support.class";
265
+ }
266
+ return "string";
267
+ },
268
+ regex: ".*$",
269
+ next: "start"
270
+ }]
271
+ }
272
+ }, {
273
+ token : "keyword.operator",
274
+ regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
275
+ }, {
276
+ token : "paren.lparen",
277
+ regex : "[[({]"
278
+ }, {
279
+ token : "paren.rparen",
280
+ regex : "[\\])}]"
281
+ }, {
282
+ token : "text",
283
+ regex : "\\s+"
284
+ }
285
+ ],
286
+ "comment" : [
287
+ {
288
+ token : "comment", // closing comment
289
+ regex : "^=end(?:$|\\s.*$)",
290
+ next : "start"
291
+ }, {
292
+ token : "comment", // comment spanning whole line
293
+ regex : ".+"
294
+ }
295
+ ]
296
+ };
297
+
298
+ this.normalizeRules();
299
+ };
300
+
301
+ oop.inherits(RubyHighlightRules, TextHighlightRules);
302
+
303
+ exports.RubyHighlightRules = RubyHighlightRules;
304
+ });
305
+
306
+ define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
307
+
308
+
309
+ var Range = require("../range").Range;
310
+
311
+ var MatchingBraceOutdent = function() {};
312
+
313
+ (function() {
314
+
315
+ this.checkOutdent = function(line, input) {
316
+ if (! /^\s+$/.test(line))
317
+ return false;
318
+
319
+ return /^\s*\}/.test(input);
320
+ };
321
+
322
+ this.autoOutdent = function(doc, row) {
323
+ var line = doc.getLine(row);
324
+ var match = line.match(/^(\s*\})/);
325
+
326
+ if (!match) return 0;
327
+
328
+ var column = match[1].length;
329
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
330
+
331
+ if (!openBracePos || openBracePos.row == row) return 0;
332
+
333
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
334
+ doc.replace(new Range(row, 0, row, column-1), indent);
335
+ };
336
+
337
+ this.$getIndent = function(line) {
338
+ return line.match(/^\s*/)[0];
339
+ };
340
+
341
+ }).call(MatchingBraceOutdent.prototype);
342
+
343
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
344
+ });
345
+
346
+ define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
347
+
348
+
349
+ var oop = require("../../lib/oop");
350
+ var BaseFoldMode = require("./fold_mode").FoldMode;
351
+ var Range = require("../../range").Range;
352
+
353
+ var FoldMode = exports.FoldMode = function() {};
354
+ oop.inherits(FoldMode, BaseFoldMode);
355
+
356
+ (function() {
357
+
358
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
359
+ var range = this.indentationBlock(session, row);
360
+ if (range)
361
+ return range;
362
+
363
+ var re = /\S/;
364
+ var line = session.getLine(row);
365
+ var startLevel = line.search(re);
366
+ if (startLevel == -1 || line[startLevel] != "#")
367
+ return;
368
+
369
+ var startColumn = line.length;
370
+ var maxRow = session.getLength();
371
+ var startRow = row;
372
+ var endRow = row;
373
+
374
+ while (++row < maxRow) {
375
+ line = session.getLine(row);
376
+ var level = line.search(re);
377
+
378
+ if (level == -1)
379
+ continue;
380
+
381
+ if (line[level] != "#")
382
+ break;
383
+
384
+ endRow = row;
385
+ }
386
+
387
+ if (endRow > startRow) {
388
+ var endColumn = session.getLine(endRow).length;
389
+ return new Range(startRow, startColumn, endRow, endColumn);
390
+ }
391
+ };
392
+ this.getFoldWidget = function(session, foldStyle, row) {
393
+ var line = session.getLine(row);
394
+ var indent = line.search(/\S/);
395
+ var next = session.getLine(row + 1);
396
+ var prev = session.getLine(row - 1);
397
+ var prevIndent = prev.search(/\S/);
398
+ var nextIndent = next.search(/\S/);
399
+
400
+ if (indent == -1) {
401
+ session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
402
+ return "";
403
+ }
404
+ if (prevIndent == -1) {
405
+ if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
406
+ session.foldWidgets[row - 1] = "";
407
+ session.foldWidgets[row + 1] = "";
408
+ return "start";
409
+ }
410
+ } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
411
+ if (session.getLine(row - 2).search(/\S/) == -1) {
412
+ session.foldWidgets[row - 1] = "start";
413
+ session.foldWidgets[row + 1] = "";
414
+ return "";
415
+ }
416
+ }
417
+
418
+ if (prevIndent!= -1 && prevIndent < indent)
419
+ session.foldWidgets[row - 1] = "start";
420
+ else
421
+ session.foldWidgets[row - 1] = "";
422
+
423
+ if (indent < nextIndent)
424
+ return "start";
425
+ else
426
+ return "";
427
+ };
428
+
429
+ }).call(FoldMode.prototype);
430
+
431
+ });