summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--without-tests1
-rw-r--r--yarnlib/__init__.py2
-rw-r--r--yarnlib/elements.py51
3 files changed, 53 insertions, 1 deletions
diff --git a/without-tests b/without-tests
index 1a44653..6aa40f1 100644
--- a/without-tests
+++ b/without-tests
@@ -1,2 +1,3 @@
yarnlib/__init__.py
setup.py
+yarnlib/elements.py
diff --git a/yarnlib/__init__.py b/yarnlib/__init__.py
index 44e83e3..2abc3ad 100644
--- a/yarnlib/__init__.py
+++ b/yarnlib/__init__.py
@@ -17,4 +17,4 @@
from mdparser import MarkdownParser
-
+from elements import Story, StoryStep, Implementation
diff --git a/yarnlib/elements.py b/yarnlib/elements.py
new file mode 100644
index 0000000..a1dea0d
--- /dev/null
+++ b/yarnlib/elements.py
@@ -0,0 +1,51 @@
+# Copyright 2013 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+# This is a step in a story: GIVEN, WHEN, THEN, etc.
+
+class StoryStep(object):
+
+ def __init__(self, what, text):
+ self.what = what
+ self.text = text
+ self.implementation = None
+
+
+# This is the story itself.
+
+class Story(object):
+
+ def __init__(self, name):
+ self.name = name
+ self.steps = []
+
+
+# This is an IMPLEMENTS chunk.
+
+class Implementation(object):
+
+ def __init__(self, what, regexp, shell):
+ self.what = what
+ self.regexp = regexp
+ self.shell = shell
+
+ def execute(self):
+ exit, out, err = cliapp.runcmd_unchecked(
+ ['sh', '-c', 'set -eu\n' + self.shell])
+ return exit
+