Please disable Adblockers and enable JavaScript for domain CEWebS.cs.univie.ac.at! We have NO ADS, but they may interfere with some of our course material.
Name: examples/activity_syncing_after.rb
1: | #!/usr/bin/ruby |
2: | require '../../riddl/lib/ruby/client' |
3: | require 'xml/smart' |
4: | |
5: | def build_notification(key,what,content,type) |
6: | res = [] |
7: | res << ['key' , key] |
8: | res << ['topic' , ::File::dirname(what)] |
9: | res << [type , ::File::basename(what)] |
10: | res << ['notification', content.to_yaml.sub('--- ','')] |
11: | res << ['uid' , Digest::MD5.hexdigest(Kernel::rand().to_s)] |
12: | res << ['fp' , Digest::MD5.hexdigest(res.join(''))] |
13: | # TODO add secret to fp |
14: | end |
15: | |
16: | if ARGV.length != 3 |
17: | puts "Usage : #{File.basename($0)} [OPTION=VALUE] ..." |
18: | puts "Example: #{File.basename($0)} instance=3 activity=a1 endpoint=http://www.pri.univie.ac.at/~mangler/services/timeout2.php" |
19: | exit |
20: | end |
21: | |
22: | args = {} |
23: | ARGV.each do |a| |
24: | if a =~ /([A-Za-z]+)=(.*)/ |
25: | args[$1] = $2 |
26: | end |
27: | end |
28: | |
29: | ev = build_notification("xxx","activity/syncing_after",args,"vote") |
30: | |
31: | srv = Riddl::Client.new("http://localhost:9399/") |
32: | res = srv.resource("/1/events") |
33: | res.post ev.map{|k,v|Riddl::Parameter::Simple.new(k,v)} |