ramaze 2012.04.14 → 2012.12.08b
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/.gems +28 -35
- data/.gitignore +4 -0
- data/.travis.yml +3 -3
- data/Gemfile +3 -0
- data/README.md +1 -5
- data/Rakefile +9 -20
- data/examples/app/blog/app.rb +5 -14
- data/examples/app/todolist/start.rb +1 -5
- data/guide/AUTHORS +8 -3
- data/guide/CHANGELOG +587 -0
- data/guide/general/cache.md +1 -0
- data/guide/general/configuration.md +2 -1
- data/guide/general/contributing.md +1 -0
- data/guide/general/controllers.md +105 -10
- data/guide/general/helpers.md +6 -7
- data/guide/general/installation.md +2 -1
- data/guide/general/logging.md +1 -4
- data/guide/general/middlewares.md +15 -23
- data/guide/general/models.md +1 -0
- data/guide/general/principles.md +1 -0
- data/guide/general/ramaze_command.md +9 -54
- data/guide/general/routes.md +1 -0
- data/guide/general/sessions.md +3 -2
- data/guide/general/special_thanks.md +1 -0
- data/guide/general/testing.md +1 -0
- data/guide/general/views.md +35 -22
- data/lib/proto/Gemfile +4 -0
- data/lib/proto/README.md +35 -0
- data/lib/proto/Rakefile +1 -0
- data/lib/proto/app.rb +2 -6
- data/lib/proto/spec/helper.rb +39 -0
- data/lib/proto/task/ramaze.rake +57 -0
- data/lib/ramaze.rb +12 -39
- data/lib/ramaze/bin/create.rb +1 -3
- data/lib/ramaze/bin/runner.rb +0 -14
- data/lib/ramaze/cache.rb +21 -0
- data/lib/ramaze/cache/memcache.rb +1 -3
- data/lib/ramaze/cache/redis.rb +2 -4
- data/lib/ramaze/cache/sequel.rb +4 -5
- data/lib/ramaze/controller.rb +10 -3
- data/lib/ramaze/default_middleware.rb +24 -0
- data/lib/ramaze/files.rb +5 -5
- data/lib/ramaze/gestalt.rb +10 -10
- data/lib/ramaze/helper/blue_form.rb +33 -6
- data/lib/ramaze/helper/csrf.rb +22 -30
- data/lib/ramaze/helper/flash.rb +1 -1
- data/lib/ramaze/helper/upload.rb +5 -3
- data/lib/ramaze/helper/user.rb +1 -0
- data/lib/ramaze/log.rb +0 -5
- data/lib/ramaze/log/informer.rb +3 -3
- data/lib/ramaze/log/logging.rb +4 -4
- data/lib/ramaze/log/syslog.rb +2 -2
- data/lib/ramaze/response.rb +1 -1
- data/lib/ramaze/snippets.rb +0 -20
- data/lib/ramaze/spec/bacon.rb +5 -13
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view/erector.rb +1 -3
- data/lib/ramaze/view/erubis.rb +1 -3
- data/lib/ramaze/view/ezamar.rb +1 -3
- data/lib/ramaze/view/haml.rb +1 -4
- data/lib/ramaze/view/liquid.rb +1 -3
- data/lib/ramaze/view/lokar.rb +1 -3
- data/lib/ramaze/view/mustache.rb +1 -3
- data/lib/ramaze/view/nagoro.rb +1 -4
- data/lib/ramaze/view/remarkably.rb +1 -4
- data/lib/ramaze/view/sass.rb +2 -5
- data/lib/ramaze/view/slim.rb +1 -3
- data/lib/ramaze/view/slippers.rb +1 -3
- data/lib/ramaze/view/tagz.rb +1 -3
- data/lib/ramaze/view/tenjin.rb +1 -3
- data/ramaze.gemspec +45 -16
- data/spec/helper.rb +0 -1
- data/spec/ramaze/cache/localmemcache.rb +0 -4
- data/spec/ramaze/controller/mapping.rb +17 -0
- data/spec/ramaze/dispatcher/directory.rb +6 -5
- data/spec/ramaze/dispatcher/file.rb +7 -4
- data/spec/ramaze/files.rb +0 -2
- data/spec/ramaze/helper/csrf.rb +0 -26
- data/spec/ramaze/helper/upload.rb +1 -0
- data/spec/ramaze/helper/user.rb +12 -0
- data/spec/ramaze/log/syslog.rb +5 -1
- data/spec/ramaze/view/lokar.rb +1 -1
- data/spec/ramaze/view/nagoro.rb +1 -1
- data/tasks/bacon.rake +1 -1
- data/tasks/gems.rake +15 -0
- data/tasks/release.rake +37 -8
- metadata +106 -139
- data/guide/_static/ramaze_console.png +0 -0
- data/guide/tutorials/introduction.md +0 -263
- data/lib/proto/model/init.rb +0 -6
- data/lib/proto/public/.htaccess +0 -24
- data/lib/proto/public/dispatch.fcgi +0 -11
- data/lib/proto/spec/main.rb +0 -20
- data/lib/proto/start.rb +0 -20
- data/lib/ramaze/app_graph.rb +0 -105
- data/lib/ramaze/bin/console.rb +0 -87
- data/lib/ramaze/bin/helper.rb +0 -107
- data/lib/ramaze/bin/restart.rb +0 -95
- data/lib/ramaze/bin/start.rb +0 -221
- data/lib/ramaze/bin/status.rb +0 -152
- data/lib/ramaze/bin/stop.rb +0 -112
- data/lib/ramaze/dependencies.rb +0 -84
- data/lib/ramaze/helper/disqus.rb +0 -27
- data/lib/ramaze/helper/ultraviolet.rb +0 -49
- data/lib/ramaze/log/analogger.rb +0 -50
- data/lib/ramaze/log/growl.rb +0 -55
- data/lib/ramaze/log/knotify.rb +0 -31
- data/lib/ramaze/log/xosd.rb +0 -94
- data/lib/ramaze/middleware_compiler.rb +0 -36
- data/lib/ramaze/plugin.rb +0 -69
- data/lib/ramaze/setup.rb +0 -210
- data/lib/ramaze/snippets/array/put_within.rb +0 -38
- data/lib/ramaze/snippets/binding/locals.rb +0 -20
- data/lib/ramaze/snippets/fiber.rb +0 -41
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +0 -18
- data/lib/ramaze/snippets/metaid.rb +0 -17
- data/lib/ramaze/snippets/numeric/filesize_format.rb +0 -30
- data/lib/ramaze/snippets/numeric/time.rb +0 -59
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +0 -16
- data/lib/ramaze/snippets/object/pretty.rb +0 -12
- data/lib/ramaze/snippets/object/scope.rb +0 -16
- data/lib/ramaze/snippets/ordered_set.rb +0 -51
- data/lib/ramaze/snippets/proc/locals.rb +0 -19
- data/lib/ramaze/snippets/ramaze/acquire.rb +0 -32
- data/lib/ramaze/snippets/ramaze/dictionary.rb +0 -400
- data/lib/ramaze/snippets/ramaze/fiber.rb +0 -24
- data/lib/ramaze/snippets/ramaze/struct.rb +0 -43
- data/lib/ramaze/snippets/string/end_with.rb +0 -17
- data/lib/ramaze/snippets/string/ord.rb +0 -16
- data/lib/ramaze/snippets/string/start_with.rb +0 -14
- data/lib/ramaze/snippets/thread/into.rb +0 -16
- data/lib/ramaze/spec.rb +0 -4
- data/spec/ramaze/bin/start.rb +0 -34
- data/spec/ramaze/log/growl.rb +0 -45
- data/spec/ramaze/struct.rb +0 -50
- data/spec/snippets/array/put_within.rb +0 -38
- data/spec/snippets/binding/locals.rb +0 -12
- data/spec/snippets/numeric/filesize_format.rb +0 -15
- data/spec/snippets/numeric/time.rb +0 -15
- data/spec/snippets/ordered_set.rb +0 -66
- data/spec/snippets/ramaze/acquire.rb +0 -80
- data/spec/snippets/ramaze/dictionary.rb +0 -113
- data/spec/snippets/ramaze/struct.rb +0 -15
- data/spec/snippets/thread/into.rb +0 -12
- data/tasks/gem.rake +0 -21
- data/tasks/setup.rake +0 -14
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Ramaze
|
|
2
|
-
class Fiber < ::Fiber
|
|
3
|
-
# initialize isn't being called, so we have to hook into ::new
|
|
4
|
-
def self.new(*args)
|
|
5
|
-
instance = super
|
|
6
|
-
instance.state = {}
|
|
7
|
-
instance
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
attr_accessor :state
|
|
11
|
-
|
|
12
|
-
def [](key)
|
|
13
|
-
@state[key]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def []=(key, value)
|
|
17
|
-
@state[key] = value
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def key?(key)
|
|
21
|
-
@state.key?(key)
|
|
22
|
-
end
|
|
23
|
-
end if defined?(::Fiber)
|
|
24
|
-
end # Ramaze
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
|
3
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
4
|
-
|
|
5
|
-
module Ramaze
|
|
6
|
-
class Struct < ::Struct
|
|
7
|
-
# Makes it possible to access the keys directly by their name, not only
|
|
8
|
-
# their index. The original Struct#values_at tries to call #to_int on the
|
|
9
|
-
# arguments.
|
|
10
|
-
# in Ruby < 1.9 this would lead to a quite unintuitive IndexError, while
|
|
11
|
-
# in 1.9 it will say outright that it cannot convert Symbol into Integer.
|
|
12
|
-
# I think this is neither useful nor expected, so we extend
|
|
13
|
-
# Struct#values_at to recognize valid members of the Struct passed into
|
|
14
|
-
# the method and return their values in the same order, just like
|
|
15
|
-
# Hash#values_at.
|
|
16
|
-
#
|
|
17
|
-
# Example:
|
|
18
|
-
# Point = Struct.new(:x, :y)
|
|
19
|
-
# point = Point.new(15, 10)
|
|
20
|
-
#
|
|
21
|
-
# # Old behaviour:
|
|
22
|
-
# point.values_at(0, 1)
|
|
23
|
-
# # => [15, 10]
|
|
24
|
-
# point.values_at(0..1)
|
|
25
|
-
# # => [15, 10]
|
|
26
|
-
# point.values_at(:y, :x)
|
|
27
|
-
# # => IndexError: offset 20697 too large for struct(size:2)
|
|
28
|
-
#
|
|
29
|
-
# # Added new behaviour:
|
|
30
|
-
# point.values_at(:y, :x)
|
|
31
|
-
# # => [10, 15]
|
|
32
|
-
def values_at(*keys)
|
|
33
|
-
keys.map do |key|
|
|
34
|
-
case key
|
|
35
|
-
when String, Symbol
|
|
36
|
-
self[key]
|
|
37
|
-
else
|
|
38
|
-
return super
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end # Struct
|
|
43
|
-
end # Ramaze
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
module Ramaze
|
|
5
|
-
module CoreExtensions
|
|
6
|
-
# Extensions for String
|
|
7
|
-
module String
|
|
8
|
-
unless ''.respond_to?(:end_with?)
|
|
9
|
-
# Compatibility with 1.9
|
|
10
|
-
def end_with?(other)
|
|
11
|
-
other = other.to_s
|
|
12
|
-
self[-other.size, other.size] == other
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end # String
|
|
16
|
-
end # CoreExtensions
|
|
17
|
-
end # Ramaze
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
module Ramaze
|
|
5
|
-
module CoreExtensions
|
|
6
|
-
# Extensions for String
|
|
7
|
-
module String
|
|
8
|
-
unless ''.respond_to?(:ord)
|
|
9
|
-
# compatibility with Ruby 1.9
|
|
10
|
-
def ord
|
|
11
|
-
self[0]
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end # String
|
|
15
|
-
end # CoreExtensions
|
|
16
|
-
end # Ramaze
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Ramaze
|
|
2
|
-
module CoreExtensions
|
|
3
|
-
# Extensions for String
|
|
4
|
-
module String
|
|
5
|
-
unless ''.respond_to?(:start_with?)
|
|
6
|
-
# Compatibility with 1.9
|
|
7
|
-
def start_with?(other)
|
|
8
|
-
other = other.to_s
|
|
9
|
-
self[0, other.size] == other
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end # String
|
|
13
|
-
end # CoreExtensions
|
|
14
|
-
end # Ramaze
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
# Extensions for Thread
|
|
5
|
-
class Thread
|
|
6
|
-
# Copy all thread variables into the new thread
|
|
7
|
-
def self.into(*args)
|
|
8
|
-
Thread.new(Thread.current, *args) do |thread, *thread_args|
|
|
9
|
-
thread.keys.each do |k|
|
|
10
|
-
Thread.current[k] = thread[k] unless k.to_s =~ /^__/
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
yield(*thread_args)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end # Thread
|
data/lib/ramaze/spec.rb
DELETED
data/spec/ramaze/bin/start.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
2
|
-
require __DIR__('../../../lib/ramaze/bin/runner')
|
|
3
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
describe('Ramaze::Bin::Start') do
|
|
16
|
-
it('Should show a help message') do
|
|
17
|
-
help = `#{Ramaze::BINPATH} start -h`.strip
|
|
18
|
-
|
|
19
|
-
help.include?(Ramaze::Bin::Start::Banner).should === true
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it('Start using a directory') do
|
|
23
|
-
cmd = Ramaze::Bin::Start.new
|
|
24
|
-
|
|
25
|
-
cmd.run([Ramaze::BIN_APP]).should == true
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it('Start using a file') do
|
|
29
|
-
path = File.join(Ramaze::BIN_APP, 'config.ru')
|
|
30
|
-
cmd = Ramaze::Bin::Start.new
|
|
31
|
-
|
|
32
|
-
cmd.run([path]).should == true
|
|
33
|
-
end
|
|
34
|
-
end
|
data/spec/ramaze/log/growl.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
spec_precondition 'ruby-growl should be supported' do
|
|
4
|
-
should.flunk if Ramaze::UNSUPPORTED_GEMS.include?('ruby-growl')
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
spec_require 'ruby-growl'
|
|
8
|
-
|
|
9
|
-
spec_precondition 'Growl should be running' do
|
|
10
|
-
begin
|
|
11
|
-
growl = Ramaze::Logger::Growl.new
|
|
12
|
-
growl.log(:info, 'Ramaze connection test')
|
|
13
|
-
rescue
|
|
14
|
-
should.flunk 'Growl is not running'
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
require 'ramaze/log/growl'
|
|
19
|
-
|
|
20
|
-
# Configure Growl, make sure your growl server matches
|
|
21
|
-
# these settings.
|
|
22
|
-
Ramaze::Logger::Growl.trait[:defaults][:name] = 'ramaze'
|
|
23
|
-
Ramaze::Logger::Growl.trait[:defaults][:password] = 'ramaze'
|
|
24
|
-
|
|
25
|
-
describe Ramaze::Logger::Growl do
|
|
26
|
-
it 'Create a new instance of the Growl logger' do
|
|
27
|
-
growl = Ramaze::Logger::Growl.new
|
|
28
|
-
|
|
29
|
-
growl.should.respond_to? :log
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'Send a growl notification' do
|
|
33
|
-
growl = Ramaze::Logger::Growl.new
|
|
34
|
-
growl.log(:info, 'Hello, Ramaze!')
|
|
35
|
-
|
|
36
|
-
# The Growl library doesn't seem to return anything,
|
|
37
|
-
# let's ask the user if the notification was sent
|
|
38
|
-
print "Did you see the the notification? (y/n) "
|
|
39
|
-
response = gets.strip
|
|
40
|
-
|
|
41
|
-
response.should.satisfy do |object|
|
|
42
|
-
object === 'y' or object === 'yes'
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
data/spec/ramaze/struct.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../spec/helper', __FILE__)
|
|
5
|
-
|
|
6
|
-
Point = Ramaze::Struct.new(:x,:y)
|
|
7
|
-
|
|
8
|
-
describe "Ramaze::Struct" do
|
|
9
|
-
describe '#values_at' do
|
|
10
|
-
@point = Point.new(1,2)
|
|
11
|
-
|
|
12
|
-
it "should access a single value" do
|
|
13
|
-
@point.values_at(:x).should == [1]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should access multiple values" do
|
|
17
|
-
@point.values_at(:x,:y).should == [1,2]
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should access values regardless of order" do
|
|
21
|
-
@point.values_at(:y,:x).should == [2,1]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should get same value twice" do
|
|
25
|
-
@point.values_at(:x,:x).should == [1,1]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should raise on wrong value" do
|
|
29
|
-
should.raise(NameError){
|
|
30
|
-
@point.values_at(:k)
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should work with strings" do
|
|
35
|
-
@point.values_at('x').should == [1]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should work with numbers (ruby compat)" do
|
|
39
|
-
@point.values_at(0).should == [1]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
should 'work with ranges' do
|
|
43
|
-
@point.values_at(0..1).should == [1,2]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
should 'work with multiple ranges' do
|
|
47
|
-
@point.values_at(0..1, 0..1).should == [1,2,1,2]
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../lib/ramaze/spec/helper/snippets', __FILE__)
|
|
5
|
-
|
|
6
|
-
describe 'Array' do
|
|
7
|
-
describe '#put_within' do
|
|
8
|
-
it 'puts a given object at a well-described position' do
|
|
9
|
-
array = [:foo, :bar, :baz]
|
|
10
|
-
array.put_within(:foobar, :after => :bar, :before => :baz)
|
|
11
|
-
array.should == [:foo, :bar, :foobar, :baz]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'raises on uncertainity' do
|
|
15
|
-
array = [:foo, :bar, :baz]
|
|
16
|
-
lambda{
|
|
17
|
-
array.put_within(:foobar, :after => :foo, :before => :baz)
|
|
18
|
-
}.should.raise(ArgumentError).
|
|
19
|
-
message.should == "Too many elements within constrain"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
describe '#put_after' do
|
|
24
|
-
it 'puts a given object at a well-described position' do
|
|
25
|
-
array = [:foo, :bar, :baz]
|
|
26
|
-
array.put_after(:bar, :foobar)
|
|
27
|
-
array.should == [:foo, :bar, :foobar, :baz]
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe '#put_within' do
|
|
32
|
-
it 'puts a given object at a well-described position' do
|
|
33
|
-
array = [:foo, :bar, :baz]
|
|
34
|
-
array.put_before(:bar, :foobar)
|
|
35
|
-
array.should == [:foo, :foobar, :bar, :baz]
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../lib/ramaze/spec/helper/snippets', __FILE__)
|
|
5
|
-
|
|
6
|
-
describe 'locals' do
|
|
7
|
-
should 'find locals' do
|
|
8
|
-
a = 1
|
|
9
|
-
b = 2
|
|
10
|
-
binding.locals.should == {'a' => 1, 'b' => 2}
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../lib/ramaze/spec/helper/snippets', __FILE__)
|
|
5
|
-
|
|
6
|
-
describe "Numeric#filesize_format" do
|
|
7
|
-
it 'it should convert filesizes to human readable format' do
|
|
8
|
-
1.filesize_format.should == '1'
|
|
9
|
-
1024.filesize_format.should == '1.0K'
|
|
10
|
-
(1 << 20).filesize_format.should == '1.0M'
|
|
11
|
-
(1 << 20).filesize_format.should == '1.0M'
|
|
12
|
-
(1 << 30).filesize_format.should == '1.0G'
|
|
13
|
-
(1 << 40).filesize_format.should == '1.0T'
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../lib/ramaze/spec/helper/snippets', __FILE__)
|
|
5
|
-
|
|
6
|
-
describe "Numeric time extensions" do
|
|
7
|
-
it 'should provide times in the past' do
|
|
8
|
-
3.days.ago.to_i.should == (Time.now - 3*24*60*60).to_i
|
|
9
|
-
2.months.ago.to_i.should == (Time.now - 2*30*24*60*60).to_i
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'should provide times in the future' do
|
|
13
|
-
2.weeks.from_now.to_i.should == (Time.now + 2*7*24*60*60).to_i
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../lib/ramaze/spec/helper/snippets', __FILE__)
|
|
5
|
-
|
|
6
|
-
describe 'OrderedSet' do
|
|
7
|
-
os = OrderedSet.new(1,2,3,1)
|
|
8
|
-
|
|
9
|
-
it 'should create sets' do
|
|
10
|
-
OrderedSet.new.should == []
|
|
11
|
-
OrderedSet.new(1).should == [1]
|
|
12
|
-
OrderedSet.new(1,2).should == [1,2]
|
|
13
|
-
OrderedSet.new([1,2,3]).should == [1,2,3]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'should compare sets' do
|
|
17
|
-
os.should == OrderedSet.new(1,2,3,1)
|
|
18
|
-
os.should == OrderedSet.new([1,2,3,1])
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should not contain duplicates' do
|
|
22
|
-
os.should == [1,2,3]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'should not duplicate entries' do
|
|
26
|
-
os << 4
|
|
27
|
-
os.should == [1,2,3,4]
|
|
28
|
-
|
|
29
|
-
os << 4
|
|
30
|
-
os.should == [1,2,3,4]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'should append with push and prepend with unshift' do
|
|
34
|
-
os.push 1
|
|
35
|
-
os.should == [2,3,4,1]
|
|
36
|
-
|
|
37
|
-
os.unshift 1
|
|
38
|
-
os.should == [1,2,3,4]
|
|
39
|
-
|
|
40
|
-
os.push [1,2]
|
|
41
|
-
os.should == [1,2,3,4,[1,2]]
|
|
42
|
-
|
|
43
|
-
os.unshift [1,2]
|
|
44
|
-
os.should == [[1,2],1,2,3,4]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'should support Array#[]=' do
|
|
48
|
-
os = OrderedSet.new(1)
|
|
49
|
-
os.should == [1]
|
|
50
|
-
|
|
51
|
-
os[0] = 1
|
|
52
|
-
os.should == [1]
|
|
53
|
-
|
|
54
|
-
os[1,0] = [3,4,5,1]
|
|
55
|
-
os.should == [3,4,5,1]
|
|
56
|
-
|
|
57
|
-
os[0,0] = [1,2]
|
|
58
|
-
os.should == [1,2,3,4,5]
|
|
59
|
-
|
|
60
|
-
os[5..5] = [7,8,1,2]
|
|
61
|
-
os.should == [3,4,5,7,8,1,2]
|
|
62
|
-
|
|
63
|
-
os[1..2] = 3
|
|
64
|
-
os.should == [3,7,8,1,2]
|
|
65
|
-
end
|
|
66
|
-
end
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the MIT license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../lib/ramaze/spec/helper/snippets', __FILE__)
|
|
5
|
-
require 'fileutils'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Mock require to only record attempts
|
|
9
|
-
$required = []
|
|
10
|
-
|
|
11
|
-
module Ramaze
|
|
12
|
-
def self.require(name)
|
|
13
|
-
$required << name
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe 'Ramaze::acquire' do
|
|
18
|
-
before do
|
|
19
|
-
dir = 'tmp_dir_for_acquire'
|
|
20
|
-
FileUtils.mkdir_p(dir + '/sub')
|
|
21
|
-
|
|
22
|
-
%w[ foo.rb bar.rb baz.so baz.yml sub/baz.rb ].
|
|
23
|
-
each do |path|
|
|
24
|
-
FileUtils.touch("#{dir}/#{path}")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
$required = []
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'should not load a single file' do
|
|
31
|
-
Ramaze::acquire 'tmp_dir_for_acquire/foo'
|
|
32
|
-
$required.should == []
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'should load dir' do
|
|
36
|
-
Ramaze::acquire 'tmp_dir_for_acquire/sub/*'
|
|
37
|
-
$required.should == %w[
|
|
38
|
-
tmp_dir_for_acquire/sub/baz.rb]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'should be aliased to acquire' do
|
|
42
|
-
Ramaze::acquire 'tmp_dir_for_acquire/sub/*'
|
|
43
|
-
$required.should.not.be.empty
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'should load {so,rb}, not others' do
|
|
47
|
-
Ramaze::acquire 'tmp_dir_for_acquire/*'
|
|
48
|
-
$required.sort.should == %w[
|
|
49
|
-
tmp_dir_for_acquire/bar.rb
|
|
50
|
-
tmp_dir_for_acquire/baz.so
|
|
51
|
-
tmp_dir_for_acquire/foo.rb]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'should use globbing' do
|
|
55
|
-
Ramaze::acquire 'tmp_dir_for_acquire/ba*'
|
|
56
|
-
$required.sort.should == %w[
|
|
57
|
-
tmp_dir_for_acquire/bar.rb
|
|
58
|
-
tmp_dir_for_acquire/baz.so]
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'should use recursive globbing' do
|
|
62
|
-
Ramaze::acquire 'tmp_dir_for_acquire/**/*'
|
|
63
|
-
$required.sort.should == %w[
|
|
64
|
-
tmp_dir_for_acquire/bar.rb
|
|
65
|
-
tmp_dir_for_acquire/baz.so
|
|
66
|
-
tmp_dir_for_acquire/foo.rb
|
|
67
|
-
tmp_dir_for_acquire/sub/baz.rb]
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'should accept multiple arguments' do
|
|
71
|
-
Ramaze::acquire 'tmp_dir_for_acquire/*', 'tmp_dir_for_acquire/sub/*'
|
|
72
|
-
$required.sort.should == %w[
|
|
73
|
-
tmp_dir_for_acquire/bar.rb
|
|
74
|
-
tmp_dir_for_acquire/baz.so
|
|
75
|
-
tmp_dir_for_acquire/foo.rb
|
|
76
|
-
tmp_dir_for_acquire/sub/baz.rb]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
FileUtils.rm_rf('tmp_dir_for_acquire')
|
|
80
|
-
end
|