ramaze 0.1.3 → 0.1.4

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.
Files changed (149) hide show
  1. data/bin/ramaze +58 -26
  2. data/doc/AUTHORS +2 -0
  3. data/doc/CHANGELOG +401 -0
  4. data/doc/README +14 -9
  5. data/doc/README.html +737 -0
  6. data/doc/TODO +14 -14
  7. data/doc/changes.txt +401 -0
  8. data/doc/changes.xml +401 -0
  9. data/doc/meta/announcement.txt +28 -15
  10. data/doc/meta/configuration.txt +3 -3
  11. data/doc/meta/internals.txt +2 -2
  12. data/doc/meta/users.kml +62 -0
  13. data/doc/readme_chunks/examples.txt +1 -1
  14. data/doc/readme_chunks/features.txt +13 -8
  15. data/doc/tutorial/todolist.html +2 -2
  16. data/doc/tutorial/todolist.mkd +2 -2
  17. data/examples/blog/README +3 -0
  18. data/examples/blog/spec/blog.rb +101 -0
  19. data/examples/blog/{main.rb → start.rb} +0 -0
  20. data/examples/caching.rb +16 -5
  21. data/examples/layout.rb +41 -0
  22. data/examples/templates/template_amrita2.rb +1 -1
  23. data/examples/templates/template_erubis.rb +1 -1
  24. data/examples/templates/template_ezamar.rb +1 -1
  25. data/examples/templates/template_haml.rb +1 -1
  26. data/examples/templates/template_liquid.rb +1 -1
  27. data/examples/templates/template_markaby.rb +1 -1
  28. data/examples/templates/template_remarkably.rb +1 -1
  29. data/examples/todolist/README +1 -0
  30. data/{spec/examples → examples/todolist/spec}/todolist.rb +3 -3
  31. data/examples/todolist/{main.rb → start.rb} +0 -0
  32. data/examples/whywiki/{main.rb → start.rb} +0 -0
  33. data/examples/wiktacular/README +2 -0
  34. data/examples/wiktacular/spec/wiktacular.rb +146 -0
  35. data/examples/wiktacular/src/controller.rb +11 -0
  36. data/examples/wiktacular/src/model.rb +5 -1
  37. data/examples/wiktacular/{main.rb → start.rb} +0 -1
  38. data/examples/wiktacular/template/edit.xhtml +1 -2
  39. data/examples/wiktacular/template/html_layout.xhtml +27 -0
  40. data/examples/wiktacular/template/index.xhtml +8 -10
  41. data/examples/wiktacular/template/new.xhtml +1 -2
  42. data/lib/proto/{main.rb → start.rb} +0 -0
  43. data/lib/proto/template/index.xhtml +1 -1
  44. data/lib/ramaze/action/render.rb +58 -4
  45. data/lib/ramaze/action.rb +20 -0
  46. data/lib/ramaze/adapter/cgi.rb +7 -4
  47. data/lib/ramaze/adapter/fcgi.rb +6 -4
  48. data/lib/ramaze/adapter/mongrel.rb +4 -0
  49. data/lib/ramaze/adapter/webrick.rb +20 -9
  50. data/lib/ramaze/adapter.rb +3 -1
  51. data/lib/ramaze/cache/memcached.rb +2 -26
  52. data/lib/ramaze/cache.rb +8 -4
  53. data/lib/ramaze/controller/resolve.rb +26 -8
  54. data/lib/ramaze/controller.rb +44 -7
  55. data/lib/ramaze/dispatcher/action.rb +5 -1
  56. data/lib/ramaze/dispatcher/directory.rb +115 -0
  57. data/lib/ramaze/dispatcher/error.rb +19 -5
  58. data/lib/ramaze/dispatcher/file.rb +2 -2
  59. data/lib/ramaze/dispatcher.rb +52 -39
  60. data/lib/ramaze/global/dsl.rb +3 -2
  61. data/lib/ramaze/global/globalstruct.rb +26 -4
  62. data/lib/ramaze/global.rb +20 -11
  63. data/lib/ramaze/helper/aspect.rb +29 -11
  64. data/lib/ramaze/helper/auth.rb +2 -2
  65. data/lib/ramaze/helper/cache.rb +2 -0
  66. data/lib/ramaze/helper/identity.rb +21 -6
  67. data/lib/ramaze/helper/link.rb +1 -1
  68. data/lib/ramaze/helper/pager.rb +158 -100
  69. data/lib/ramaze/helper/partial.rb +22 -0
  70. data/lib/ramaze/helper/redirect.rb +1 -2
  71. data/lib/ramaze/helper/stack.rb +1 -1
  72. data/lib/ramaze/inform/informer.rb +20 -0
  73. data/lib/ramaze/inform/syslog.rb +5 -0
  74. data/lib/ramaze/snippets/kernel/__dir__.rb +21 -0
  75. data/lib/ramaze/snippets/kernel/aquire.rb +22 -12
  76. data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +33 -0
  77. data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
  78. data/lib/ramaze/snippets/struct/values_at.rb +11 -4
  79. data/lib/ramaze/sourcereload.rb +29 -1
  80. data/{spec → lib/ramaze/spec}/helper/context.rb +0 -0
  81. data/{spec → lib/ramaze/spec}/helper/layout.rb +1 -1
  82. data/{spec → lib/ramaze/spec}/helper/minimal.rb +0 -0
  83. data/{spec → lib/ramaze/spec}/helper/mock_http.rb +0 -0
  84. data/{spec → lib/ramaze/spec}/helper/requester.rb +0 -0
  85. data/{spec → lib/ramaze/spec}/helper/simple_http.rb +0 -0
  86. data/{spec → lib/ramaze/spec}/helper/wrap.rb +0 -0
  87. data/lib/ramaze/spec/helper.rb +60 -0
  88. data/lib/ramaze/store/default.rb +3 -0
  89. data/lib/ramaze/template/ezamar/render_partial.rb +3 -0
  90. data/lib/ramaze/template/sass.rb +45 -0
  91. data/lib/ramaze/template.rb +1 -1
  92. data/lib/ramaze/tool/create.rb +5 -5
  93. data/lib/ramaze/tool/localize.rb +26 -5
  94. data/lib/ramaze/tool/mime.rb +7 -0
  95. data/lib/ramaze/trinity/response.rb +15 -0
  96. data/lib/ramaze/trinity/session.rb +1 -1
  97. data/lib/ramaze/version.rb +1 -1
  98. data/lib/ramaze.rb +5 -0
  99. data/rake_tasks/conf.rake +4 -4
  100. data/rake_tasks/maintaince.rake +12 -7
  101. data/rake_tasks/spec.rake +7 -4
  102. data/spec/examples/caching.rb +6 -8
  103. data/spec/helper.rb +3 -60
  104. data/spec/ramaze/action/basics.rb +17 -0
  105. data/spec/ramaze/action/cache.rb +28 -0
  106. data/spec/ramaze/action/layout.rb +110 -0
  107. data/spec/ramaze/action/render.rb +14 -0
  108. data/spec/ramaze/action/template/bar.xhtml +1 -0
  109. data/spec/ramaze/action/template/other_wrapper.xhtml +1 -0
  110. data/spec/ramaze/action/template/single_wrapper.xhtml +1 -0
  111. data/spec/ramaze/controller/template/edit/content.xhtml +1 -0
  112. data/spec/ramaze/controller/template/edit.xhtml +1 -0
  113. data/spec/ramaze/controller/template_resolving.rb +2 -2
  114. data/spec/ramaze/dispatcher/directory.rb +53 -0
  115. data/spec/ramaze/dispatcher/file.rb +0 -3
  116. data/spec/ramaze/error.rb +17 -2
  117. data/spec/ramaze/helper/aspect.rb +14 -20
  118. data/spec/ramaze/helper/pager.rb +83 -1
  119. data/spec/ramaze/helper/partial.rb +1 -1
  120. data/spec/ramaze/helper/template/test_template.xhtml +1 -0
  121. data/spec/ramaze/inform/informer.rb +37 -5
  122. data/spec/ramaze/localize.rb +1 -1
  123. data/spec/ramaze/template/haml.rb +5 -5
  124. data/spec/ramaze/template/sass/file.css.sass +5 -0
  125. data/spec/ramaze/template/sass.rb +46 -0
  126. data/spec/ramaze/template.rb +1 -1
  127. data/spec/ramaze/trinity/session.rb +27 -0
  128. data/spec/snippets/kernel/__dir__.rb +8 -0
  129. data/spec/snippets/kernel/aquire.rb +71 -0
  130. data/spec/snippets/kernel/constant.rb +27 -0
  131. data/spec/snippets/numeric/human_readable_filesize_format.rb +11 -0
  132. data/spec/snippets/ramaze/caller_info.rb +39 -0
  133. data/spec/snippets/ramaze/caller_lines.rb +27 -0
  134. data/spec/snippets/string/DIVIDE.rb +18 -0
  135. data/spec/snippets/string/camel_case.rb +25 -0
  136. data/spec/snippets/string/color.rb +11 -0
  137. data/spec/snippets/string/snake_case.rb +17 -0
  138. data/spec/snippets/struct/fill.rb +27 -0
  139. data/spec/snippets/struct/values_at.rb +39 -0
  140. metadata +71 -31
  141. data/examples/todolist/todolist.db +0 -5
  142. data/examples/wiktacular/src/page.rb +0 -66
  143. data/lib/ramaze/helper/feed.rb +0 -135
  144. data/lib/ramaze/helper/form.rb +0 -204
  145. data/lib/ramaze/snippets/openstruct/temp.rb +0 -13
  146. data/lib/ramaze/store/yaml.rb +0 -170
  147. data/spec/ramaze/helper/feed.rb +0 -127
  148. data/spec/ramaze/helper/form.rb +0 -146
  149. data/spec/ramaze/store/yaml.rb +0 -76
@@ -4,6 +4,9 @@
4
4
  require 'yaml/store'
5
5
 
6
6
  module Ramaze
7
+
8
+ # Namespace for Stores in Ramaze
9
+
7
10
  module Store
8
11
 
9
12
  # A simple wrapper around YAML::Store
@@ -5,6 +5,9 @@ require 'ramaze/template/ezamar/engine'
5
5
  require 'ramaze/helper/partial'
6
6
 
7
7
  module Ezamar
8
+
9
+ # A transformer for <render /> tags.
10
+
8
11
  class RenderPartial
9
12
  extend Ramaze::PartialHelper
10
13
 
@@ -0,0 +1,45 @@
1
+ # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
+ # All files in this distribution are subject to the terms of the Ruby license.
3
+
4
+ require 'sass/engine'
5
+
6
+ module Ramaze
7
+ module Template
8
+
9
+ # Is responsible for compiling a template using the Sass CSS templating engine.
10
+ # Can be found at: http://haml.hamptoncatlin.com/
11
+
12
+ class Sass < Template
13
+
14
+ # Custom SASS-options for your controller to be merged.
15
+
16
+ trait :sass_options => {
17
+ :locals => {}
18
+ }
19
+
20
+ ENGINES[self] = %w[ sass ]
21
+
22
+ class << self
23
+
24
+ # Transform any String via Sass, takes optionally an hash with the
25
+ # sass_options that you can set also by
26
+ # trait :sass_options => {}
27
+ # if you pass the options it will merge the trait with them. (your
28
+ # options override the defaults from trait[:sass_options]
29
+
30
+ def transform action
31
+ Response.current['Content-Type'] = "text/css"
32
+ sass = wrap_compile(action)
33
+ sass.to_css()
34
+ end
35
+
36
+ # Instantiates Sass::Engine with the template and sass_options from
37
+ # the trait.
38
+
39
+ def compile(action, template)
40
+ ::Sass::Engine.new(template, ancestral_trait[:sass_options])
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -16,7 +16,7 @@ module Ramaze
16
16
 
17
17
  ENGINES = {} unless defined?(ENGINES)
18
18
 
19
- %w[ Amrita2 Erubis Haml Liquid Markaby Remarkably ].each do |const|
19
+ %w[ Amrita2 Erubis Haml Liquid Markaby Remarkably Sass ].each do |const|
20
20
  autoload(const, "ramaze/template/#{const.downcase}")
21
21
  end
22
22
 
@@ -29,14 +29,14 @@ module Ramaze
29
29
  @basedir = ::Ramaze::BASEDIR / 'proto'
30
30
  @destdir = Dir.pwd / project
31
31
 
32
- puts "creating project: #{project}"
32
+ puts "Creating project #{project}"
33
33
 
34
34
  FileUtils.mkdir_p(project)
35
35
 
36
- puts "copy proto to new project (#@destdir)..."
36
+ puts "Copying skeleton project to new project (#@destdir)..."
37
37
 
38
38
  directories, files =
39
- Dir[@basedir / '**' / '*'].partition{|f| File.directory?(f) }
39
+ Dir[@basedir / '**' / '*'].partition{ |f| File.directory?(f) }
40
40
 
41
41
  create_dirs(*directories)
42
42
  copy_files(*files)
@@ -49,7 +49,7 @@ module Ramaze
49
49
  dirs.each do |dir|
50
50
  dest = dir.gsub(@basedir, @destdir)
51
51
 
52
- puts "create directory: '#{dest}'"
52
+ puts "Create directory: '#{dest}'"
53
53
  FileUtils.mkdir_p(dest)
54
54
  end
55
55
  end
@@ -60,7 +60,7 @@ module Ramaze
60
60
  files.each do |file|
61
61
  dest = file.gsub(@basedir, @destdir)
62
62
 
63
- puts "copy file: '#{dest}'"
63
+ puts "Copy file: '#{dest}'"
64
64
  FileUtils.cp(file, dest)
65
65
  end
66
66
  end
@@ -4,6 +4,10 @@
4
4
  $KCODE = 'UTF-8'
5
5
  require 'ya2yaml'
6
6
 
7
+ # Localize helps transforming arbitrary text into localized forms using
8
+ # a simple regular expression and substituting occurences with predefined
9
+ # snippets stored in YAML files.
10
+
7
11
  class Ramaze::Tool::Localize
8
12
 
9
13
  # Enable Localization
@@ -16,8 +20,8 @@ class Ramaze::Tool::Localize
16
20
  # languages supported
17
21
  trait :languages => %w[ en ]
18
22
 
19
- # YAML files the localizations are saved to and loaded from, %s is substituded
20
- # by the values from trait[:languages]
23
+ # YAML files the localizations are saved to and loaded from, %s is
24
+ # substituted by the values from trait[:languages]
21
25
  trait :file => 'conf/locale_%s.yaml'.freeze
22
26
 
23
27
  # The pattern that is substituted with the translation of the current locale.
@@ -36,6 +40,8 @@ class Ramaze::Tool::Localize
36
40
 
37
41
  include Ramaze::Trinity
38
42
 
43
+ # Enables being plugged into Dispatcher::Action::FILTER
44
+
39
45
  def call(response, options = {})
40
46
  return response unless trait[:enable]
41
47
  return response if response.body.nil?
@@ -44,6 +50,10 @@ class Ramaze::Tool::Localize
44
50
  response
45
51
  end
46
52
 
53
+ # Localizes a response body. It reacts to a regular expression as given
54
+ # in trait[:regex]. Every 'entity' in it will be translated, see
55
+ # `localize` for more information.
56
+
47
57
  def localize_body(body, options)
48
58
  locale = session[:LOCALE] || set_session_locale
49
59
 
@@ -56,9 +66,10 @@ class Ramaze::Tool::Localize
56
66
  body
57
67
  end
58
68
 
59
- def localize(str, locale)
60
- Ramaze::Inform.debug "localizing: #{locale} => '#{str}'"
69
+ # Localizes a single 'entity'. If a translation in the chosen language is
70
+ # not available, it falls back to the default language.
61
71
 
72
+ def localize(str, locale)
62
73
  trans = nil
63
74
  default_language = trait[:default_language]
64
75
  dict = dictionary
@@ -81,6 +92,10 @@ class Ramaze::Tool::Localize
81
92
  str
82
93
  end
83
94
 
95
+ # Sets session[:LOCALE] to one of the languages defined in the dictionary.
96
+ # It first tries to honor the browsers accepted languages and then falls
97
+ # back to the default language.
98
+
84
99
  def set_session_locale
85
100
  session[:LOCALE] = trait[:default_language]
86
101
  accepted_langs = request.http_accept_language rescue 'en'
@@ -98,12 +113,16 @@ class Ramaze::Tool::Localize
98
113
  end
99
114
 
100
115
  session[:LOCALE]
101
- end # end set_session_locale
116
+ end
117
+
118
+ # Returns the dictionary used for translation.
102
119
 
103
120
  def dictionary
104
121
  trait[:dictionary] || load(*trait[:languages])
105
122
  end
106
123
 
124
+ # Load given locales from disk and save it into the dictionary.
125
+
107
126
  def load(*locales)
108
127
  Ramaze::Inform.debug "loading locales: #{locales.inspect}"
109
128
 
@@ -120,6 +139,8 @@ class Ramaze::Tool::Localize
120
139
  trait[:dictionary] = dict
121
140
  end
122
141
 
142
+ # Stores given locales from the dictionary to disk.
143
+
123
144
  def store(*locales)
124
145
  locales.uniq.compact.each do |locale|
125
146
  Ramaze::Inform.debug "saving localized to: #{trait[:file] % locale}"
@@ -5,11 +5,18 @@ require 'yaml'
5
5
 
6
6
  module Ramaze
7
7
  module Tool
8
+
9
+ # Responsible for lookup of MIME info for filetypes based on extension.
10
+
8
11
  module MIME
9
12
 
13
+ # the mime_types.yaml as full path, we use a copy of mongrels.
10
14
  trait :types => YAML.load_file(BASEDIR/'ramaze'/'tool'/'mime_types.yaml')
11
15
 
12
16
  class << self
17
+
18
+ # Get MIME-type for the given filename based on extension.
19
+ # Answers with an empty string if none is found.
13
20
  def type_for file
14
21
  ext = File.extname(file)
15
22
  trait[:types][ext].to_s
@@ -2,7 +2,22 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
+
6
+ # Subclassing Rack::Response for our own purposes.
5
7
  class Response < ::Rack::Response
8
+ # build a response, default values are from the current response.
9
+
10
+ def build body = body, status = status, head = header
11
+ Dispatcher.set_cookie if Global.sessions
12
+
13
+ head.each do |key, value|
14
+ self[key] = value
15
+ end
16
+
17
+ self.body, self.status = body, status
18
+ self
19
+ end
20
+
6
21
  class << self
7
22
 
8
23
  # get the current response out of Thread.current[:response]
@@ -76,7 +76,7 @@ module Ramaze
76
76
  # enabled
77
77
 
78
78
  def startup(options = {})
79
- Cache.add(:sessions) if Global.cookies
79
+ Cache.add(:sessions) if Global.sessions
80
80
  end
81
81
 
82
82
  # answers with Thread.current[:session] which holds the current session
@@ -5,7 +5,7 @@ module Ramaze #:nodoc:
5
5
  module Version #:nodoc:
6
6
  MAJOR = 0
7
7
  MINOR = 1
8
- TINY = 3
8
+ TINY = 4
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY].join('.')
11
11
  end
data/lib/ramaze.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ end
8
+
4
9
  # The main namespace for Ramaze
5
10
  module Ramaze
6
11
  BASEDIR = File.dirname(File.expand_path(__FILE__))
data/rake_tasks/conf.rake CHANGED
@@ -1,6 +1,6 @@
1
1
  AUTHOR = "manveru"
2
2
  EMAIL = "m.fellinger@gmail.com"
3
- DESCRIPTION = "Ramaze tries to be a very simple Webframework without the voodoo"
3
+ DESCRIPTION = "Ramaze is a simple and modular web framework"
4
4
  HOMEPATH = 'http://ramaze.rubyforge.org'
5
5
  BIN_FILES = %w( ramaze )
6
6
 
@@ -49,8 +49,8 @@ You can now do following:
49
49
  * Create a new project using the `ramaze' command:
50
50
  ramaze --create yourproject
51
51
 
52
- * Browse and try the Examples in
53
- #{File.join(Gem.path, 'gems', 'ramaze-' + VERS, 'examples')}
54
-
55
52
  #{'=' * 60}
56
53
  }.strip
54
+
55
+ # * Browse and try the Examples in
56
+ # #{File.join(Gem.path, 'gems', 'ramaze-' + VERS, 'examples')}
@@ -155,6 +155,7 @@ task 'tutorial2html' do
155
155
  File.open(basefile + '.html', 'w+'){|f| f.puts(wrap) }
156
156
  end
157
157
 
158
+ desc "Rebuild doc/tutorial/todolist.html"
158
159
  task 'tutorial' => ['tutorial2html'] do
159
160
  require 'hpricot'
160
161
 
@@ -196,17 +197,19 @@ task 'tutorial' => ['tutorial2html'] do
196
197
  end
197
198
  end
198
199
 
200
+ desc "Update /doc/AUTORS"
199
201
  task 'authors' do
200
202
  changes = `darcs changes`
201
203
  authors = []
202
204
  mapping = {}
203
205
  author_map = {
204
- 'm.fellinger@gmail.com' => 'Michael Fellinger',
205
- 'manveru@weez-int.com' => 'Michael Fellinger',
206
- 'clive@crous.co.za' => 'Clive Crous',
207
- 'blueonyx@dev-area.net' => 'Martin Hilbig',
208
- 'rff.rff@gmail.com' => 'Gabriele Renzi',
209
- 'comp.lang.zenix+ramaze@gmail.com' => 'zenix',
206
+ 'm.fellinger@gmail.com' => 'Michael Fellinger',
207
+ 'manveru@weez-int.com' => 'Michael Fellinger',
208
+ 'clive@crous.co.za' => 'Clive Crous',
209
+ 'blueonyx@dev-area.net' => 'Martin Hilbig',
210
+ 'rff.rff@gmail.com' => 'Gabriele Renzi',
211
+ 'comp.lang.zenix+ramaze@gmail.com' => 'zenix',
212
+ 'jesuswasramazing.10.pistos@geoshell.com' => 'Pistos',
210
213
  }
211
214
  changes.split("\n").grep(/^\w/).each do |line|
212
215
  splat = line.split
@@ -230,6 +233,7 @@ task 'authors' do
230
233
  end
231
234
  end
232
235
 
236
+ desc "upload packages to rubyforge"
233
237
  task 'release' => ['distribute'] do
234
238
  sh 'rubyforge login'
235
239
  #sh "rubyforge add_release ramaze ramaze #{VERS} pkg/ramaze-#{VERS}.gem"
@@ -248,7 +252,6 @@ task 'release' => ['distribute'] do
248
252
  sh "rubyforge add_file ramaze ramaze #{release_id} pkg/ramaze-#{VERS}.tar.bz2"
249
253
  end
250
254
 
251
- desc "list all undocumented methods"
252
255
  task 'undocumented-module' do
253
256
  require 'strscan'
254
257
  require 'term/ansicolor'
@@ -342,11 +345,13 @@ task 'undocumented-module' do
342
345
  puts
343
346
  end
344
347
 
348
+ desc "list all undocumented methods"
345
349
  task 'undocumented' do
346
350
  $VERBOSE = false
347
351
  Rake::Task['undocumented-module'].execute
348
352
  end
349
353
 
354
+ desc "list all undocumented methods verbosely"
350
355
  task 'undocumented-verbose' do
351
356
  $VERBOSE = true
352
357
  Rake::Task['undocumented-module'].execute
data/rake_tasks/spec.rake CHANGED
@@ -2,15 +2,18 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  require 'rake'
5
- require 'spec/helper/layout'
5
+ require 'ramaze/spec/helper/layout'
6
6
  require 'lib/ramaze/snippets/string/DIVIDE'
7
7
 
8
8
  SPEC_BASE = File.expand_path('spec')
9
-
9
+ EXAMPLE_BASE = File.expand_path('examples')
10
+ SNIPPETS_BASE = File.expand_path('snippets')
10
11
  # ignore files with these paths
11
12
  ignores = [ './*', './helper/*', './ramaze/adapter.rb', './ramaze/request.rb', ]
12
13
 
13
- files = Dir[SPEC_BASE/'**'/'*.rb']
14
+ files = Dir[SPEC_BASE/'**'/'*.rb'] +
15
+ Dir[EXAMPLE_BASE/'**/spec'/'*.rb']
16
+ Dir[SNIPPETS_BASE/'**/*.rb']
14
17
  ignores.each do |ignore|
15
18
  ignore_files = Dir[SPEC_BASE/ignore]
16
19
  ignore_files.each do |ignore_file|
@@ -23,7 +26,7 @@ files.sort!
23
26
  spec_layout = Hash.new{|h,k| h[k] = []}
24
27
 
25
28
  files.each do |file|
26
- name = file.gsub(/^#{SPEC_BASE}/, '.')
29
+ name = file.gsub(/^(#{SPEC_BASE}|#{EXAMPLE_BASE})/, '.')
27
30
  dir_name = File.dirname(name)[2..-1]
28
31
  task_name = ([:test] + dir_name.split('/')).join(':')
29
32
  spec_layout[task_name] << file
@@ -6,14 +6,12 @@ describe 'Caching' do
6
6
  ramaze
7
7
 
8
8
  it '/' do
9
- n1 = 10_000
10
- n2 = 10_000
11
- result = n1 ** n2
12
- url = "/#{n1}/#{n2}"
13
- result_string = "Hello, i'm a little method with this calculation:\n#{n1} ** #{n2} = #{result}"
9
+ 3.times do
10
+ lambda{ get('/') }.should_not change{ get('/').body }
11
+ end
14
12
 
15
- intense_time = Benchmark.realtime{ get(url).body.should == result_string }
16
- cached_already = Benchmark.realtime{ 10.times{ get(url) } }
17
- intense_time.should be > cached_already
13
+ 3.times do
14
+ lambda{ get('/invalidate') }.should change{ get('/').body }
15
+ end
18
16
  end
19
17
  end
data/spec/helper.rb CHANGED
@@ -1,60 +1,3 @@
1
- # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the Ruby license.
3
-
4
- require 'spec/helper/minimal'
5
- require 'spec/helper/mock_http'
6
- require 'spec/helper/simple_http'
7
- require 'spec/helper/requester'
8
- require 'spec/helper/context'
9
-
10
- Spec::Runner.configure do |config|
11
- config.include MockHTTP
12
- end
13
-
14
-
15
- if defined?(::Spec)
16
- exclude = Ramaze::Controller.class_trait[:exclude_action_modules]
17
- exclude += [Base64::Deprecated, Base64, Spec::Expectations::ObjectExpectations]
18
- exclude << Spec::Mocks::Methods if defined?(Spec::Mock::Methods)
19
- end
20
-
21
- # start up ramaze with a given hash of options
22
- # that will be merged with the default-options.
23
-
24
- def ramaze_start hash = {}
25
- options = {
26
- :adapter => false,
27
- :run_loose => true,
28
- :error_page => false,
29
- :port => 7007,
30
- :host => '127.0.0.1',
31
- :force => true,
32
- :origin => :spec,
33
- }.merge(hash)
34
-
35
- Ramaze.start(options)
36
- end
37
-
38
- alias ramaze ramaze_start
39
-
40
- # shutdown ramaze, this is not implemeted yet
41
- # (and might never be due to limited possibilites)
42
-
43
- def browser(*args, &block)
44
- Browser.new(*args, &block)
45
- end
46
-
47
-
48
- # require each of the following and rescue LoadError, telling you why it failed.
49
-
50
- def testcase_requires(*following)
51
- following.each do |file|
52
- require(file.to_s)
53
- end
54
- rescue LoadError => ex
55
- puts ex
56
- puts "Can't run #{$0}: #{ex}"
57
- puts "Usually you should not worry about this failure, just install the"
58
- puts "library and try again (if you want to use that feature later on)"
59
- exit
60
- end
1
+ $LOAD_PATH.unshift( File.join( File.dirname(__FILE__), "lib" ) )
2
+ require 'ramaze'
3
+ require 'ramaze/spec/helper'