ramaze 2012.12.08 → 2023.01.06

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -1
  3. data/examples/app/whywiki/spec/whywiki.rb +22 -24
  4. data/examples/app/whywiki/start.rb +10 -9
  5. data/examples/app/whywiki/{template → view}/edit.xhtml +2 -2
  6. data/examples/app/whywiki/view/show.xhtml +20 -0
  7. data/examples/app/wikore/spec/wikore.rb +1 -1
  8. data/guide/AUTHORS +11 -3
  9. data/guide/CHANGELOG +3761 -3599
  10. data/guide/general/sessions.md +42 -0
  11. data/lib/proto/Gemfile +2 -2
  12. data/lib/ramaze/cache/memcache.rb +3 -3
  13. data/lib/ramaze/cache/moneta.rb +143 -0
  14. data/lib/ramaze/cache/redis.rb +8 -11
  15. data/lib/ramaze/cache/sequel.rb +2 -2
  16. data/lib/ramaze/cache.rb +1 -0
  17. data/lib/ramaze/files.rb +1 -1
  18. data/lib/ramaze/helper/paginate.rb +5 -0
  19. data/lib/ramaze/helper/request_accessor.rb +3 -1
  20. data/lib/ramaze/helper/stack.rb +1 -1
  21. data/lib/ramaze/helper/upload.rb +1 -1
  22. data/lib/ramaze/log/syslog.rb +1 -1
  23. data/lib/ramaze/request.rb +2 -2
  24. data/lib/ramaze/snippets.rb +0 -1
  25. data/lib/ramaze/version.rb +3 -1
  26. data/lib/ramaze/view/nagoro/render_partial.rb +1 -1
  27. data/lib/ramaze.rb +1 -1
  28. data/ramaze.gemspec +11 -12
  29. data/spec/ramaze/cache/moneta.rb +53 -0
  30. data/spec/ramaze/cache/redis.rb +1 -1
  31. data/spec/ramaze/dispatcher/directory.rb +14 -7
  32. data/spec/ramaze/dispatcher/file.rb +0 -5
  33. data/spec/ramaze/error.rb +13 -17
  34. data/spec/ramaze/helper/paginate.rb +25 -0
  35. data/spec/ramaze/log/syslog.rb +11 -2
  36. data/spec/ramaze/session/redis.rb +2 -2
  37. data/spec/ramaze/view/haml.rb +3 -3
  38. data/spec/ramaze/view/slim.rb +1 -1
  39. metadata +88 -158
  40. data/.gems +0 -28
  41. data/.gitignore +0 -14
  42. data/.mailmap +0 -34
  43. data/.rvmrc +0 -2
  44. data/.travis.yml +0 -16
  45. data/.yardopts +0 -14
  46. data/examples/app/blog/public/.htaccess +0 -24
  47. data/examples/app/whywiki/template/show.xhtml +0 -18
  48. data/lib/ramaze/cache/localmemcache.rb +0 -53
  49. data/lib/ramaze/snippets/ramaze/lru_hash.rb +0 -247
  50. data/spec/ramaze/cache/localmemcache.rb +0 -50
  51. data/spec/ramaze/session/localmemcache.rb +0 -60
@@ -138,6 +138,12 @@ To make it easier to display flash based messages you can use
138
138
  {Ramaze::Helper::Flash#flashbox}. You can load this helper by calling
139
139
  ``helper(:flash)`` inside your controller.
140
140
 
141
+ Displaying the flashbox is then as simple as :
142
+
143
+ #{flashbox}
144
+
145
+ anywhere in your layouts or views.
146
+
141
147
  To change the markup of the flashbox' HTML you can use the following trait
142
148
  inside your controller:
143
149
 
@@ -166,3 +172,39 @@ displayed because the flash data isn't there yet. As soon as the client visits
166
172
  "Hello, Ramaze!" would be displayed. Refreshing the page would clear the flash
167
173
  data and the message would no longer be displayed until the client visits
168
174
  /set\_message again.
175
+
176
+ In the above example, the content of the flash is returned by a method in the
177
+ controller. However, the most common scenario is to address the flash object
178
+ directly in the layouts or viems. You can display flash data (in your
179
+ layout for instance), just like any other variable :
180
+
181
+ #{flash[:message]}
182
+
183
+ and you can use any key in flash, and display in a view or in a layout
184
+ afterwards (no just :message of course).
185
+
186
+ For instance, let's say you want to display information boxes at the top of your
187
+ layout page. This information is displayed when an operation succeeds, fails, or
188
+ when you just want to inform the user. You can easily take advantage of your key
189
+ values and use them as css selectors like that :
190
+
191
+ ....
192
+ <div>
193
+ <!-- flash -->
194
+ <?r [:success, :error, :info].each do |type| ?>
195
+ <?r if flash[type] ?>
196
+
197
+ <div class="alert alert-block alert-#{type} fade in">
198
+ <a class="close" data-dismiss="alert" href="#">×</a>
199
+ <h4 class="alert-heading">#{ type.capitalize }</h4>
200
+ #{flash[type]}
201
+ </div>
202
+
203
+ <?r end ?>
204
+ <?r end ?>
205
+
206
+ #{@content}
207
+
208
+ </div>
209
+ ...
210
+
data/lib/proto/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'ramaze', '>= 2.0.0'
3
+ gem 'ramaze'
4
4
  gem 'rake'
@@ -10,7 +10,7 @@ module Ramaze
10
10
  ##
11
11
  # Cache driver for the Memcache storage engine. Memcache is a key/value
12
12
  # store that's extremely useful for caching data such as views or API
13
- # responses. More inforamtion about Memcache can be found on it's website:
13
+ # responses. More information about Memcache can be found on it's website:
14
14
  # <http://memcached.org/>.
15
15
  #
16
16
  # Note that this cache driver requires the Dalli gem rather than Memcache
@@ -21,7 +21,7 @@ module Ramaze
21
21
  # operate but you won't get the nice speed boost.
22
22
  #
23
23
  # This driver works similar to Ramaze::Cache::Sequel in that it allows you
24
- # to specify instance specific options uisng the using() method:
24
+ # to specify instance specific options using the using() method:
25
25
  #
26
26
  # Ramaze::Cache.options.session = Ramaze::Cache::MemCache.using(
27
27
  # :compression => false
@@ -203,7 +203,7 @@ module Ramaze
203
203
  # specified key.
204
204
  # @return [Mixed]
205
205
  #
206
- def cache_store(key, value, ttl = nil, options = {})
206
+ def cache_store(key, value, options = {})
207
207
  ttl = options.delete(:ttl) || @options[:expires_in]
208
208
 
209
209
  if ttl > MAX_TTL
@@ -0,0 +1,143 @@
1
+ require 'moneta'
2
+
3
+ module Ramaze
4
+ class Cache
5
+ ##
6
+ # The Moneta cache is a cache driver for Moneta (http://github.com/minad/moneta). Moneta is a
7
+ # unified interface to key/value stores.
8
+ #
9
+ # The usage of this cache is very similar to the Memcache driver. You load
10
+ # it by simply specifying the class:
11
+ #
12
+ # Ramaze::Cache.options.session = Ramaze::Cache::Moneta
13
+ #
14
+ # If you want to specify custom options you can do so by calling {.using} on
15
+ # the class:
16
+ #
17
+ # Ramaze::Cache.options.session = Ramaze::Cache::Moneta.using(...)
18
+ #
19
+ # @example Configuring the Moneta backend
20
+ # Ramaze::Cache.options.names.push(:moneta)
21
+ # Ramaze::Cache.options.moneta = Ramaze::Cache::Moneta.using(
22
+ # :adapter => :File,
23
+ # :dir => './ramaze-cache'
24
+ # )
25
+ #
26
+ # @author Daniel Mendler
27
+ #
28
+ class Moneta
29
+ include Cache::API
30
+ include Innate::Traited
31
+
32
+ # Hash containing all the default options to use when no custom ones are
33
+ # specified in .using().
34
+ trait :default => {
35
+ :expires_in => 604800,
36
+ :adapter => :Memory,
37
+ }
38
+
39
+ # Hash containing all the default options merged with the user specified
40
+ # ones.
41
+ attr_accessor :options
42
+
43
+ class << self
44
+ attr_accessor :options
45
+
46
+ ##
47
+ # Creates a new instance of the cache class and merges the default
48
+ # options with the custom ones.
49
+ #
50
+ # Using this method you can specify custom options for various caches.
51
+ # For example, the Moneta cache for your sessions could be located at
52
+ # server #1 while a custom cache is located on server #2.
53
+ #
54
+ # @author Daniel Mendler
55
+ # @param [Hash] options A hash containing custom options.
56
+ # @option options [Fixnum] :expires_in The default time after which a
57
+ # key should expire.
58
+ # @option options [Symbol] :adapter Moneta adapter
59
+ #
60
+ def using(options = {})
61
+ merged = Ramaze::Cache::Moneta.trait[:default].merge(options)
62
+ Class.new(self) { @options = merged }
63
+ end
64
+ end # class << self
65
+
66
+ ##
67
+ # Creates a new instance of the cache and merges the options if they
68
+ # haven't already been set.
69
+ #
70
+ # @author Daniel Mendler
71
+ # @param [Hash] options A hash with custom options. See
72
+ # Ramaze::Cache::Moneta.using() and the trait :default for more
73
+ # information.
74
+ #
75
+ def initialize(options = {})
76
+ self.class.options ||=
77
+ Ramaze::Cache::Moneta.trait[:default].merge(options)
78
+
79
+ @options = options.merge(self.class.options)
80
+ end
81
+
82
+ ##
83
+ # Prepares the cache by setting up the prefix and loading Moneta.
84
+ #
85
+ # @author Daniel Mendler
86
+ #
87
+ def cache_setup(*args)
88
+ opts = options.dup
89
+ opts[:prefix] = ['ramaze', *args].compact.join(':')
90
+ opts[:expires] = opts.delete(:expires_in)
91
+ adapter = opts.delete(:adapter)
92
+ @moneta = ::Moneta.new(adapter, options)
93
+ end
94
+
95
+ ##
96
+ # Clears the entire cache.
97
+ #
98
+ # @author Daniel Mendler
99
+ #
100
+ def cache_clear
101
+ @moneta.clear
102
+ end
103
+
104
+ ##
105
+ # Removes a number of keys from the cache.
106
+ #
107
+ # @author Daniel Mendler
108
+ # @param [Array] keys An array of key names to remove.
109
+ #
110
+ def cache_delete(*keys)
111
+ keys.each {|key| @moneta.delete(key) }
112
+ end
113
+
114
+ ##
115
+ # Retrieves the value of the given key. If no value could be retrieved the
116
+ # default value (set to nil by default) will be returned instead.
117
+ #
118
+ # @author Daniel Mendler
119
+ # @param [String] key The name of the key to retrieve.
120
+ # @param [Mixed] default The default value.
121
+ # @return [Mixed]
122
+ #
123
+ def cache_fetch(key, default = nil)
124
+ @moneta.fetch(key, default)
125
+ end
126
+
127
+ ##
128
+ # Stores a new value under the given key.
129
+ #
130
+ # @author Daniel Mendler
131
+ # @param [String] key The name of the key to store.
132
+ # @param [Mixed] value The value of the key.
133
+ # @param [Fixnum] ttl The Time To Live of the key.
134
+ # @param [Hash] options A hash containing key specific options.
135
+ # @option options :expires_in The time after which the key should expire.
136
+ #
137
+ def cache_store(key, value, options = {})
138
+ options[:expires] = options.delete(:ttl) || @options[:expires_in]
139
+ @moneta.store(key, value, options)
140
+ end
141
+ end # Moneta
142
+ end # Cache
143
+ end # Ramaze
@@ -1,4 +1,4 @@
1
- require 'redis'
1
+ require 'redis-namespace'
2
2
 
3
3
  module Ramaze
4
4
  class Cache
@@ -102,8 +102,8 @@ module Ramaze
102
102
  options[:namespace] = [
103
103
  'ramaze', hostname, username, appname, cachename
104
104
  ].compact.join(':')
105
-
106
- @client = ::Redis.new(options)
105
+ redis_connection = ::Redis.new
106
+ @client = ::Redis::Namespace.new(options[:namespace], redis: redis_connection)
107
107
  end
108
108
 
109
109
  ##
@@ -123,7 +123,7 @@ module Ramaze
123
123
  # @param [Array] keys An array of key names to remove.
124
124
  #
125
125
  def cache_delete(*keys)
126
- @client.del(*keys.map{|key| namespaced_key(key) })
126
+ @client.del(*keys)
127
127
  end
128
128
 
129
129
  ##
@@ -136,7 +136,7 @@ module Ramaze
136
136
  # @return [Mixed]
137
137
  #
138
138
  def cache_fetch(key, default = nil)
139
- value = @client.get(namespaced_key(key))
139
+ value = @client.get(key)
140
140
  value.nil? ? default : ::Marshal.load(value)
141
141
  end
142
142
 
@@ -150,17 +150,14 @@ module Ramaze
150
150
  # @param [Hash] options A hash containing key specific options.
151
151
  # @option options :expires_in The time after which the key should expire.
152
152
  #
153
- def cache_store(key, value, ttl = nil, options = {})
153
+ def cache_store(key, value, options = {})
154
154
  ttl = options[:ttl] || @options[:expires_in]
155
155
 
156
- @client.setex(namespaced_key(key), ttl, ::Marshal.dump(value))
156
+ @client.setex(key, ttl, ::Marshal.dump(value))
157
157
 
158
158
  return value
159
159
  end
160
-
161
- def namespaced_key(key)
162
- [options[:namespace], key].join(':')
163
- end
160
+
164
161
  end # Redis
165
162
  end # Cache
166
163
  end # Ramaze
@@ -108,13 +108,13 @@ module Ramaze
108
108
  # should be set to an integer representing the number of seconds before
109
109
  # a cache item becomes invalidated.
110
110
  # @option options [TrueClass] :display_warnings When this option is set
111
- # to true, failure to serialiaze or deserialize cache items will produce
111
+ # to true, failure to serialize or de-serialize cache items will produce
112
112
  # a warning in the Ramaze log. This option is set to false by default.
113
113
  # Please note that certain objects (for instance Procs) cannot be
114
114
  # serialized by ruby and therefore cannot be cached by this cache class.
115
115
  # Setting this option to true is a good way to find out if the stuff you
116
116
  # are trying to cache is affected by this. Failure to
117
- # serialize/deserialize a cache item will never raise an exception, the
117
+ # serialize/de-serialize a cache item will never raise an exception, the
118
118
  # item will just remain uncached.
119
119
  # @return [Object]
120
120
  #
data/lib/ramaze/cache.rb CHANGED
@@ -12,6 +12,7 @@ module Ramaze
12
12
  autoload :MemCache, 'ramaze/cache/memcache'
13
13
  autoload :Sequel, 'ramaze/cache/sequel'
14
14
  autoload :Redis, 'ramaze/cache/redis'
15
+ autoload :Moneta, 'ramaze/cache/moneta'
15
16
 
16
17
  ##
17
18
  # Overwrites {Innate::Cache#initialize} to make cache classes application
data/lib/ramaze/files.rb CHANGED
@@ -52,7 +52,7 @@ module Ramaze
52
52
  # @since 14-03-2009
53
53
  #
54
54
  def sync
55
- file_apps = @roots.map { |root| Rack::File.new(root) }
55
+ file_apps = @roots.map { |root| Rack::Files.new(root) }
56
56
  @cascade = Rack::Cascade.new(file_apps)
57
57
  end
58
58
  end # Files
@@ -226,6 +226,11 @@ module Ramaze
226
226
 
227
227
  action = Current.action
228
228
  params = request.params.merge(@var.to_s => n)
229
+ params.keys.each do |p|
230
+ if params[p].is_a?(Array) and not p.end_with?('[]')
231
+ params["#{p}[]"] = params.delete(p)
232
+ end
233
+ end
229
234
  hash[:href] = action.node.r(action.path, params)
230
235
 
231
236
  g.a(hash){ text }
@@ -1,12 +1,14 @@
1
+ require 'rack/request'
1
2
  module Ramaze
2
3
  module Helper
3
4
  module RequestAccessor
4
- classes = [Rack::Request, Innate::Request, Ramaze::Request]
5
+ classes = [Rack::Request, Rack::Request::Helpers, Rack::Request::Env, Innate::Request, Ramaze::Request]
5
6
  methods = classes.map { |klass|
6
7
  klass.instance_methods(false)
7
8
  }.flatten.uniq
8
9
 
9
10
  methods.each do |method|
11
+ next if method == :intialize
10
12
  if method =~ /=/
11
13
  eval("def %s(a) request.%s a; end" % [method, method])
12
14
  else
@@ -7,7 +7,7 @@ module Ramaze
7
7
  # Provides an call/answer mechanism, this is useful for example in a
8
8
  # login-system.
9
9
  #
10
- # It is basically good to redirect temporarly somewhere else without
10
+ # It is basically good to redirect temporarily somewhere else without
11
11
  # forgetting where you come from and offering a nice way to get back
12
12
  # to the last urls.
13
13
  #
@@ -2,7 +2,7 @@ module Ramaze
2
2
  module Helper
3
3
  ##
4
4
  # Helper module for handling file uploads. File uploads are mostly handled
5
- # by Rack, but this helper adds some conveniance methods for handling
5
+ # by Rack, but this helper adds some convenience methods for handling
6
6
  # and saving the uploaded files.
7
7
  #
8
8
  # @example
@@ -19,7 +19,7 @@ module Ramaze
19
19
  ALIASES = {:dev => :debug, :warn => :warning, :error => :err}
20
20
 
21
21
  ##
22
- # Open the syslog library, if it is allready open, we reopen it using the
22
+ # Open the syslog library, if it is already open, we reopen it using the
23
23
  # new argument list. The argument list is passed on to the Syslog library
24
24
  # so please check that, and man syslog for detailed information.
25
25
  #
@@ -3,7 +3,7 @@
3
3
  module Ramaze
4
4
  ##
5
5
  # The purpose of this class is to act as a simple wrapper for Rack::Request
6
- # and provide some convinient methods for our own use.
6
+ # and provide some convenient methods for our own use.
7
7
  class Request < Innate::Request
8
8
  ##
9
9
  # you can access the original @request via this method_missing,
@@ -105,7 +105,7 @@ module Ramaze
105
105
  end
106
106
  alias inspect to_s
107
107
 
108
- # Pretty prints current action with parameters, cookies and enviroment
108
+ # Pretty prints current action with parameters, cookies and environment
109
109
  # variables.
110
110
  def pretty_print(pp)
111
111
  pp.object_group(self) do
@@ -4,7 +4,6 @@
4
4
  require 'ramaze/snippets/blankslate'
5
5
  require 'ramaze/snippets/object/__dir__'
6
6
  require 'ramaze/snippets/ramaze/deprecated'
7
- require 'ramaze/snippets/ramaze/lru_hash'
8
7
  require 'ramaze/snippets/string/camel_case'
9
8
  require 'ramaze/snippets/string/color'
10
9
  require 'ramaze/snippets/string/esc'
@@ -1,3 +1,5 @@
1
1
  module Ramaze
2
- VERSION = '2012.12.08'
2
+ VERSION = Gem::Specification.load(
3
+ File.expand_path('../../../ramaze.gemspec', __FILE__)
4
+ ).version.to_s
3
5
  end
@@ -5,7 +5,7 @@ module Nagoro
5
5
  # Pipe that transforms <render /> tags.
6
6
  #
7
7
  # the src parameter in the render tag will be used as first parameter to
8
- # render_partial, all other paramters are passed on as +variables+.
8
+ # render_partial, all other parameters are passed on as +variables+.
9
9
  #
10
10
  # Example calling render_partial('hello'):
11
11
  # <render src="hello" />
data/lib/ramaze.rb CHANGED
@@ -61,7 +61,7 @@ module Ramaze
61
61
  roots, publics = options[:roots], options[:publics]
62
62
 
63
63
  joined = roots.map { |r| publics.map { |p| File.join(r, p) } }
64
- joined = joined.flatten.map { |p| Rack::File.new(p) }
64
+ joined = joined.flatten.map { |p| Rack::Files.new(p) }
65
65
  current = Current.new(Route.new(AppMap), Rewrite.new(AppMap))
66
66
 
67
67
  return Rack::Cascade.new(joined << current, [404, 405])
data/ramaze.gemspec CHANGED
@@ -1,10 +1,6 @@
1
- require File.expand_path('../lib/ramaze/version', __FILE__)
2
-
3
- path = File.expand_path('../', __FILE__)
4
-
5
1
  Gem::Specification.new do |s|
6
2
  s.name = 'ramaze'
7
- s.version = Ramaze::VERSION
3
+ s.version = '2023.01.06'
8
4
  s.date = Time.now.strftime('%Y-%m-%d')
9
5
  s.authors = ['Michael \'manveru\' Fellinger', 'Yorick Peterse']
10
6
  s.email = ['m.fellinger@gmail.com', 'yorickpeterse@gmail.com']
@@ -13,15 +9,18 @@ Gem::Specification.new do |s|
13
9
  s.description = s.summary
14
10
 
15
11
  s.required_rubygems_version = '>= 1.3.5'
16
- s.files = `cd #{path}; git ls-files`.split("\n").sort
17
- s.has_rdoc = 'yard'
12
+ s.files = (
13
+ Dir['{bin,examples,guide,lib,spec,tasks}/**/*'] |
14
+ %w[Gemfile Rakefile README.md ramaze.gemspec]
15
+ ).sort
16
+
18
17
  s.executables = ['ramaze']
19
18
 
20
- s.add_dependency 'innate', '>= 2012.12'
19
+ s.add_dependency 'innate', '>= 2023.01.05'
21
20
  s.add_dependency 'rake'
22
21
 
23
- s.add_development_dependency 'Remarkably'
24
22
  s.add_development_dependency 'bacon'
23
+ s.add_development_dependency 'bluecloth'
25
24
  s.add_development_dependency 'dalli'
26
25
  s.add_development_dependency 'erector'
27
26
  s.add_development_dependency 'erubis'
@@ -30,10 +29,11 @@ Gem::Specification.new do |s|
30
29
  s.add_development_dependency 'liquid'
31
30
  s.add_development_dependency 'locale'
32
31
  s.add_development_dependency 'maruku'
32
+ s.add_development_dependency 'moneta'
33
33
  s.add_development_dependency 'mustache'
34
- s.add_development_dependency 'rack-contrib'
35
34
  s.add_development_dependency 'rack-test'
36
- s.add_development_dependency 'redis'
35
+ s.add_development_dependency 'redis-namespace'
36
+ s.add_development_dependency 'Remarkably'
37
37
  s.add_development_dependency 'sass'
38
38
  s.add_development_dependency 'sequel'
39
39
  s.add_development_dependency 'slim'
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
49
49
  # C extensions don't work reliably on jruby and Travis CI doesn't have them
50
50
  # enabled.
51
51
  if !RUBY_DESCRIPTION.include?('jruby')
52
- s.add_development_dependency 'localmemcache'
53
52
  s.add_development_dependency 'nokogiri'
54
53
  s.add_development_dependency 'rdiscount'
55
54
  s.add_development_dependency 'sqlite3'
@@ -0,0 +1,53 @@
1
+ require File.expand_path('../../../../spec/helper', __FILE__)
2
+ spec_require 'moneta'
3
+
4
+ describe Ramaze::Cache::Moneta do
5
+ Ramaze.options.cache.names = [:one, :two]
6
+ Ramaze.options.cache.default = Ramaze::Cache::Moneta
7
+ Ramaze.setup_dependencies
8
+
9
+ cache = Ramaze::Cache.one
10
+ hello = 'Hello, World!'
11
+
12
+ should 'store without ttl' do
13
+ cache.store(:hello, hello).should == hello
14
+ end
15
+
16
+ should 'fetch' do
17
+ cache.fetch(:hello).should == hello
18
+ end
19
+
20
+ should 'delete' do
21
+ cache.delete(:hello)
22
+ cache.fetch(:hello).should == nil
23
+ end
24
+
25
+ should 'delete two key/value pairs at once' do
26
+ cache.store(:hello, hello).should == hello
27
+ cache.store(:ramaze, 'ramaze').should == 'ramaze'
28
+ cache.delete(:hello, :ramaze)
29
+ cache.fetch(:hello).should == nil
30
+ cache.fetch(:innate).should == nil
31
+ end
32
+
33
+ should 'store with ttl' do
34
+ cache.store(:hello, @hello, :ttl => 1)
35
+ cache.fetch(:hello).should == @hello
36
+ sleep 2
37
+ cache.fetch(:hello).should == nil
38
+ end
39
+
40
+ should 'clear' do
41
+ cache.store(:hello, @hello)
42
+ cache.fetch(:hello).should == @hello
43
+ cache.clear
44
+ cache.fetch(:hello).should == nil
45
+ end
46
+
47
+ should 'use a custom set of options' do
48
+ klass = Ramaze::Cache::Moneta.using(:answer => 42)
49
+
50
+ klass.options[:answer].should == 42
51
+ klass.new.options[:answer].should == 42
52
+ end
53
+ end
@@ -3,7 +3,7 @@ spec_require 'redis'
3
3
 
4
4
  spec_precondition 'redis is running' do
5
5
  cache = Redis.new
6
- cache['active'] = true
6
+ "OK" == cache.set('testkey', 'testval')
7
7
  end
8
8
 
9
9
  describe Ramaze::Cache::Redis do
@@ -36,7 +36,7 @@ describe 'Directory listing' do
36
36
  get('path').body
37
37
  end
38
38
 
39
- def check(url, title, list)
39
+ def check(url, title, list, ignore_order = false)
40
40
  got = get(url)
41
41
 
42
42
  got.status.should == 200
@@ -46,16 +46,23 @@ describe 'Directory listing' do
46
46
 
47
47
  doc.at(:title).inner_text.should == title
48
48
 
49
- doc.css('td.name a').map{|a| [a[:href], a.inner_text] }.should == list
49
+ urls = doc.css('td.name a').map do |a|
50
+ ["/#{a[:href]}".squeeze('/'), a.inner_text]
51
+ end
52
+ if ignore_order
53
+ urls.flatten.sort.should == list.flatten.sort
54
+ else
55
+ urls.should == list
56
+ end
50
57
  end
51
58
 
52
59
  should 'dry serve root directory' do
53
60
  files = [
54
- ["../", "Parent Directory"],
61
+ # ["/../", "Parent Directory"],
55
62
  ["/favicon.ico", "favicon.ico"],
56
- ["/file+name.txt", "file name.txt"],
57
63
  ["/test/", "test/"],
58
- ["/test_download.css", "test_download.css"]
64
+ ["/test_download.css", "test_download.css"],
65
+ ["/file%20name.txt", "file name.txt"]
59
66
  ]
60
67
 
61
68
  check '/', '/', files
@@ -63,13 +70,13 @@ describe 'Directory listing' do
63
70
 
64
71
  should 'serve hierarchies' do
65
72
  files = [
66
- ["../", "Parent Directory"],
73
+ ["/test/../", "Parent Directory"],
67
74
  ["/test/deep/", "deep/"],
68
75
  ["/test/five.txt", "five.txt"],
69
76
  ["/test/six.txt", "six.txt"]
70
77
  ]
71
78
 
72
- check '/test', '/test', files
79
+ check '/test', '/test', files, true
73
80
  end
74
81
 
75
82
  FileUtils.rm_rf(__DIR__('public/test'))
@@ -3,11 +3,6 @@
3
3
 
4
4
  require File.expand_path('../../../../spec/helper', __FILE__)
5
5
 
6
- # This spec more or less tries to ensure that we integrate with rack and
7
- # rack-contrib in regards to static file serving.
8
-
9
- spec_require 'rack/contrib'
10
-
11
6
  Ramaze.middleware(:spec) do
12
7
  use Rack::ConditionalGet
13
8
  use Rack::ETag