ramaze 2011.01.30 → 2011.07.25
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/.gitignore +2 -1
- data/.mailmap +2 -0
- data/.rvmrc +1 -0
- data/README.md +119 -197
- data/Rakefile +14 -97
- data/bin/ramaze +6 -14
- data/doc/AUTHORS +8 -4
- data/doc/CHANGELOG +3784 -3339
- data/examples/app/chat/start.rb +2 -2
- data/lib/proto/app.rb +2 -3
- data/lib/proto/config.ru +4 -5
- data/lib/proto/controller/init.rb +11 -4
- data/lib/proto/controller/main.rb +12 -7
- data/lib/proto/layout/default.xhtml +56 -23
- data/lib/proto/model/init.rb +3 -1
- data/lib/proto/public/css/grid.css +107 -0
- data/lib/proto/public/css/layout.css +81 -0
- data/lib/proto/public/css/reset.css +123 -0
- data/lib/proto/public/css/text.css +109 -0
- data/lib/proto/public/images/bg.png +0 -0
- data/lib/proto/spec/main.rb +2 -2
- data/lib/proto/start.rb +11 -1
- data/lib/proto/view/index.xhtml +27 -23
- data/lib/ramaze.rb +0 -1
- data/lib/ramaze/app.rb +85 -12
- data/lib/ramaze/app_graph.rb +107 -0
- data/lib/ramaze/bin/console.rb +87 -0
- data/lib/ramaze/bin/create.rb +94 -0
- data/lib/ramaze/bin/helper.rb +107 -0
- data/lib/ramaze/bin/restart.rb +95 -0
- data/lib/ramaze/bin/runner.rb +141 -0
- data/lib/ramaze/bin/start.rb +206 -0
- data/lib/ramaze/bin/status.rb +152 -0
- data/lib/ramaze/bin/stop.rb +112 -0
- data/lib/ramaze/cache.rb +9 -4
- data/lib/ramaze/cache/localmemcache.rb +10 -13
- data/lib/ramaze/cache/lru.rb +49 -7
- data/lib/ramaze/cache/memcache.rb +170 -92
- data/lib/ramaze/cache/sequel.rb +301 -118
- data/lib/ramaze/controller.rb +108 -9
- data/lib/ramaze/controller/default.rb +15 -2
- data/lib/ramaze/current.rb +14 -2
- data/lib/ramaze/dependencies.rb +46 -0
- data/lib/ramaze/files.rb +38 -3
- data/lib/ramaze/gestalt.rb +12 -12
- data/lib/ramaze/helper.rb +0 -2
- data/lib/ramaze/helper/auth.rb +30 -23
- data/lib/ramaze/helper/blue_form.rb +175 -126
- data/lib/ramaze/helper/csrf.rb +76 -91
- data/lib/ramaze/helper/email.rb +105 -0
- data/lib/ramaze/helper/erector.rb +16 -15
- data/lib/ramaze/helper/gestalt.rb +2 -2
- data/lib/ramaze/helper/layout.rb +89 -73
- data/lib/ramaze/helper/link.rb +7 -6
- data/lib/ramaze/helper/localize.rb +6 -5
- data/lib/ramaze/helper/markaby.rb +25 -23
- data/lib/ramaze/helper/maruku.rb +3 -3
- data/lib/ramaze/helper/paginate.rb +19 -27
- data/lib/ramaze/helper/remarkably.rb +3 -3
- data/lib/ramaze/helper/request_accessor.rb +3 -3
- data/lib/ramaze/helper/send_file.rb +12 -8
- data/lib/ramaze/helper/simple_captcha.rb +5 -6
- data/lib/ramaze/helper/stack.rb +7 -4
- data/lib/ramaze/helper/tagz.rb +10 -11
- data/lib/ramaze/helper/thread.rb +19 -16
- data/lib/ramaze/helper/ultraviolet.rb +7 -4
- data/lib/ramaze/helper/user.rb +40 -21
- data/lib/ramaze/helper/xhtml.rb +29 -20
- data/lib/ramaze/log.rb +3 -11
- data/lib/ramaze/log/analogger.rb +5 -4
- data/lib/ramaze/log/growl.rb +9 -7
- data/lib/ramaze/log/hub.rb +3 -5
- data/lib/ramaze/log/informer.rb +15 -12
- data/lib/ramaze/log/knotify.rb +3 -5
- data/lib/ramaze/log/logger.rb +3 -5
- data/lib/ramaze/log/logging.rb +6 -8
- data/lib/ramaze/log/rotatinginformer.rb +27 -17
- data/lib/ramaze/log/syslog.rb +7 -7
- data/lib/ramaze/log/xosd.rb +3 -5
- data/lib/ramaze/middleware_compiler.rb +27 -4
- data/lib/ramaze/reloader.rb +50 -12
- data/lib/ramaze/reloader/watch_inotify.rb +4 -5
- data/lib/ramaze/reloader/watch_stat.rb +3 -3
- data/lib/ramaze/request.rb +18 -8
- data/lib/ramaze/response.rb +38 -7
- data/lib/ramaze/rest.rb +36 -0
- data/lib/ramaze/setup.rb +101 -31
- data/lib/ramaze/spec.rb +1 -1
- data/lib/ramaze/spec/bacon.rb +6 -3
- data/lib/ramaze/spec/helper/bacon.rb +0 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +2 -11
- data/lib/ramaze/view/erector.rb +46 -31
- data/lib/ramaze/view/erubis.rb +7 -3
- data/lib/ramaze/view/ezamar.rb +7 -3
- data/lib/ramaze/view/gestalt.rb +9 -3
- data/lib/ramaze/view/haml.rb +7 -3
- data/lib/ramaze/view/liquid.rb +3 -3
- data/lib/ramaze/view/lokar.rb +7 -3
- data/lib/ramaze/view/mustache.rb +11 -5
- data/lib/ramaze/view/nagoro.rb +3 -3
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/slippers.rb +40 -13
- data/lib/ramaze/view/tagz.rb +9 -5
- data/ramaze.gemspec +23 -128
- data/spec/helper.rb +5 -0
- data/spec/ramaze/bin/app/config.ru +11 -0
- data/spec/ramaze/bin/create.rb +28 -0
- data/spec/ramaze/bin/runner.rb +30 -0
- data/spec/ramaze/bin/start.rb +38 -0
- data/spec/ramaze/cache/memcache.rb +10 -3
- data/spec/ramaze/cache/sequel.rb +7 -0
- data/spec/ramaze/controller/provide_inheritance.rb +0 -10
- data/spec/ramaze/dispatcher/file.rb +19 -15
- data/spec/ramaze/helper/auth.rb +10 -9
- data/spec/ramaze/helper/blue_form.rb +121 -68
- data/spec/ramaze/helper/email.rb +69 -0
- data/spec/ramaze/helper/layout.rb +12 -15
- data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
- data/spec/ramaze/helper/user.rb +2 -0
- data/spec/ramaze/log/growl.rb +14 -1
- data/spec/{contrib → ramaze}/rest.rb +1 -1
- data/spec/ramaze/session/memcache.rb +2 -2
- data/spec/ramaze/view/sass.rb +1 -1
- data/tasks/bacon.rake +3 -3
- data/tasks/gem.rake +17 -18
- data/tasks/rcov.rake +2 -3
- data/tasks/release.rake +8 -65
- data/tasks/setup.rake +10 -8
- data/tasks/todo.rake +9 -5
- data/tasks/yard.rake +3 -2
- metadata +105 -397
- data/MANIFEST +0 -532
- data/TODO.md +0 -19
- data/benchmark/bench_templates/bench.rb +0 -67
- data/benchmark/bench_templates/view/large.erb +0 -79
- data/benchmark/bench_templates/view/large.haml +0 -41
- data/benchmark/bench_templates/view/large.lok +0 -79
- data/benchmark/bench_templates/view/large.xhtml +0 -79
- data/benchmark/bench_templates/view/small.erb +0 -21
- data/benchmark/bench_templates/view/small.haml +0 -12
- data/benchmark/bench_templates/view/small.lok +0 -21
- data/benchmark/bench_templates/view/small.xhtml +0 -21
- data/benchmark/results.txt +0 -131
- data/benchmark/run.rb +0 -355
- data/benchmark/suite/minimal.rb +0 -11
- data/benchmark/suite/no_informer.rb +0 -7
- data/benchmark/suite/no_sessions.rb +0 -9
- data/benchmark/suite/no_template.rb +0 -7
- data/benchmark/suite/simple.rb +0 -5
- data/benchmark/suite/template_erubis.rb +0 -8
- data/benchmark/suite/template_etanni.rb +0 -8
- data/benchmark/suite/template_ezamar.rb +0 -8
- data/benchmark/suite/template_haml.rb +0 -13
- data/benchmark/suite/template_liquid.rb +0 -11
- data/benchmark/suite/template_markaby.rb +0 -9
- data/benchmark/suite/template_nagoro.rb +0 -8
- data/benchmark/suite/template_redcloth.rb +0 -13
- data/benchmark/suite/template_tenjin.rb +0 -8
- data/benchmark/test.rb +0 -35
- data/doc/FAQ +0 -92
- data/doc/INSTALL +0 -92
- data/doc/TODO +0 -29
- data/doc/meta/announcement.txt +0 -119
- data/doc/meta/configuration.txt +0 -163
- data/doc/meta/internals.txt +0 -278
- data/doc/meta/users.kml +0 -64
- data/doc/tutorial/todolist.html +0 -1512
- data/doc/tutorial/todolist.txt +0 -920
- data/examples/app/sourceview/public/coderay.css +0 -104
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +0 -11
- data/examples/app/sourceview/public/jquery.treeview.css +0 -48
- data/examples/app/sourceview/public/jquery.treeview.js +0 -223
- data/examples/app/sourceview/public/sourceview.js +0 -52
- data/examples/app/sourceview/start.rb +0 -79
- data/examples/app/sourceview/view/index.haml +0 -59
- data/examples/helpers/httpdigest.rb +0 -107
- data/lib/proto/public/css/screen.css +0 -30
- data/lib/proto/public/js/jquery.js +0 -7179
- data/lib/ramaze/contrib/addressable_route.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/contrib/email.rb +0 -88
- data/lib/ramaze/contrib/facebook.rb +0 -23
- data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
- data/lib/ramaze/contrib/gettext.rb +0 -113
- data/lib/ramaze/contrib/gettext/mo.rb +0 -155
- data/lib/ramaze/contrib/gettext/parser.rb +0 -46
- data/lib/ramaze/contrib/gettext/po.rb +0 -109
- data/lib/ramaze/contrib/gzip_filter.rb +0 -1
- data/lib/ramaze/contrib/maruku_uv.rb +0 -59
- data/lib/ramaze/contrib/profiling.rb +0 -36
- data/lib/ramaze/contrib/rest.rb +0 -23
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
- data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
- data/lib/ramaze/contrib/sequel/image.rb +0 -196
- data/lib/ramaze/contrib/sequel/relation.rb +0 -98
- data/lib/ramaze/helper/httpdigest.rb +0 -96
- data/lib/ramaze/tool/bin.rb +0 -340
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -120
- data/lib/ramaze/view/less.rb +0 -12
- data/lib/ramaze/view/maruku.rb +0 -15
- data/lib/ramaze/view/redcloth.rb +0 -21
- data/spec/contrib/addressable_route.rb +0 -30
- data/spec/examples/helpers/httpdigest.rb +0 -64
- data/spec/examples/templates/template_redcloth.rb +0 -13
- data/spec/ramaze/bin/ramaze.rb +0 -96
- data/spec/ramaze/helper/httpdigest.rb +0 -176
- data/spec/ramaze/view/less.rb +0 -60
- data/spec/ramaze/view/less/file.css.less +0 -8
- data/spec/ramaze/view/redcloth.rb +0 -66
- data/spec/ramaze/view/redcloth/external.redcloth +0 -8
- data/tasks/copyright.rake +0 -21
- data/tasks/gem_setup.rake +0 -112
- data/tasks/git.rake +0 -46
- data/tasks/grancher.rake +0 -12
- data/tasks/jquery.rake +0 -15
- data/tasks/manifest.rake +0 -4
- data/tasks/metric_changes.rake +0 -24
- data/tasks/reversion.rake +0 -8
- data/tasks/traits.rake +0 -21
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stylesheet used for styling headings, links, etc.
|
|
3
|
+
*
|
|
4
|
+
* @author Yorick Peterse
|
|
5
|
+
* @link http://yorickpeterse.com/
|
|
6
|
+
*/
|
|
7
|
+
body
|
|
8
|
+
{
|
|
9
|
+
background: url('../images/bg.png') repeat top left;
|
|
10
|
+
border-top: 5px solid #444;
|
|
11
|
+
color: #444;
|
|
12
|
+
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, sans-serif;
|
|
13
|
+
font-size: 14px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
p
|
|
17
|
+
{
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
line-height: 22px;
|
|
20
|
+
margin-bottom: 20px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
a
|
|
24
|
+
{
|
|
25
|
+
color: #444;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ol
|
|
29
|
+
{
|
|
30
|
+
margin-left: 20px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
ol li
|
|
34
|
+
{
|
|
35
|
+
list-style-type: decimal;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ul
|
|
39
|
+
{
|
|
40
|
+
margin-left: 18px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ul li
|
|
44
|
+
{
|
|
45
|
+
list-style-type: disc;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ul, ol
|
|
49
|
+
{
|
|
50
|
+
line-height: 22px;
|
|
51
|
+
margin-bottom: 20px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
a:hover, h1 a:hover
|
|
55
|
+
{
|
|
56
|
+
color: #E33F1E;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
h1, h2, h3, h4, h5, h6
|
|
60
|
+
{
|
|
61
|
+
font-weight: bold;
|
|
62
|
+
margin-bottom: 5px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
h1
|
|
66
|
+
{
|
|
67
|
+
font-size: 28px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
h2
|
|
71
|
+
{
|
|
72
|
+
font-size: 24px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
h3
|
|
76
|
+
{
|
|
77
|
+
font-size: 22px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
h4
|
|
81
|
+
{
|
|
82
|
+
font-size: 20px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
h5
|
|
86
|
+
{
|
|
87
|
+
font-size: 18px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
h6
|
|
91
|
+
{
|
|
92
|
+
font-size: 16px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
h1 a
|
|
96
|
+
{
|
|
97
|
+
color: #444;
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
pre
|
|
102
|
+
{
|
|
103
|
+
margin: 20px 0px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
code
|
|
107
|
+
{
|
|
108
|
+
background: #eee;
|
|
109
|
+
}
|
|
Binary file
|
data/lib/proto/spec/main.rb
CHANGED
|
@@ -9,12 +9,12 @@ describe MainController do
|
|
|
9
9
|
should 'show start page' do
|
|
10
10
|
get('/').status.should == 200
|
|
11
11
|
last_response['Content-Type'].should == 'text/html'
|
|
12
|
-
last_response.should =~
|
|
12
|
+
last_response.should =~ /Congratulations, Ramaze is running fine/
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
should 'show /notemplate' do
|
|
16
16
|
get('/notemplate').status.should == 200
|
|
17
17
|
last_response['Content-Type'].should == 'text/html'
|
|
18
|
-
last_response.should =~ /
|
|
18
|
+
last_response.should =~ /There is no 'notemplate\.xhtml' associated with this action\./
|
|
19
19
|
end
|
|
20
20
|
end
|
data/lib/proto/start.rb
CHANGED
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
# Use this file directly like `ruby start.rb` if you don't want to use the
|
|
4
4
|
# `ramaze start` command.
|
|
5
|
+
#
|
|
5
6
|
# All application related things should go into `app.rb`, this file is simply
|
|
6
7
|
# for options related to running the application locally.
|
|
7
|
-
|
|
8
|
+
#
|
|
9
|
+
# You can run this file as following:
|
|
10
|
+
#
|
|
11
|
+
# $ ruby start.rb
|
|
12
|
+
# $ ./start.rb
|
|
13
|
+
#
|
|
14
|
+
# If you want to be able to do the latter you'll have to make sure the file can be
|
|
15
|
+
# executed:
|
|
16
|
+
#
|
|
17
|
+
# $ chmod +x ./start.rb
|
|
8
18
|
require File.expand_path('../app', __FILE__)
|
|
9
19
|
|
|
10
20
|
Ramaze.start(:adapter => :webrick, :port => 7000, :file => __FILE__)
|
data/lib/proto/view/index.xhtml
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
<p>
|
|
2
|
-
|
|
2
|
+
Congratulations, Ramaze is running fine and you can start working on your application.
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p>
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
You can play around with this prototype by changing the following:
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<ul>
|
|
8
10
|
<li>
|
|
9
|
-
|
|
11
|
+
<code>view/index.xhtml</code>: the content of this page.
|
|
10
12
|
</li>
|
|
11
13
|
<li>
|
|
12
|
-
|
|
14
|
+
<code>layout/default.xhtml</code>: the layout for this page.
|
|
13
15
|
</li>
|
|
14
16
|
<li>
|
|
15
|
-
|
|
16
|
-
page and the <a href="/notemplate">notemplate</a> action
|
|
17
|
+
<code>controller/main.rb</code>: the controller responsible for server this page.
|
|
17
18
|
</li>
|
|
18
|
-
|
|
19
|
-
</p>
|
|
19
|
+
</ul>
|
|
20
20
|
|
|
21
|
-
<p>
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
<p>
|
|
22
|
+
For more information, check out <a href="http://ramaze.net">ramaze.net</a> and
|
|
23
|
+
<a href="http://ramaze.net/documentation/index.html">the documentation</a>.
|
|
24
|
+
<br />
|
|
25
|
+
You can also read the
|
|
26
|
+
<a href="http://doc.rubyists.com/ramaze%2binnate/">YARD documentation</a>
|
|
27
|
+
or browse around the <a href="https://github.com/ramaze/ramaze">Ramaze source code</a>.
|
|
27
28
|
</p>
|
|
28
29
|
|
|
29
30
|
<p>
|
|
30
|
-
|
|
31
|
-
<a href="
|
|
32
|
-
|
|
33
|
-
<a href="http://
|
|
31
|
+
For help with Ramaze, visit
|
|
32
|
+
<a href="irc://chat.freenode.net/ramaze">#ramaze on irc.freenode.net</a>.
|
|
33
|
+
<br />
|
|
34
|
+
You can use <a href="http://embed.mibbit.com/?server=irc.freenode.net&channel=#ramaze,#ruby-lang&forcePrompt=true">Mibbit</a>,
|
|
35
|
+
an AJAX based IRC client or
|
|
36
|
+
<a href="http://java.freenode.net/?channel=ramaze">
|
|
37
|
+
the official freenode irc java applet
|
|
38
|
+
</a>.
|
|
34
39
|
</p>
|
|
35
40
|
|
|
36
41
|
<p>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Feel free to post to the <a href="http://groups.google.com/group/ramaze">Ramaze Google Group</a>, your first mail has to go through moderation, so please be patient.
|
|
42
|
+
Feel free to post to the
|
|
43
|
+
<a href="https://groups.google.com/forum/#!forum/ramaze">Ramaze Google Group</a>, your
|
|
44
|
+
first mail has to go through moderation, so please be patient.
|
|
41
45
|
</p>
|
data/lib/ramaze.rb
CHANGED
data/lib/ramaze/app.rb
CHANGED
|
@@ -3,9 +3,9 @@ module Ramaze
|
|
|
3
3
|
# common name.
|
|
4
4
|
# Every application has a location it dispatches from, this behaves similar
|
|
5
5
|
# to Rack::URLMap.
|
|
6
|
-
|
|
7
6
|
AppMap = Innate::URLMap.new
|
|
8
7
|
|
|
8
|
+
#:nodoc:
|
|
9
9
|
def self.to(object)
|
|
10
10
|
app_name = object.ancestral_trait[:app]
|
|
11
11
|
App[app_name].to(object)
|
|
@@ -70,6 +70,38 @@ module Ramaze
|
|
|
70
70
|
|
|
71
71
|
attr_reader :name, :location, :url_map, :options
|
|
72
72
|
|
|
73
|
+
##
|
|
74
|
+
# Finds or creates an application for the given name and URI.
|
|
75
|
+
#
|
|
76
|
+
# @author Michael Fellinger
|
|
77
|
+
# @param [String] name The name of the application.
|
|
78
|
+
# @param [String] location The URI to which the app is mapped.
|
|
79
|
+
# @return [Ramaze::App]
|
|
80
|
+
#
|
|
81
|
+
def self.find_or_create(name, location = nil)
|
|
82
|
+
location = '/' if location.nil? && name == :pristine
|
|
83
|
+
self[name] || new(name, location)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# Returns the application for the given name.
|
|
88
|
+
#
|
|
89
|
+
# @author Michael Fellinger
|
|
90
|
+
# @param [String] name The name of the application.
|
|
91
|
+
# @return [Ramaze::App]
|
|
92
|
+
#
|
|
93
|
+
def self.[](name)
|
|
94
|
+
APP_LIST[name.to_sym]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
##
|
|
98
|
+
# Creates a new instance of the application and sets the name and location.
|
|
99
|
+
#
|
|
100
|
+
# @author Michael Fellinger
|
|
101
|
+
# @since 30-06-2009
|
|
102
|
+
# @param [String] name The name of the application.
|
|
103
|
+
# @param [String] location The location to which the application is mapped.
|
|
104
|
+
#
|
|
73
105
|
def initialize(name, location = nil)
|
|
74
106
|
@name = name.to_sym
|
|
75
107
|
@url_map = Innate::URLMap.new
|
|
@@ -80,46 +112,87 @@ module Ramaze
|
|
|
80
112
|
@options = self.class.options.sub(@name)
|
|
81
113
|
end
|
|
82
114
|
|
|
115
|
+
##
|
|
116
|
+
# Syncs the instance of the current application with Ramaze::AppMap.
|
|
117
|
+
#
|
|
118
|
+
# @author Michael Fellinger
|
|
119
|
+
# @since 30-06-2009
|
|
120
|
+
#
|
|
83
121
|
def sync
|
|
84
122
|
AppMap.map(location, self)
|
|
85
123
|
end
|
|
86
124
|
|
|
125
|
+
##
|
|
126
|
+
# Sets the location and syncs the application.
|
|
127
|
+
#
|
|
128
|
+
# @author Michael Fellinger
|
|
129
|
+
# @since 30-06-2009
|
|
130
|
+
#
|
|
87
131
|
def location=(location)
|
|
88
132
|
@location = location.to_str.freeze
|
|
89
133
|
sync
|
|
90
134
|
end
|
|
91
135
|
|
|
136
|
+
##
|
|
137
|
+
# Allows the application to be called as a Rack middleware.
|
|
138
|
+
#
|
|
139
|
+
# @author Michael Fellinger
|
|
140
|
+
# @since 30-06-2009
|
|
141
|
+
# @param [Hash] env The environment hash.
|
|
142
|
+
#
|
|
92
143
|
def call(env)
|
|
93
144
|
to_app.call(env)
|
|
94
145
|
end
|
|
95
146
|
|
|
147
|
+
##
|
|
148
|
+
# Converts the application to a Rack compatible class.
|
|
149
|
+
#
|
|
150
|
+
# @author Michael Fellinger
|
|
151
|
+
# @since 30-06-2009
|
|
152
|
+
# @return [Rack::Cascade]
|
|
153
|
+
#
|
|
96
154
|
def to_app
|
|
97
155
|
files = Ramaze::Files.new(*public_roots)
|
|
98
156
|
app = Current.new(Route.new(url_map), Rewrite.new(url_map))
|
|
99
157
|
Rack::Cascade.new([files, app])
|
|
100
158
|
end
|
|
101
159
|
|
|
160
|
+
##
|
|
161
|
+
# Maps an object to the given URI.
|
|
162
|
+
#
|
|
163
|
+
# @author Michael Fellinger
|
|
164
|
+
# @since 30-06-2009
|
|
165
|
+
# @param [String] location The URI to map the object to.
|
|
166
|
+
# @param [Object] object The object (usually a controller) to map to the
|
|
167
|
+
# URI.
|
|
168
|
+
#
|
|
102
169
|
def map(location, object)
|
|
103
170
|
url_map.map(location, object)
|
|
104
171
|
end
|
|
105
172
|
|
|
173
|
+
##
|
|
174
|
+
# Returns a URI to the given object.
|
|
175
|
+
#
|
|
176
|
+
# @author Michael Fellinger
|
|
177
|
+
# @since 30-06-2009
|
|
178
|
+
# @param [Object] object An object for which to generate the URI.
|
|
179
|
+
#
|
|
106
180
|
def to(object)
|
|
107
181
|
return unless mapped = url_map.to(object)
|
|
108
182
|
[location, mapped].join('/').squeeze('/')
|
|
109
183
|
end
|
|
110
184
|
|
|
185
|
+
##
|
|
186
|
+
# Returns an array containing all the public directories for each root
|
|
187
|
+
# directory.
|
|
188
|
+
#
|
|
189
|
+
# @author Michael Fellinger
|
|
190
|
+
# @since 30-06-2009
|
|
191
|
+
# @return [Array]
|
|
192
|
+
#
|
|
111
193
|
def public_roots
|
|
112
194
|
roots, publics = [*options.roots], [*options.publics]
|
|
113
195
|
roots.map{|root| publics.map{|public| ::File.join(root, public) }}.flatten
|
|
114
196
|
end
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
location = '/' if location.nil? && name == :pristine
|
|
118
|
-
self[name] || new(name, location)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def self.[](name)
|
|
122
|
-
APP_LIST[name.to_sym]
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
197
|
+
end # App
|
|
198
|
+
end # Ramaze
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
3
|
+
module Ramaze
|
|
4
|
+
##
|
|
5
|
+
# The AppGraph class can be used to generate a graph of all the URLs mapped in
|
|
6
|
+
# a Ramaze application and saves this graph as an image.
|
|
7
|
+
#
|
|
8
|
+
# == Usage
|
|
9
|
+
#
|
|
10
|
+
# In order to generate a graph of your application all you need to do is the
|
|
11
|
+
# following:
|
|
12
|
+
#
|
|
13
|
+
# require 'ramaze/app_graph'
|
|
14
|
+
#
|
|
15
|
+
# graph = Ramaze::AppGraph.new graph.generate graph.show
|
|
16
|
+
#
|
|
17
|
+
# Once this code is executed you can find the .dot and PNG files in the root
|
|
18
|
+
# directory of your application.
|
|
19
|
+
#
|
|
20
|
+
# @author Michael Fellinger
|
|
21
|
+
#
|
|
22
|
+
class AppGraph
|
|
23
|
+
##
|
|
24
|
+
# Creates a new instance of the class.
|
|
25
|
+
#
|
|
26
|
+
# @author Michael Fellinger
|
|
27
|
+
#
|
|
28
|
+
def initialize
|
|
29
|
+
@out = Set.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# Generates the graph based on all the current routes. The graph is saved in
|
|
34
|
+
# the application directory.
|
|
35
|
+
#
|
|
36
|
+
# @author Michael Fellinger
|
|
37
|
+
#
|
|
38
|
+
def generate
|
|
39
|
+
Ramaze::AppMap.to_hash.each do |location, app|
|
|
40
|
+
connect(location => app.name)
|
|
41
|
+
|
|
42
|
+
app.url_map.to_hash.each do |c_location, c_node|
|
|
43
|
+
connect(app.name => c_node)
|
|
44
|
+
connect(c_node.mapping => c_node)
|
|
45
|
+
|
|
46
|
+
c_node.update_template_mappings
|
|
47
|
+
c_node.view_templates.each do |wish, mapping|
|
|
48
|
+
mapping.each do |action_name, template|
|
|
49
|
+
action_path = File.join(c_node.mapping, action_name)
|
|
50
|
+
connect(c_node => action_path, action_path => template)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
c_node.update_method_arities
|
|
55
|
+
c_node.method_arities.each do |method, arity|
|
|
56
|
+
action_path = File.join(c_node.mapping, method.to_s)
|
|
57
|
+
connect(
|
|
58
|
+
action_path => "#{c_node}##{method}[#{arity}]",
|
|
59
|
+
c_node => action_path
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# Connects various elements in the graph to each other.
|
|
68
|
+
#
|
|
69
|
+
# @author Michael Fellinger
|
|
70
|
+
#
|
|
71
|
+
def connect(hash)
|
|
72
|
+
hash.each do |from, to|
|
|
73
|
+
@out << (" %p -> %p;" % [from.to_s, to.to_s])
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
##
|
|
78
|
+
# Writes the dot file containing the graph data.
|
|
79
|
+
#
|
|
80
|
+
# @author Michael Fellinger
|
|
81
|
+
#
|
|
82
|
+
def write_dot
|
|
83
|
+
File.open('graph.dot', 'w+') do |dot|
|
|
84
|
+
dot.puts 'digraph appmap {'
|
|
85
|
+
dot.puts(*@out)
|
|
86
|
+
dot.puts '}'
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
# Generates a PNG file based on the .dot file.
|
|
92
|
+
#
|
|
93
|
+
# @author Michael Fellinger
|
|
94
|
+
#
|
|
95
|
+
def show
|
|
96
|
+
write_dot
|
|
97
|
+
options = {
|
|
98
|
+
'rankdir' => 'LR',
|
|
99
|
+
'splines' => 'true',
|
|
100
|
+
'overlap' => 'false',
|
|
101
|
+
}
|
|
102
|
+
args = options.map{|k,v| "-G#{k}=#{v}" }
|
|
103
|
+
system("dot -O -Tpng #{args.join(' ')} graph.dot")
|
|
104
|
+
system('feh graph.dot.png')
|
|
105
|
+
end
|
|
106
|
+
end # AppGraph
|
|
107
|
+
end # Ramaze
|