aster 0.0.2 → 0.0.3
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 +4 -4
- data/TODO +2 -0
- data/lib/aster/environment.rb +16 -13
- data/lib/aster/version.rb +1 -1
- data/test/test_environment.rb +12 -0
- 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: 7ae416c0202884d73a16768ac01f7b0e5693e5bb
|
4
|
+
data.tar.gz: fdcb60a7b8bf0b6cdcdbe48bbfb2555f78189cb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f18dd67914ad7c8ee11eabb2024be171584dd0bab372f19cca0ecd60061c84b5591ec3dfa66c8dcdc37b3a511181658e617dcf13b242e40ecbc3cc6446ea26f2
|
7
|
+
data.tar.gz: 6e99ec823ba740726b5ec263587e2743257b6f046c034179d574fbbd997b92dd511517f045a2c550c478f4396fd01ced36cef6de72d57174c8950502cd66f9fb
|
data/TODO
CHANGED
data/lib/aster/environment.rb
CHANGED
@@ -65,10 +65,11 @@ module Aster
|
|
65
65
|
command.sub_commands
|
66
66
|
)
|
67
67
|
when :if
|
68
|
-
cond_value =
|
69
|
-
if is_true?(cond_value)
|
70
|
-
|
71
|
-
|
68
|
+
cond_value = eval_argument command.arguments.first
|
69
|
+
eval_tree command.sub_commands if is_true?(cond_value)
|
70
|
+
when :set
|
71
|
+
var, value, _ = command.arguments
|
72
|
+
self[var] = eval_argument value
|
72
73
|
when :not
|
73
74
|
cond_value = eval_arguments([command.arguments.first]).first
|
74
75
|
is_true?(cond_value) ? "no" : "yes"
|
@@ -88,18 +89,20 @@ module Aster
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
arg
|
99
|
-
end
|
92
|
+
def eval_argument(arg)
|
93
|
+
if arg.is_a?(Command)
|
94
|
+
eval_command(arg)
|
95
|
+
elsif arg.is_a?(Variable)
|
96
|
+
self[arg.name]
|
97
|
+
else
|
98
|
+
arg
|
100
99
|
end
|
101
100
|
end
|
102
101
|
|
102
|
+
def eval_arguments(arguments)
|
103
|
+
arguments.map{|arg| eval_argument arg}
|
104
|
+
end
|
105
|
+
|
103
106
|
def is_true?(val)
|
104
107
|
val && val.strip == "yes"
|
105
108
|
end
|
data/lib/aster/version.rb
CHANGED
data/test/test_environment.rb
CHANGED
@@ -30,6 +30,12 @@ class TestEnvironment < Test::Unit::TestCase
|
|
30
30
|
assert_equal "12", eval("add 1 2 3 {add 3 3}")
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_set
|
34
|
+
e = Aster::Environment.new
|
35
|
+
e.eval "set key value"
|
36
|
+
assert_equal "yes", e.eval("equal value $key")
|
37
|
+
end
|
38
|
+
|
33
39
|
def test_function
|
34
40
|
e = Aster::Environment.new
|
35
41
|
e.eval "function test arg1 arg2\n echo $arg1 and $arg2"
|
@@ -37,6 +43,12 @@ class TestEnvironment < Test::Unit::TestCase
|
|
37
43
|
assert_equal("one and two", e.stdout)
|
38
44
|
end
|
39
45
|
|
46
|
+
def test_if
|
47
|
+
e = Aster::Environment.new
|
48
|
+
e.eval "if yes\n echo test"
|
49
|
+
assert_equal e.stdout, "test"
|
50
|
+
end
|
51
|
+
|
40
52
|
def test_macro
|
41
53
|
e = Aster::Environment.new
|
42
54
|
e.define_macro :double do |c|
|