petrinet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ca5cb3389ec8322e7851cf937e15b1d7fef235b22f88f2897f5eba513bb3231e
4
+ data.tar.gz: 71ff8229ac9063bc50ec0fb4bf1b163c9dd9d40ac51c2ed21f53c53ebdabfd67
5
+ SHA512:
6
+ metadata.gz: ed35c9308bfc520d96f40fdd4a63e7294d9996d0d0bc1eaabc30be003af2ffead875dc2c763ed8644303984dd4e7ad5e0d8e3a65b048efc8694ac0a6aea6e68b
7
+ data.tar.gz: c3626f4573b6ea2ad70605103c2d165ef7299c5421b2c24d28c72693708a6ee0dab8349accac37246cce1d6704babc7ab39964285b6fef7111190186054cb14c
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .idea/
13
+ Gemfile.lock
14
+ .DS_Store
15
+ .rspec_ok
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.4
7
+ before_install: gem install bundler -v 2.0.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in petrinet.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Aslak Hellesøy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,33 @@
1
+ SHELL := /usr/bin/env bash
2
+ PNML_FILES=$(wildcard examples/**/*.xml)
3
+ SVG_FILES=$(wildcard examples/**/**/*.svg)
4
+ RUBY_FILES=$(wildcard lib/**/*.rb)
5
+
6
+ .SECONDARY:
7
+
8
+ default: .rspec_ok examples/cucumber-protocol/transition_sample_1.gif examples/x-ray-machine/v1-problem.gif examples/x-ray-machine/v2-fixed.gif
9
+
10
+ .rspec_ok: Gemfile.lock $(RUBY_FILES)
11
+ bundle exec rspec
12
+ touch $@
13
+
14
+ Gemfile.lock: Gemfile
15
+ bundle install
16
+ touch $@
17
+
18
+ examples/cucumber-protocol/transition_sample_1.gif: examples/cucumber-protocol/cucumber-protocol.xml Gemfile.lock $(RUBY_FILES) exe/petrinet
19
+ ruby -Ilib exe/petrinet --script examples/cucumber-protocol/transition_sample_1.txt --output $@ $<
20
+
21
+ examples/x-ray-machine/v1-problem.gif: examples/x-ray-machine/x-ray-machine-1.xml Gemfile.lock $(RUBY_FILES) exe/petrinet
22
+ ruby -Ilib exe/petrinet --script examples/x-ray-machine/v1-problem.txt --output $@ $<
23
+
24
+ examples/x-ray-machine/v2-fixed.gif: examples/x-ray-machine/x-ray-machine-2.xml Gemfile.lock $(RUBY_FILES) exe/petrinet
25
+ ruby -Ilib exe/petrinet --script examples/x-ray-machine/v2-fixed.txt --output $@ $<
26
+
27
+ clean:
28
+ rm -f examples/**/*.gif .rspec_ok
29
+ .PHONY: clean
30
+
31
+ clobber: clean
32
+ rm -f Gemfile.lock
33
+ .PHONY: clobber
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Petrinet
2
+
3
+ A command line utility for generating animated gifs of petri nets. This tool is designed to support living
4
+ documentation and test-driven development of systems that can be modelled with petri nets.
5
+
6
+ ## Example
7
+
8
+ An X-Ray machine in a hospital, taken from [Modeling Business Processes - A Petri Net-Oriented Approach](https://mitpress.mit.edu/books/modeling-business-processes).
9
+
10
+ ![x-ray](./examples/x-ray-machine/v2-fixed.gif)
11
+
12
+ The input for generating this gif is two file:
13
+
14
+ * a [PNML](https://en.wikipedia.org/wiki/Petri_Net_Markup_Language) file, for example created with
15
+ [PIPE](https://sarahtattersall.github.io/PIPE/) or other petri net diagramming tool.
16
+ * a *marking-transition* script
17
+
18
+ ## Marking-Transition script
19
+
20
+ This is a simple text file to specify the initial *marking* of the net, and transitions to fire. The animation
21
+ above was generated from the following marking file:
22
+
23
+ ```
24
+ wait:3
25
+ free:1
26
+ enter
27
+ make_photo
28
+ leave
29
+ enter
30
+ make_photo
31
+ leave
32
+ enter
33
+ make_photo
34
+ leave
35
+ ```
36
+
37
+ This file can be written by hand, or it can be generated.
38
+
39
+ ### Generating a Marking-Transition script
40
+
41
+ There are two typical ways to generate a marking-transition script - either via *controlled* automated tests,
42
+ or from a running production system. Both of them require the system to *log* internal events and commands.
43
+
44
+ A specialised (but simple) tool could parse those logs and generate a marking-transition script, which can then
45
+ be fed to `petrinet` for validation and generation of living documentation in the form of animated petri nets.
46
+
47
+ ## Installation
48
+
49
+ You need the following tools installed:
50
+
51
+ * Graphviz - the `dot` executable must be on your `PATH`
52
+ * ImageMagick - the `convert` executable must be on your `PATH`
53
+ * Ruby
54
+
55
+ Then run the following from the command line:
56
+
57
+ gem install petrinet
58
+
59
+ ## Usage
60
+
61
+ You need a `.pnml` file that describes your net, and a `.txt` marking-transition file. Generate an animated gif:
62
+
63
+ petrinet --script my-marking-transition.txt my-petri-net-pnml.xml
64
+
65
+ This will generate a file named `my-marking-transition.gif` (the name is derived from the `.txt` file)
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cucumber/petrinet.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec