aster 0.0.2 → 0.0.3

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: 0c85417587339f5f431df3347c2045046b742aae
4
- data.tar.gz: 72836e9ed31cd3f4ba159509bebcbbfe28bca42c
3
+ metadata.gz: 7ae416c0202884d73a16768ac01f7b0e5693e5bb
4
+ data.tar.gz: fdcb60a7b8bf0b6cdcdbe48bbfb2555f78189cb5
5
5
  SHA512:
6
- metadata.gz: 54058d24e135d2efee5e8abfc2755b32067f84a4f4210029cdfa688460d478b43ab4ca6f83f2a3904b65a7ea93eb4e84bed1d2e98367e3e0fcac974573122557
7
- data.tar.gz: b8d77eb5a75520e918749ebb2e875e3488e25e055c017749a853db83d662caa3da0a975352e36880a45219e18f6b02106786e0aee8d1dbb75ea0ea78181758b5
6
+ metadata.gz: f18dd67914ad7c8ee11eabb2024be171584dd0bab372f19cca0ecd60061c84b5591ec3dfa66c8dcdc37b3a511181658e617dcf13b242e40ecbc3cc6446ea26f2
7
+ data.tar.gz: 6e99ec823ba740726b5ec263587e2743257b6f046c034179d574fbbd997b92dd511517f045a2c550c478f4396fd01ced36cef6de72d57174c8950502cd66f9fb
data/TODO CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  # Done
6
6
 
7
+ * implement set
8
+ * fix if
7
9
  * implement sub-language text gathering
8
10
  * implement ruby-side macros
9
11
  * implement equal
@@ -65,10 +65,11 @@ module Aster
65
65
  command.sub_commands
66
66
  )
67
67
  when :if
68
- cond_value = eval_command Command.new(command.rest)
69
- if is_true?(cond_value)
70
- eval_tree command.sub_commands
71
- end
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 eval_arguments(arguments)
92
- arguments.map do |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
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
@@ -1,3 +1,3 @@
1
1
  module Aster
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Murphy