From 885ac26cd1282196931bdc0c042a6a8451864484 Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Mon, 9 Sep 2013 15:47:15 +0200 Subject: [PATCH] Accept prompt in parser --- lib/biju/parser.rb | 3 ++- spec/biju/parser_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/biju/parser.rb b/lib/biju/parser.rb index 900be5c..885ffdf 100644 --- a/lib/biju/parser.rb +++ b/lib/biju/parser.rb @@ -12,7 +12,8 @@ module Biju rule(:prefix) { str('AT') | str('at') } # RESPONSE - rule(:response) { cr >> crlf >> (status | command) >> crlf } + rule(:response) { cr >> crlf >> (((status | command) >> crlf) | prompt) } + rule(:prompt) { str('> ') } rule(:command) { mgl | pms | mgf | mserror } rule(:mserror) { str('+CMS ERROR').as(:cmd) >> str(': ') >> message } diff --git a/spec/biju/parser_spec.rb b/spec/biju/parser_spec.rb index 1d17641..d71edc7 100644 --- a/spec/biju/parser_spec.rb +++ b/spec/biju/parser_spec.rb @@ -15,6 +15,13 @@ describe Biju::ATParser do end context "response" do + it "parses cmgs prompt" do + mgs = "AT+CMGS=18\r\r\n> " + + expect { Biju::ATTransform.new.apply( + Biju::ATParser.new.parse(mgs)) }.not_to raise_error + end + it "parses messages list" do messages = "AT+CMGL=1\r\r\n" << "+CMGL: 0,1,,23\r\n" <<