bio 1.0.0 → 1.1.0

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 (340) hide show
  1. data/bin/bioruby +14 -122
  2. data/bin/br_biofetch.rb +2 -2
  3. data/bin/br_bioflat.rb +2 -2
  4. data/bin/br_biogetseq.rb +2 -2
  5. data/bin/br_pmfetch.rb +3 -3
  6. data/doc/Changes-0.7.rd +77 -0
  7. data/doc/KEGG_API.rd +523 -232
  8. data/doc/KEGG_API.rd.ja +529 -207
  9. data/doc/Tutorial.rd +48 -11
  10. data/lib/bio.rb +59 -6
  11. data/lib/bio/alignment.rb +713 -103
  12. data/lib/bio/appl/bl2seq/report.rb +2 -18
  13. data/lib/bio/appl/blast.rb +108 -91
  14. data/lib/bio/appl/blast/format0.rb +33 -18
  15. data/lib/bio/appl/blast/format8.rb +6 -20
  16. data/lib/bio/appl/blast/report.rb +293 -429
  17. data/lib/bio/appl/blast/rexml.rb +8 -22
  18. data/lib/bio/appl/blast/wublast.rb +21 -12
  19. data/lib/bio/appl/blast/xmlparser.rb +180 -183
  20. data/lib/bio/appl/blat/report.rb +127 -30
  21. data/lib/bio/appl/clustalw.rb +87 -59
  22. data/lib/bio/appl/clustalw/report.rb +20 -22
  23. data/lib/bio/appl/emboss.rb +113 -20
  24. data/lib/bio/appl/fasta.rb +173 -198
  25. data/lib/bio/appl/fasta/format10.rb +244 -347
  26. data/lib/bio/appl/gcg/msf.rb +212 -0
  27. data/lib/bio/appl/gcg/seq.rb +195 -0
  28. data/lib/bio/appl/genscan/report.rb +5 -23
  29. data/lib/bio/appl/hmmer.rb +8 -45
  30. data/lib/bio/appl/hmmer/report.rb +2 -20
  31. data/lib/bio/appl/iprscan/report.rb +374 -0
  32. data/lib/bio/appl/mafft.rb +87 -50
  33. data/lib/bio/appl/mafft/report.rb +151 -44
  34. data/lib/bio/appl/muscle.rb +52 -0
  35. data/lib/bio/appl/phylip/alignment.rb +129 -0
  36. data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
  37. data/lib/bio/appl/probcons.rb +41 -0
  38. data/lib/bio/appl/psort.rb +89 -96
  39. data/lib/bio/appl/psort/report.rb +6 -22
  40. data/lib/bio/appl/pts1.rb +263 -0
  41. data/lib/bio/appl/sim4.rb +26 -36
  42. data/lib/bio/appl/sim4/report.rb +2 -18
  43. data/lib/bio/appl/sosui/report.rb +5 -20
  44. data/lib/bio/appl/spidey/report.rb +2 -2
  45. data/lib/bio/appl/targetp/report.rb +4 -20
  46. data/lib/bio/appl/tcoffee.rb +55 -0
  47. data/lib/bio/appl/tmhmm/report.rb +4 -20
  48. data/lib/bio/command.rb +235 -64
  49. data/lib/bio/data/aa.rb +21 -26
  50. data/lib/bio/data/codontable.rb +2 -20
  51. data/lib/bio/data/na.rb +19 -4
  52. data/lib/bio/db.rb +27 -12
  53. data/lib/bio/db/aaindex.rb +2 -20
  54. data/lib/bio/db/embl/common.rb +4 -21
  55. data/lib/bio/db/embl/embl.rb +33 -85
  56. data/lib/bio/db/embl/sptr.rb +612 -302
  57. data/lib/bio/db/embl/swissprot.rb +10 -29
  58. data/lib/bio/db/embl/trembl.rb +10 -29
  59. data/lib/bio/db/embl/uniprot.rb +10 -29
  60. data/lib/bio/db/fantom.rb +15 -20
  61. data/lib/bio/db/fasta.rb +3 -3
  62. data/lib/bio/db/genbank/common.rb +37 -46
  63. data/lib/bio/db/genbank/ddbj.rb +6 -18
  64. data/lib/bio/db/genbank/genbank.rb +47 -186
  65. data/lib/bio/db/genbank/genpept.rb +4 -17
  66. data/lib/bio/db/genbank/refseq.rb +4 -17
  67. data/lib/bio/db/gff.rb +103 -35
  68. data/lib/bio/db/go.rb +4 -20
  69. data/lib/bio/db/kegg/brite.rb +26 -36
  70. data/lib/bio/db/kegg/compound.rb +81 -85
  71. data/lib/bio/db/kegg/drug.rb +98 -0
  72. data/lib/bio/db/kegg/enzyme.rb +133 -110
  73. data/lib/bio/db/kegg/expression.rb +2 -20
  74. data/lib/bio/db/kegg/genes.rb +208 -238
  75. data/lib/bio/db/kegg/genome.rb +164 -285
  76. data/lib/bio/db/kegg/glycan.rb +114 -157
  77. data/lib/bio/db/kegg/keggtab.rb +242 -303
  78. data/lib/bio/db/kegg/kgml.rb +117 -160
  79. data/lib/bio/db/kegg/orthology.rb +112 -0
  80. data/lib/bio/db/kegg/reaction.rb +54 -69
  81. data/lib/bio/db/kegg/taxonomy.rb +331 -0
  82. data/lib/bio/db/lasergene.rb +209 -0
  83. data/lib/bio/db/litdb.rb +3 -27
  84. data/lib/bio/db/medline.rb +228 -249
  85. data/lib/bio/db/nbrf.rb +3 -3
  86. data/lib/bio/db/newick.rb +510 -0
  87. data/lib/bio/db/nexus.rb +1854 -0
  88. data/lib/bio/db/pdb.rb +5 -17
  89. data/lib/bio/db/pdb/atom.rb +2 -18
  90. data/lib/bio/db/pdb/chain.rb +2 -18
  91. data/lib/bio/db/pdb/chemicalcomponent.rb +2 -18
  92. data/lib/bio/db/pdb/model.rb +2 -18
  93. data/lib/bio/db/pdb/pdb.rb +73 -34
  94. data/lib/bio/db/pdb/residue.rb +4 -20
  95. data/lib/bio/db/pdb/utils.rb +2 -18
  96. data/lib/bio/db/prosite.rb +403 -422
  97. data/lib/bio/db/rebase.rb +84 -40
  98. data/lib/bio/db/soft.rb +404 -0
  99. data/lib/bio/db/transfac.rb +5 -17
  100. data/lib/bio/feature.rb +106 -52
  101. data/lib/bio/io/das.rb +32 -42
  102. data/lib/bio/io/dbget.rb +2 -20
  103. data/lib/bio/io/ddbjxml.rb +77 -138
  104. data/lib/bio/io/ebisoap.rb +158 -0
  105. data/lib/bio/io/ensembl.rb +229 -0
  106. data/lib/bio/io/fastacmd.rb +89 -82
  107. data/lib/bio/io/fetch.rb +163 -96
  108. data/lib/bio/io/flatfile.rb +170 -73
  109. data/lib/bio/io/flatfile/bdb.rb +3 -16
  110. data/lib/bio/io/flatfile/index.rb +2 -2
  111. data/lib/bio/io/flatfile/indexer.rb +3 -2
  112. data/lib/bio/io/higet.rb +12 -31
  113. data/lib/bio/io/keggapi.rb +210 -269
  114. data/lib/bio/io/ncbisoap.rb +155 -0
  115. data/lib/bio/io/pubmed.rb +169 -147
  116. data/lib/bio/io/registry.rb +4 -20
  117. data/lib/bio/io/soapwsdl.rb +43 -38
  118. data/lib/bio/io/sql.rb +242 -305
  119. data/lib/bio/location.rb +407 -285
  120. data/lib/bio/map.rb +410 -0
  121. data/lib/bio/pathway.rb +558 -695
  122. data/lib/bio/reference.rb +272 -75
  123. data/lib/bio/sequence.rb +255 -13
  124. data/lib/bio/sequence/aa.rb +71 -10
  125. data/lib/bio/sequence/common.rb +187 -33
  126. data/lib/bio/sequence/compat.rb +59 -4
  127. data/lib/bio/sequence/format.rb +54 -7
  128. data/lib/bio/sequence/generic.rb +3 -3
  129. data/lib/bio/sequence/na.rb +328 -26
  130. data/lib/bio/shell.rb +11 -4
  131. data/lib/bio/shell/core.rb +221 -160
  132. data/lib/bio/shell/demo.rb +18 -15
  133. data/lib/bio/shell/interface.rb +14 -12
  134. data/lib/bio/shell/irb.rb +95 -0
  135. data/lib/bio/shell/object.rb +45 -26
  136. data/lib/bio/shell/plugin/blast.rb +42 -0
  137. data/lib/bio/shell/plugin/codon.rb +22 -14
  138. data/lib/bio/shell/plugin/das.rb +58 -0
  139. data/lib/bio/shell/plugin/emboss.rb +2 -2
  140. data/lib/bio/shell/plugin/entry.rb +22 -11
  141. data/lib/bio/shell/plugin/flatfile.rb +2 -2
  142. data/lib/bio/shell/plugin/keggapi.rb +13 -6
  143. data/lib/bio/shell/plugin/midi.rb +4 -4
  144. data/lib/bio/shell/plugin/obda.rb +2 -2
  145. data/lib/bio/shell/plugin/psort.rb +56 -0
  146. data/lib/bio/shell/plugin/seq.rb +35 -8
  147. data/lib/bio/shell/plugin/soap.rb +87 -0
  148. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/bioruby_generator.rb +29 -0
  149. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_classes.rhtml +4 -0
  150. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_log.rhtml +27 -0
  151. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_methods.rhtml +11 -0
  152. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_modules.rhtml +4 -0
  153. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_variables.rhtml +7 -0
  154. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-bg.gif +0 -0
  155. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-console.png +0 -0
  156. data/lib/bio/shell/rails/{public/images/icon.png → vendor/plugins/generators/bioruby/templates/bioruby-gem.png} +0 -0
  157. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-link.gif +0 -0
  158. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.css +369 -0
  159. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml +47 -0
  160. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_controller.rb +144 -0
  161. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_helper.rb +47 -0
  162. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/commands.rhtml +8 -0
  163. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/history.rhtml +10 -0
  164. data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/index.rhtml +22 -0
  165. data/lib/bio/shell/script.rb +25 -0
  166. data/lib/bio/shell/setup.rb +109 -0
  167. data/lib/bio/shell/web.rb +70 -58
  168. data/lib/bio/tree.rb +850 -0
  169. data/lib/bio/util/color_scheme.rb +84 -107
  170. data/lib/bio/util/color_scheme/buried.rb +5 -24
  171. data/lib/bio/util/color_scheme/helix.rb +5 -24
  172. data/lib/bio/util/color_scheme/hydropathy.rb +5 -24
  173. data/lib/bio/util/color_scheme/nucleotide.rb +5 -24
  174. data/lib/bio/util/color_scheme/strand.rb +5 -24
  175. data/lib/bio/util/color_scheme/taylor.rb +5 -24
  176. data/lib/bio/util/color_scheme/turn.rb +5 -24
  177. data/lib/bio/util/color_scheme/zappo.rb +5 -24
  178. data/lib/bio/util/contingency_table.rb +70 -43
  179. data/lib/bio/util/restriction_enzyme.rb +228 -0
  180. data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
  181. data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
  182. data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
  183. data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
  184. data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
  185. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
  186. data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
  187. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
  188. data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
  189. data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
  190. data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
  191. data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
  192. data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
  193. data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
  194. data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
  195. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
  196. data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
  197. data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
  198. data/lib/bio/util/restriction_enzyme/single_strand.rb +199 -0
  199. data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
  200. data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
  201. data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
  202. data/lib/bio/util/sirna.rb +4 -22
  203. data/sample/color_scheme_na.rb +4 -12
  204. data/sample/enzymes.rb +78 -0
  205. data/sample/goslim.rb +5 -13
  206. data/sample/psortplot_html.rb +4 -12
  207. data/test/data/blast/2.2.15.blastp.m7 +876 -0
  208. data/test/data/embl/AB090716.embl.rel89 +63 -0
  209. data/test/data/fasta/example1.txt +75 -0
  210. data/test/data/fasta/example2.txt +21 -0
  211. data/test/data/iprscan/merged.raw +32 -0
  212. data/test/data/iprscan/merged.txt +74 -0
  213. data/test/data/soft/GDS100_partial.soft +92 -0
  214. data/test/data/soft/GSE3457_family_partial.soft +874 -0
  215. data/test/functional/bio/io/test_ensembl.rb +103 -0
  216. data/test/functional/bio/io/test_soapwsdl.rb +5 -17
  217. data/test/unit/bio/appl/bl2seq/test_report.rb +2 -2
  218. data/test/unit/bio/appl/blast/test_report.rb +3 -16
  219. data/test/unit/bio/appl/blast/test_xmlparser.rb +4 -16
  220. data/test/unit/bio/appl/genscan/test_report.rb +3 -16
  221. data/test/unit/bio/appl/hmmer/test_report.rb +3 -16
  222. data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
  223. data/test/unit/bio/appl/mafft/test_report.rb +63 -0
  224. data/test/unit/bio/appl/sosui/test_report.rb +3 -16
  225. data/test/unit/bio/appl/targetp/test_report.rb +3 -16
  226. data/test/unit/bio/appl/test_blast.rb +3 -16
  227. data/test/unit/bio/appl/test_fasta.rb +4 -16
  228. data/test/unit/bio/appl/test_pts1.rb +140 -0
  229. data/test/unit/bio/appl/tmhmm/test_report.rb +3 -16
  230. data/test/unit/bio/data/test_aa.rb +4 -17
  231. data/test/unit/bio/data/test_codontable.rb +3 -16
  232. data/test/unit/bio/data/test_na.rb +3 -3
  233. data/test/unit/bio/db/embl/test_common.rb +3 -16
  234. data/test/unit/bio/db/embl/test_embl.rb +3 -16
  235. data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
  236. data/test/unit/bio/db/embl/test_sptr.rb +1548 -41
  237. data/test/unit/bio/db/embl/test_uniprot.rb +3 -16
  238. data/test/unit/bio/db/kegg/test_genes.rb +3 -16
  239. data/test/unit/bio/db/pdb/test_pdb.rb +7 -24
  240. data/test/unit/bio/db/test_aaindex.rb +2 -2
  241. data/test/unit/bio/db/test_fasta.rb +3 -16
  242. data/test/unit/bio/db/test_gff.rb +3 -16
  243. data/test/unit/bio/db/test_lasergene.rb +95 -0
  244. data/test/unit/bio/db/test_newick.rb +56 -0
  245. data/test/unit/bio/db/test_nexus.rb +360 -0
  246. data/test/unit/bio/db/test_prosite.rb +5 -18
  247. data/test/unit/bio/db/test_rebase.rb +11 -25
  248. data/test/unit/bio/db/test_soft.rb +138 -0
  249. data/test/unit/bio/io/test_ddbjxml.rb +5 -17
  250. data/test/unit/bio/io/test_ensembl.rb +109 -0
  251. data/test/unit/bio/io/test_fastacmd.rb +3 -16
  252. data/test/unit/bio/io/test_flatfile.rb +237 -0
  253. data/test/unit/bio/io/test_soapwsdl.rb +4 -17
  254. data/test/unit/bio/sequence/test_aa.rb +3 -3
  255. data/test/unit/bio/sequence/test_common.rb +3 -16
  256. data/test/unit/bio/sequence/test_compat.rb +3 -16
  257. data/test/unit/bio/sequence/test_na.rb +29 -3
  258. data/test/unit/bio/shell/plugin/test_seq.rb +8 -8
  259. data/test/unit/bio/test_alignment.rb +16 -27
  260. data/test/unit/bio/test_command.rb +242 -25
  261. data/test/unit/bio/test_db.rb +3 -16
  262. data/test/unit/bio/test_feature.rb +4 -16
  263. data/test/unit/bio/test_location.rb +4 -16
  264. data/test/unit/bio/test_map.rb +230 -0
  265. data/test/unit/bio/test_pathway.rb +4 -16
  266. data/test/unit/bio/test_reference.rb +2 -2
  267. data/test/unit/bio/test_sequence.rb +7 -19
  268. data/test/unit/bio/test_shell.rb +3 -16
  269. data/test/unit/bio/test_tree.rb +593 -0
  270. data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
  271. data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
  272. data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
  273. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +100 -0
  274. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
  275. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
  276. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
  277. data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
  278. data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
  279. data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
  280. data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
  281. data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
  282. data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
  283. data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
  284. data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
  285. data/test/unit/bio/util/test_color_scheme.rb +6 -18
  286. data/test/unit/bio/util/test_contingency_table.rb +6 -18
  287. data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
  288. data/test/unit/bio/util/test_sirna.rb +3 -16
  289. metadata +228 -169
  290. data/doc/BioRuby.rd.ja +0 -225
  291. data/doc/Design.rd.ja +0 -341
  292. data/doc/TODO.rd.ja +0 -138
  293. data/lib/bio/appl/fasta/format6.rb +0 -37
  294. data/lib/bio/db/kegg/cell.rb +0 -88
  295. data/lib/bio/db/kegg/ko.rb +0 -178
  296. data/lib/bio/shell/rails/Rakefile +0 -10
  297. data/lib/bio/shell/rails/app/controllers/application.rb +0 -4
  298. data/lib/bio/shell/rails/app/controllers/shell_controller.rb +0 -94
  299. data/lib/bio/shell/rails/app/helpers/application_helper.rb +0 -3
  300. data/lib/bio/shell/rails/app/models/shell_connection.rb +0 -30
  301. data/lib/bio/shell/rails/app/views/layouts/shell.rhtml +0 -37
  302. data/lib/bio/shell/rails/app/views/shell/history.rhtml +0 -5
  303. data/lib/bio/shell/rails/app/views/shell/index.rhtml +0 -2
  304. data/lib/bio/shell/rails/app/views/shell/show.rhtml +0 -13
  305. data/lib/bio/shell/rails/config/boot.rb +0 -19
  306. data/lib/bio/shell/rails/config/database.yml +0 -85
  307. data/lib/bio/shell/rails/config/environment.rb +0 -53
  308. data/lib/bio/shell/rails/config/environments/development.rb +0 -19
  309. data/lib/bio/shell/rails/config/environments/production.rb +0 -19
  310. data/lib/bio/shell/rails/config/environments/test.rb +0 -19
  311. data/lib/bio/shell/rails/config/routes.rb +0 -19
  312. data/lib/bio/shell/rails/doc/README_FOR_APP +0 -2
  313. data/lib/bio/shell/rails/public/404.html +0 -8
  314. data/lib/bio/shell/rails/public/500.html +0 -8
  315. data/lib/bio/shell/rails/public/dispatch.cgi +0 -10
  316. data/lib/bio/shell/rails/public/dispatch.fcgi +0 -24
  317. data/lib/bio/shell/rails/public/dispatch.rb +0 -10
  318. data/lib/bio/shell/rails/public/favicon.ico +0 -0
  319. data/lib/bio/shell/rails/public/images/rails.png +0 -0
  320. data/lib/bio/shell/rails/public/index.html +0 -277
  321. data/lib/bio/shell/rails/public/javascripts/controls.js +0 -750
  322. data/lib/bio/shell/rails/public/javascripts/dragdrop.js +0 -584
  323. data/lib/bio/shell/rails/public/javascripts/effects.js +0 -854
  324. data/lib/bio/shell/rails/public/javascripts/prototype.js +0 -1785
  325. data/lib/bio/shell/rails/public/robots.txt +0 -1
  326. data/lib/bio/shell/rails/public/stylesheets/main.css +0 -187
  327. data/lib/bio/shell/rails/script/about +0 -3
  328. data/lib/bio/shell/rails/script/breakpointer +0 -3
  329. data/lib/bio/shell/rails/script/console +0 -3
  330. data/lib/bio/shell/rails/script/destroy +0 -3
  331. data/lib/bio/shell/rails/script/generate +0 -3
  332. data/lib/bio/shell/rails/script/performance/benchmarker +0 -3
  333. data/lib/bio/shell/rails/script/performance/profiler +0 -3
  334. data/lib/bio/shell/rails/script/plugin +0 -3
  335. data/lib/bio/shell/rails/script/process/reaper +0 -3
  336. data/lib/bio/shell/rails/script/process/spawner +0 -3
  337. data/lib/bio/shell/rails/script/process/spinner +0 -3
  338. data/lib/bio/shell/rails/script/runner +0 -3
  339. data/lib/bio/shell/rails/script/server +0 -42
  340. data/lib/bio/shell/rails/test/test_helper.rb +0 -28
@@ -1,8 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
- "http://www.w3.org/TR/html4/loose.dtd">
3
- <html>
4
- <body>
5
- <h1>File not found</h1>
6
- <p>Change this error message for pages not found in public/404.html</p>
7
- </body>
8
- </html>
@@ -1,8 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
- "http://www.w3.org/TR/html4/loose.dtd">
3
- <html>
4
- <body>
5
- <h1>Application error (Apache)</h1>
6
- <p>Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html</p>
7
- </body>
8
- </html>
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
-
5
- # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
- # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
- require "dispatcher"
8
-
9
- ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
- Dispatcher.dispatch
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # You may specify the path to the FastCGI crash log (a log of unhandled
4
- # exceptions which forced the FastCGI instance to exit, great for debugging)
5
- # and the number of requests to process before running garbage collection.
6
- #
7
- # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log
8
- # and the GC period is nil (turned off). A reasonable number of requests
9
- # could range from 10-100 depending on the memory footprint of your app.
10
- #
11
- # Example:
12
- # # Default log path, normal GC behavior.
13
- # RailsFCGIHandler.process!
14
- #
15
- # # Default log path, 50 requests between GC.
16
- # RailsFCGIHandler.process! nil, 50
17
- #
18
- # # Custom log path, normal GC behavior.
19
- # RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log'
20
- #
21
- require File.dirname(__FILE__) + "/../config/environment"
22
- require 'fcgi_handler'
23
-
24
- RailsFCGIHandler.process!
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
-
5
- # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
- # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
- require "dispatcher"
8
-
9
- ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
10
- Dispatcher.dispatch
File without changes
@@ -1,277 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html>
4
- <head>
5
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
- <title>Ruby on Rails: Welcome aboard</title>
7
- <style type="text/css" media="screen">
8
- body {
9
- margin: 0;
10
- margin-bottom: 25px;
11
- padding: 0;
12
- background-color: #f0f0f0;
13
- font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
14
- font-size: 13px;
15
- color: #333;
16
- }
17
-
18
- h1 {
19
- font-size: 28px;
20
- color: #000;
21
- }
22
-
23
- a {color: #03c}
24
- a:hover {
25
- background-color: #03c;
26
- color: white;
27
- text-decoration: none;
28
- }
29
-
30
-
31
- #page {
32
- background-color: #f0f0f0;
33
- width: 750px;
34
- margin: 0;
35
- margin-left: auto;
36
- margin-right: auto;
37
- }
38
-
39
- #content {
40
- float: left;
41
- background-color: white;
42
- border: 3px solid #aaa;
43
- border-top: none;
44
- padding: 25px;
45
- width: 500px;
46
- }
47
-
48
- #sidebar {
49
- float: right;
50
- width: 175px;
51
- }
52
-
53
- #footer {
54
- clear: both;
55
- }
56
-
57
-
58
- #header, #about, #getting-started {
59
- padding-left: 75px;
60
- padding-right: 30px;
61
- }
62
-
63
-
64
- #header {
65
- background-image: url("images/rails.png");
66
- background-repeat: no-repeat;
67
- background-position: top left;
68
- height: 64px;
69
- }
70
- #header h1, #header h2 {margin: 0}
71
- #header h2 {
72
- color: #888;
73
- font-weight: normal;
74
- font-size: 16px;
75
- }
76
-
77
-
78
- #about h3 {
79
- margin: 0;
80
- margin-bottom: 10px;
81
- font-size: 14px;
82
- }
83
-
84
- #about-content {
85
- background-color: #ffd;
86
- border: 1px solid #fc0;
87
- margin-left: -11px;
88
- }
89
- #about-content table {
90
- margin-top: 10px;
91
- margin-bottom: 10px;
92
- font-size: 11px;
93
- border-collapse: collapse;
94
- }
95
- #about-content td {
96
- padding: 10px;
97
- padding-top: 3px;
98
- padding-bottom: 3px;
99
- }
100
- #about-content td.name {color: #555}
101
- #about-content td.value {color: #000}
102
-
103
- #about-content.failure {
104
- background-color: #fcc;
105
- border: 1px solid #f00;
106
- }
107
- #about-content.failure p {
108
- margin: 0;
109
- padding: 10px;
110
- }
111
-
112
-
113
- #getting-started {
114
- border-top: 1px solid #ccc;
115
- margin-top: 25px;
116
- padding-top: 15px;
117
- }
118
- #getting-started h1 {
119
- margin: 0;
120
- font-size: 20px;
121
- }
122
- #getting-started h2 {
123
- margin: 0;
124
- font-size: 14px;
125
- font-weight: normal;
126
- color: #333;
127
- margin-bottom: 25px;
128
- }
129
- #getting-started ol {
130
- margin-left: 0;
131
- padding-left: 0;
132
- }
133
- #getting-started li {
134
- font-size: 18px;
135
- color: #888;
136
- margin-bottom: 25px;
137
- }
138
- #getting-started li h2 {
139
- margin: 0;
140
- font-weight: normal;
141
- font-size: 18px;
142
- color: #333;
143
- }
144
- #getting-started li p {
145
- color: #555;
146
- font-size: 13px;
147
- }
148
-
149
-
150
- #search {
151
- margin: 0;
152
- padding-top: 10px;
153
- padding-bottom: 10px;
154
- font-size: 11px;
155
- }
156
- #search input {
157
- font-size: 11px;
158
- margin: 2px;
159
- }
160
- #search-text {width: 170px}
161
-
162
-
163
- #sidebar ul {
164
- margin-left: 0;
165
- padding-left: 0;
166
- }
167
- #sidebar ul h3 {
168
- margin-top: 25px;
169
- font-size: 16px;
170
- padding-bottom: 10px;
171
- border-bottom: 1px solid #ccc;
172
- }
173
- #sidebar li {
174
- list-style-type: none;
175
- }
176
- #sidebar ul.links li {
177
- margin-bottom: 5px;
178
- }
179
-
180
- </style>
181
- <script type="text/javascript" src="javascripts/prototype.js"></script>
182
- <script type="text/javascript" src="javascripts/effects.js"></script>
183
- <script type="text/javascript">
184
- function about() {
185
- if (Element.empty('about-content')) {
186
- new Ajax.Updater('about-content', 'rails_info/properties', {
187
- method: 'get',
188
- onFailure: function() {Element.classNames('about-content').add('failure')},
189
- onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
190
- });
191
- } else {
192
- new Effect[Element.visible('about-content') ?
193
- 'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
194
- }
195
- }
196
-
197
- window.onload = function() {
198
- $('search-text').value = '';
199
- $('search').onsubmit = function() {
200
- $('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
201
- }
202
- }
203
- </script>
204
- </head>
205
- <body>
206
- <div id="page">
207
- <div id="sidebar">
208
- <ul id="sidebar-items">
209
- <li>
210
- <form id="search" action="http://www.google.com/search" method="get">
211
- <input type="hidden" name="hl" value="en" />
212
- <input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
213
- <input type="submit" value="Search" /> the Rails site
214
- </form>
215
- </li>
216
-
217
- <li>
218
- <h3>Join the community</h3>
219
- <ul class="links">
220
- <li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
221
- <li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
222
- <li><a href="http://lists.rubyonrails.org/">Mailing lists</a></li>
223
- <li><a href="http://wiki.rubyonrails.org/rails/pages/IRC">IRC channel</a></li>
224
- <li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
225
- <li><a href="http://dev.rubyonrails.org/">Bug tracker</a></li>
226
- </ul>
227
- </li>
228
-
229
- <li>
230
- <h3>Browse the documentation</h3>
231
- <ul class="links">
232
- <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
233
- <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
234
- <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
235
- </ul>
236
- </li>
237
- </ul>
238
- </div>
239
-
240
- <div id="content">
241
- <div id="header">
242
- <h1>Welcome aboard</h1>
243
- <h2>You&rsquo;re riding the Rails!</h2>
244
- </div>
245
-
246
- <div id="about">
247
- <h3><a href="rails_info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
248
- <div id="about-content" style="display: none"></div>
249
- </div>
250
-
251
- <div id="getting-started">
252
- <h1>Getting started</h1>
253
- <h2>Here&rsquo;s how to get rolling:</h2>
254
-
255
- <ol>
256
- <li>
257
- <h2>Create your databases and edit <tt>config/database.yml</tt></h2>
258
- <p>Rails needs to know your login and password.</p>
259
- </li>
260
-
261
- <li>
262
- <h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
263
- <p>To see all available options, run it without parameters.</p>
264
- </li>
265
-
266
- <li>
267
- <h2>Set up a default route and remove or rename this file</h2>
268
- <p>Routes are setup in config/routes.rb.</p>
269
- </li>
270
- </ol>
271
- </div>
272
- </div>
273
-
274
- <div id="footer">&nbsp;</div>
275
- </div>
276
- </body>
277
- </html>
@@ -1,750 +0,0 @@
1
- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
- // (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
3
- // (c) 2005 Jon Tirsen (http://www.tirsen.com)
4
- // Contributors:
5
- // Richard Livsey
6
- // Rahul Bhargava
7
- // Rob Wills
8
- //
9
- // See scriptaculous.js for full license.
10
-
11
- // Autocompleter.Base handles all the autocompletion functionality
12
- // that's independent of the data source for autocompletion. This
13
- // includes drawing the autocompletion menu, observing keyboard
14
- // and mouse events, and similar.
15
- //
16
- // Specific autocompleters need to provide, at the very least,
17
- // a getUpdatedChoices function that will be invoked every time
18
- // the text inside the monitored textbox changes. This method
19
- // should get the text for which to provide autocompletion by
20
- // invoking this.getToken(), NOT by directly accessing
21
- // this.element.value. This is to allow incremental tokenized
22
- // autocompletion. Specific auto-completion logic (AJAX, etc)
23
- // belongs in getUpdatedChoices.
24
- //
25
- // Tokenized incremental autocompletion is enabled automatically
26
- // when an autocompleter is instantiated with the 'tokens' option
27
- // in the options parameter, e.g.:
28
- // new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });
29
- // will incrementally autocomplete with a comma as the token.
30
- // Additionally, ',' in the above example can be replaced with
31
- // a token array, e.g. { tokens: [',', '\n'] } which
32
- // enables autocompletion on multiple tokens. This is most
33
- // useful when one of the tokens is \n (a newline), as it
34
- // allows smart autocompletion after linebreaks.
35
-
36
- var Autocompleter = {}
37
- Autocompleter.Base = function() {};
38
- Autocompleter.Base.prototype = {
39
- baseInitialize: function(element, update, options) {
40
- this.element = $(element);
41
- this.update = $(update);
42
- this.hasFocus = false;
43
- this.changed = false;
44
- this.active = false;
45
- this.index = 0;
46
- this.entryCount = 0;
47
-
48
- if (this.setOptions)
49
- this.setOptions(options);
50
- else
51
- this.options = options || {};
52
-
53
- this.options.paramName = this.options.paramName || this.element.name;
54
- this.options.tokens = this.options.tokens || [];
55
- this.options.frequency = this.options.frequency || 0.4;
56
- this.options.minChars = this.options.minChars || 1;
57
- this.options.onShow = this.options.onShow ||
58
- function(element, update){
59
- if(!update.style.position || update.style.position=='absolute') {
60
- update.style.position = 'absolute';
61
- Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight});
62
- }
63
- Effect.Appear(update,{duration:0.15});
64
- };
65
- this.options.onHide = this.options.onHide ||
66
- function(element, update){ new Effect.Fade(update,{duration:0.15}) };
67
-
68
- if (typeof(this.options.tokens) == 'string')
69
- this.options.tokens = new Array(this.options.tokens);
70
-
71
- this.observer = null;
72
-
73
- this.element.setAttribute('autocomplete','off');
74
-
75
- Element.hide(this.update);
76
-
77
- Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
78
- Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
79
- },
80
-
81
- show: function() {
82
- if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
83
- if(!this.iefix &&
84
- (navigator.appVersion.indexOf('MSIE')>0) &&
85
- (navigator.userAgent.indexOf('Opera')<0) &&
86
- (Element.getStyle(this.update, 'position')=='absolute')) {
87
- new Insertion.After(this.update,
88
- '<iframe id="' + this.update.id + '_iefix" '+
89
- 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +
90
- 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
91
- this.iefix = $(this.update.id+'_iefix');
92
- }
93
- if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
94
- },
95
-
96
- fixIEOverlapping: function() {
97
- Position.clone(this.update, this.iefix);
98
- this.iefix.style.zIndex = 1;
99
- this.update.style.zIndex = 2;
100
- Element.show(this.iefix);
101
- },
102
-
103
- hide: function() {
104
- this.stopIndicator();
105
- if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
106
- if(this.iefix) Element.hide(this.iefix);
107
- },
108
-
109
- startIndicator: function() {
110
- if(this.options.indicator) Element.show(this.options.indicator);
111
- },
112
-
113
- stopIndicator: function() {
114
- if(this.options.indicator) Element.hide(this.options.indicator);
115
- },
116
-
117
- onKeyPress: function(event) {
118
- if(this.active)
119
- switch(event.keyCode) {
120
- case Event.KEY_TAB:
121
- case Event.KEY_RETURN:
122
- this.selectEntry();
123
- Event.stop(event);
124
- case Event.KEY_ESC:
125
- this.hide();
126
- this.active = false;
127
- Event.stop(event);
128
- return;
129
- case Event.KEY_LEFT:
130
- case Event.KEY_RIGHT:
131
- return;
132
- case Event.KEY_UP:
133
- this.markPrevious();
134
- this.render();
135
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
136
- return;
137
- case Event.KEY_DOWN:
138
- this.markNext();
139
- this.render();
140
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
141
- return;
142
- }
143
- else
144
- if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN)
145
- return;
146
-
147
- this.changed = true;
148
- this.hasFocus = true;
149
-
150
- if(this.observer) clearTimeout(this.observer);
151
- this.observer =
152
- setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
153
- },
154
-
155
- onHover: function(event) {
156
- var element = Event.findElement(event, 'LI');
157
- if(this.index != element.autocompleteIndex)
158
- {
159
- this.index = element.autocompleteIndex;
160
- this.render();
161
- }
162
- Event.stop(event);
163
- },
164
-
165
- onClick: function(event) {
166
- var element = Event.findElement(event, 'LI');
167
- this.index = element.autocompleteIndex;
168
- this.selectEntry();
169
- this.hide();
170
- },
171
-
172
- onBlur: function(event) {
173
- // needed to make click events working
174
- setTimeout(this.hide.bind(this), 250);
175
- this.hasFocus = false;
176
- this.active = false;
177
- },
178
-
179
- render: function() {
180
- if(this.entryCount > 0) {
181
- for (var i = 0; i < this.entryCount; i++)
182
- this.index==i ?
183
- Element.addClassName(this.getEntry(i),"selected") :
184
- Element.removeClassName(this.getEntry(i),"selected");
185
-
186
- if(this.hasFocus) {
187
- this.show();
188
- this.active = true;
189
- }
190
- } else {
191
- this.active = false;
192
- this.hide();
193
- }
194
- },
195
-
196
- markPrevious: function() {
197
- if(this.index > 0) this.index--
198
- else this.index = this.entryCount-1;
199
- },
200
-
201
- markNext: function() {
202
- if(this.index < this.entryCount-1) this.index++
203
- else this.index = 0;
204
- },
205
-
206
- getEntry: function(index) {
207
- return this.update.firstChild.childNodes[index];
208
- },
209
-
210
- getCurrentEntry: function() {
211
- return this.getEntry(this.index);
212
- },
213
-
214
- selectEntry: function() {
215
- this.active = false;
216
- this.updateElement(this.getCurrentEntry());
217
- },
218
-
219
- updateElement: function(selectedElement) {
220
- if (this.options.updateElement) {
221
- this.options.updateElement(selectedElement);
222
- return;
223
- }
224
-
225
- var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
226
- var lastTokenPos = this.findLastToken();
227
- if (lastTokenPos != -1) {
228
- var newValue = this.element.value.substr(0, lastTokenPos + 1);
229
- var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
230
- if (whitespace)
231
- newValue += whitespace[0];
232
- this.element.value = newValue + value;
233
- } else {
234
- this.element.value = value;
235
- }
236
- this.element.focus();
237
-
238
- if (this.options.afterUpdateElement)
239
- this.options.afterUpdateElement(this.element, selectedElement);
240
- },
241
-
242
- updateChoices: function(choices) {
243
- if(!this.changed && this.hasFocus) {
244
- this.update.innerHTML = choices;
245
- Element.cleanWhitespace(this.update);
246
- Element.cleanWhitespace(this.update.firstChild);
247
-
248
- if(this.update.firstChild && this.update.firstChild.childNodes) {
249
- this.entryCount =
250
- this.update.firstChild.childNodes.length;
251
- for (var i = 0; i < this.entryCount; i++) {
252
- var entry = this.getEntry(i);
253
- entry.autocompleteIndex = i;
254
- this.addObservers(entry);
255
- }
256
- } else {
257
- this.entryCount = 0;
258
- }
259
-
260
- this.stopIndicator();
261
-
262
- this.index = 0;
263
- this.render();
264
- }
265
- },
266
-
267
- addObservers: function(element) {
268
- Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
269
- Event.observe(element, "click", this.onClick.bindAsEventListener(this));
270
- },
271
-
272
- onObserverEvent: function() {
273
- this.changed = false;
274
- if(this.getToken().length>=this.options.minChars) {
275
- this.startIndicator();
276
- this.getUpdatedChoices();
277
- } else {
278
- this.active = false;
279
- this.hide();
280
- }
281
- },
282
-
283
- getToken: function() {
284
- var tokenPos = this.findLastToken();
285
- if (tokenPos != -1)
286
- var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
287
- else
288
- var ret = this.element.value;
289
-
290
- return /\n/.test(ret) ? '' : ret;
291
- },
292
-
293
- findLastToken: function() {
294
- var lastTokenPos = -1;
295
-
296
- for (var i=0; i<this.options.tokens.length; i++) {
297
- var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
298
- if (thisTokenPos > lastTokenPos)
299
- lastTokenPos = thisTokenPos;
300
- }
301
- return lastTokenPos;
302
- }
303
- }
304
-
305
- Ajax.Autocompleter = Class.create();
306
- Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
307
- initialize: function(element, update, url, options) {
308
- this.baseInitialize(element, update, options);
309
- this.options.asynchronous = true;
310
- this.options.onComplete = this.onComplete.bind(this);
311
- this.options.defaultParams = this.options.parameters || null;
312
- this.url = url;
313
- },
314
-
315
- getUpdatedChoices: function() {
316
- entry = encodeURIComponent(this.options.paramName) + '=' +
317
- encodeURIComponent(this.getToken());
318
-
319
- this.options.parameters = this.options.callback ?
320
- this.options.callback(this.element, entry) : entry;
321
-
322
- if(this.options.defaultParams)
323
- this.options.parameters += '&' + this.options.defaultParams;
324
-
325
- new Ajax.Request(this.url, this.options);
326
- },
327
-
328
- onComplete: function(request) {
329
- this.updateChoices(request.responseText);
330
- }
331
-
332
- });
333
-
334
- // The local array autocompleter. Used when you'd prefer to
335
- // inject an array of autocompletion options into the page, rather
336
- // than sending out Ajax queries, which can be quite slow sometimes.
337
- //
338
- // The constructor takes four parameters. The first two are, as usual,
339
- // the id of the monitored textbox, and id of the autocompletion menu.
340
- // The third is the array you want to autocomplete from, and the fourth
341
- // is the options block.
342
- //
343
- // Extra local autocompletion options:
344
- // - choices - How many autocompletion choices to offer
345
- //
346
- // - partialSearch - If false, the autocompleter will match entered
347
- // text only at the beginning of strings in the
348
- // autocomplete array. Defaults to true, which will
349
- // match text at the beginning of any *word* in the
350
- // strings in the autocomplete array. If you want to
351
- // search anywhere in the string, additionally set
352
- // the option fullSearch to true (default: off).
353
- //
354
- // - fullSsearch - Search anywhere in autocomplete array strings.
355
- //
356
- // - partialChars - How many characters to enter before triggering
357
- // a partial match (unlike minChars, which defines
358
- // how many characters are required to do any match
359
- // at all). Defaults to 2.
360
- //
361
- // - ignoreCase - Whether to ignore case when autocompleting.
362
- // Defaults to true.
363
- //
364
- // It's possible to pass in a custom function as the 'selector'
365
- // option, if you prefer to write your own autocompletion logic.
366
- // In that case, the other options above will not apply unless
367
- // you support them.
368
-
369
- Autocompleter.Local = Class.create();
370
- Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
371
- initialize: function(element, update, array, options) {
372
- this.baseInitialize(element, update, options);
373
- this.options.array = array;
374
- },
375
-
376
- getUpdatedChoices: function() {
377
- this.updateChoices(this.options.selector(this));
378
- },
379
-
380
- setOptions: function(options) {
381
- this.options = Object.extend({
382
- choices: 10,
383
- partialSearch: true,
384
- partialChars: 2,
385
- ignoreCase: true,
386
- fullSearch: false,
387
- selector: function(instance) {
388
- var ret = []; // Beginning matches
389
- var partial = []; // Inside matches
390
- var entry = instance.getToken();
391
- var count = 0;
392
-
393
- for (var i = 0; i < instance.options.array.length &&
394
- ret.length < instance.options.choices ; i++) {
395
-
396
- var elem = instance.options.array[i];
397
- var foundPos = instance.options.ignoreCase ?
398
- elem.toLowerCase().indexOf(entry.toLowerCase()) :
399
- elem.indexOf(entry);
400
-
401
- while (foundPos != -1) {
402
- if (foundPos == 0 && elem.length != entry.length) {
403
- ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +
404
- elem.substr(entry.length) + "</li>");
405
- break;
406
- } else if (entry.length >= instance.options.partialChars &&
407
- instance.options.partialSearch && foundPos != -1) {
408
- if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
409
- partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +
410
- elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(
411
- foundPos + entry.length) + "</li>");
412
- break;
413
- }
414
- }
415
-
416
- foundPos = instance.options.ignoreCase ?
417
- elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
418
- elem.indexOf(entry, foundPos + 1);
419
-
420
- }
421
- }
422
- if (partial.length)
423
- ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
424
- return "<ul>" + ret.join('') + "</ul>";
425
- }
426
- }, options || {});
427
- }
428
- });
429
-
430
- // AJAX in-place editor
431
- //
432
- // see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
433
-
434
- // Use this if you notice weird scrolling problems on some browsers,
435
- // the DOM might be a bit confused when this gets called so do this
436
- // waits 1 ms (with setTimeout) until it does the activation
437
- Field.scrollFreeActivate = function(field) {
438
- setTimeout(function() {
439
- Field.activate(field);
440
- }, 1);
441
- }
442
-
443
- Ajax.InPlaceEditor = Class.create();
444
- Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
445
- Ajax.InPlaceEditor.prototype = {
446
- initialize: function(element, url, options) {
447
- this.url = url;
448
- this.element = $(element);
449
-
450
- this.options = Object.extend({
451
- okText: "ok",
452
- cancelText: "cancel",
453
- savingText: "Saving...",
454
- clickToEditText: "Click to edit",
455
- okText: "ok",
456
- rows: 1,
457
- onComplete: function(transport, element) {
458
- new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
459
- },
460
- onFailure: function(transport) {
461
- alert("Error communicating with the server: " + transport.responseText.stripTags());
462
- },
463
- callback: function(form) {
464
- return Form.serialize(form);
465
- },
466
- handleLineBreaks: true,
467
- loadingText: 'Loading...',
468
- savingClassName: 'inplaceeditor-saving',
469
- loadingClassName: 'inplaceeditor-loading',
470
- formClassName: 'inplaceeditor-form',
471
- highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
472
- highlightendcolor: "#FFFFFF",
473
- externalControl: null,
474
- ajaxOptions: {}
475
- }, options || {});
476
-
477
- if(!this.options.formId && this.element.id) {
478
- this.options.formId = this.element.id + "-inplaceeditor";
479
- if ($(this.options.formId)) {
480
- // there's already a form with that name, don't specify an id
481
- this.options.formId = null;
482
- }
483
- }
484
-
485
- if (this.options.externalControl) {
486
- this.options.externalControl = $(this.options.externalControl);
487
- }
488
-
489
- this.originalBackground = Element.getStyle(this.element, 'background-color');
490
- if (!this.originalBackground) {
491
- this.originalBackground = "transparent";
492
- }
493
-
494
- this.element.title = this.options.clickToEditText;
495
-
496
- this.onclickListener = this.enterEditMode.bindAsEventListener(this);
497
- this.mouseoverListener = this.enterHover.bindAsEventListener(this);
498
- this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
499
- Event.observe(this.element, 'click', this.onclickListener);
500
- Event.observe(this.element, 'mouseover', this.mouseoverListener);
501
- Event.observe(this.element, 'mouseout', this.mouseoutListener);
502
- if (this.options.externalControl) {
503
- Event.observe(this.options.externalControl, 'click', this.onclickListener);
504
- Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
505
- Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
506
- }
507
- },
508
- enterEditMode: function(evt) {
509
- if (this.saving) return;
510
- if (this.editing) return;
511
- this.editing = true;
512
- this.onEnterEditMode();
513
- if (this.options.externalControl) {
514
- Element.hide(this.options.externalControl);
515
- }
516
- Element.hide(this.element);
517
- this.createForm();
518
- this.element.parentNode.insertBefore(this.form, this.element);
519
- Field.scrollFreeActivate(this.editField);
520
- // stop the event to avoid a page refresh in Safari
521
- if (evt) {
522
- Event.stop(evt);
523
- }
524
- return false;
525
- },
526
- createForm: function() {
527
- this.form = document.createElement("form");
528
- this.form.id = this.options.formId;
529
- Element.addClassName(this.form, this.options.formClassName)
530
- this.form.onsubmit = this.onSubmit.bind(this);
531
-
532
- this.createEditField();
533
-
534
- if (this.options.textarea) {
535
- var br = document.createElement("br");
536
- this.form.appendChild(br);
537
- }
538
-
539
- okButton = document.createElement("input");
540
- okButton.type = "submit";
541
- okButton.value = this.options.okText;
542
- this.form.appendChild(okButton);
543
-
544
- cancelLink = document.createElement("a");
545
- cancelLink.href = "#";
546
- cancelLink.appendChild(document.createTextNode(this.options.cancelText));
547
- cancelLink.onclick = this.onclickCancel.bind(this);
548
- this.form.appendChild(cancelLink);
549
- },
550
- hasHTMLLineBreaks: function(string) {
551
- if (!this.options.handleLineBreaks) return false;
552
- return string.match(/<br/i) || string.match(/<p>/i);
553
- },
554
- convertHTMLLineBreaks: function(string) {
555
- return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
556
- },
557
- createEditField: function() {
558
- var text;
559
- if(this.options.loadTextURL) {
560
- text = this.options.loadingText;
561
- } else {
562
- text = this.getText();
563
- }
564
-
565
- if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
566
- this.options.textarea = false;
567
- var textField = document.createElement("input");
568
- textField.type = "text";
569
- textField.name = "value";
570
- textField.value = text;
571
- textField.style.backgroundColor = this.options.highlightcolor;
572
- var size = this.options.size || this.options.cols || 0;
573
- if (size != 0) textField.size = size;
574
- this.editField = textField;
575
- } else {
576
- this.options.textarea = true;
577
- var textArea = document.createElement("textarea");
578
- textArea.name = "value";
579
- textArea.value = this.convertHTMLLineBreaks(text);
580
- textArea.rows = this.options.rows;
581
- textArea.cols = this.options.cols || 40;
582
- this.editField = textArea;
583
- }
584
-
585
- if(this.options.loadTextURL) {
586
- this.loadExternalText();
587
- }
588
- this.form.appendChild(this.editField);
589
- },
590
- getText: function() {
591
- return this.element.innerHTML;
592
- },
593
- loadExternalText: function() {
594
- Element.addClassName(this.form, this.options.loadingClassName);
595
- this.editField.disabled = true;
596
- new Ajax.Request(
597
- this.options.loadTextURL,
598
- Object.extend({
599
- asynchronous: true,
600
- onComplete: this.onLoadedExternalText.bind(this)
601
- }, this.options.ajaxOptions)
602
- );
603
- },
604
- onLoadedExternalText: function(transport) {
605
- Element.removeClassName(this.form, this.options.loadingClassName);
606
- this.editField.disabled = false;
607
- this.editField.value = transport.responseText.stripTags();
608
- },
609
- onclickCancel: function() {
610
- this.onComplete();
611
- this.leaveEditMode();
612
- return false;
613
- },
614
- onFailure: function(transport) {
615
- this.options.onFailure(transport);
616
- if (this.oldInnerHTML) {
617
- this.element.innerHTML = this.oldInnerHTML;
618
- this.oldInnerHTML = null;
619
- }
620
- return false;
621
- },
622
- onSubmit: function() {
623
- // onLoading resets these so we need to save them away for the Ajax call
624
- var form = this.form;
625
- var value = this.editField.value;
626
-
627
- // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
628
- // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
629
- // to be displayed indefinitely
630
- this.onLoading();
631
-
632
- new Ajax.Updater(
633
- {
634
- success: this.element,
635
- // don't update on failure (this could be an option)
636
- failure: null
637
- },
638
- this.url,
639
- Object.extend({
640
- parameters: this.options.callback(form, value),
641
- onComplete: this.onComplete.bind(this),
642
- onFailure: this.onFailure.bind(this)
643
- }, this.options.ajaxOptions)
644
- );
645
- // stop the event to avoid a page refresh in Safari
646
- if (arguments.length > 1) {
647
- Event.stop(arguments[0]);
648
- }
649
- return false;
650
- },
651
- onLoading: function() {
652
- this.saving = true;
653
- this.removeForm();
654
- this.leaveHover();
655
- this.showSaving();
656
- },
657
- showSaving: function() {
658
- this.oldInnerHTML = this.element.innerHTML;
659
- this.element.innerHTML = this.options.savingText;
660
- Element.addClassName(this.element, this.options.savingClassName);
661
- this.element.style.backgroundColor = this.originalBackground;
662
- Element.show(this.element);
663
- },
664
- removeForm: function() {
665
- if(this.form) {
666
- if (this.form.parentNode) Element.remove(this.form);
667
- this.form = null;
668
- }
669
- },
670
- enterHover: function() {
671
- if (this.saving) return;
672
- this.element.style.backgroundColor = this.options.highlightcolor;
673
- if (this.effect) {
674
- this.effect.cancel();
675
- }
676
- Element.addClassName(this.element, this.options.hoverClassName)
677
- },
678
- leaveHover: function() {
679
- if (this.options.backgroundColor) {
680
- this.element.style.backgroundColor = this.oldBackground;
681
- }
682
- Element.removeClassName(this.element, this.options.hoverClassName)
683
- if (this.saving) return;
684
- this.effect = new Effect.Highlight(this.element, {
685
- startcolor: this.options.highlightcolor,
686
- endcolor: this.options.highlightendcolor,
687
- restorecolor: this.originalBackground
688
- });
689
- },
690
- leaveEditMode: function() {
691
- Element.removeClassName(this.element, this.options.savingClassName);
692
- this.removeForm();
693
- this.leaveHover();
694
- this.element.style.backgroundColor = this.originalBackground;
695
- Element.show(this.element);
696
- if (this.options.externalControl) {
697
- Element.show(this.options.externalControl);
698
- }
699
- this.editing = false;
700
- this.saving = false;
701
- this.oldInnerHTML = null;
702
- this.onLeaveEditMode();
703
- },
704
- onComplete: function(transport) {
705
- this.leaveEditMode();
706
- this.options.onComplete.bind(this)(transport, this.element);
707
- },
708
- onEnterEditMode: function() {},
709
- onLeaveEditMode: function() {},
710
- dispose: function() {
711
- if (this.oldInnerHTML) {
712
- this.element.innerHTML = this.oldInnerHTML;
713
- }
714
- this.leaveEditMode();
715
- Event.stopObserving(this.element, 'click', this.onclickListener);
716
- Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
717
- Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
718
- if (this.options.externalControl) {
719
- Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
720
- Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
721
- Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
722
- }
723
- }
724
- };
725
-
726
- // Delayed observer, like Form.Element.Observer,
727
- // but waits for delay after last key input
728
- // Ideal for live-search fields
729
-
730
- Form.Element.DelayedObserver = Class.create();
731
- Form.Element.DelayedObserver.prototype = {
732
- initialize: function(element, delay, callback) {
733
- this.delay = delay || 0.5;
734
- this.element = $(element);
735
- this.callback = callback;
736
- this.timer = null;
737
- this.lastValue = $F(this.element);
738
- Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
739
- },
740
- delayedListener: function(event) {
741
- if(this.lastValue == $F(this.element)) return;
742
- if(this.timer) clearTimeout(this.timer);
743
- this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
744
- this.lastValue = $F(this.element);
745
- },
746
- onTimerEvent: function() {
747
- this.timer = null;
748
- this.callback(this.element, $F(this.element));
749
- }
750
- };