aster 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +2 -0
- data/aster.gemspec +1 -2
- data/lib/aster/environment.rb +1 -0
- data/lib/aster/parser.rb +17 -1
- data/lib/aster/sexp.treetop +1 -1
- data/lib/aster/version.rb +1 -1
- data/test/helper.rb +1 -0
- data/test/test_environment.rb +2 -0
- data/test/test_parser.rb +38 -14
- metadata +6 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86ae38efe125e81c630c4809edbafbc19455939c
|
4
|
+
data.tar.gz: 7459061363e884eef7c18cf0985109bf7b5ae684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6efbc37aac9bbe54efb6f11d35cd94b409d301359d4cbe70578a4d9e10c3e17f41e170ebd939564b7c03e1395248bb2b2d7dc6a196f2d6529d9885dac4b4bb82
|
7
|
+
data.tar.gz: aa0f874e642c9fd23f8e557f750e164a983b8027ece0d9b0a3a349870affc5ac09868be835b1fd59d0bc39fcfbf891a25e2f447d936af0ded50c734e96425874
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/aster.gemspec
CHANGED
@@ -21,8 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "treetop"
|
22
22
|
#spec.add_dependency "thor"
|
23
23
|
|
24
|
-
spec.add_development_dependency "bundler", "~> 1.
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
25
|
spec.add_development_dependency "rake"
|
26
26
|
spec.add_development_dependency "pry"
|
27
|
-
spec.add_development_dependency "ZenTest"
|
28
27
|
end
|
data/lib/aster/environment.rb
CHANGED
data/lib/aster/parser.rb
CHANGED
@@ -23,8 +23,24 @@ module Aster
|
|
23
23
|
|
24
24
|
def raw_parse_line(line)
|
25
25
|
@sexp ||= SexpParser.new
|
26
|
+
|
26
27
|
result = @sexp.parse(line)
|
27
|
-
|
28
|
+
|
29
|
+
if result && result.value
|
30
|
+
res = result.value
|
31
|
+
def res.garbage?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
res
|
35
|
+
else
|
36
|
+
# garbage mode
|
37
|
+
result = line.split(' ', 2)
|
38
|
+
def result.garbage?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
result
|
42
|
+
end
|
43
|
+
|
28
44
|
end
|
29
45
|
|
30
46
|
def parse_line(line)
|
data/lib/aster/sexp.treetop
CHANGED
data/lib/aster/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_environment.rb
CHANGED
@@ -33,7 +33,9 @@ class TestEnvironment < Test::Unit::TestCase
|
|
33
33
|
def test_set
|
34
34
|
e = Aster::Environment.new
|
35
35
|
e.eval "set key value"
|
36
|
+
e.eval "set whatev 22"
|
36
37
|
assert_equal "yes", e.eval("equal value $key")
|
38
|
+
assert_equal "yes", e.eval("equal $whatev {add 2 10 10}")
|
37
39
|
end
|
38
40
|
|
39
41
|
def test_function
|
data/test/test_parser.rb
CHANGED
@@ -2,11 +2,17 @@ require_relative './helper'
|
|
2
2
|
|
3
3
|
class TestParser < Test::Unit::TestCase
|
4
4
|
|
5
|
-
def
|
5
|
+
def raw_parse_line text
|
6
6
|
p = Aster::Parser.new
|
7
7
|
p.send :raw_parse_line, text
|
8
8
|
end
|
9
9
|
|
10
|
+
def parse_line text
|
11
|
+
r = raw_parse_line text
|
12
|
+
assert_equal false, r.garbage?
|
13
|
+
r
|
14
|
+
end
|
15
|
+
|
10
16
|
def parse text
|
11
17
|
p = Aster::Parser.new
|
12
18
|
p.parse text
|
@@ -27,11 +33,29 @@ class TestParser < Test::Unit::TestCase
|
|
27
33
|
|
28
34
|
def test_line_parse
|
29
35
|
assert_equal ["a"], parse_line("a")
|
30
|
-
|
36
|
+
|
37
|
+
tree = parse_line("a $a")
|
38
|
+
assert_equal "a", tree.first
|
39
|
+
assert_equal :a, tree.last.name
|
40
|
+
|
31
41
|
assert_equal [:a, :b], parse_line("{$a $b}").first.map{|v| v.name.to_sym}
|
32
42
|
assert_equal ["upload", "\"asdf.jpg\""], parse_line(%q(upload "asdf.jpg"))
|
43
|
+
assert_equal ["upload", "nginx.conf"], parse_line("upload nginx.conf")
|
44
|
+
assert_equal ["upload", "nginx/nginx.conf", "~/nginx.test"], parse_line("upload nginx/nginx.conf ~/nginx.test")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_parse_garbage
|
48
|
+
|
49
|
+
def g p
|
50
|
+
raw_parse_line(p).tap do |g|
|
51
|
+
assert_equal true, g.garbage?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
33
56
|
end
|
34
57
|
|
58
|
+
|
35
59
|
def test_command_parse
|
36
60
|
c = parse "asdf one two"
|
37
61
|
assert_equal c.first.function_name, :asdf
|
@@ -55,17 +79,17 @@ function test2 asdf
|
|
55
79
|
tree = parser.parse file
|
56
80
|
end
|
57
81
|
|
58
|
-
|
59
|
-
|
60
|
-
ruby
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
82
|
+
# def test_ruby_script
|
83
|
+
# tree = parse %Q{
|
84
|
+
# ruby
|
85
|
+
# require 'rubygems'
|
86
|
+
# a = ArchiveRecord::Base;
|
87
|
+
# a.define "s" do |asdf|
|
88
|
+
# asdf.asdf << #end
|
89
|
+
# end
|
90
|
+
# }
|
91
|
+
# text = "require 'rubygems'\na = ArchiveRecord::Base;\na.define \"s\" do |asdf|\n asdf.asdf << #end\nend\n "
|
92
|
+
# assert_equal text, tree.first.sub_text
|
93
|
+
# end
|
70
94
|
|
71
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Murphy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: ZenTest
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
description:
|
84
70
|
email:
|
85
71
|
- sam.murphy@gmail.com
|
@@ -88,6 +74,7 @@ extensions: []
|
|
88
74
|
extra_rdoc_files: []
|
89
75
|
files:
|
90
76
|
- .gitignore
|
77
|
+
- .travis.yml
|
91
78
|
- Gemfile
|
92
79
|
- LICENSE.txt
|
93
80
|
- README.md
|
@@ -127,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
114
|
version: '0'
|
128
115
|
requirements: []
|
129
116
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.2.2
|
131
118
|
signing_key:
|
132
119
|
specification_version: 4
|
133
120
|
summary: A programming language for configuring servers
|