pygments.rb 0.5.4 → 0.6.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 (267) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +3 -0
  4. data/lexers +0 -0
  5. data/lib/pygments/popen.rb +3 -2
  6. data/lib/pygments/version.rb +1 -1
  7. data/pygments.rb.gemspec +2 -1
  8. data/vendor/pygments-main/AUTHORS +20 -1
  9. data/vendor/pygments-main/CHANGES +55 -3
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/MANIFEST.in +1 -1
  12. data/vendor/pygments-main/Makefile +5 -8
  13. data/vendor/pygments-main/REVISION +1 -1
  14. data/vendor/pygments-main/doc/Makefile +153 -0
  15. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  16. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  17. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  18. data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
  19. data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
  20. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
  21. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  22. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  23. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  24. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  25. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  26. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
  27. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
  28. data/vendor/pygments-main/doc/conf.py +249 -0
  29. data/vendor/pygments-main/doc/docs/api.rst +316 -0
  30. data/vendor/pygments-main/doc/docs/authors.rst +4 -0
  31. data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
  32. data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
  33. data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
  34. data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
  35. data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
  36. data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
  37. data/vendor/pygments-main/doc/docs/index.rst +66 -0
  38. data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
  39. data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
  40. data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
  41. data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
  42. data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
  43. data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
  44. data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
  45. data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
  46. data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
  47. data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
  48. data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
  49. data/vendor/pygments-main/doc/download.rst +41 -0
  50. data/vendor/pygments-main/doc/faq.rst +143 -0
  51. data/vendor/pygments-main/doc/index.rst +53 -0
  52. data/vendor/pygments-main/doc/languages.rst +151 -0
  53. data/vendor/pygments-main/doc/make.bat +190 -0
  54. data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
  55. data/vendor/pygments-main/external/autopygmentize +65 -48
  56. data/vendor/pygments-main/external/markdown-processor.py +15 -15
  57. data/vendor/pygments-main/external/moin-parser.py +1 -1
  58. data/vendor/pygments-main/external/rst-directive.py +2 -3
  59. data/vendor/pygments-main/ez_setup.py +340 -234
  60. data/vendor/pygments-main/pygments/__init__.py +4 -4
  61. data/vendor/pygments-main/pygments/cmdline.py +81 -68
  62. data/vendor/pygments-main/pygments/console.py +1 -1
  63. data/vendor/pygments-main/pygments/filter.py +1 -1
  64. data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
  65. data/vendor/pygments-main/pygments/formatter.py +3 -3
  66. data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
  67. data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
  68. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  69. data/vendor/pygments-main/pygments/formatters/html.py +44 -26
  70. data/vendor/pygments-main/pygments/formatters/img.py +21 -14
  71. data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
  72. data/vendor/pygments-main/pygments/formatters/other.py +53 -6
  73. data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
  74. data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
  75. data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
  76. data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
  77. data/vendor/pygments-main/pygments/lexer.py +59 -39
  78. data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
  79. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
  81. data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
  82. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
  83. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
  84. data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
  85. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
  86. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
  87. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
  88. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
  89. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
  91. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
  92. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
  94. data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
  95. data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
  96. data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
  97. data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
  98. data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
  99. data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
  100. data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
  101. data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
  102. data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
  103. data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
  104. data/vendor/pygments-main/pygments/lexers/math.py +438 -70
  105. data/vendor/pygments-main/pygments/lexers/other.py +885 -171
  106. data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
  107. data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
  108. data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
  109. data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
  110. data/vendor/pygments-main/pygments/lexers/special.py +7 -8
  111. data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
  112. data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
  113. data/vendor/pygments-main/pygments/lexers/text.py +208 -46
  114. data/vendor/pygments-main/pygments/lexers/web.py +729 -264
  115. data/vendor/pygments-main/pygments/modeline.py +1 -1
  116. data/vendor/pygments-main/pygments/plugin.py +1 -1
  117. data/vendor/pygments-main/pygments/scanner.py +1 -1
  118. data/vendor/pygments-main/pygments/sphinxext.py +153 -0
  119. data/vendor/pygments-main/pygments/style.py +3 -2
  120. data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
  121. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  122. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  123. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  124. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  125. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  126. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  127. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  128. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  129. data/vendor/pygments-main/pygments/styles/igor.py +29 -0
  130. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  131. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  132. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  133. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  134. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
  135. data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
  136. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  137. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  138. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  139. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  140. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  141. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  142. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  143. data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
  144. data/vendor/pygments-main/pygments/token.py +4 -1
  145. data/vendor/pygments-main/pygments/unistring.py +6 -5
  146. data/vendor/pygments-main/pygments/util.py +35 -21
  147. data/vendor/pygments-main/scripts/check_sources.py +28 -44
  148. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
  149. data/vendor/pygments-main/scripts/find_codetags.py +27 -19
  150. data/vendor/pygments-main/scripts/find_error.py +16 -13
  151. data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
  152. data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
  153. data/vendor/pygments-main/setup.py +19 -19
  154. data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
  155. data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
  156. data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
  157. data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
  158. data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
  159. data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
  160. data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
  161. data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
  162. data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
  163. data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
  164. data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
  165. data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
  166. data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
  167. data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
  168. data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
  169. data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
  170. data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
  171. data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
  172. data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
  173. data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
  174. data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
  175. data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
  176. data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
  177. data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
  178. data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
  179. data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
  180. data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
  181. data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
  182. data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
  183. data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
  184. data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
  185. data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
  191. data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
  196. data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
  197. data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
  198. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
  199. data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
  200. data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
  201. data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
  202. data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
  203. data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
  204. data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
  205. data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
  206. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
  207. data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
  208. data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
  209. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
  210. data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
  211. data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
  212. data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
  213. data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
  214. data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
  215. data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
  216. data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
  217. data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
  218. data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
  219. data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
  220. data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
  221. data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
  222. data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
  223. data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
  224. data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
  225. data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
  226. data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
  227. data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
  228. data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
  229. data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
  230. data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
  231. data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
  232. data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
  233. data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
  234. data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
  235. data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
  236. data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
  237. data/vendor/pygments-main/tests/run.py +14 -19
  238. data/vendor/pygments-main/tests/string_asserts.py +22 -0
  239. data/vendor/pygments-main/tests/test_basic_api.py +28 -14
  240. data/vendor/pygments-main/tests/test_cfm.py +46 -0
  241. data/vendor/pygments-main/tests/test_clexer.py +208 -3
  242. data/vendor/pygments-main/tests/test_cmdline.py +6 -5
  243. data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
  244. data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
  245. data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
  246. data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
  247. data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
  248. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  249. data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
  250. data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
  251. data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
  252. data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
  253. data/vendor/pygments-main/tests/test_token.py +3 -3
  254. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  255. data/vendor/pygments-main/tests/test_util.py +1 -1
  256. metadata +138 -51
  257. data/vendor/pygments-main/docs/generate.py +0 -472
  258. data/vendor/pygments-main/docs/src/api.txt +0 -270
  259. data/vendor/pygments-main/docs/src/authors.txt +0 -5
  260. data/vendor/pygments-main/docs/src/changelog.txt +0 -5
  261. data/vendor/pygments-main/docs/src/index.txt +0 -69
  262. data/vendor/pygments-main/docs/src/installation.txt +0 -71
  263. data/vendor/pygments-main/external/rst-directive-old.py +0 -77
  264. data/vendor/pygments-main/scripts/reindent.py +0 -291
  265. data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
  266. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
  267. data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ printf "%d %s\n" 10 "foo"
4
+ printf "%d %s\n" $((10#1)) "bar"
5
+
6
+ let "m = 10#${1:1:2}"
7
+ echo $m
8
+
9
+ m=$((10#${1:4:3} + 10#${1:1:3}))
10
+ echo $m
11
+
12
+ m=$((10#${1:4:3}))
13
+ echo $m
14
+
15
+ m=$((10#$1))
16
+ echo $m
17
+
18
+ m=$((10#1))
19
+ echo $m
20
+
21
+ m=$((10))
22
+ echo $m
@@ -0,0 +1,31 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title Slim Examples
5
+ meta name="keywords" content="template language"
6
+ meta name="author" content=author
7
+ javascript:
8
+ alert('Slim supports embedded javascript!')
9
+
10
+ body
11
+ h1 Markup examples
12
+
13
+ #content
14
+ p This example shows you how a basic Slim file looks like.
15
+
16
+ == yield
17
+
18
+ - unless items.empty?
19
+ table
20
+ - for item in items do
21
+ tr
22
+ td.name = item.name
23
+ td.price = item.price
24
+ - else
25
+ p
26
+ | No items found. Please add some inventory.
27
+ Thank you!
28
+
29
+ div id="footer"
30
+ = render 'footer'
31
+ | Copyright (C) #{year} #{author}
@@ -0,0 +1,51 @@
1
+ include:
2
+ - moosefs
3
+
4
+ {% for mnt in salt['cmd.run']('ls /dev/data/moose*').split() %}
5
+ /mnt/moose{{ mnt[-1] }}:
6
+ mount.mounted:
7
+ - device: {{ mnt }}
8
+ - fstype: xfs
9
+ - mkmnt: True
10
+ file.directory:
11
+ - user: mfs
12
+ - group: mfs
13
+ - require:
14
+ - user: mfs
15
+ - group: mfs
16
+ {% endfor %}
17
+
18
+ /etc/mfshdd.cfg:
19
+ file.managed:
20
+ - source: salt://moosefs/mfshdd.cfg
21
+ - user: root
22
+ - group: root
23
+ - mode: 644
24
+ - template: jinja
25
+ - require:
26
+ - pkg: mfs-chunkserver
27
+
28
+ /etc/mfschunkserver.cfg:
29
+ file.managed:
30
+ - source: salt://moosefs/mfschunkserver.cfg
31
+ - user: root
32
+ - group: root
33
+ - mode: 644
34
+ - template: jinja
35
+ - require:
36
+ - pkg: mfs-chunkserver
37
+
38
+ mfs-chunkserver:
39
+ pkg:
40
+ - installed
41
+ mfschunkserver:
42
+ service:
43
+ - running
44
+ - require:
45
+ {% for mnt in salt['cmd.run']('ls /dev/data/moose*') %}
46
+ - mount: /mnt/moose{{ mnt[-1] }}
47
+ - file: /mnt/moose{{ mnt[-1] }}
48
+ {% endfor %}
49
+ - file: /etc/mfschunkserver.cfg
50
+ - file: /etc/mfshdd.cfg
51
+ - file: /var/lib/mfs
@@ -19,6 +19,7 @@ data {
19
19
  positive_ordered[3] wibble;
20
20
  corr_matrix[3] grault;
21
21
  cov_matrix[3] garply;
22
+ cholesky_factor_cov[3] waldo;
22
23
 
23
24
  real<lower=-1,upper=1> foo1;
24
25
  real<lower=0> foo2;
@@ -94,6 +95,7 @@ model {
94
95
  // lp__ should be highlighted
95
96
  // normal_log as a function
96
97
  lp__ <- lp__ + normal_log(plugh, 0, 1);
98
+ increment_log_prob(normal_log(plugh, 0, 1));
97
99
 
98
100
  // print statement and string literal
99
101
  print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: ");
@@ -0,0 +1,9 @@
1
+ (A) Call Mom @Phone +Family
2
+ (A) 2014-01-08 Schedule annual checkup +Health
3
+ (B) Outline chapter 5 +Novel @Computer
4
+ (C) Add cover sheets @Office +TPSReports
5
+ Plan backyard herb garden @Home
6
+ Pick up milk @GroceryStore
7
+ Research self-publishing services +Novel @Computer
8
+ x 2014-01-10 Download Todo.txt mobile app @Phone
9
+ x 2014-01-10 2014-01-07 Download Todo.txt CLI @Computer
@@ -0,0 +1,241 @@
1
+ <cfscript>
2
+ /**
3
+ ********************************************************************************
4
+ ContentBox - A Modular Content Platform
5
+ Copyright 2012 by Luis Majano and Ortus Solutions, Corp
6
+ www.gocontentbox.org | www.luismajano.com | www.ortussolutions.com
7
+ ********************************************************************************
8
+ Apache License, Version 2.0
9
+
10
+ Copyright Since [2012] [Luis Majano and Ortus Solutions,Corp]
11
+
12
+ Licensed under the Apache License, Version 2.0 (the "License");
13
+ you may not use this file except in compliance with the License.
14
+ You may obtain a copy of the License at
15
+
16
+ http://www.apache.org/licenses/LICENSE-2.0
17
+
18
+ Unless required by applicable law or agreed to in writing, software
19
+ distributed under the License is distributed on an "AS IS" BASIS,
20
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ See the License for the specific language governing permissions and
22
+ limitations under the License.
23
+ ********************************************************************************
24
+ * A generic content service for content objects
25
+ */
26
+ component extends="coldbox.system.orm.hibernate.VirtualEntityService" singleton{
27
+
28
+ // DI
29
+ property name="settingService" inject="id:settingService@cb";
30
+ property name="cacheBox" inject="cachebox";
31
+ property name="log" inject="logbox:logger:{this}";
32
+ property name="customFieldService" inject="customFieldService@cb";
33
+ property name="categoryService" inject="categoryService@cb";
34
+ property name="commentService" inject="commentService@cb";
35
+ property name="contentVersionService" inject="contentVersionService@cb";
36
+ property name="authorService" inject="authorService@cb";
37
+ property name="populator" inject="wirebox:populator";
38
+ property name="systemUtil" inject="SystemUtil@cb";
39
+
40
+ /*
41
+ * Constructor
42
+ * @entityName.hint The content entity name to bind this service to.
43
+ */
44
+ ContentService function init(entityName="cbContent"){
45
+ // init it
46
+ super.init(entityName=arguments.entityName, useQueryCaching=true);
47
+
48
+ // Test scope coloring in pygments
49
+ this.colorTestVar = "Just for testing pygments!";
50
+ cookie.colorTestVar = "";
51
+ client.colorTestVar = ""
52
+ session.colorTestVar = "";
53
+ application.colorTestVar = "";
54
+
55
+ return this;
56
+ }
57
+
58
+ /**
59
+ * Clear all content caches
60
+ * @async.hint Run it asynchronously or not, defaults to false
61
+ */
62
+ function clearAllCaches(boolean async=false){
63
+ var settings = settingService.getAllSettings(asStruct=true);
64
+ // Get appropriate cache provider
65
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
66
+ cache.clearByKeySnippet(keySnippet="cb-content",async=arguments.async);
67
+ return this;
68
+ }
69
+
70
+ /**
71
+ * Clear all page wrapper caches
72
+ * @async.hint Run it asynchronously or not, defaults to false
73
+ */
74
+ function clearAllPageWrapperCaches(boolean async=false){
75
+ var settings = settingService.getAllSettings(asStruct=true);
76
+ // Get appropriate cache provider
77
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
78
+ cache.clearByKeySnippet(keySnippet="cb-content-pagewrapper",async=arguments.async);
79
+ return this;
80
+ }
81
+
82
+ /**
83
+ * Clear all page wrapper caches
84
+ * @slug.hint The slug partial to clean on
85
+ * @async.hint Run it asynchronously or not, defaults to false
86
+ */
87
+ function clearPageWrapperCaches(required any slug, boolean async=false){
88
+ var settings = settingService.getAllSettings(asStruct=true);
89
+ // Get appropriate cache provider
90
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
91
+ cache.clearByKeySnippet(keySnippet="cb-content-pagewrapper-#arguments.slug#",async=arguments.async);
92
+ return this;
93
+ }
94
+
95
+ /**
96
+ * Clear a page wrapper cache
97
+ * @slug.hint The slug to clean
98
+ * @async.hint Run it asynchronously or not, defaults to false
99
+ */
100
+ function clearPageWrapper(required any slug, boolean async=false){
101
+ var settings = settingService.getAllSettings(asStruct=true);
102
+ // Get appropriate cache provider
103
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
104
+ cache.clear("cb-content-pagewrapper-#arguments.slug#/");
105
+ return this;
106
+ }
107
+
108
+ /**
109
+ * Searches published content with cool paramters, remember published content only
110
+ * @searchTerm.hint The search term to search
111
+ * @max.hint The maximum number of records to paginate
112
+ * @offset.hint The offset in the pagination
113
+ * @asQuery.hint Return as query or array of objects, defaults to array of objects
114
+ * @sortOrder.hint The sorting of the search results, defaults to publishedDate DESC
115
+ * @isPublished.hint Search for published, non-published or both content objects [true, false, 'all']
116
+ * @searchActiveContent.hint Search only content titles or both title and active content. Defaults to both.
117
+ */
118
+ function searchContent(
119
+ any searchTerm="",
120
+ numeric max=0,
121
+ numeric offset=0,
122
+ boolean asQuery=false,
123
+ any sortOrder="publishedDate DESC",
124
+ any isPublished=true,
125
+ boolean searchActiveContent=true){
126
+
127
+ var results = {};
128
+ var c = newCriteria();
129
+
130
+ // only published content
131
+ if( isBoolean( arguments.isPublished ) ){
132
+ // Published bit
133
+ c.isEq( "isPublished", javaCast( "Boolean", arguments.isPublished ) );
134
+ // Published eq true evaluate other params
135
+ if( arguments.isPublished ){
136
+ c.isLt("publishedDate", now() )
137
+ .$or( c.restrictions.isNull("expireDate"), c.restrictions.isGT("expireDate", now() ) )
138
+ .isEq("passwordProtection","");
139
+ }
140
+ }
141
+
142
+ // Search Criteria
143
+ if( len( arguments.searchTerm ) ){
144
+ // like disjunctions
145
+ c.createAlias("activeContent","ac");
146
+ // Do we search title and active content or just title?
147
+ if( arguments.searchActiveContent ){
148
+ c.$or( c.restrictions.like("title","%#arguments.searchTerm#%"),
149
+ c.restrictions.like("ac.content", "%#arguments.searchTerm#%") );
150
+ }
151
+ else{
152
+ c.like( "title", "%#arguments.searchTerm#%" );
153
+ }
154
+ }
155
+
156
+ // run criteria query and projections count
157
+ results.count = c.count( "contentID" );
158
+ results.content = c.resultTransformer( c.DISTINCT_ROOT_ENTITY )
159
+ .list(offset=arguments.offset, max=arguments.max, sortOrder=arguments.sortOrder, asQuery=arguments.asQuery);
160
+
161
+ return results;
162
+ }
163
+
164
+ /********************************************* PRIVATE *********************************************/
165
+
166
+
167
+ /**
168
+ * Update the content hits
169
+ * @contentID.hint The content id to update
170
+ */
171
+ private function syncUpdateHits(required contentID){
172
+ var q = new Query(sql="UPDATE cb_content SET hits = hits + 1 WHERE contentID = #arguments.contentID#").execute();
173
+ return this;
174
+ }
175
+
176
+
177
+ private function closureTest(){
178
+ methodCall(
179
+ param1,
180
+ function( arg1, required arg2 ){
181
+ var settings = settingService.getAllSettings(asStruct=true);
182
+ // Get appropriate cache provider
183
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
184
+ cache.clear("cb-content-pagewrapper-#arguments.slug#/");
185
+ return this;
186
+ },
187
+ param1
188
+ );
189
+ }
190
+
191
+ private function StructliteralTest(){
192
+ return {
193
+ foo = bar,
194
+ brad = 'Wood',
195
+ func = function( arg1, required arg2 ){
196
+ var settings = settingService.getAllSettings(asStruct=true);
197
+ // Get appropriate cache provider
198
+ var cache = cacheBox.getCache( settings.cb_content_cacheName );
199
+ cache.clear("cb-content-pagewrapper-#arguments.slug#/");
200
+ return this;
201
+ },
202
+ array = [
203
+ 1,
204
+ 2,
205
+ 3,
206
+ 4,
207
+ 5,
208
+ 'test',
209
+ 'testing',
210
+ 'testerton',
211
+ {
212
+ foo = true,
213
+ brad = false,
214
+ wood = null
215
+ }
216
+ ],
217
+ last = "final"
218
+ };
219
+ }
220
+
221
+ private function arrayliteralTest(){
222
+ return [
223
+ 1,
224
+ 2,
225
+ 3,
226
+ 4,
227
+ 5,
228
+ 'test',
229
+ 'testing',
230
+ 'testerton',
231
+ {
232
+ foo = true,
233
+ brad = false,
234
+ wood = null
235
+ },
236
+ 'testy-von-testavich'
237
+ ];
238
+ }
239
+
240
+ }
241
+ </cfscript>
@@ -0,0 +1,18 @@
1
+ <cfcomponent>
2
+
3
+ <cffunction name="init" access="public" returntype="any">
4
+ <cfargument name="arg1" type="any" required="true">
5
+ <cfset this.myVariable = arguments.arg1>
6
+
7
+ <cfreturn this>
8
+ </cffunction>
9
+
10
+ <cffunction name="testFunc" access="private" returntype="void">
11
+ <cfargument name="arg1" type="any" required="false">
12
+
13
+ <cfif structKeyExists(arguments, "arg1")>
14
+ <cfset writeoutput("Argument exists")>
15
+ </cfif>
16
+ </cffunction>
17
+
18
+ </cfcomponent>
@@ -1,363 +1,205 @@
1
- # We cannot use to_char_list because it depends on inspect,
2
- # which depends on protocol, which depends on this module.
3
- import Elixir::Builtin, except: [to_char_list: 1]
4
-
5
- defmodule Module do
6
- require Erlang.ets, as: ETS
7
-
8
- @moduledoc """
9
- This module provides many functions to deal with modules during
10
- compilation time. It allows a developer to dynamically attach
11
- documentation, merge data, register attributes and so forth.
12
-
13
- After the module is compiled, using many of the functions in
14
- this module will raise errors, since it is out of their purpose
15
- to inspect runtime data. Most of the runtime data can be inspected
16
- via the `__info__(attr)` function attached to each compiled module.
17
- """
18
-
19
- @doc """
20
- Evalutes the quotes contents in the given module context.
21
- Raises an error if the module was already compiled.
22
-
23
- ## Examples
24
-
25
- defmodule Foo do
26
- contents = quote do: (def sum(a, b), do: a + b)
27
- Module.eval_quoted __MODULE__, contents, [], __FILE__, __LINE__
28
- end
29
-
30
- Foo.sum(1, 2) #=> 3
31
- """
32
- def eval_quoted(module, quoted, binding, filename, line) do
33
- assert_not_compiled!(:eval_quoted, module)
34
- { binding, scope } = Erlang.elixir_module.binding_and_scope_for_eval(line, to_char_list(filename), module, binding)
35
- Erlang.elixir_def.reset_last(module)
36
- Erlang.elixir.eval_quoted([quoted], binding, line, scope)
37
- end
38
-
39
- @doc """
40
- Checks if the module is compiled or not.
41
-
42
- ## Examples
43
-
44
- defmodule Foo do
45
- Module.compiled?(__MODULE__) #=> false
46
- end
47
-
48
- Module.compiled?(Foo) #=> true
49
-
50
- """
51
- def compiled?(module) do
52
- table = data_table_for(module)
53
- table == ETS.info(table, :name)
54
- end
55
-
56
- @doc """
57
- Reads the data for the given module. This is used
58
- to read data of uncompiled modules. If the module
59
- was already compiled, you shoul access the data
60
- directly by invoking `__info__(:data)` in that module.
61
-
62
- ## Examples
63
-
64
- defmodule Foo do
65
- Module.merge_data __MODULE__, value: 1
66
- Module.read_data __MODULE__ #=> [value: 1]
67
- end
68
-
69
- """
70
- def read_data(module) do
71
- assert_not_compiled!(:read_data, module)
72
- ETS.lookup_element(data_table_for(module), :data, 2)
73
- end
74
-
75
- @doc """
76
- Reads the data from `module` at the given key `at`.
77
-
78
- ## Examples
79
-
80
- defmodule Foo do
81
- Module.merge_data __MODULE__, value: 1
82
- Module.read_data __MODULE__, :value #=> 1
83
- end
84
-
85
- """
86
- def read_data(module, at) do
87
- Orddict.get read_data(module), at
88
- end
89
-
90
- @doc """
91
- Merge the given data into the module, overriding any
92
- previous one.
93
-
94
- If any of the given data is a registered attribute, it is
95
- automatically added to the attribute set, instead of marking
96
- it as data. See register_attribute/2 and add_attribute/3 for
97
- more info.
98
-
99
- ## Examples
100
-
101
- defmodule Foo do
102
- Module.merge_data __MODULE__, value: 1
103
- end
104
-
105
- Foo.__info__(:data) #=> [value: 1]
106
-
107
- """
108
- def merge_data(module, data) do
109
- assert_not_compiled!(:merge_data, module)
110
-
111
- table = data_table_for(module)
112
- old = ETS.lookup_element(table, :data, 2)
113
- registered = ETS.lookup_element(table, :registered_attributes, 2)
114
-
115
- { attrs, new } = Enum.partition data, fn({k,_}) -> List.member?(registered, k) end
116
- Enum.each attrs, fn({k,v}) -> add_attribute(module, k, v) end
117
- ETS.insert(table, { :data, Orddict.merge(old, new) })
118
- end
119
-
120
- @doc """
121
- Attaches documentation to a given function. It expects
122
- the module the function belongs to, the line (a non negative
123
- integer), the kind (def or defmacro), a tuple representing
124
- the function and its arity and the documentation, which should
125
- be either a binary or a boolean.
126
-
127
- ## Examples
128
-
129
- defmodule MyModule do
130
- Module.add_doc(__MODULE__, __LINE__ + 1, :def, { :version, 0 }, "Manually added docs")
131
- def version, do: 1
132
- end
133
-
134
- """
135
- def add_doc(module, line, kind, tuple, doc) when
136
- is_binary(doc) or is_boolean(doc) do
137
- assert_not_compiled!(:add_doc, module)
138
- case kind do
139
- match: :defp
140
- :warn
141
- else:
142
- table = docs_table_for(module)
143
- ETS.insert(table, { tuple, line, kind, doc })
144
- :ok
145
- end
146
- end
1
+ # Numbers
2
+ 0b0101011
3
+ 1234 ; 0x1A ; 0xbeef ; 0763
4
+ 3.14 ; 5.0e21 ; 0.5e-12
5
+ 100_000_000
6
+
7
+ # Characters
8
+ ?a ; ?1 ; ?\n ; ?\s ; ?\c ; ? ; ?,
9
+ ?\x{12} ; ?\x{abcd}
10
+ ?\x34 ; ?\xf
11
+ ?\123 ; ?\12 ; ?\7
12
+
13
+ # Atoms
14
+ :this ; :that
15
+ :'complex atom'
16
+ :"with' \"\" 'quotes"
17
+ :" multi
18
+ line ' \s \123 \xff
19
+ atom"
20
+ :... ; :<<>> ; :%{} ; :% ; :{}
21
+ :++; :--; :*; :~~~
22
+
23
+ # Strings
24
+ "Hello world"
25
+ "Interspersed \x{ff} codes \7 \8 \65 \016 and \t\s\z\+ \\ escapes"
26
+ "Quotes ' inside \" \123 the \"\" \xF string \\\" end"
27
+ "Multiline
28
+ string"
29
+
30
+ # Char lists
31
+ 'this is a list'
32
+ 'escapes \' \t \\\''
33
+ 'Multiline
34
+ char
35
+ list
36
+ '
37
+
38
+ # Binaries
39
+ <<1, 2, 3>>
40
+ <<"hello"::binary, c :: utf8, x::[4, unit(2)]>> = "hello™1"
41
+
42
+ # Sigils
43
+ ~r/this + i\s "a" regex/
44
+ ~R'this + i\s "a" regex too'
45
+ ~w(hello #{ ["has" <> "123", '\c\d', "\123 interpol" | []] } world)s
46
+ ~W(hello #{no "123" \c\d \123 interpol} world)s
47
+
48
+ ~S"No escapes \s\t\n and no #{interpolation}"
49
+
50
+ :"atoms work #{"to" <> "o"}"
51
+
52
+ # Operators
53
+ x = 1 + 2.0 * 3
54
+ y = true and false; z = false xor true
55
+ ... = 144
56
+ ... == !x && y || z
57
+ "hello" |> String.upcase |> String.downcase()
58
+ {^z, a} = {true, x}
59
+
60
+ # Lists, tuples, maps, keywords
61
+ [1, :a, 'hello'] ++ [2, 3]
62
+ [:head | [?t, ?a, ?i, ?l]]
63
+
64
+ {:one, 2.0, "three"}
65
+
66
+ [...: "this", <<>>: "is", %{}: "a keyword", %: "list", {}: "too"]
67
+ ["this is an atom too": 1, "so is this": 2]
68
+ [option: "value", key: :word]
69
+ [++: "operator", ~~~: :&&&]
70
+
71
+ map = %{shortcut: "syntax"}
72
+ %{map | "update" => "me"}
73
+ %{ 12 => 13, :weird => ['thing'] }
74
+
75
+ # Comprehensions
76
+ for x <- 1..10, x < 5, do: {x, x}
77
+ pixels = "12345678"
78
+ for << <<r::4, g::4, b::4, a::4>> <- pixels >> do
79
+ [r, {g, %{"b" => a}}]
80
+ end
81
+
82
+ # String interpolation
83
+ "String #{inspect "interpolation"} is quite #{1+4+7} difficult"
84
+
85
+ # Modules
86
+ defmodule Long.Module.Name do
87
+ @moduledoc "Simple module docstring"
147
88
 
148
89
  @doc """
149
- Checks if a function was defined, regardless if it is
150
- a macro or a private function. Use function_defined?/3
151
- to assert for an specific type.
152
-
153
- ## Examples
154
-
155
- defmodule Example do
156
- Module.function_defined? __MODULE__, { :version, 0 } #=> false
157
- def version, do: 1
158
- Module.function_defined? __MODULE__, { :version, 0 } #=> true
159
- end
160
-
90
+ Multiline docstring
91
+ "with quotes"
92
+ and #{ %{"interpolation" => "in" <> "action"} }
161
93
  """
162
- def function_defined?(module, tuple) when is_tuple(tuple) do
163
- assert_not_compiled!(:function_defined?, module)
164
- table = function_table_for(module)
165
- ETS.lookup(table, tuple) != []
166
- end
94
+ defstruct [:a, :name, :height]
167
95
 
168
- @doc """
169
- Checks if a function was defined and also for its `kind`.
170
- `kind` can be either :def, :defp or :defmacro.
96
+ @doc ~S'''
97
+ No #{interpolation} of any kind.
98
+ \000 \x{ff}
171
99
 
172
- ## Examples
173
-
174
- defmodule Example do
175
- Module.function_defined? __MODULE__, { :version, 0 }, :defp #=> false
176
- def version, do: 1
177
- Module.function_defined? __MODULE__, { :version, 0 }, :defp #=> false
178
- end
179
-
180
- """
181
- def function_defined?(module, tuple, kind) do
182
- List.member? defined_functions(module, kind), tuple
183
- end
184
-
185
- @doc """
186
- Return all functions defined in the given module.
187
-
188
- ## Examples
189
-
190
- defmodule Example do
191
- def version, do: 1
192
- Module.defined_functions __MODULE__ #=> [{:version,1}]
193
- end
194
-
195
- """
196
- def defined_functions(module) do
197
- assert_not_compiled!(:defined_functions, module)
198
- table = function_table_for(module)
199
- lc { tuple, _, _ } in ETS.tab2list(table), do: tuple
200
- end
201
-
202
- @doc """
203
- Returns all functions defined in te given module according
204
- to its kind.
205
-
206
- ## Examples
207
-
208
- defmodule Example do
209
- def version, do: 1
210
- Module.defined_functions __MODULE__, :def #=> [{:version,1}]
211
- Module.defined_functions __MODULE__, :defp #=> []
212
- end
213
-
214
- """
215
- def defined_functions(module, kind) do
216
- assert_not_compiled!(:defined_functions, module)
217
- table = function_table_for(module)
218
- entry = kind_to_entry(kind)
219
- ETS.lookup_element(table, entry, 2)
220
- end
221
-
222
- @doc """
223
- Adds a compilation callback hook that is invoked
224
- exactly before the module is compiled.
225
-
226
- This callback is useful when used with `use` as a mechanism
227
- to clean up any internal data in the module before it is compiled.
228
-
229
- ## Examples
230
-
231
- Imagine you are creating a module/library that is meant for
232
- external usage called `MyLib`. It could be defined as:
233
-
234
- defmodule MyLib do
235
- def __using__(target) do
236
- Module.merge_data target, some_data: true
237
- Module.add_compile_callback(target, __MODULE__, :__callback__)
238
- end
239
-
240
- defmacro __callback__(target) do
241
- value = Orddict.get(Module.read_data(target), :some_data, [])
242
- quote do: (def my_lib_value, do: unquote(value))
243
- end
244
- end
245
-
246
- And a module could use `MyLib` with:
247
-
248
- defmodule App do
249
- use ModuleTest::ToBeUsed
250
- end
251
-
252
- In the example above, `MyLib` defines a data to the target. This data
253
- can be updated throughout the module definition and therefore, the final
254
- value of the data can only be compiled using a compiation callback,
255
- which will read the final value of :some_data and compile to a function.
256
- """
257
- def add_compile_callback(module, target, fun // :__compiling__) do
258
- assert_not_compiled!(:add_compile_callback, module)
259
- new = { target, fun }
260
- table = data_table_for(module)
261
- old = ETS.lookup_element(table, :compile_callbacks, 2)
262
- ETS.insert(table, { :compile_callbacks, [new|old] })
263
- end
264
-
265
- @doc """
266
- Adds an Erlang attribute to the given module with the given
267
- key and value. The same attribute can be added more than once.
268
-
269
- ## Examples
270
-
271
- defmodule MyModule do
272
- Module.add_attribute __MODULE__, :custom_threshold_for_lib, 10
273
- end
274
-
275
- """
276
- def add_attribute(module, key, value) when is_atom(key) do
277
- assert_not_compiled!(:add_attribute, module)
278
- table = data_table_for(module)
279
- attrs = ETS.lookup_element(table, :attributes, 2)
280
- ETS.insert(table, { :attributes, [{key, value}|attrs] })
281
- end
282
-
283
- @doc """
284
- Deletes all attributes that matches the given key.
285
-
286
- ## Examples
287
-
288
- defmodule MyModule do
289
- Module.add_attribute __MODULE__, :custom_threshold_for_lib, 10
290
- Module.delete_attribute __MODULE__, :custom_threshold_for_lib
291
- end
292
-
293
- """
294
- def delete_attribute(module, key) when is_atom(key) do
295
- assert_not_compiled!(:delete_attribute, module)
296
- table = data_table_for(module)
297
- attrs = ETS.lookup_element(table, :attributes, 2)
298
- final = lc {k,v} in attrs, k != key, do: {k,v}
299
- ETS.insert(table, { :attributes, final })
300
- end
301
-
302
- @doc """
303
- Registers an attribute. This allows a developer to use the data API
304
- but Elixir will register the data as an attribute automatically.
305
- By default, `vsn`, `behavior` and other Erlang attributes are
306
- automatically registered.
307
-
308
- ## Examples
309
-
310
- defmodule MyModule do
311
- Module.register_attribute __MODULE__, :custom_threshold_for_lib
312
- @custom_threshold_for_lib 10
313
- end
314
-
315
- """
316
- def register_attribute(module, new) do
317
- assert_not_compiled!(:register_attribute, module)
318
- table = data_table_for(module)
319
- old = ETS.lookup_element(table, :registered_attributes, 2)
320
- ETS.insert(table, { :registered_attributes, [new|old] })
321
- end
100
+ \n #{\x{ff}}
101
+ '''
102
+ def func(a, b \\ []), do: :ok
322
103
 
323
104
  @doc false
324
- # Used internally to compile documentation. This function
325
- # is private and must be used only internally.
326
- def compile_doc(module, line, kind, pair) do
327
- case read_data(module, :doc) do
328
- match: nil
329
- # We simply discard nil
330
- match: doc
331
- result = add_doc(module, line, kind, pair, doc)
332
- merge_data(module, doc: nil)
333
- result
334
- end
105
+ def __before_compile__(_) do
106
+ :ok
335
107
  end
108
+ end
336
109
 
337
- ## Helpers
110
+ # Structs
111
+ defmodule Second.Module do
112
+ s = %Long.Module.Name{name: "Silly"}
113
+ %{s | height: {192, :cm}}
114
+ end
338
115
 
339
- defp kind_to_entry(:def), do: :public
340
- defp kind_to_entry(:defp), do: :private
341
- defp kind_to_entry(:defmacro), do: :macros
116
+ # Types, pseudo-vars, attributes
117
+ defmodule M do
118
+ @custom_attr :some_constant
342
119
 
343
- defp to_char_list(list) when is_list(list), do: list
344
- defp to_char_list(bin) when is_binary(bin), do: binary_to_list(bin)
120
+ @before_compile Long.Module.Name
345
121
 
346
- defp data_table_for(module) do
347
- list_to_atom Erlang.lists.concat([:d, module])
348
- end
122
+ @typedoc "This is a type"
123
+ @type typ :: integer
349
124
 
350
- defp function_table_for(module) do
351
- list_to_atom Erlang.lists.concat([:f, module])
352
- end
353
-
354
- defp docs_table_for(module) do
355
- list_to_atom Erlang.lists.concat([:o, module])
356
- end
357
-
358
- defp assert_not_compiled!(fun, module) do
359
- compiled?(module) ||
360
- raise ArgumentError, message:
361
- "could not call #{fun} on module #{module} because it was already compiled"
362
- end
363
- end
125
+ @typedoc """
126
+ Another type
127
+ """
128
+ @opaque typtyp :: 1..10
129
+
130
+ @spec func(typ, typtyp) :: :ok | :fail
131
+ def func(a, b) do
132
+ a || b || :ok || :fail
133
+ Path.expand("..", __DIR__)
134
+ IO.inspect __ENV__
135
+ __NOTAPSEUDOVAR__ = 11
136
+ __MODULE__.func(b, a)
137
+ end
138
+
139
+ defmacro m() do
140
+ __CALLER__
141
+ end
142
+ end
143
+
144
+ # Functions
145
+ anon = fn x, y, z ->
146
+ fn(a, b, c) ->
147
+ &(x + y - z * a / &1 + b + div(&2, c))
148
+ end
149
+ end
150
+
151
+ &Set.put(&1, &2) ; & Set.put(&1, &2) ; &( Set.put(&1, &1) )
152
+
153
+ # Function calls
154
+ anon.(1, 2, 3); self; hd([1,2,3])
155
+ Kernel.spawn(fn -> :ok end)
156
+ IO.ANSI.black
157
+
158
+ # Control flow
159
+ if :this do
160
+ :that
161
+ else
162
+ :otherwise
163
+ end
164
+
165
+ pid = self
166
+ receive do
167
+ {:EXIT, _} -> :done
168
+ {^pid, :_} -> nil
169
+ after 100 -> :no_luck
170
+ end
171
+
172
+ case __ENV__.line do
173
+ x when is_integer(x) -> x
174
+ x when x in 1..12 -> -x
175
+ end
176
+
177
+ cond do
178
+ false -> "too bad"
179
+ 4 > 5 -> "oops"
180
+ true -> nil
181
+ end
182
+
183
+ # Lexical scope modifiers
184
+ import Kernel, except: [spawn: 1, +: 2, /: 2, Unless: 2]
185
+ alias Long.Module.Name, as: Namen
186
+ use Bitwise
187
+
188
+ 4 &&& 5
189
+ 2 <<< 3
190
+
191
+ # Protocols
192
+ defprotocol Useless do
193
+ def func1(this)
194
+ def func2(that)
195
+ end
196
+
197
+ defimpl Useless, for: Atom do
198
+ end
199
+
200
+ # Exceptions
201
+ defmodule NotAnError do
202
+ defexception [:message]
203
+ end
204
+
205
+ raise NotAnError, message: "This is not an error"