Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
0b607a38
Commit
0b607a38
authored
Jan 13, 2015
by
sergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add setVariable
parent
6c570ae0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
context.js
lib/context.js
+4
-0
index.js
lib/index.js
+2
-2
index.js
test/index.js
+7
-0
No files found.
lib/context.js
View file @
0b607a38
...
...
@@ -105,6 +105,10 @@ Context.prototype.getVariable = function (name, cb) {
this
.
send
(
'
GET VARIABLE
'
+
name
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
setVariable
=
function
(
name
,
value
,
cb
)
{
this
.
send
(
'
SET VARIABLE
'
+
name
+
'
'
+
value
+
'
\n
'
,
cb
||
function
()
{
});
};
Context
.
prototype
.
answer
=
function
(
cb
)
{
this
.
send
(
'
ANSWER
'
+
'
\n
'
,
cb
||
function
()
{
});
};
...
...
lib/index.js
View file @
0b607a38
...
...
@@ -3,8 +3,8 @@ var Context = require('./context');
var
agi
=
{
state
:
require
(
'
./state
'
),
Context
:
Context
,
createServer
:
function
(
handler
)
{
return
require
(
'
net
'
).
createServer
(
function
(
stream
)
{
createServer
:
function
(
handler
)
{
return
require
(
'
net
'
).
createServer
(
function
(
stream
)
{
var
context
=
new
Context
(
stream
);
handler
(
context
);
});
...
...
test/index.js
View file @
0b607a38
...
...
@@ -146,6 +146,13 @@ describe('Context', function() {
});
});
describe
(
'
setVariable
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
setVariable
(
'
test
'
,
'
test
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SET VARIABLE test test
\n
'
);
});
});
describe
(
'
getVariable
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
getVariable
(
'
test
'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment