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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +40 -0
- data/README.md +3 -0
- data/lexers +0 -0
- data/lib/pygments/popen.rb +3 -2
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -1
- data/vendor/pygments-main/AUTHORS +20 -1
- data/vendor/pygments-main/CHANGES +55 -3
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/MANIFEST.in +1 -1
- data/vendor/pygments-main/Makefile +5 -8
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/doc/Makefile +153 -0
- data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
- data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
- data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
- data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
- data/vendor/pygments-main/doc/conf.py +249 -0
- data/vendor/pygments-main/doc/docs/api.rst +316 -0
- data/vendor/pygments-main/doc/docs/authors.rst +4 -0
- data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
- data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
- data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
- data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
- data/vendor/pygments-main/doc/docs/index.rst +66 -0
- data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
- data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
- data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
- data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
- data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
- data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
- data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
- data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
- data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
- data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
- data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
- data/vendor/pygments-main/doc/download.rst +41 -0
- data/vendor/pygments-main/doc/faq.rst +143 -0
- data/vendor/pygments-main/doc/index.rst +53 -0
- data/vendor/pygments-main/doc/languages.rst +151 -0
- data/vendor/pygments-main/doc/make.bat +190 -0
- data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
- data/vendor/pygments-main/external/autopygmentize +65 -48
- data/vendor/pygments-main/external/markdown-processor.py +15 -15
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +2 -3
- data/vendor/pygments-main/ez_setup.py +340 -234
- data/vendor/pygments-main/pygments/__init__.py +4 -4
- data/vendor/pygments-main/pygments/cmdline.py +81 -68
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
- data/vendor/pygments-main/pygments/formatter.py +3 -3
- data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
- data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +44 -26
- data/vendor/pygments-main/pygments/formatters/img.py +21 -14
- data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
- data/vendor/pygments-main/pygments/formatters/other.py +53 -6
- data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
- data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
- data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
- data/vendor/pygments-main/pygments/lexer.py +59 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
- data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
- data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
- data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
- data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
- data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
- data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
- data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
- data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
- data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
- data/vendor/pygments-main/pygments/lexers/math.py +438 -70
- data/vendor/pygments-main/pygments/lexers/other.py +885 -171
- data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
- data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
- data/vendor/pygments-main/pygments/lexers/special.py +7 -8
- data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
- data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
- data/vendor/pygments-main/pygments/lexers/text.py +208 -46
- data/vendor/pygments-main/pygments/lexers/web.py +729 -264
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/sphinxext.py +153 -0
- data/vendor/pygments-main/pygments/style.py +3 -2
- data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/igor.py +29 -0
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
- data/vendor/pygments-main/pygments/token.py +4 -1
- data/vendor/pygments-main/pygments/unistring.py +6 -5
- data/vendor/pygments-main/pygments/util.py +35 -21
- data/vendor/pygments-main/scripts/check_sources.py +28 -44
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
- data/vendor/pygments-main/scripts/find_codetags.py +27 -19
- data/vendor/pygments-main/scripts/find_error.py +16 -13
- data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
- data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
- data/vendor/pygments-main/setup.py +19 -19
- data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
- data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
- data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
- data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
- data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
- data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
- data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
- data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
- data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
- data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
- data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
- data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
- data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
- data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
- data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
- data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
- data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
- data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
- data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
- data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
- data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
- data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
- data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
- data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
- data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
- data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
- data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
- data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
- data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
- data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
- data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
- data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
- data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
- data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
- data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
- data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
- data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
- data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
- data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
- data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
- data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
- data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
- data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
- data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
- data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
- data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
- data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
- data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
- data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
- data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
- data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
- data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
- data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
- data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
- data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
- data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
- data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
- data/vendor/pygments-main/tests/run.py +14 -19
- data/vendor/pygments-main/tests/string_asserts.py +22 -0
- data/vendor/pygments-main/tests/test_basic_api.py +28 -14
- data/vendor/pygments-main/tests/test_cfm.py +46 -0
- data/vendor/pygments-main/tests/test_clexer.py +208 -3
- data/vendor/pygments-main/tests/test_cmdline.py +6 -5
- data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
- data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
- data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
- data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
- data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
- data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
- data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
- data/vendor/pygments-main/tests/test_token.py +3 -3
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +1 -1
- metadata +138 -51
- data/vendor/pygments-main/docs/generate.py +0 -472
- data/vendor/pygments-main/docs/src/api.txt +0 -270
- data/vendor/pygments-main/docs/src/authors.txt +0 -5
- data/vendor/pygments-main/docs/src/changelog.txt +0 -5
- data/vendor/pygments-main/docs/src/index.txt +0 -69
- data/vendor/pygments-main/docs/src/installation.txt +0 -71
- data/vendor/pygments-main/external/rst-directive-old.py +0 -77
- data/vendor/pygments-main/scripts/reindent.py +0 -291
- data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
- 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
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
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
|
-
|
|
170
|
-
|
|
96
|
+
@doc ~S'''
|
|
97
|
+
No #{interpolation} of any kind.
|
|
98
|
+
\000 \x{ff}
|
|
171
99
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
325
|
-
|
|
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
|
-
|
|
110
|
+
# Structs
|
|
111
|
+
defmodule Second.Module do
|
|
112
|
+
s = %Long.Module.Name{name: "Silly"}
|
|
113
|
+
%{s | height: {192, :cm}}
|
|
114
|
+
end
|
|
338
115
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
116
|
+
# Types, pseudo-vars, attributes
|
|
117
|
+
defmodule M do
|
|
118
|
+
@custom_attr :some_constant
|
|
342
119
|
|
|
343
|
-
|
|
344
|
-
defp to_char_list(bin) when is_binary(bin), do: binary_to_list(bin)
|
|
120
|
+
@before_compile Long.Module.Name
|
|
345
121
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
end
|
|
122
|
+
@typedoc "This is a type"
|
|
123
|
+
@type typ :: integer
|
|
349
124
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
end
|
|
363
|
-
|
|
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"
|