ramaze 2011.07.25 → 2011.10.23
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 +3 -0
- data/.mailmap +3 -2
- data/.travis.yml +17 -0
- data/.yardopts +13 -0
- data/README.md +95 -352
- data/examples/app/blog/app.rb +25 -64
- data/examples/app/blog/config.ru +11 -9
- data/examples/app/blog/controller/init.rb +29 -86
- data/examples/app/blog/controller/posts.rb +232 -0
- data/examples/app/blog/controller/users.rb +160 -0
- data/examples/app/blog/layout/default.xhtml +61 -0
- data/examples/app/blog/migrations/01_create_schema.rb +50 -0
- data/examples/app/blog/model/comment.rb +41 -54
- data/examples/app/blog/model/init.rb +41 -13
- data/examples/app/blog/model/post.rb +35 -0
- data/examples/app/blog/model/user.rb +105 -0
- data/examples/app/blog/public/.htaccess +24 -0
- data/examples/app/blog/public/css/grid.css +107 -0
- data/examples/app/blog/public/css/layout.css +203 -0
- data/examples/app/blog/public/css/reset.css +123 -0
- data/examples/app/blog/public/css/text.css +109 -0
- data/examples/app/blog/public/dispatch.fcgi +11 -0
- data/examples/app/blog/public/favicon.ico +0 -0
- data/examples/app/blog/public/images/bg.png +0 -0
- data/examples/app/blog/start.rb +18 -3
- data/examples/app/blog/view/feed.xhtml +23 -0
- data/examples/app/blog/view/form.xhtml +11 -0
- data/examples/app/blog/view/index.xhtml +44 -0
- data/examples/app/blog/view/users/form.xhtml +12 -0
- data/examples/app/blog/view/users/index.xhtml +30 -0
- data/examples/app/blog/view/users/login.xhtml +8 -0
- data/examples/app/blog/view/view.xhtml +68 -0
- data/{doc → guide}/AUTHORS +5 -3
- data/{doc → guide}/CHANGELOG +428 -0
- data/{doc/GPL → guide/GPL_LICENSE} +0 -0
- data/{doc/COPYING → guide/RUBY_LICENSE} +3 -6
- data/guide/_static/logo.png +0 -0
- data/guide/_static/logo.svg +49 -0
- data/guide/_static/ramaze_console.png +0 -0
- data/guide/css/common.css +20 -0
- data/guide/general/cache.md +167 -0
- data/guide/general/configuration.md +168 -0
- data/guide/general/contributing.md +108 -0
- data/guide/general/controllers.md +115 -0
- data/guide/general/helpers.md +76 -0
- data/guide/general/installation.md +58 -0
- data/guide/general/logging.md +99 -0
- data/guide/general/middlewares.md +100 -0
- data/guide/general/models.md +78 -0
- data/guide/general/principles.md +53 -0
- data/guide/general/ramaze_command.md +155 -0
- data/guide/general/routes.md +81 -0
- data/guide/general/sessions.md +140 -0
- data/guide/general/special_thanks.md +67 -0
- data/guide/general/testing.md +61 -0
- data/guide/general/views.md +322 -0
- data/guide/tutorials/introduction.md +259 -0
- data/lib/proto/config.ru +1 -1
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/view/index.xhtml +7 -7
- data/lib/ramaze.rb +4 -4
- data/lib/ramaze/app.rb +11 -11
- data/lib/ramaze/app_graph.rb +2 -4
- data/lib/ramaze/bin/console.rb +3 -3
- data/lib/ramaze/bin/create.rb +2 -2
- data/lib/ramaze/bin/restart.rb +4 -4
- data/lib/ramaze/bin/runner.rb +5 -5
- data/lib/ramaze/bin/start.rb +19 -4
- data/lib/ramaze/bin/status.rb +3 -3
- data/lib/ramaze/bin/stop.rb +3 -3
- data/lib/ramaze/cache.rb +1 -0
- data/lib/ramaze/cache/lru.rb +8 -4
- data/lib/ramaze/cache/memcache.rb +32 -13
- data/lib/ramaze/cache/redis.rb +164 -0
- data/lib/ramaze/cache/sequel.rb +43 -28
- data/lib/ramaze/controller.rb +1 -2
- data/lib/ramaze/dependencies.rb +40 -3
- data/lib/ramaze/helper/bench.rb +26 -16
- data/lib/ramaze/helper/blue_form.rb +46 -73
- data/lib/ramaze/helper/cache.rb +10 -6
- data/lib/ramaze/helper/csrf.rb +35 -39
- data/lib/ramaze/helper/disqus.rb +5 -4
- data/lib/ramaze/helper/email.rb +35 -24
- data/lib/ramaze/helper/erector.rb +9 -13
- data/lib/ramaze/helper/flash.rb +7 -9
- data/lib/ramaze/helper/formatting.rb +194 -179
- data/lib/ramaze/helper/gravatar.rb +4 -8
- data/lib/ramaze/helper/identity.rb +3 -3
- data/lib/ramaze/helper/layout.rb +23 -8
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/paginate.rb +46 -39
- data/lib/ramaze/helper/request_accessor.rb +3 -1
- data/lib/ramaze/helper/simple_captcha.rb +18 -17
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/helper/tagz.rb +4 -2
- data/lib/ramaze/helper/upload.rb +523 -0
- data/lib/ramaze/helper/user.rb +4 -8
- data/lib/ramaze/helper/xhtml.rb +11 -15
- data/lib/ramaze/log.rb +9 -6
- data/lib/ramaze/log/rotatinginformer.rb +62 -27
- data/lib/ramaze/log/syslog.rb +20 -15
- data/lib/ramaze/log/xosd.rb +2 -1
- data/lib/ramaze/reloader.rb +2 -0
- data/lib/ramaze/request.rb +11 -10
- data/lib/ramaze/setup.rb +23 -6
- data/lib/ramaze/snippets/array/put_within.rb +3 -9
- data/lib/ramaze/snippets/binding/locals.rb +5 -10
- data/lib/ramaze/snippets/fiber.rb +1 -23
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +3 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +3 -5
- data/lib/ramaze/snippets/numeric/time.rb +3 -7
- data/lib/ramaze/snippets/object/__dir__.rb +3 -7
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +3 -6
- data/lib/ramaze/snippets/object/pretty.rb +3 -7
- data/lib/ramaze/snippets/object/scope.rb +7 -9
- data/lib/ramaze/snippets/proc/locals.rb +12 -12
- data/lib/ramaze/snippets/ramaze/acquire.rb +15 -14
- data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -1
- data/lib/ramaze/snippets/ramaze/fiber.rb +1 -1
- data/lib/ramaze/snippets/ramaze/lru_hash.rb +2 -3
- data/lib/ramaze/snippets/ramaze/struct.rb +2 -4
- data/lib/ramaze/snippets/string/camel_case.rb +8 -10
- data/lib/ramaze/snippets/string/color.rb +3 -4
- data/lib/ramaze/snippets/string/end_with.rb +3 -6
- data/lib/ramaze/snippets/string/esc.rb +3 -8
- data/lib/ramaze/snippets/string/ord.rb +3 -8
- data/lib/ramaze/snippets/string/snake_case.rb +6 -9
- data/lib/ramaze/snippets/string/start_with.rb +3 -8
- data/lib/ramaze/snippets/string/unindent.rb +3 -6
- data/lib/ramaze/snippets/thread/into.rb +1 -3
- data/lib/ramaze/spec.rb +2 -31
- data/lib/ramaze/spec/bacon.rb +18 -2
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +1 -1
- data/ramaze.gemspec +1 -1
- data/spec/helper.rb +2 -1
- data/spec/ramaze/bin/start.rb +16 -20
- data/spec/ramaze/cache/localmemcache.rb +4 -7
- data/spec/ramaze/cache/memcache.rb +3 -1
- data/spec/ramaze/cache/redis.rb +62 -0
- data/spec/ramaze/helper/blue_form.rb +33 -4
- data/spec/ramaze/helper/layout.rb +40 -7
- data/spec/ramaze/helper/upload.rb +149 -0
- data/spec/ramaze/helper/uploads/text_1.txt +1 -0
- data/spec/ramaze/helper/uploads/text_2.txt +1 -0
- data/spec/ramaze/log/growl.rb +4 -6
- data/spec/ramaze/log/syslog.rb +6 -0
- data/spec/ramaze/view/lokar.rb +5 -0
- data/spec/ramaze/view/nagoro.rb +5 -0
- data/tasks/authors.rake +1 -1
- data/tasks/bacon.rake +14 -5
- data/tasks/changelog.rake +1 -1
- data/tasks/yard.rake +12 -4
- metadata +277 -239
- data/doc/LEGAL +0 -26
- data/examples/app/blog/README +0 -3
- data/examples/app/blog/controller/comment.rb +0 -45
- data/examples/app/blog/controller/entry.rb +0 -85
- data/examples/app/blog/controller/main.rb +0 -20
- data/examples/app/blog/controller/tag.rb +0 -9
- data/examples/app/blog/layout/default.nag +0 -31
- data/examples/app/blog/model/entry.rb +0 -89
- data/examples/app/blog/model/tag.rb +0 -36
- data/examples/app/blog/public/css/screen.css +0 -273
- data/examples/app/blog/spec/blog.rb +0 -87
- data/examples/app/blog/view/comment/form.nag +0 -10
- data/examples/app/blog/view/comment/show.nag +0 -16
- data/examples/app/blog/view/entry/edit.nag +0 -14
- data/examples/app/blog/view/entry/feed.atom.nag +0 -8
- data/examples/app/blog/view/entry/feed.rss.nag +0 -7
- data/examples/app/blog/view/entry/index.nag +0 -7
- data/examples/app/blog/view/entry/new.nag +0 -13
- data/examples/app/blog/view/entry/show.nag +0 -36
- data/examples/app/blog/view/feed.atom.nag +0 -18
- data/examples/app/blog/view/feed.rss.nag +0 -25
- data/examples/app/blog/view/index.nag +0 -6
- data/examples/app/blog/view/tag/index.nag +0 -5
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/ramaze/rest.rb +0 -36
- data/spec/ramaze/rest.rb +0 -28
- data/tasks/rcov.rake +0 -22
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
module Ramaze
|
|
5
5
|
module CoreExtensions
|
|
6
|
-
|
|
7
6
|
# Extensions for String
|
|
8
|
-
|
|
9
7
|
module String
|
|
10
8
|
unless ''.respond_to?(:end_with?)
|
|
11
9
|
# Compatibility with 1.9
|
|
@@ -14,7 +12,6 @@ module Ramaze
|
|
|
14
12
|
self[-other.size, other.size] == other
|
|
15
13
|
end
|
|
16
14
|
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
15
|
+
end # String
|
|
16
|
+
end # CoreExtensions
|
|
17
|
+
end # Ramaze
|
|
@@ -3,17 +3,13 @@ require 'uri'
|
|
|
3
3
|
|
|
4
4
|
module Ramaze
|
|
5
5
|
module CoreExtensions
|
|
6
|
-
|
|
7
6
|
# Extensions for String
|
|
8
|
-
|
|
9
7
|
module String
|
|
10
|
-
|
|
11
8
|
# String#escape is an extensible escaping mechanism for string. currently
|
|
12
9
|
# it suports
|
|
13
10
|
# '<div>foo bar</div>'.esc(:html)
|
|
14
11
|
# 'foo bar'.esc(:uri)
|
|
15
12
|
# 'foo bar'.esc(:cgi)
|
|
16
|
-
|
|
17
13
|
def escape which = :html
|
|
18
14
|
case which
|
|
19
15
|
when :html
|
|
@@ -28,7 +24,6 @@ module Ramaze
|
|
|
28
24
|
end
|
|
29
25
|
|
|
30
26
|
alias_method 'esc', 'escape'
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
end
|
|
27
|
+
end # String
|
|
28
|
+
end # CoreExtensions
|
|
29
|
+
end # Ramaze
|
|
@@ -3,19 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
module Ramaze
|
|
5
5
|
module CoreExtensions
|
|
6
|
-
|
|
7
6
|
# Extensions for String
|
|
8
|
-
|
|
9
7
|
module String
|
|
10
8
|
unless ''.respond_to?(:ord)
|
|
11
|
-
|
|
12
9
|
# compatibility with Ruby 1.9
|
|
13
|
-
|
|
14
10
|
def ord
|
|
15
11
|
self[0]
|
|
16
12
|
end
|
|
17
13
|
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
14
|
+
end # String
|
|
15
|
+
end # CoreExtensions
|
|
16
|
+
end # Ramaze
|
|
@@ -3,19 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
module Ramaze
|
|
5
5
|
module CoreExtensions
|
|
6
|
-
|
|
7
6
|
# Extensions for String
|
|
8
|
-
|
|
9
7
|
module String
|
|
10
|
-
|
|
11
8
|
# convert to snake_case from CamelCase
|
|
12
9
|
#
|
|
13
|
-
#
|
|
14
|
-
|
|
10
|
+
# @example
|
|
11
|
+
# 'FooBar'.snake_case # => 'foo_bar'
|
|
12
|
+
#
|
|
15
13
|
def snake_case
|
|
16
14
|
gsub(/\B[A-Z][^A-Z]/, '_\&').downcase.gsub(' ', '_')
|
|
17
15
|
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
end
|
|
16
|
+
end # String
|
|
17
|
+
end # CoreExtensions
|
|
18
|
+
end # Ramaze
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
module Ramaze
|
|
2
2
|
module CoreExtensions
|
|
3
|
-
|
|
4
3
|
# Extensions for String
|
|
5
|
-
|
|
6
4
|
module String
|
|
7
|
-
|
|
8
5
|
unless ''.respond_to?(:start_with?)
|
|
9
|
-
|
|
10
6
|
# Compatibility with 1.9
|
|
11
|
-
|
|
12
7
|
def start_with?(other)
|
|
13
8
|
other = other.to_s
|
|
14
9
|
self[0, other.size] == other
|
|
15
10
|
end
|
|
16
11
|
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
12
|
+
end # String
|
|
13
|
+
end # CoreExtensions
|
|
14
|
+
end # Ramaze
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
module Ramaze
|
|
2
2
|
module CoreExtensions
|
|
3
|
-
|
|
4
3
|
# Extensions for String
|
|
5
|
-
|
|
6
4
|
module String
|
|
7
|
-
|
|
8
5
|
# Useful for writing indented String and unindent on demand, based on the
|
|
9
6
|
# first line with indentation.
|
|
10
7
|
def unindent
|
|
@@ -23,6 +20,6 @@ module Ramaze
|
|
|
23
20
|
self.replace unindent
|
|
24
21
|
end
|
|
25
22
|
alias ui! unindent!
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
23
|
+
end # String
|
|
24
|
+
end # CoreExtensions
|
|
25
|
+
end # Ramaze
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
3
|
|
|
4
4
|
# Extensions for Thread
|
|
5
|
-
|
|
6
5
|
class Thread
|
|
7
6
|
# Copy all thread variables into the new thread
|
|
8
|
-
|
|
9
7
|
def self.into *args
|
|
10
8
|
Thread.new(Thread.current, *args) do |thread, *args|
|
|
11
9
|
thread.keys.each do |k|
|
|
@@ -15,4 +13,4 @@ class Thread
|
|
|
15
13
|
yield(*args)
|
|
16
14
|
end
|
|
17
15
|
end
|
|
18
|
-
end
|
|
16
|
+
end # Thread
|
data/lib/ramaze/spec.rb
CHANGED
|
@@ -1,33 +1,4 @@
|
|
|
1
1
|
require File.expand_path('../', __FILE__) unless defined?(Ramaze)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
libs.each { |lib| require(lib) }
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
alias spec_require spec_requires
|
|
9
|
-
|
|
10
|
-
def spec_precondition(name)
|
|
11
|
-
yield
|
|
12
|
-
rescue LoadError => ex
|
|
13
|
-
puts "Spec require: %p failed: %p" % [name, ex.message]
|
|
14
|
-
exit 0
|
|
15
|
-
rescue Exception => ex
|
|
16
|
-
puts "Spec precondition: %p failed: %p" % [name, ex.message]
|
|
17
|
-
exit 0
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
module Ramaze
|
|
21
|
-
Mock::OPTIONS[:app] = Ramaze
|
|
22
|
-
|
|
23
|
-
middleware!(:spec){|m| m.run(AppMap) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# FIXME: will remove that in 2009.07, and then we can offer integration with
|
|
27
|
-
# any other test-framework we like and they can share this code.
|
|
28
|
-
# Then Ramaze can be:
|
|
29
|
-
# Any ruby, any ORM, any templating-engine, any test-framework
|
|
30
|
-
unless defined?(Bacon)
|
|
31
|
-
Ramaze.deprecated "require('ramaze/spec')", "require('ramaze/spec/bacon')"
|
|
32
|
-
require 'ramaze/spec/bacon'
|
|
33
|
-
end
|
|
3
|
+
Ramaze.deprecated "require('ramaze/spec')", "require('ramaze/spec/bacon')"
|
|
4
|
+
require File.expand_path('../spec/bacon', __FILE__)
|
data/lib/ramaze/spec/bacon.rb
CHANGED
|
@@ -5,10 +5,26 @@ rescue LoadError
|
|
|
5
5
|
require 'bacon'
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
require File.expand_path('
|
|
9
|
-
|
|
8
|
+
require File.expand_path('../../../ramaze', __FILE__)
|
|
10
9
|
require 'innate/spec/bacon'
|
|
11
10
|
|
|
11
|
+
def spec_requires(*libs)
|
|
12
|
+
spec_precondition 'require' do
|
|
13
|
+
libs.each { |lib| require(lib) }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
alias spec_require spec_requires
|
|
17
|
+
|
|
18
|
+
def spec_precondition(name)
|
|
19
|
+
yield
|
|
20
|
+
rescue LoadError => ex
|
|
21
|
+
puts "Spec require: %p failed: %p" % [name, ex.message]
|
|
22
|
+
exit 0
|
|
23
|
+
rescue Exception => ex
|
|
24
|
+
puts "Spec precondition: %p failed: %p" % [name, ex.message]
|
|
25
|
+
exit 0
|
|
26
|
+
end
|
|
27
|
+
|
|
12
28
|
# minimal middleware, no exception handling
|
|
13
29
|
Ramaze.middleware!(:spec) do |m|
|
|
14
30
|
m.run(Ramaze::AppMap)
|
data/lib/ramaze/version.rb
CHANGED
data/lib/ramaze/view.rb
CHANGED
data/ramaze.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ path = File.expand_path('../', __FILE__)
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = 'ramaze'
|
|
9
9
|
s.version = Ramaze::VERSION
|
|
10
|
-
s.date = '
|
|
10
|
+
s.date = '2011-10-23'
|
|
11
11
|
s.authors = ['Michael \'manveru\' Fellinger']
|
|
12
12
|
s.email = 'm.fellinger@gmail.com'
|
|
13
13
|
s.summary = 'Ramaze is a simple and modular web framework'
|
data/spec/helper.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
if caller_line = caller.grep(%r!spec/ramaze/!).first
|
|
2
2
|
caller_file = caller_line.split(':', 2).first
|
|
3
3
|
caller_root = File.dirname(caller_file)
|
|
4
|
-
$0
|
|
4
|
+
$0 = caller_file
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
require File.expand_path('../../lib/ramaze/spec/bacon', __FILE__)
|
|
8
|
+
require File.expand_path('../../lib/ramaze/dependencies', __FILE__)
|
|
8
9
|
|
|
9
10
|
Ramaze.options.roots = [caller_root] if caller_root
|
|
10
11
|
|
data/spec/ramaze/bin/start.rb
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
2
2
|
require __DIR__('../../../lib/ramaze/bin/runner')
|
|
3
|
-
require 'open3'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
module Ramaze
|
|
5
|
+
module Bin
|
|
6
|
+
class Start
|
|
7
|
+
# Stub the method so that WEBrick doesn't have to be booted up.
|
|
8
|
+
def start_server(rackup_path, rackup_config, *params)
|
|
9
|
+
return true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
6
14
|
|
|
15
|
+
describe('Ramaze::Bin::Start') do
|
|
7
16
|
it('Should show a help message') do
|
|
8
17
|
help = `#{Ramaze::BINPATH} start -h`.strip
|
|
9
18
|
|
|
@@ -11,28 +20,15 @@ describe('Ramaze::Bin::Start') do
|
|
|
11
20
|
end
|
|
12
21
|
|
|
13
22
|
it('Start using a directory') do
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Open3.popen3(Ramaze::BINPATH, 'start', Ramaze::BIN_APP) do |sin, sout, serr|
|
|
17
|
-
output += serr.gets(100).strip
|
|
23
|
+
cmd = Ramaze::Bin::Start.new
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
output.should.match /INFO\s+WEBrick/
|
|
25
|
+
cmd.run([Ramaze::BIN_APP]).should == true
|
|
23
26
|
end
|
|
24
27
|
|
|
25
28
|
it('Start using a file') do
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Open3.popen3(Ramaze::BINPATH, 'start', path) do |sin, sout, serr|
|
|
30
|
-
output += serr.gets(100).strip
|
|
29
|
+
path = File.join(Ramaze::BIN_APP, 'config.ru')
|
|
30
|
+
cmd = Ramaze::Bin::Start.new
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
output.should.match /INFO\s+WEBrick/
|
|
32
|
+
cmd.run([path]).should == true
|
|
36
33
|
end
|
|
37
|
-
|
|
38
34
|
end
|
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if RUBY_PLATFORM.include? 'darwin'
|
|
9
|
-
should.flunk "Localmemcache doesn't work on Mac OS X and thus this test will be ignored."
|
|
10
|
-
else
|
|
11
|
-
spec_require 'localmemcache'
|
|
12
|
-
end
|
|
6
|
+
spec_precondition 'LocalMemcache should be supported' do
|
|
7
|
+
should.flunk if Ramaze::UNSUPPORTED_GEMS.include?('localmemcache')
|
|
13
8
|
end
|
|
14
9
|
|
|
10
|
+
spec_require 'localmemcache'
|
|
11
|
+
|
|
15
12
|
describe Ramaze::Cache::LocalMemCache do
|
|
16
13
|
Ramaze.options.cache.names = [:one, :two]
|
|
17
14
|
Ramaze.options.cache.default = Ramaze::Cache::LocalMemCache
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
3
|
|
|
4
4
|
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
|
-
|
|
5
|
+
spec_require 'dalli'
|
|
6
|
+
|
|
7
|
+
Dalli.logger.level = Logger::ERROR
|
|
6
8
|
|
|
7
9
|
spec_precondition 'memcached is running' do
|
|
8
10
|
cache = Dalli::Client.new('localhost:11211')
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Copyright (c) 2011 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
|
+
spec_require 'redis'
|
|
6
|
+
|
|
7
|
+
spec_precondition 'redis is running' do
|
|
8
|
+
cache = Redis.new
|
|
9
|
+
cache['active'] = true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe Ramaze::Cache::Redis do
|
|
13
|
+
Ramaze.options.cache.names = [:one, :two]
|
|
14
|
+
Ramaze.options.cache.default = Ramaze::Cache::Redis
|
|
15
|
+
Ramaze.setup_dependencies
|
|
16
|
+
|
|
17
|
+
cache = Ramaze::Cache.one
|
|
18
|
+
hello = 'Hello, World!'
|
|
19
|
+
|
|
20
|
+
should 'store without ttl' do
|
|
21
|
+
cache.store(:hello, hello).should == hello
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
should 'fetch' do
|
|
25
|
+
cache.fetch(:hello).should == hello
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
should 'delete' do
|
|
29
|
+
cache.delete(:hello)
|
|
30
|
+
cache.fetch(:hello).should == nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
should 'delete two key/value pairs at once' do
|
|
34
|
+
cache.store(:hello, hello).should == hello
|
|
35
|
+
cache.store(:ramaze, 'ramaze').should == 'ramaze'
|
|
36
|
+
cache.delete(:hello, :ramaze)
|
|
37
|
+
cache.fetch(:hello).should == nil
|
|
38
|
+
cache.fetch(:innate).should == nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
should 'store with ttl' do
|
|
42
|
+
cache.store(:hello, @hello, :ttl => 0.2)
|
|
43
|
+
cache.fetch(:hello).should == @hello
|
|
44
|
+
sleep 0.3
|
|
45
|
+
cache.fetch(:hello).should == nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
should 'clear' do
|
|
49
|
+
cache.store(:hello, @hello)
|
|
50
|
+
cache.fetch(:hello).should == @hello
|
|
51
|
+
cache.clear
|
|
52
|
+
cache.fetch(:hello).should == nil
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
should 'use a custom set of options' do
|
|
56
|
+
klass = Ramaze::Cache::Redis.using(:answer => 42)
|
|
57
|
+
|
|
58
|
+
klass.options[:answer].should == 42
|
|
59
|
+
klass.new.options[:answer].should == 42
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
require File.expand_path('../../../../
|
|
2
|
-
|
|
3
|
-
require 'bacon'
|
|
4
|
-
Bacon.summary_at_exit
|
|
1
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
2
|
+
require 'ramaze/helper/blue_form'
|
|
5
3
|
|
|
6
4
|
describe BF = Ramaze::Helper::BlueForm do
|
|
7
5
|
extend BF
|
|
@@ -251,6 +249,37 @@ describe BF = Ramaze::Helper::BlueForm do
|
|
|
251
249
|
FORM
|
|
252
250
|
end
|
|
253
251
|
|
|
252
|
+
it 'Make a form with input_checkbox and check multiple values using an array' do
|
|
253
|
+
out = form_for(@data, :method => :get) do |f|
|
|
254
|
+
f.input_checkbox 'Assigned', :assigned, ['boo'], :values => ['boo', 'foo']
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
assert(<<-FORM, out)
|
|
258
|
+
<form method="get">
|
|
259
|
+
<p>
|
|
260
|
+
<label for="form_assigned_0">Assigned</label>
|
|
261
|
+
<span class="checkbox_wrap"><input type="checkbox" name="assigned[]" id="form_assigned_0" checked="checked" value="boo" /> boo</span>
|
|
262
|
+
<span class="checkbox_wrap"><input type="checkbox" name="assigned[]" id="form_assigned_1" value="foo" /> foo</span>
|
|
263
|
+
</p>
|
|
264
|
+
</form>
|
|
265
|
+
FORM
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
it 'Make a form with input_checkbox and check multiple values using a hash' do
|
|
269
|
+
out = form_for(@data, :method => :get) do |f|
|
|
270
|
+
f.input_checkbox 'Assigned', :assigned, ['boo'], :values => {'Boo' => 'boo'}
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
assert(<<-FORM, out)
|
|
274
|
+
<form method="get">
|
|
275
|
+
<p>
|
|
276
|
+
<label for="form_assigned_0">Assigned</label>
|
|
277
|
+
<span class="checkbox_wrap"><input type="checkbox" name="assigned[]" id="form_assigned_0" checked="checked" value="boo" /> Boo</span>
|
|
278
|
+
</p>
|
|
279
|
+
</form>
|
|
280
|
+
FORM
|
|
281
|
+
end
|
|
282
|
+
|
|
254
283
|
it 'Make a form with input_checkbox(label, name) but hide the value of the checkbox' do
|
|
255
284
|
out = form_for(@data, :method => :get) do |f|
|
|
256
285
|
f.input_checkbox 'Assigned', :assigned, nil, :show_value => false
|