teepee 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73e4c9f9bfdf81a27259d00bfc83506d5296d091
4
- data.tar.gz: ca33965c5c377195817a023ab06a86ba385f071a
3
+ metadata.gz: 6c45396e7f2b0a6b960ef62bff80936d88406519
4
+ data.tar.gz: fbb58e98d5718551c823017d6343230999a09312
5
5
  SHA512:
6
- metadata.gz: abd50f42a45619391afa669e159abcbca1c4764950cd610e0aa473cae5c92e9b74b85593af3def0439d470b2ae621c74a9b2945de7480ce4332c9cce1b22ab4d
7
- data.tar.gz: 2bb367a3e121cf795af6f830d7f836a21f87a15cb5664a5a9883e3ab22cfffa67b50757ab8932ab724b5682ab700a95762fb86a8b8cee62eee47af5f2c24b0c5
6
+ metadata.gz: f87f75931f26ddc9704a44f5498fe103fd6e228dd7e1af8e2e8f2aab84c77d1d1233b45822f1a434750ce0fd4dc7a7eb0b3f603884142d297b648b441cd3b7da
7
+ data.tar.gz: cf674f0a047d5bbcd517ebf4a76881887cfd95d6fd92fed816ba04256c64094846f4101275e39e52cb5433f4ee3d06eaaf95623646f40978ef94e72b66fda058
@@ -64,7 +64,9 @@ module Teepee
64
64
 
65
65
  def to_html
66
66
  case command.word
67
- when "backslash", "bslash"
67
+ when "backslash",
68
+ "bslash",
69
+ "-/"
68
70
  @@commander.backslash
69
71
  when "left-brace",
70
72
  "left_brace",
@@ -73,7 +75,8 @@ module Teepee
73
75
  "opening-brace",
74
76
  "opening_brace",
75
77
  "openingbrace",
76
- "obrace"
78
+ "obrace",
79
+ "-["
77
80
  @@commander.left_brace
78
81
  when "right-brace",
79
82
  "right_brace",
@@ -82,10 +85,11 @@ module Teepee
82
85
  "closing-brace",
83
86
  "closing_brace",
84
87
  "closingbrace",
85
- "cbrace"
88
+ "cbrace",
89
+ "]-"
86
90
  @@commander.right_brace
87
91
  when "_"
88
- @@commander.nbsp
92
+ @@commander.nbsp optional_number_from_expression
89
93
  when "space"
90
94
  @@commander.space
91
95
  when "br", "newline"
@@ -331,6 +335,14 @@ module Teepee
331
335
  @@commander.boolean_and expressions
332
336
  when "or"
333
337
  @@commander.boolean_or expressions
338
+ when "nand"
339
+ @@commander.boolean_nand expressions
340
+ when "nor"
341
+ @@commander.boolean_nor expressions
342
+ when "xor"
343
+ @@commander.boolean_xor expressions
344
+ when "xnor"
345
+ @@commander.boolean_xnor expressions
334
346
  else
335
347
  command_error "unknown command #{command.to_html}"
336
348
  end
@@ -363,6 +375,12 @@ module Teepee
363
375
  numbers_from_expressions.first
364
376
  end
365
377
 
378
+ def optional_number_from_expression
379
+ if not expressions.empty?
380
+ number_from_expression
381
+ end
382
+ end
383
+
366
384
  class << self
367
385
  @@commander = Commander.new
368
386
  @@action_view = nil
@@ -240,6 +240,14 @@ module Teepee
240
240
  end
241
241
  end
242
242
 
243
+ def boolean_nand expressions
244
+ boolean_not boolean_and expressions
245
+ end
246
+
247
+ def boolean_nor expressions
248
+ boolean_not boolean_or expressions
249
+ end
250
+
243
251
  def boolean_not expression
244
252
  if expression.to_s == "true"
245
253
  "false"
@@ -262,6 +270,39 @@ module Teepee
262
270
  end
263
271
  end
264
272
 
273
+ def boolean_xnor expressions
274
+ boolean_not boolean_xor expressions
275
+ end
276
+
277
+ def boolean_xor expressions
278
+ # There are two schools of thought as to what a multi-variable XOR is.
279
+ # 1. Chained XORs, giving a parity check.
280
+ # 2. 'Exclusively' one true for ALL inputs.
281
+ # I'm going with the second: one and only one true, the rest false.
282
+ # It seems therefore that the zero-argument version should be false then.
283
+ if expressions.empty?
284
+ "false"
285
+ else
286
+ any_trues = false
287
+ expressions.each do |expression|
288
+ if expression.to_s == "true"
289
+ if any_trues
290
+ return "false"
291
+ else
292
+ any_trues = true
293
+ end
294
+ elsif expression.to_s == "false"
295
+ # do nothing
296
+ elsif expression.kind_of? WhitespaceToken
297
+ # do nothing
298
+ else
299
+ return command_error "Not a boolean value"
300
+ end
301
+ end
302
+ return any_trues.to_s
303
+ end
304
+ end
305
+
265
306
  def br
266
307
  html_tag :br, nil
267
308
  end
@@ -466,8 +507,9 @@ module Teepee
466
507
  ensure_numeric numbers.reduce :%
467
508
  end
468
509
 
469
- def nbsp
470
- "&nbsp;"
510
+ def nbsp count
511
+ count = 1 unless count and count.kind_of? Numeric and count > 0
512
+ "&nbsp;" * count
471
513
  end
472
514
 
473
515
  def note_id id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teepee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mark Gore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport