teepee 0.14.2 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/teepee.rb +7 -0
- data/lib/teepee/command-parser.rb +10 -2
- data/lib/teepee/commander.rb +27 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2091fbdcf89abb71108a72003d0e556cc0ae859c
|
4
|
+
data.tar.gz: 851d783a735722e9cf6eac53f62803ae677ec0a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e733f41d8acc60cb5a1481701314e44bd2a1dc9c978e4649228dd0bbe49aa1d7df8266ed04a4f4b1baa879581ff658fbfee2cc42113eaef29c188c16506c80ae
|
7
|
+
data.tar.gz: 118aa06480c8c2a6d4c7b0d27fda745fc9cc290ab1b76533c6502be1f29be5663d85f9de2c37598bb733c7dcfc253287ddefe94ba48256475180024b2e5beff7
|
data/lib/teepee.rb
CHANGED
@@ -38,6 +38,7 @@
|
|
38
38
|
module Teepee
|
39
39
|
end
|
40
40
|
|
41
|
+
require 'set'
|
41
42
|
require 'active_support/all'
|
42
43
|
require 'monkey-patch'
|
43
44
|
|
@@ -65,6 +66,12 @@ class String
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
69
|
+
class NilClass
|
70
|
+
def to_html
|
71
|
+
""
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
68
75
|
require 'teepee/constants'
|
69
76
|
require 'teepee/errors'
|
70
77
|
require 'teepee/parser-node'
|
@@ -424,14 +424,22 @@ module Teepee
|
|
424
424
|
@@commander.prog1_operator expressions
|
425
425
|
when "progn"
|
426
426
|
@@commander.progn_operator expressions
|
427
|
+
when "prognil"
|
428
|
+
@@commander.prognil expressions
|
427
429
|
when "cond"
|
428
430
|
@@commander.cond_operator expressions
|
429
431
|
when "case"
|
430
432
|
@@commander.case_operator expressions
|
431
433
|
when "get"
|
432
434
|
@@commander.get_operator first_word_token
|
433
|
-
when "
|
434
|
-
|
435
|
+
when "define",
|
436
|
+
"def"
|
437
|
+
@@commander.define expressions
|
438
|
+
when "undefine",
|
439
|
+
"undef"
|
440
|
+
@@commander.undefine expressions
|
441
|
+
when "defined?"
|
442
|
+
@@commander.defined? word_tokens
|
435
443
|
when "dotimes"
|
436
444
|
@@commander.dotimes expressions
|
437
445
|
else
|
data/lib/teepee/commander.rb
CHANGED
@@ -378,6 +378,20 @@ module Teepee
|
|
378
378
|
ensure_numeric Math.cosh angle.to_number
|
379
379
|
end
|
380
380
|
|
381
|
+
def define expressions
|
382
|
+
variable, _, value = expressions
|
383
|
+
@variables[variable.to_html] = value
|
384
|
+
value.to_html
|
385
|
+
end
|
386
|
+
|
387
|
+
def defined? variables
|
388
|
+
if Set.new(variables.map(&:to_html)).subset? Set.new(@variables.keys)
|
389
|
+
true_constant
|
390
|
+
else
|
391
|
+
false_constant
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
381
395
|
def degrees2radians degrees
|
382
396
|
ensure_numeric degrees.to_number * Math::PI / 180.0
|
383
397
|
end
|
@@ -461,7 +475,7 @@ module Teepee
|
|
461
475
|
end
|
462
476
|
|
463
477
|
def get_operator variable
|
464
|
-
@variables[variable.
|
478
|
+
@variables[variable.to_html].to_html
|
465
479
|
end
|
466
480
|
|
467
481
|
def greater_than numbers
|
@@ -697,6 +711,11 @@ module Teepee
|
|
697
711
|
expressions.map(&:to_html).last
|
698
712
|
end
|
699
713
|
|
714
|
+
def prognil expressions
|
715
|
+
expressions.map(&:to_html)
|
716
|
+
""
|
717
|
+
end
|
718
|
+
|
700
719
|
def radians2degrees radians
|
701
720
|
ensure_numeric(radians.to_number * 180.0 / Math::PI)
|
702
721
|
end
|
@@ -717,12 +736,6 @@ module Teepee
|
|
717
736
|
end
|
718
737
|
end
|
719
738
|
|
720
|
-
def set_operator expressions
|
721
|
-
variable, _, value = expressions
|
722
|
-
@variables[variable.to_s] = value
|
723
|
-
value.to_html
|
724
|
-
end
|
725
|
-
|
726
739
|
def sin angle
|
727
740
|
ensure_numeric Math.sin angle.to_number
|
728
741
|
end
|
@@ -799,6 +812,13 @@ module Teepee
|
|
799
812
|
html_tag :u, expressions
|
800
813
|
end
|
801
814
|
|
815
|
+
def undefine expressions
|
816
|
+
expressions.each do |expression|
|
817
|
+
@variables.delete expression.to_html
|
818
|
+
end
|
819
|
+
""
|
820
|
+
end
|
821
|
+
|
802
822
|
def unless_operator expressions
|
803
823
|
expressions = strip expressions
|
804
824
|
conditional = expressions.first
|