summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-12-15 11:56:36 -0500
committerCasey Dahlin <cdahlin@redhat.com>2008-12-15 11:56:36 -0500
commit1866af3a886d3ffff30560eb2ec4ebed1f078cae (patch)
tree609c5ffc036ea4e6dab620f33f6872e96bde5c73
parent5fb3948ea10e63cd04ba47cffed82a2ba897d467 (diff)
downloadupstate-1866af3a886d3ffff30560eb2ec4ebed1f078cae.tar.gz
upstate-1866af3a886d3ffff30560eb2ec4ebed1f078cae.tar.xz
upstate-1866af3a886d3ffff30560eb2ec4ebed1f078cae.zip
Add real-world example file
-rw-r--r--example.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/example.rb b/example.rb
new file mode 100644
index 0000000..3dbd12b
--- /dev/null
+++ b/example.rb
@@ -0,0 +1,19 @@
+require 'state'
+
+include UpState
+
+HdAvail = State.new_type("hdAvail", [Event.new("DevKit_FoundHD")], [], [:uid, :name, :blkdev])
+FstabAvail = State.new_type("fstabLine", [Event.new("Can_Mount", {:mount_str => /.*/})], [], [[:uid, :name, :blkdev], :mount_str])
+Mount = State.new_type("mount", [Event::Epsilon], [Dependency.new(HdAvail, {:uid => /.*/, :mount_str => /.*/}), Dependency.new(FstabAvail)])
+
+events = [
+ ["DevKit_FoundHD", {:uid => "1234", :name => "myhd", :blkdev => "/dev/sda1"}],
+ ["Can_Mount", {:uid => "1234", :mount_str => "/home"}],
+ ["Can_Mount", {:uid => "1234"}],
+]
+
+State.print_all_color
+events.each do |x|
+ State.process_event Event.new(*x)
+ State.print_all_color
+end