ruby-6b64e482.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. import{g as r}from"./index-b2e76ed2.js";function d(s,p){for(var n=0;n<p.length;n++){const t=p[n];if(typeof t!="string"&&!Array.isArray(t)){for(const e in t)if(e!=="default"&&!(e in s)){const i=Object.getOwnPropertyDescriptor(t,e);i&&Object.defineProperty(s,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}var a={exports:{}};(function(s,p){ace.define("ace/snippets/ruby.snippets",["require","exports","module"],function(n,t,e){e.exports=`########################################
  2. # Ruby snippets - for Rails, see below #
  3. ########################################
  4. # encoding for Ruby 1.9
  5. snippet enc
  6. # encoding: utf-8
  7. # #!/usr/bin/env ruby
  8. snippet #!
  9. #!/usr/bin/env ruby
  10. # encoding: utf-8
  11. # New Block
  12. snippet =b
  13. =begin rdoc
  14. \${1}
  15. =end
  16. snippet y
  17. :yields: \${1:arguments}
  18. snippet rb
  19. #!/usr/bin/env ruby -wKU
  20. snippet beg
  21. begin
  22. \${3}
  23. rescue \${1:Exception} => \${2:e}
  24. end
  25. snippet req require
  26. require "\${1}"\${2}
  27. snippet #
  28. # =>
  29. snippet end
  30. __END__
  31. snippet case
  32. case \${1:object}
  33. when \${2:condition}
  34. \${3}
  35. end
  36. snippet when
  37. when \${1:condition}
  38. \${2}
  39. snippet def
  40. def \${1:method_name}
  41. \${2}
  42. end
  43. snippet deft
  44. def test_\${1:case_name}
  45. \${2}
  46. end
  47. snippet if
  48. if \${1:condition}
  49. \${2}
  50. end
  51. snippet ife
  52. if \${1:condition}
  53. \${2}
  54. else
  55. \${3}
  56. end
  57. snippet elsif
  58. elsif \${1:condition}
  59. \${2}
  60. snippet unless
  61. unless \${1:condition}
  62. \${2}
  63. end
  64. snippet while
  65. while \${1:condition}
  66. \${2}
  67. end
  68. snippet for
  69. for \${1:e} in \${2:c}
  70. \${3}
  71. end
  72. snippet until
  73. until \${1:condition}
  74. \${2}
  75. end
  76. snippet cla class .. end
  77. class \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`}
  78. \${2}
  79. end
  80. snippet cla class .. initialize .. end
  81. class \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`}
  82. def initialize(\${2:args})
  83. \${3}
  84. end
  85. end
  86. snippet cla class .. < ParentClass .. initialize .. end
  87. class \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`} < \${2:ParentClass}
  88. def initialize(\${3:args})
  89. \${4}
  90. end
  91. end
  92. snippet cla ClassName = Struct .. do .. end
  93. \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`} = Struct.new(:\${2:attr_names}) do
  94. def \${3:method_name}
  95. \${4}
  96. end
  97. end
  98. snippet cla class BlankSlate .. initialize .. end
  99. class \${1:BlankSlate}
  100. instance_methods.each { |meth| undef_method(meth) unless meth =~ /\\A__/ }
  101. end
  102. snippet cla class << self .. end
  103. class << \${1:self}
  104. \${2}
  105. end
  106. # class .. < DelegateClass .. initialize .. end
  107. snippet cla-
  108. class \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`} < DelegateClass(\${2:ParentClass})
  109. def initialize(\${3:args})
  110. super(\${4:del_obj})
  111. \${5}
  112. end
  113. end
  114. snippet mod module .. end
  115. module \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`}
  116. \${2}
  117. end
  118. snippet mod module .. module_function .. end
  119. module \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`}
  120. module_function
  121. \${2}
  122. end
  123. snippet mod module .. ClassMethods .. end
  124. module \${1:\`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')\`}
  125. module ClassMethods
  126. \${2}
  127. end
  128. module InstanceMethods
  129. end
  130. def self.included(receiver)
  131. receiver.extend ClassMethods
  132. receiver.send :include, InstanceMethods
  133. end
  134. end
  135. # attr_reader
  136. snippet r
  137. attr_reader :\${1:attr_names}
  138. # attr_writer
  139. snippet w
  140. attr_writer :\${1:attr_names}
  141. # attr_accessor
  142. snippet rw
  143. attr_accessor :\${1:attr_names}
  144. snippet atp
  145. attr_protected :\${1:attr_names}
  146. snippet ata
  147. attr_accessible :\${1:attr_names}
  148. # include Enumerable
  149. snippet Enum
  150. include Enumerable
  151. def each(&block)
  152. \${1}
  153. end
  154. # include Comparable
  155. snippet Comp
  156. include Comparable
  157. def <=>(other)
  158. \${1}
  159. end
  160. # extend Forwardable
  161. snippet Forw-
  162. extend Forwardable
  163. # def self
  164. snippet defs
  165. def self.\${1:class_method_name}
  166. \${2}
  167. end
  168. # def method_missing
  169. snippet defmm
  170. def method_missing(meth, *args, &blk)
  171. \${1}
  172. end
  173. snippet defd
  174. def_delegator :\${1:@del_obj}, :\${2:del_meth}, :\${3:new_name}
  175. snippet defds
  176. def_delegators :\${1:@del_obj}, :\${2:del_methods}
  177. snippet am
  178. alias_method :\${1:new_name}, :\${2:old_name}
  179. snippet app
  180. if __FILE__ == $PROGRAM_NAME
  181. \${1}
  182. end
  183. # usage_if()
  184. snippet usai
  185. if ARGV.\${1}
  186. abort "Usage: #{$PROGRAM_NAME} \${2:ARGS_GO_HERE}"\${3}
  187. end
  188. # usage_unless()
  189. snippet usau
  190. unless ARGV.\${1}
  191. abort "Usage: #{$PROGRAM_NAME} \${2:ARGS_GO_HERE}"\${3}
  192. end
  193. snippet array
  194. Array.new(\${1:10}) { |\${2:i}| \${3} }
  195. snippet hash
  196. Hash.new { |\${1:hash}, \${2:key}| $1[$2] = \${3} }
  197. snippet file File.foreach() { |line| .. }
  198. File.foreach(\${1:"path/to/file"}) { |\${2:line}| \${3} }
  199. snippet file File.read()
  200. File.read(\${1:"path/to/file"})\${2}
  201. snippet Dir Dir.global() { |file| .. }
  202. Dir.glob(\${1:"dir/glob/*"}) { |\${2:file}| \${3} }
  203. snippet Dir Dir[".."]
  204. Dir[\${1:"glob/**/*.rb"}]\${2}
  205. snippet dir
  206. Filename.dirname(__FILE__)
  207. snippet deli
  208. delete_if { |\${1:e}| \${2} }
  209. snippet fil
  210. fill(\${1:range}) { |\${2:i}| \${3} }
  211. # flatten_once()
  212. snippet flao
  213. inject(Array.new) { |\${1:arr}, \${2:a}| $1.push(*$2)}\${3}
  214. snippet zip
  215. zip(\${1:enums}) { |\${2:row}| \${3} }
  216. # downto(0) { |n| .. }
  217. snippet dow
  218. downto(\${1:0}) { |\${2:n}| \${3} }
  219. snippet ste
  220. step(\${1:2}) { |\${2:n}| \${3} }
  221. snippet tim
  222. times { |\${1:n}| \${2} }
  223. snippet upt
  224. upto(\${1:1.0/0.0}) { |\${2:n}| \${3} }
  225. snippet loo
  226. loop { \${1} }
  227. snippet ea
  228. each { |\${1:e}| \${2} }
  229. snippet ead
  230. each do |\${1:e}|
  231. \${2}
  232. end
  233. snippet eab
  234. each_byte { |\${1:byte}| \${2} }
  235. snippet eac- each_char { |chr| .. }
  236. each_char { |\${1:chr}| \${2} }
  237. snippet eac- each_cons(..) { |group| .. }
  238. each_cons(\${1:2}) { |\${2:group}| \${3} }
  239. snippet eai
  240. each_index { |\${1:i}| \${2} }
  241. snippet eaid
  242. each_index do |\${1:i}|
  243. \${2}
  244. end
  245. snippet eak
  246. each_key { |\${1:key}| \${2} }
  247. snippet eakd
  248. each_key do |\${1:key}|
  249. \${2}
  250. end
  251. snippet eal
  252. each_line { |\${1:line}| \${2} }
  253. snippet eald
  254. each_line do |\${1:line}|
  255. \${2}
  256. end
  257. snippet eap
  258. each_pair { |\${1:name}, \${2:val}| \${3} }
  259. snippet eapd
  260. each_pair do |\${1:name}, \${2:val}|
  261. \${3}
  262. end
  263. snippet eas-
  264. each_slice(\${1:2}) { |\${2:group}| \${3} }
  265. snippet easd-
  266. each_slice(\${1:2}) do |\${2:group}|
  267. \${3}
  268. end
  269. snippet eav
  270. each_value { |\${1:val}| \${2} }
  271. snippet eavd
  272. each_value do |\${1:val}|
  273. \${2}
  274. end
  275. snippet eawi
  276. each_with_index { |\${1:e}, \${2:i}| \${3} }
  277. snippet eawid
  278. each_with_index do |\${1:e},\${2:i}|
  279. \${3}
  280. end
  281. snippet reve
  282. reverse_each { |\${1:e}| \${2} }
  283. snippet reved
  284. reverse_each do |\${1:e}|
  285. \${2}
  286. end
  287. snippet inj
  288. inject(\${1:init}) { |\${2:mem}, \${3:var}| \${4} }
  289. snippet injd
  290. inject(\${1:init}) do |\${2:mem}, \${3:var}|
  291. \${4}
  292. end
  293. snippet map
  294. map { |\${1:e}| \${2} }
  295. snippet mapd
  296. map do |\${1:e}|
  297. \${2}
  298. end
  299. snippet mapwi-
  300. enum_with_index.map { |\${1:e}, \${2:i}| \${3} }
  301. snippet sor
  302. sort { |a, b| \${1} }
  303. snippet sorb
  304. sort_by { |\${1:e}| \${2} }
  305. snippet ran
  306. sort_by { rand }
  307. snippet all
  308. all? { |\${1:e}| \${2} }
  309. snippet any
  310. any? { |\${1:e}| \${2} }
  311. snippet cl
  312. classify { |\${1:e}| \${2} }
  313. snippet col
  314. collect { |\${1:e}| \${2} }
  315. snippet cold
  316. collect do |\${1:e}|
  317. \${2}
  318. end
  319. snippet det
  320. detect { |\${1:e}| \${2} }
  321. snippet detd
  322. detect do |\${1:e}|
  323. \${2}
  324. end
  325. snippet fet
  326. fetch(\${1:name}) { |\${2:key}| \${3} }
  327. snippet fin
  328. find { |\${1:e}| \${2} }
  329. snippet find
  330. find do |\${1:e}|
  331. \${2}
  332. end
  333. snippet fina
  334. find_all { |\${1:e}| \${2} }
  335. snippet finad
  336. find_all do |\${1:e}|
  337. \${2}
  338. end
  339. snippet gre
  340. grep(\${1:/pattern/}) { |\${2:match}| \${3} }
  341. snippet sub
  342. \${1:g}sub(\${2:/pattern/}) { |\${3:match}| \${4} }
  343. snippet sca
  344. scan(\${1:/pattern/}) { |\${2:match}| \${3} }
  345. snippet scad
  346. scan(\${1:/pattern/}) do |\${2:match}|
  347. \${3}
  348. end
  349. snippet max
  350. max { |a, b| \${1} }
  351. snippet min
  352. min { |a, b| \${1} }
  353. snippet par
  354. partition { |\${1:e}| \${2} }
  355. snippet pard
  356. partition do |\${1:e}|
  357. \${2}
  358. end
  359. snippet rej
  360. reject { |\${1:e}| \${2} }
  361. snippet rejd
  362. reject do |\${1:e}|
  363. \${2}
  364. end
  365. snippet sel
  366. select { |\${1:e}| \${2} }
  367. snippet seld
  368. select do |\${1:e}|
  369. \${2}
  370. end
  371. snippet lam
  372. lambda { |\${1:args}| \${2} }
  373. snippet doo
  374. do
  375. \${1}
  376. end
  377. snippet dov
  378. do |\${1:variable}|
  379. \${2}
  380. end
  381. snippet :
  382. :\${1:key} => \${2:"value"}\${3}
  383. snippet ope
  384. open(\${1:"path/or/url/or/pipe"}, "\${2:w}") { |\${3:io}| \${4} }
  385. # path_from_here()
  386. snippet fpath
  387. File.join(File.dirname(__FILE__), *%2[\${1:rel path here}])\${2}
  388. # unix_filter {}
  389. snippet unif
  390. ARGF.each_line\${1} do |\${2:line}|
  391. \${3}
  392. end
  393. # option_parse {}
  394. snippet optp
  395. require "optparse"
  396. options = {\${1:default => "args"}}
  397. ARGV.options do |opts|
  398. opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
  399. snippet opt
  400. opts.on( "-\${1:o}", "--\${2:long-option-name}", \${3:String},
  401. "\${4:Option description.}") do |\${5:opt}|
  402. \${6}
  403. end
  404. snippet tc
  405. require "test/unit"
  406. require "\${1:library_file_name}"
  407. class Test\${2:$1} < Test::Unit::TestCase
  408. def test_\${3:case_name}
  409. \${4}
  410. end
  411. end
  412. snippet ts
  413. require "test/unit"
  414. require "tc_\${1:test_case_file}"
  415. require "tc_\${2:test_case_file}"\${3}
  416. snippet as
  417. assert \${1:test}, "\${2:Failure message.}"\${3}
  418. snippet ase
  419. assert_equal \${1:expected}, \${2:actual}\${3}
  420. snippet asne
  421. assert_not_equal \${1:unexpected}, \${2:actual}\${3}
  422. snippet asid
  423. assert_in_delta \${1:expected_float}, \${2:actual_float}, \${3:2 ** -20}\${4}
  424. snippet asio
  425. assert_instance_of \${1:ExpectedClass}, \${2:actual_instance}\${3}
  426. snippet asko
  427. assert_kind_of \${1:ExpectedKind}, \${2:actual_instance}\${3}
  428. snippet asn
  429. assert_nil \${1:instance}\${2}
  430. snippet asnn
  431. assert_not_nil \${1:instance}\${2}
  432. snippet asm
  433. assert_match /\${1:expected_pattern}/, \${2:actual_string}\${3}
  434. snippet asnm
  435. assert_no_match /\${1:unexpected_pattern}/, \${2:actual_string}\${3}
  436. snippet aso
  437. assert_operator \${1:left}, :\${2:operator}, \${3:right}\${4}
  438. snippet asr
  439. assert_raise \${1:Exception} { \${2} }
  440. snippet asrd
  441. assert_raise \${1:Exception} do
  442. \${2}
  443. end
  444. snippet asnr
  445. assert_nothing_raised \${1:Exception} { \${2} }
  446. snippet asnrd
  447. assert_nothing_raised \${1:Exception} do
  448. \${2}
  449. end
  450. snippet asrt
  451. assert_respond_to \${1:object}, :\${2:method}\${3}
  452. snippet ass assert_same(..)
  453. assert_same \${1:expected}, \${2:actual}\${3}
  454. snippet ass assert_send(..)
  455. assert_send [\${1:object}, :\${2:message}, \${3:args}]\${4}
  456. snippet asns
  457. assert_not_same \${1:unexpected}, \${2:actual}\${3}
  458. snippet ast
  459. assert_throws :\${1:expected} { \${2} }
  460. snippet astd
  461. assert_throws :\${1:expected} do
  462. \${2}
  463. end
  464. snippet asnt
  465. assert_nothing_thrown { \${1} }
  466. snippet asntd
  467. assert_nothing_thrown do
  468. \${1}
  469. end
  470. snippet fl
  471. flunk "\${1:Failure message.}"\${2}
  472. # Benchmark.bmbm do .. end
  473. snippet bm-
  474. TESTS = \${1:10_000}
  475. Benchmark.bmbm do |results|
  476. \${2}
  477. end
  478. snippet rep
  479. results.report("\${1:name}:") { TESTS.times { \${2} }}
  480. # Marshal.dump(.., file)
  481. snippet Md
  482. File.open(\${1:"path/to/file.dump"}, "wb") { |\${2:file}| Marshal.dump(\${3:obj}, $2) }\${4}
  483. # Mashal.load(obj)
  484. snippet Ml
  485. File.open(\${1:"path/to/file.dump"}, "rb") { |\${2:file}| Marshal.load($2) }\${3}
  486. # deep_copy(..)
  487. snippet deec
  488. Marshal.load(Marshal.dump(\${1:obj_to_copy}))\${2}
  489. snippet Pn-
  490. PStore.new(\${1:"file_name.pstore"})\${2}
  491. snippet tra
  492. transaction(\${1:true}) { \${2} }
  493. # xmlread(..)
  494. snippet xml-
  495. REXML::Document.new(File.read(\${1:"path/to/file"}))\${2}
  496. # xpath(..) { .. }
  497. snippet xpa
  498. elements.each(\${1:"//Xpath"}) do |\${2:node}|
  499. \${3}
  500. end
  501. # class_from_name()
  502. snippet clafn
  503. split("::").inject(Object) { |par, const| par.const_get(const) }
  504. # singleton_class()
  505. snippet sinc
  506. class << self; self end
  507. snippet nam
  508. namespace :\${1:\`Filename()\`} do
  509. \${2}
  510. end
  511. snippet tas
  512. desc "\${1:Task description}"
  513. task :\${2:task_name => [:dependent, :tasks]} do
  514. \${3}
  515. end
  516. # block
  517. snippet b
  518. { |\${1:var}| \${2} }
  519. snippet begin
  520. begin
  521. raise 'A test exception.'
  522. rescue Exception => e
  523. puts e.message
  524. puts e.backtrace.inspect
  525. else
  526. # other exception
  527. ensure
  528. # always executed
  529. end
  530. #debugging
  531. snippet debug
  532. require 'ruby-debug'; debugger; true;
  533. snippet pry
  534. require 'pry'; binding.pry
  535. #############################################
  536. # Rails snippets - for pure Ruby, see above #
  537. #############################################
  538. snippet art
  539. assert_redirected_to \${1::action => "\${2:index}"}
  540. snippet artnp
  541. assert_redirected_to \${1:parent}_\${2:child}_path(\${3:@$1}, \${4:@$2})
  542. snippet artnpp
  543. assert_redirected_to \${1:parent}_\${2:child}_path(\${3:@$1})
  544. snippet artp
  545. assert_redirected_to \${1:model}_path(\${2:@$1})
  546. snippet artpp
  547. assert_redirected_to \${1:model}s_path
  548. snippet asd
  549. assert_difference "\${1:Model}.\${2:count}", $1 do
  550. \${3}
  551. end
  552. snippet asnd
  553. assert_no_difference "\${1:Model}.\${2:count}" do
  554. \${3}
  555. end
  556. snippet asre
  557. assert_response :\${1:success}, @response.body\${2}
  558. snippet asrj
  559. assert_rjs :\${1:replace}, "\${2:dom id}"
  560. snippet ass assert_select(..)
  561. assert_select '\${1:path}', :\${2:text} => '\${3:inner_html' \${4:do}
  562. snippet bf
  563. before_filter :\${1:method}
  564. snippet bt
  565. belongs_to :\${1:association}
  566. snippet crw
  567. cattr_accessor :\${1:attr_names}
  568. snippet defcreate
  569. def create
  570. @\${1:model_class_name} = \${2:ModelClassName}.new(params[:$1])
  571. respond_to do |wants|
  572. if @$1.save
  573. flash[:notice] = '$2 was successfully created.'
  574. wants.html { redirect_to(@$1) }
  575. wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
  576. else
  577. wants.html { render :action => "new" }
  578. wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
  579. end
  580. end
  581. end\${3}
  582. snippet defdestroy
  583. def destroy
  584. @\${1:model_class_name} = \${2:ModelClassName}.find(params[:id])
  585. @$1.destroy
  586. respond_to do |wants|
  587. wants.html { redirect_to($1s_url) }
  588. wants.xml { head :ok }
  589. end
  590. end\${3}
  591. snippet defedit
  592. def edit
  593. @\${1:model_class_name} = \${2:ModelClassName}.find(params[:id])
  594. end
  595. snippet defindex
  596. def index
  597. @\${1:model_class_name} = \${2:ModelClassName}.all
  598. respond_to do |wants|
  599. wants.html # index.html.erb
  600. wants.xml { render :xml => @$1s }
  601. end
  602. end\${3}
  603. snippet defnew
  604. def new
  605. @\${1:model_class_name} = \${2:ModelClassName}.new
  606. respond_to do |wants|
  607. wants.html # new.html.erb
  608. wants.xml { render :xml => @$1 }
  609. end
  610. end\${3}
  611. snippet defshow
  612. def show
  613. @\${1:model_class_name} = \${2:ModelClassName}.find(params[:id])
  614. respond_to do |wants|
  615. wants.html # show.html.erb
  616. wants.xml { render :xml => @$1 }
  617. end
  618. end\${3}
  619. snippet defupdate
  620. def update
  621. @\${1:model_class_name} = \${2:ModelClassName}.find(params[:id])
  622. respond_to do |wants|
  623. if @$1.update_attributes(params[:$1])
  624. flash[:notice] = '$2 was successfully updated.'
  625. wants.html { redirect_to(@$1) }
  626. wants.xml { head :ok }
  627. else
  628. wants.html { render :action => "edit" }
  629. wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
  630. end
  631. end
  632. end\${3}
  633. snippet flash
  634. flash[:\${1:notice}] = "\${2}"
  635. snippet habtm
  636. has_and_belongs_to_many :\${1:object}, :join_table => "\${2:table_name}", :foreign_key => "\${3}_id"\${4}
  637. snippet hm
  638. has_many :\${1:object}
  639. snippet hmd
  640. has_many :\${1:other}s, :class_name => "\${2:$1}", :foreign_key => "\${3:$1}_id", :dependent => :destroy\${4}
  641. snippet hmt
  642. has_many :\${1:object}, :through => :\${2:object}
  643. snippet ho
  644. has_one :\${1:object}
  645. snippet i18
  646. I18n.t('\${1:type.key}')\${2}
  647. snippet ist
  648. <%= image_submit_tag("\${1:agree.png}", :id => "\${2:id}"\${3} %>
  649. snippet log
  650. Rails.logger.\${1:debug} \${2}
  651. snippet log2
  652. RAILS_DEFAULT_LOGGER.\${1:debug} \${2}
  653. snippet logd
  654. logger.debug { "\${1:message}" }\${2}
  655. snippet loge
  656. logger.error { "\${1:message}" }\${2}
  657. snippet logf
  658. logger.fatal { "\${1:message}" }\${2}
  659. snippet logi
  660. logger.info { "\${1:message}" }\${2}
  661. snippet logw
  662. logger.warn { "\${1:message}" }\${2}
  663. snippet mapc
  664. \${1:map}.\${2:connect} '\${3:controller/:action/:id}'
  665. snippet mapca
  666. \${1:map}.catch_all "*\${2:anything}", :controller => "\${3:default}", :action => "\${4:error}"\${5}
  667. snippet mapr
  668. \${1:map}.resource :\${2:resource}
  669. snippet maprs
  670. \${1:map}.resources :\${2:resource}
  671. snippet mapwo
  672. \${1:map}.with_options :\${2:controller} => '\${3:thing}' do |$3|
  673. \${4}
  674. end
  675. snippet mbs
  676. before_save :\${1:method}
  677. snippet mcht
  678. change_table :\${1:table_name} do |t|
  679. \${2}
  680. end
  681. snippet mp
  682. map(&:\${1:id})
  683. snippet mrw
  684. mattr_accessor :\${1:attr_names}
  685. snippet oa
  686. order("\${1:field}")
  687. snippet od
  688. order("\${1:field} DESC")
  689. snippet pa
  690. params[:\${1:id}]\${2}
  691. snippet ra
  692. render :action => "\${1:action}"
  693. snippet ral
  694. render :action => "\${1:action}", :layout => "\${2:layoutname}"
  695. snippet rest
  696. respond_to do |wants|
  697. wants.\${1:html} { \${2} }
  698. end
  699. snippet rf
  700. render :file => "\${1:filepath}"
  701. snippet rfu
  702. render :file => "\${1:filepath}", :use_full_path => \${2:false}
  703. snippet ri
  704. render :inline => "\${1:<%= 'hello' %>}"
  705. snippet ril
  706. render :inline => "\${1:<%= 'hello' %>}", :locals => { \${2::name} => "\${3:value}"\${4} }
  707. snippet rit
  708. render :inline => "\${1:<%= 'hello' %>}", :type => \${2::rxml}
  709. snippet rjson
  710. render :json => \${1:text to render}
  711. snippet rl
  712. render :layout => "\${1:layoutname}"
  713. snippet rn
  714. render :nothing => \${1:true}
  715. snippet rns
  716. render :nothing => \${1:true}, :status => \${2:401}
  717. snippet rp
  718. render :partial => "\${1:item}"
  719. snippet rpc
  720. render :partial => "\${1:item}", :collection => \${2:@$1s}
  721. snippet rpl
  722. render :partial => "\${1:item}", :locals => { :\${2:$1} => \${3:@$1}
  723. snippet rpo
  724. render :partial => "\${1:item}", :object => \${2:@$1}
  725. snippet rps
  726. render :partial => "\${1:item}", :status => \${2:500}
  727. snippet rt
  728. render :text => "\${1:text to render}"
  729. snippet rtl
  730. render :text => "\${1:text to render}", :layout => "\${2:layoutname}"
  731. snippet rtlt
  732. render :text => "\${1:text to render}", :layout => \${2:true}
  733. snippet rts
  734. render :text => "\${1:text to render}", :status => \${2:401}
  735. snippet ru
  736. render :update do |\${1:page}|
  737. $1.\${2}
  738. end
  739. snippet rxml
  740. render :xml => \${1:text to render}
  741. snippet sc
  742. scope :\${1:name}, :where(:@\${2:field} => \${3:value})
  743. snippet sl
  744. scope :\${1:name}, lambda do |\${2:value}|
  745. where("\${3:field = ?}", \${4:bind var})
  746. end
  747. snippet sha1
  748. Digest::SHA1.hexdigest(\${1:string})
  749. snippet sweeper
  750. class \${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper
  751. observe $1
  752. def after_save(\${2:model_class_name})
  753. expire_cache($2)
  754. end
  755. def after_destroy($2)
  756. expire_cache($2)
  757. end
  758. def expire_cache($2)
  759. expire_page
  760. end
  761. end
  762. snippet tcb
  763. t.boolean :\${1:title}
  764. \${2}
  765. snippet tcbi
  766. t.binary :\${1:title}, :limit => \${2:2}.megabytes
  767. \${3}
  768. snippet tcd
  769. t.decimal :\${1:title}, :precision => \${2:10}, :scale => \${3:2}
  770. \${4}
  771. snippet tcda
  772. t.date :\${1:title}
  773. \${2}
  774. snippet tcdt
  775. t.datetime :\${1:title}
  776. \${2}
  777. snippet tcf
  778. t.float :\${1:title}
  779. \${2}
  780. snippet tch
  781. t.change :\${1:name}, :\${2:string}, :\${3:limit} => \${4:80}
  782. \${5}
  783. snippet tci
  784. t.integer :\${1:title}
  785. \${2}
  786. snippet tcl
  787. t.integer :lock_version, :null => false, :default => 0
  788. \${1}
  789. snippet tcr
  790. t.references :\${1:taggable}, :polymorphic => { :default => '\${2:Photo}' }
  791. \${3}
  792. snippet tcs
  793. t.string :\${1:title}
  794. \${2}
  795. snippet tct
  796. t.text :\${1:title}
  797. \${2}
  798. snippet tcti
  799. t.time :\${1:title}
  800. \${2}
  801. snippet tcts
  802. t.timestamp :\${1:title}
  803. \${2}
  804. snippet tctss
  805. t.timestamps
  806. \${1}
  807. snippet va
  808. validates_associated :\${1:attribute}
  809. snippet vao
  810. validates_acceptance_of :\${1:terms}
  811. snippet vc
  812. validates_confirmation_of :\${1:attribute}
  813. snippet ve
  814. validates_exclusion_of :\${1:attribute}, :in => \${2:%w( mov avi )}
  815. snippet vf
  816. validates_format_of :\${1:attribute}, :with => /\${2:regex}/
  817. snippet vi
  818. validates_inclusion_of :\${1:attribute}, :in => %w(\${2: mov avi })
  819. snippet vl
  820. validates_length_of :\${1:attribute}, :within => \${2:3}..\${3:20}
  821. snippet vn
  822. validates_numericality_of :\${1:attribute}
  823. snippet vpo
  824. validates_presence_of :\${1:attribute}
  825. snippet vu
  826. validates_uniqueness_of :\${1:attribute}
  827. snippet wants
  828. wants.\${1:js|xml|html} { \${2} }
  829. snippet wc
  830. where(\${1:"conditions"}\${2:, bind_var})
  831. snippet wh
  832. where(\${1:field} => \${2:value})
  833. snippet xdelete
  834. xhr :delete, :\${1:destroy}, :id => \${2:1}\${3}
  835. snippet xget
  836. xhr :get, :\${1:show}, :id => \${2:1}\${3}
  837. snippet xpost
  838. xhr :post, :\${1:create}, :\${2:object} => { \${3} }
  839. snippet xput
  840. xhr :put, :\${1:update}, :id => \${2:1}, :\${3:object} => { \${4} }\${5}
  841. snippet test
  842. test "should \${1:do something}" do
  843. \${2}
  844. end
  845. #migrations
  846. snippet mac
  847. add_column :\${1:table_name}, :\${2:column_name}, :\${3:data_type}
  848. snippet mrc
  849. remove_column :\${1:table_name}, :\${2:column_name}
  850. snippet mrnc
  851. rename_column :\${1:table_name}, :\${2:old_column_name}, :\${3:new_column_name}
  852. snippet mcc
  853. change_column :\${1:table}, :\${2:column}, :\${3:type}
  854. snippet mccc
  855. t.column :\${1:title}, :\${2:string}
  856. snippet mct
  857. create_table :\${1:table_name} do |t|
  858. t.column :\${2:name}, :\${3:type}
  859. end
  860. snippet migration
  861. class \${1:class_name} < ActiveRecord::Migration
  862. def self.up
  863. \${2}
  864. end
  865. def self.down
  866. end
  867. end
  868. snippet trc
  869. t.remove :\${1:column}
  870. snippet tre
  871. t.rename :\${1:old_column_name}, :\${2:new_column_name}
  872. \${3}
  873. snippet tref
  874. t.references :\${1:model}
  875. #rspec
  876. snippet it
  877. it "\${1:spec_name}" do
  878. \${2}
  879. end
  880. snippet itp
  881. it "\${1:spec_name}"
  882. \${2}
  883. snippet desc
  884. describe \${1:class_name} do
  885. \${2}
  886. end
  887. snippet cont
  888. context "\${1:message}" do
  889. \${2}
  890. end
  891. snippet bef
  892. before :\${1:each} do
  893. \${2}
  894. end
  895. snippet aft
  896. after :\${1:each} do
  897. \${2}
  898. end
  899. `}),ace.define("ace/snippets/ruby",["require","exports","module","ace/snippets/ruby.snippets"],function(n,t,e){t.snippetText=n("./ruby.snippets"),t.scope="ruby"}),function(){ace.require(["ace/snippets/ruby"],function(n){s&&(s.exports=n)})}()})(a);var $=a.exports;const o=r($),c=d({__proto__:null,default:o},[$]);export{c as r};