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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ae416c0202884d73a16768ac01f7b0e5693e5bb
4
- data.tar.gz: fdcb60a7b8bf0b6cdcdbe48bbfb2555f78189cb5
3
+ metadata.gz: 86ae38efe125e81c630c4809edbafbc19455939c
4
+ data.tar.gz: 7459061363e884eef7c18cf0985109bf7b5ae684
5
5
  SHA512:
6
- metadata.gz: f18dd67914ad7c8ee11eabb2024be171584dd0bab372f19cca0ecd60061c84b5591ec3dfa66c8dcdc37b3a511181658e617dcf13b242e40ecbc3cc6446ea26f2
7
- data.tar.gz: 6e99ec823ba740726b5ec263587e2743257b6f046c034179d574fbbd997b92dd511517f045a2c550c478f4396fd01ced36cef6de72d57174c8950502cd66f9fb
6
+ metadata.gz: 6efbc37aac9bbe54efb6f11d35cd94b409d301359d4cbe70578a4d9e10c3e17f41e170ebd939564b7c03e1395248bb2b2d7dc6a196f2d6529d9885dac4b4bb82
7
+ data.tar.gz: aa0f874e642c9fd23f8e557f750e164a983b8027ece0d9b0a3a349870affc5ac09868be835b1fd59d0bc39fcfbf891a25e2f447d936af0ded50c734e96425874
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ script: "bundle exec rake test"
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Aster
2
2
 
3
+ [![Build Status](https://travis-ci.org/smurphy/aster.svg?branch=master)](https://travis-ci.org/smurphy/aster)
4
+
3
5
  Aster is a programming language that's designed to make configuration management more fun.
4
6
 
5
7
  ### Example
@@ -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.6"
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
@@ -59,6 +59,7 @@ module Aster
59
59
  case command.function_name
60
60
  when :function
61
61
  fun, *args = command.arguments
62
+
62
63
  self.define_function(
63
64
  fun,
64
65
  args,
@@ -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
- result.value
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)
@@ -31,7 +31,7 @@ grammar Sexp
31
31
  end
32
32
 
33
33
  rule identifier
34
- [a-zA-Z0-9] [a-zA-Z0-9]* {
34
+ [^\n|\s|"|\}]+ {
35
35
  def value
36
36
  text_value
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module Aster
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), *%w(.. lib aster))
2
2
 
3
+
3
4
  require 'rubygems'
4
5
  require 'test/unit'
5
6
 
@@ -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
@@ -2,11 +2,17 @@ require_relative './helper'
2
2
 
3
3
  class TestParser < Test::Unit::TestCase
4
4
 
5
- def parse_line(text)
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
- assert_equal ["a", "a"], parse_line("a a")
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
- def test_ruby_script
59
- tree = parse %Q{
60
- ruby
61
- require 'rubygems'
62
- a = ArchiveRecord::Base;
63
- a.define "s" do |asdf|
64
- asdf.asdf << #end
65
- end
66
- }
67
- text = "require 'rubygems'\na = ArchiveRecord::Base;\na.define \"s\" do |asdf|\n asdf.asdf << #end\nend\n "
68
- assert_equal text, tree.first.sub_text
69
- end
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.3
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-12 00:00:00.000000000 Z
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.6'
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.6'
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.0.3
117
+ rubygems_version: 2.2.2
131
118
  signing_key:
132
119
  specification_version: 4
133
120
  summary: A programming language for configuring servers