dramatis 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -0
- data/License.txt +20 -0
- data/Manifest.txt +119 -0
- data/README.txt +57 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/examples/README.txt +20 -0
- data/examples/auction.rb +90 -0
- data/examples/bank/bank.rb +7 -0
- data/examples/bank/bank_test.rb +7 -0
- data/examples/exception.rb +40 -0
- data/examples/fib/conservative.rb +50 -0
- data/examples/fib/future.rb +5 -0
- data/examples/fib/original.rb +33 -0
- data/examples/fib/threads.rb +51 -0
- data/examples/im/distributed/chat/client.rb +49 -0
- data/examples/im/distributed/chat/screen/fox.rb +92 -0
- data/examples/im/distributed/chat/screen.rb +11 -0
- data/examples/im/distributed/chat/server.rb +72 -0
- data/examples/im/distributed/chat.rb +5 -0
- data/examples/im/distributed/client.rb +9 -0
- data/examples/im/distributed/run.rb +18 -0
- data/examples/im/distributed/server.rb +11 -0
- data/examples/im/single/chat/client.rb +50 -0
- data/examples/im/single/chat/screen/fox.rb +96 -0
- data/examples/im/single/chat/screen/wxs.rb +63 -0
- data/examples/im/single/chat/screen.rb +11 -0
- data/examples/im/single/chat/server.rb +72 -0
- data/examples/im/single/chat.rb +5 -0
- data/examples/im/single/fox.rb +18 -0
- data/examples/im/single/wxchat.rb +19 -0
- data/examples/pingpong/actor.rb +33 -0
- data/examples/pingpong/actor_rec.rb +34 -0
- data/examples/pingpong/pingpong.txt +315 -0
- data/examples/pingpong/scala.rb +41 -0
- data/examples/pingpong/serial.rb +26 -0
- data/examples/pretty.txt +108 -0
- data/examples/telephone/.irbrc +2 -0
- data/examples/telephone/3esl.txt +21877 -0
- data/examples/telephone/fifth/kid.rb +36 -0
- data/examples/telephone/fifth/run.rb +26 -0
- data/examples/telephone/first/kid.rb +31 -0
- data/examples/telephone/first/run.rb +20 -0
- data/examples/telephone/fourth/kid.rb +31 -0
- data/examples/telephone/fourth/run.rb +26 -0
- data/examples/telephone/mangler.rb +53 -0
- data/examples/telephone/second/kid.rb +26 -0
- data/examples/telephone/second/run.rb +20 -0
- data/examples/telephone/seventh/kid.rb +40 -0
- data/examples/telephone/seventh/run.rb +35 -0
- data/examples/telephone/seventh/test.rb +28 -0
- data/examples/telephone/seventh/test2.rb +10 -0
- data/examples/telephone/sixth/kid.rb +39 -0
- data/examples/telephone/sixth/run.rb +26 -0
- data/examples/telephone/third/kid.rb +31 -0
- data/examples/telephone/third/run.rb +21 -0
- data/lib/dramatis/actor/interface.rb +118 -0
- data/lib/dramatis/actor/name/interface.rb +128 -0
- data/lib/dramatis/actor/name.rb +44 -0
- data/lib/dramatis/actor.rb +96 -0
- data/lib/dramatis/deadlock.rb +123 -0
- data/lib/dramatis/error/uncaught.rb +19 -0
- data/lib/dramatis/error.rb +125 -0
- data/lib/dramatis/future/interface.rb +45 -0
- data/lib/dramatis/future.rb +32 -0
- data/lib/dramatis/runtime/actor/main.rb +3 -0
- data/lib/dramatis/runtime/actor.rb +294 -0
- data/lib/dramatis/runtime/gate.rb +244 -0
- data/lib/dramatis/runtime/scheduler.rb +374 -0
- data/lib/dramatis/runtime/task.rb +390 -0
- data/lib/dramatis/runtime/thread_pool.rb +149 -0
- data/lib/dramatis/runtime/timer.rb +5 -0
- data/lib/dramatis/runtime.rb +129 -0
- data/lib/dramatis/shoes/runtime.rb +7 -0
- data/lib/dramatis/shoes.rb +14 -0
- data/lib/dramatis/version.rb +8 -0
- data/lib/dramatis.rb +73 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/dramatis/actor/become_spec.rb +17 -0
- data/spec/dramatis/actor/future_spec.rb +189 -0
- data/spec/dramatis/actor/name_spec.rb +141 -0
- data/spec/dramatis/actor/task_spec.rb +75 -0
- data/spec/dramatis/actor_spec.rb +492 -0
- data/spec/dramatis/dramatis_spec.rb +23 -0
- data/spec/dramatis/exc_spec.rb +78 -0
- data/spec/dramatis/runtime/gate_spec.rb +57 -0
- data/spec/dramatis/runtime/thread_pool.rb +30 -0
- data/spec/dramatis/shoes_spec.rb +11 -0
- data/spec/dramatis/simple_spec.rb +32 -0
- data/spec/exp_spec.rb +21 -0
- data/spec/simple2_spec.rb +36 -0
- data/spec/simple_spec.rb +30 -0
- data/spec/spec.opts +0 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/thread_spec.rb +13 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/website.rake +17 -0
- data/test/jruby_lm.rb +13 -0
- data/test/test.rb +19 -0
- data/test/test10.rb +43 -0
- data/test/test11.rb +45 -0
- data/test/test12.rb +60 -0
- data/test/test13.rb +71 -0
- data/test/test2.rb +12 -0
- data/test/test3.rb +10 -0
- data/test/test4.rb +29 -0
- data/test/test5.rb +8 -0
- data/test/test6.rb +32 -0
- data/test/test7.rb +48 -0
- data/test/test8.rb +133 -0
- data/test/test9.rb +105 -0
- data/test/test_exc.rb +22 -0
- metadata +180 -0
data/lib/dramatis.rb
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# :title: Dramatis Actor Library Ruby API
|
|
2
|
+
|
|
3
|
+
module Dramatis #:doc:
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
require 'dramatis/error'
|
|
7
|
+
require 'dramatis/deadlock'
|
|
8
|
+
require 'dramatis/future/interface'
|
|
9
|
+
require 'dramatis/actor/name/interface'
|
|
10
|
+
|
|
11
|
+
# The Dramatis module provides methods to manipulate dramatis objects
|
|
12
|
+
# by client code. Each function can be accessed as a module function, e.g.,
|
|
13
|
+
# Dramatis.interface(...)
|
|
14
|
+
# or by including the Dramatis module and using as an instance method, .e.,g
|
|
15
|
+
# include Dramatis
|
|
16
|
+
# interface(...)
|
|
17
|
+
|
|
18
|
+
module Dramatis #:doc:
|
|
19
|
+
|
|
20
|
+
# :call-seq:
|
|
21
|
+
# interface(object, *args, &block) -> an_interface
|
|
22
|
+
#
|
|
23
|
+
# Takes a dramatis proxy object and returns an object that can be
|
|
24
|
+
# used to operate directly on the proxy, rather than on the proxied
|
|
25
|
+
# object. Since dramatis objects like actor names and futures are
|
|
26
|
+
# proxy objects, normal method calls on them are directed to the
|
|
27
|
+
# proxied object. In order to perform operations on the proxies
|
|
28
|
+
# themselves, the interface method is used to get access to a
|
|
29
|
+
# non-proxy object. If the object passed is a Dramatis::Actor::Name,
|
|
30
|
+
# the result is a Dramatis::Actor::Name::Interface object. If the
|
|
31
|
+
# object passed is a Dramatis::Future, the result is a
|
|
32
|
+
# Dramatis::Future::Interface object.
|
|
33
|
+
|
|
34
|
+
def interface object, *args, &block
|
|
35
|
+
interface = nil
|
|
36
|
+
begin
|
|
37
|
+
interface = object.class.const_get( :Interface )
|
|
38
|
+
rescue NameError => name_error
|
|
39
|
+
raise Dramatis::Error::Interface.new( "object is not a dramatis interfaceable object: " + object.class.to_s )
|
|
40
|
+
end
|
|
41
|
+
interface.new( object, *args, &block )
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
module_function :interface
|
|
45
|
+
|
|
46
|
+
# :call-seq:
|
|
47
|
+
# release(name) -> a_name
|
|
48
|
+
#
|
|
49
|
+
# Takes an actor name and returns a new actor name which, when used
|
|
50
|
+
# as the target of a method call, will pass a null continuation. As
|
|
51
|
+
# a result, the call will not block or otherwise wait for a
|
|
52
|
+
# result. The result of such a call is always nil.
|
|
53
|
+
|
|
54
|
+
def release name
|
|
55
|
+
interface( name ).continue nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
module_function :release
|
|
59
|
+
|
|
60
|
+
# :call-seq:
|
|
61
|
+
# future(name) -> a_name
|
|
62
|
+
#
|
|
63
|
+
# Takes an actor name and returns a new actor name which, when used
|
|
64
|
+
# as the target of a method call, will pass a future
|
|
65
|
+
# continuation. It immediately returns a Dramatis::Future object.
|
|
66
|
+
|
|
67
|
+
def future name
|
|
68
|
+
interface( name ).future
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
module_function :future
|
|
72
|
+
|
|
73
|
+
end
|
data/log/debug.log
ADDED
|
File without changes
|
data/script/destroy
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/destroy'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/generate'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
begin
|
|
5
|
+
require 'newgem'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
|
8
|
+
puts "Install: gem install newgem\n\n"
|
|
9
|
+
exit(1)
|
|
10
|
+
end
|
|
11
|
+
require 'redcloth'
|
|
12
|
+
require 'syntax/convertors/html'
|
|
13
|
+
require 'erb'
|
|
14
|
+
require File.dirname(__FILE__) + '/../lib/dramatis/version.rb'
|
|
15
|
+
|
|
16
|
+
version = Dramatis::VERSION::STRING
|
|
17
|
+
download = 'http://rubyforge.org/projects/dramatis'
|
|
18
|
+
|
|
19
|
+
class Fixnum
|
|
20
|
+
def ordinal
|
|
21
|
+
# teens
|
|
22
|
+
return 'th' if (10..19).include?(self % 100)
|
|
23
|
+
# others
|
|
24
|
+
case self % 10
|
|
25
|
+
when 1: return 'st'
|
|
26
|
+
when 2: return 'nd'
|
|
27
|
+
when 3: return 'rd'
|
|
28
|
+
else return 'th'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Time
|
|
34
|
+
def pretty
|
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def convert_syntax(syntax, source)
|
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if ARGV.length >= 1
|
|
44
|
+
src, template = ARGV
|
|
45
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
|
46
|
+
|
|
47
|
+
else
|
|
48
|
+
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
|
49
|
+
exit!
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
template = ERB.new(File.open(template).read)
|
|
53
|
+
|
|
54
|
+
title = nil
|
|
55
|
+
body = nil
|
|
56
|
+
File.open(src) do |fsrc|
|
|
57
|
+
title_text = fsrc.readline
|
|
58
|
+
body_text = fsrc.read
|
|
59
|
+
syntax_items = []
|
|
60
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
|
61
|
+
ident = syntax_items.length
|
|
62
|
+
element, syntax, source = $1, $2, $3
|
|
63
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
|
64
|
+
"syntax-temp-#{ident}"
|
|
65
|
+
}
|
|
66
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
|
67
|
+
body = RedCloth.new(body_text).to_html
|
|
68
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
|
69
|
+
end
|
|
70
|
+
stat = File.stat(src)
|
|
71
|
+
created = stat.ctime
|
|
72
|
+
modified = stat.mtime
|
|
73
|
+
|
|
74
|
+
$stdout << template.result(binding)
|