Merge pull request #812 from Golmote/prism-roboconf Add support for Roboconf
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
diff --git a/components.js b/components.js
index 7a221fc..deab8e1 100644
--- a/components.js
+++ b/components.js
@@ -416,6 +416,10 @@ var components = {
"title": "Rip",
"owner": "ravinggenius"
},
+ "roboconf": {
+ "title": "Roboconf",
+ "owner": "Golmote"
+ },
"ruby": {
"title": "Ruby",
"require": "clike",
diff --git a/components/prism-roboconf.js b/components/prism-roboconf.js
new file mode 100644
index 0000000..e52967f
--- /dev/null
+++ b/components/prism-roboconf.js
@@ -0,0 +1,27 @@
+Prism.languages.roboconf = {
+ 'comment': /#.*/,
+ 'keyword': {
+ 'pattern': /(^|\s)(?:(?:facet|instance of)(?=[ \t]+[\w-]+[ \t]*\{)|(?:external|import)\b)/,
+ lookbehind: true
+ },
+ 'component': {
+ pattern: /[\w-]+(?=[ \t]*\{)/,
+ alias: 'variable'
+ },
+ 'property': /[\w.-]+(?=[ \t]*:)/,
+ 'value': {
+ pattern: /(=[ \t]*)[^,;]+/,
+ lookbehind: true,
+ alias: 'attr-value'
+ },
+ 'optional': {
+ pattern: /\(optional\)/,
+ alias: 'builtin'
+ },
+ 'wildcard': {
+ pattern: /(\.)\*/,
+ lookbehind: true,
+ alias: 'operator'
+ },
+ 'punctuation': /[{},.;:=]/
+};
\ No newline at end of file
diff --git a/components/prism-roboconf.min.js b/components/prism-roboconf.min.js
new file mode 100644
index 0000000..39596eb
--- /dev/null
+++ b/components/prism-roboconf.min.js
@@ -0,0 +1 @@
+Prism.languages.roboconf={comment:/#.*/,keyword:{pattern:/(^|\s)(?:(?:facet|instance of)(?=[ \t]+[\w-]+[ \t]*\{)|(?:external|import)\b)/,lookbehind:!0},component:{pattern:/[\w-]+(?=[ \t]*\{)/,alias:"variable"},property:/[\w.-]+(?=[ \t]*:)/,value:{pattern:/(=[ \t]*)[^,;]+/,lookbehind:!0,alias:"attr-value"},optional:{pattern:/\(optional\)/,alias:"builtin"},wildcard:{pattern:/(\.)\*/,lookbehind:!0,alias:"operator"},punctuation:/[{},.;:=]/};
\ No newline at end of file
diff --git a/examples/prism-roboconf.html b/examples/prism-roboconf.html
new file mode 100644
index 0000000..6b5dbe7
--- /dev/null
+++ b/examples/prism-roboconf.html
@@ -0,0 +1,52 @@
+<h1>Roboconf</h1>
+<p>To use this language, use the class "language-roboconf".</p>
+
+<h2>Full example</h2>
+<pre><code>ApacheServer {
+ # Apache instances will be deployed by Roboconf's Puppet extension
+ installer: puppet;
+
+ # Web applications could be deployed over this Apache server
+ children: My-Dash-Board, Marketing-Suite;
+
+ # Properties exported by this component.
+ # 'port' should have a default value, or we will have to set it when we create an instance.
+ exports: port = 19099;
+
+ # 'ip' is a special variable. It will be updated at runtime by a Roboconf agent.
+ exports: ip;
+
+ # Other components properties that this server needs to have so that it can start.
+ imports: LB.port (optional), LB.ip (optional);
+
+ # Here, the Apache may also be notified about components instances of type LB.
+ # The imports are marked as optional. It means that if there is no LB instance, an
+ # Apache instance will be able to start anyway.
+ #
+ # If the import was not optional, e.g.
+ #
+ # imports: LB.port, LB.ip;
+ # or even
+ # imports: LB.port (optional), LB.ip;
+ #
+ # ... then an Apache instance would need at least one LB instance somewhere.
+
+ # Imports may also reference variables from other applications
+ imports: external Lamp.lb-ip;
+}
+
+facet LoadBalanced {
+ exports: ip, port; # Define we export two variables.
+}
+
+instance of VM {
+
+ # This will create 5 VM instances, called VM 1, VM 2, VM3, VM 4 and VM 5.
+ name: VM ; # Yes, there is a space at the end... :)
+ count: 5;
+
+ # On every VM instance, we will deploy...
+ instance of Tomcat {
+ name: Tomcat;
+ }
+}</code></pre>
diff --git a/tests/languages/roboconf/comment_feature.test b/tests/languages/roboconf/comment_feature.test
new file mode 100644
index 0000000..09493ab
--- /dev/null
+++ b/tests/languages/roboconf/comment_feature.test
@@ -0,0 +1,13 @@
+#
+# Foobar
+
+----------------------------------------------------
+
+[
+ ["comment", "#"],
+ ["comment", "# Foobar"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/roboconf/component_feature.test b/tests/languages/roboconf/component_feature.test
new file mode 100644
index 0000000..0e93486
--- /dev/null
+++ b/tests/languages/roboconf/component_feature.test
@@ -0,0 +1,13 @@
+ApacheServer {}
+lb--apache-mod-jk--puppet {}
+
+----------------------------------------------------
+
+[
+ ["component", "ApacheServer"], ["punctuation", "{"], ["punctuation", "}"],
+ ["component", "lb--apache-mod-jk--puppet"], ["punctuation", "{"], ["punctuation", "}"]
+]
+
+----------------------------------------------------
+
+Checks for component names.
\ No newline at end of file
diff --git a/tests/languages/roboconf/keyword_feature.test b/tests/languages/roboconf/keyword_feature.test
new file mode 100644
index 0000000..e9f8c79
--- /dev/null
+++ b/tests/languages/roboconf/keyword_feature.test
@@ -0,0 +1,19 @@
+facet Foo {}
+instance of Bar {}
+external
+import
+
+----------------------------------------------------
+
+[
+ ["keyword", "facet"],
+ ["component", "Foo"], ["punctuation", "{"], ["punctuation", "}"],
+ ["keyword", "instance of"],
+ ["component", "Bar"], ["punctuation", "{"], ["punctuation", "}"],
+ ["keyword", "external"],
+ ["keyword", "import"]
+]
+
+----------------------------------------------------
+
+Checks for keywords.
\ No newline at end of file
diff --git a/tests/languages/roboconf/optional_feature.test b/tests/languages/roboconf/optional_feature.test
new file mode 100644
index 0000000..bf3e090
--- /dev/null
+++ b/tests/languages/roboconf/optional_feature.test
@@ -0,0 +1,11 @@
+(optional)
+
+----------------------------------------------------
+
+[
+ ["optional", "(optional)"]
+]
+
+----------------------------------------------------
+
+Checks for optional flag.
\ No newline at end of file
diff --git a/tests/languages/roboconf/property_feature.test b/tests/languages/roboconf/property_feature.test
new file mode 100644
index 0000000..aae2508
--- /dev/null
+++ b/tests/languages/roboconf/property_feature.test
@@ -0,0 +1,17 @@
+extends :
+imports:
+installer:
+data.ec2.elastic.ip:
+
+----------------------------------------------------
+
+[
+ ["property", "extends"], ["punctuation", ":"],
+ ["property", "imports"], ["punctuation", ":"],
+ ["property", "installer"], ["punctuation", ":"],
+ ["property", "data.ec2.elastic.ip"], ["punctuation", ":"]
+]
+
+----------------------------------------------------
+
+Checks for properties.
\ No newline at end of file
diff --git a/tests/languages/roboconf/value_feature.test b/tests/languages/roboconf/value_feature.test
new file mode 100644
index 0000000..9c63798
--- /dev/null
+++ b/tests/languages/roboconf/value_feature.test
@@ -0,0 +1,20 @@
+port = 8080;
+MySQL.port = 3307, My-Client-Database.port = 3308;
+my-own-variable = something;
+
+----------------------------------------------------
+
+[
+ "port ", ["punctuation", "="],
+ ["value", "8080"], ["punctuation", ";"],
+ "\r\nMySQL", ["punctuation", "."], "port ", ["punctuation", "="],
+ ["value", "3307"], ["punctuation", ","],
+ " My-Client-Database", ["punctuation", "."], "port ", ["punctuation", "="],
+ ["value", "3308"], ["punctuation", ";"],
+ "\r\nmy-own-variable ", ["punctuation", "="],
+ ["value", "something"], ["punctuation", ";"]
+]
+
+----------------------------------------------------
+
+Checks for default values.
\ No newline at end of file
diff --git a/tests/languages/roboconf/wildcard_feature.test b/tests/languages/roboconf/wildcard_feature.test
new file mode 100644
index 0000000..e08e18d
--- /dev/null
+++ b/tests/languages/roboconf/wildcard_feature.test
@@ -0,0 +1,12 @@
+load-balance-able.*
+
+----------------------------------------------------
+
+[
+ "load-balance-able", ["punctuation", "."],
+ ["wildcard", "*"]
+]
+
+----------------------------------------------------
+
+Checks for wildcards.
\ No newline at end of file