waves 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/waves +4 -3
- data/doc/VERSION +1 -1
- data/lib/waves.rb +52 -40
- data/lib/{caches → waves/caches}/file.rb +3 -1
- data/lib/waves/caches/memcached.rb +56 -0
- data/lib/{caches → waves/caches}/simple.rb +6 -7
- data/lib/{caches → waves/caches}/synchronized.rb +15 -1
- data/lib/{commands → waves/commands}/console.rb +4 -4
- data/lib/{commands → waves/commands}/generate.rb +6 -5
- data/lib/{commands → waves/commands}/help.rb +0 -0
- data/lib/{commands → waves/commands}/server.rb +1 -1
- data/lib/{dispatchers → waves/dispatchers}/base.rb +17 -31
- data/lib/waves/dispatchers/default.rb +19 -0
- data/lib/{ext → waves/ext}/float.rb +0 -0
- data/lib/{ext → waves/ext}/hash.rb +0 -0
- data/lib/{ext → waves/ext}/integer.rb +16 -1
- data/lib/{ext → waves/ext}/kernel.rb +3 -7
- data/lib/{ext → waves/ext}/module.rb +3 -3
- data/lib/{ext → waves/ext}/object.rb +2 -0
- data/lib/waves/ext/string.rb +73 -0
- data/lib/{ext → waves/ext}/symbol.rb +0 -1
- data/lib/{ext → waves/ext}/tempfile.rb +0 -0
- data/lib/waves/ext/time.rb +5 -0
- data/lib/{foundations → waves/foundations}/classic.rb +9 -21
- data/lib/{foundations → waves/foundations}/compact.rb +15 -20
- data/lib/waves/foundations/rest.rb +311 -0
- data/lib/waves/helpers/basic.rb +13 -0
- data/lib/{helpers → waves/helpers}/doc_type.rb +3 -0
- data/lib/waves/helpers/form.rb +94 -0
- data/lib/waves/helpers/formatting.rb +14 -0
- data/lib/waves/layers/mvc.rb +65 -0
- data/lib/{layers → waves/layers}/mvc/controllers.rb +0 -0
- data/lib/{layers → waves/layers}/mvc/extensions.rb +23 -11
- data/lib/{layers → waves/layers}/orm/migration.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/active_record.rb +2 -5
- data/lib/{layers → waves/layers}/orm/providers/active_record/migrations/empty.rb.erb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/generate.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/schema.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/data_mapper.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/filebase.rb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/sequel.rb +28 -29
- data/lib/{layers → waves/layers}/orm/providers/sequel/migrations/empty.rb.erb +0 -0
- data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/generate.rb +1 -1
- data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/schema.rb +2 -0
- data/lib/waves/layers/rack/rack_cache.rb +32 -0
- data/lib/waves/layers/renderers/erubis.rb +52 -0
- data/lib/waves/layers/renderers/haml.rb +67 -0
- data/lib/waves/layers/renderers/markaby.rb +41 -0
- data/lib/waves/layers/text/inflect/english.rb +42 -0
- data/lib/waves/matchers/accept.rb +47 -0
- data/lib/waves/matchers/ext.rb +27 -0
- data/lib/waves/matchers/path.rb +72 -0
- data/lib/waves/matchers/query.rb +43 -0
- data/lib/waves/matchers/request.rb +86 -0
- data/lib/waves/matchers/requested.rb +31 -0
- data/lib/{matchers → waves/matchers}/resource.rb +8 -1
- data/lib/waves/matchers/traits.rb +30 -0
- data/lib/waves/matchers/uri.rb +69 -0
- data/lib/waves/media/mime_types.rb +542 -0
- data/lib/waves/renderers/mixin.rb +9 -0
- data/lib/waves/request/accept.rb +92 -0
- data/lib/{runtime → waves/request}/request.rb +77 -61
- data/lib/waves/resources/file_mixin.rb +11 -0
- data/lib/{resources → waves/resources}/mixin.rb +42 -44
- data/lib/waves/resources/paths.rb +132 -0
- data/lib/waves/response/client_errors.rb +10 -0
- data/lib/waves/response/packaged.rb +19 -0
- data/lib/waves/response/redirects.rb +35 -0
- data/lib/{runtime → waves/response}/response.rb +29 -11
- data/lib/{runtime → waves/response}/response_mixin.rb +30 -17
- data/lib/waves/runtime/applications.rb +18 -0
- data/lib/{runtime → waves/runtime}/configuration.rb +31 -25
- data/lib/waves/runtime/console.rb +24 -0
- data/lib/{runtime → waves/runtime}/logger.rb +3 -3
- data/lib/{runtime → waves/runtime}/mocks.rb +2 -2
- data/lib/waves/runtime/rackup.rb +37 -0
- data/lib/waves/runtime/runtime.rb +48 -0
- data/lib/waves/runtime/server.rb +33 -0
- data/lib/{servers → waves/servers}/base.rb +0 -0
- data/lib/{servers → waves/servers}/mongrel.rb +0 -0
- data/lib/{servers → waves/servers}/webrick.rb +0 -0
- data/lib/{tasks → waves/tasks}/gem.rb +0 -0
- data/lib/{tasks → waves/tasks}/generate.rb +0 -0
- data/lib/waves/views/cassy.rb +173 -0
- data/lib/{views → waves/views}/errors.rb +8 -7
- data/lib/waves/views/mixin.rb +23 -0
- data/lib/waves/views/templated.rb +40 -0
- data/samples/basic/basic_startup.rb +70 -0
- data/samples/basic/config.ru +9 -0
- data/samples/blog/configurations/development.rb +17 -16
- data/samples/blog/configurations/production.rb +0 -11
- data/samples/blog/resources/entry.rb +3 -3
- data/samples/blog/resources/map.rb +10 -3
- data/samples/blog/startup.rb +4 -3
- data/templates/classic/Rakefile +28 -29
- data/templates/classic/configurations/default.rb.erb +8 -3
- data/templates/classic/configurations/development.rb.erb +1 -20
- data/templates/classic/configurations/production.rb.erb +2 -16
- data/templates/classic/public/images/favicon.ico +0 -0
- data/templates/classic/resources/server.rb.erb +9 -0
- data/templates/classic/startup.rb.erb +3 -3
- data/templates/classic/views/css.rb.erb +14 -0
- data/templates/classic/views/default.rb.erb +17 -0
- data/templates/classic/views/errors.rb.erb +10 -0
- data/templates/classic/views/pages.rb.erb +14 -0
- data/templates/compact/startup.rb.erb +8 -3
- data/test/ext/object.rb +55 -0
- data/test/ext/shortcuts.rb +73 -0
- data/test/helpers.rb +17 -0
- data/test/match/accept.rb +78 -0
- data/test/match/ext.rb +156 -0
- data/test/match/methods.rb +22 -0
- data/test/match/params.rb +33 -0
- data/test/match/path.rb +106 -0
- data/test/match/query.rb +60 -0
- data/test/match/request.rb +91 -0
- data/test/match/requested.rb +149 -0
- data/test/match/uri.rb +136 -0
- data/test/process/request.rb +75 -0
- data/test/process/resource.rb +53 -0
- data/test/resources/path.rb +166 -0
- data/test/runtime/configurations.rb +19 -0
- data/test/runtime/request.rb +63 -0
- data/test/runtime/response.rb +85 -0
- data/test/views/views.rb +40 -0
- metadata +243 -157
- data/lib/caches/memcached.rb +0 -40
- data/lib/dispatchers/default.rb +0 -25
- data/lib/ext/string.rb +0 -20
- data/lib/helpers/basic.rb +0 -11
- data/lib/helpers/extended.rb +0 -21
- data/lib/helpers/form.rb +0 -42
- data/lib/helpers/formatting.rb +0 -30
- data/lib/helpers/layouts.rb +0 -37
- data/lib/helpers/model.rb +0 -37
- data/lib/helpers/view.rb +0 -22
- data/lib/layers/inflect/english.rb +0 -67
- data/lib/layers/mvc.rb +0 -54
- data/lib/layers/renderers/erubis.rb +0 -60
- data/lib/layers/renderers/haml.rb +0 -47
- data/lib/layers/renderers/markaby.rb +0 -29
- data/lib/matchers/accept.rb +0 -21
- data/lib/matchers/base.rb +0 -30
- data/lib/matchers/content_type.rb +0 -17
- data/lib/matchers/path.rb +0 -67
- data/lib/matchers/query.rb +0 -21
- data/lib/matchers/request.rb +0 -27
- data/lib/matchers/traits.rb +0 -19
- data/lib/matchers/uri.rb +0 -20
- data/lib/renderers/mixin.rb +0 -36
- data/lib/resources/paths.rb +0 -34
- data/lib/runtime/console.rb +0 -23
- data/lib/runtime/mime_types.rb +0 -536
- data/lib/runtime/monitor.rb +0 -32
- data/lib/runtime/runtime.rb +0 -67
- data/lib/runtime/server.rb +0 -20
- data/lib/runtime/session.rb +0 -27
- data/lib/runtime/worker.rb +0 -86
- data/lib/views/mixin.rb +0 -62
- data/samples/blog/blog.db +0 -0
- data/samples/blog/log/waves.production +0 -3
- data/templates/classic/resources/map.rb.erb +0 -8
- data/templates/classic/templates/errors/not_found_404.mab +0 -7
- data/templates/classic/templates/errors/server_error_500.mab +0 -7
- data/templates/classic/templates/layouts/default.mab +0 -14
- data/templates/classic/tmp/sessions/.gitignore +0 -0
@@ -10,17 +10,6 @@ module Blog
|
|
10
10
|
host '0.0.0.0'
|
11
11
|
port 4000
|
12
12
|
|
13
|
-
application do
|
14
|
-
use ::Rack::Static,
|
15
|
-
:urls => %w( /css /javascript /favicon.ico ),
|
16
|
-
:root => 'public'
|
17
|
-
use Rack::Session::Cookie,
|
18
|
-
:key => 'blog.session', :path => '/',
|
19
|
-
:expire_after => 3.days
|
20
|
-
run ::Waves::Dispatchers::Default.new
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
13
|
end
|
25
14
|
end
|
26
15
|
end
|
@@ -6,8 +6,8 @@ module Blog
|
|
6
6
|
view.list( plural => controller.all )
|
7
7
|
end
|
8
8
|
|
9
|
-
on :get, :show => [ 'entry', :name ] do
|
10
|
-
|
9
|
+
on :get, :show => [ 'entry', :name ] do
|
10
|
+
view.show( :entry => controller.find( captured.name ) )
|
11
11
|
end
|
12
12
|
|
13
13
|
on :get, :edit => [ 'entry', :name, 'edit' ] do
|
@@ -16,7 +16,7 @@ module Blog
|
|
16
16
|
|
17
17
|
on :put, :update => [ 'entry', :name ] do
|
18
18
|
controller.update( captured.name )
|
19
|
-
redirect( paths.show( captured.name ))
|
19
|
+
redirect( paths.show( captured .name ))
|
20
20
|
end
|
21
21
|
|
22
22
|
on :post, :create => [ 'entry' ] do
|
@@ -1,9 +1,16 @@
|
|
1
|
+
require "autocode"
|
2
|
+
|
1
3
|
module Blog
|
4
|
+
|
2
5
|
module Resources
|
3
|
-
|
4
|
-
|
6
|
+
include AutoCode
|
7
|
+
auto_load true, :directories => "resources"
|
8
|
+
|
9
|
+
class Map
|
10
|
+
include Waves::Resources::Mixin
|
11
|
+
|
5
12
|
on( true ) { to( :entry ) }
|
6
|
-
|
13
|
+
|
7
14
|
end
|
8
15
|
end
|
9
16
|
end
|
data/samples/blog/startup.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require 'foundations/classic'
|
2
|
-
require 'layers/orm/providers/sequel'
|
3
|
-
require 'layers/renderers/markaby'
|
1
|
+
require 'waves/foundations/classic'
|
2
|
+
require 'waves/layers/orm/providers/sequel'
|
3
|
+
require 'waves/layers/renderers/markaby'
|
4
|
+
|
4
5
|
module Blog
|
5
6
|
include Waves::Foundations::Classic
|
6
7
|
include Waves::Layers::ORM::Sequel
|
data/templates/classic/Rakefile
CHANGED
@@ -21,13 +21,13 @@ else
|
|
21
21
|
end
|
22
22
|
|
23
23
|
require waves
|
24
|
-
require 'runtime/console'
|
24
|
+
require 'waves/runtime/console'
|
25
25
|
|
26
26
|
begin
|
27
27
|
Waves::Console.load(:mode => ENV['mode'])
|
28
28
|
|
29
29
|
# load tasks from waves framework
|
30
|
-
%w( generate gem ).each { |task| require "tasks/#{task}.rb" }
|
30
|
+
%w( generate gem ).each { |task| require "waves/tasks/#{task}.rb" }
|
31
31
|
|
32
32
|
# load tasks from this app's lib/tasks
|
33
33
|
Dir["lib/tasks/*.{rb,rake}"].each { |task| require task }
|
@@ -43,35 +43,36 @@ end
|
|
43
43
|
|
44
44
|
namespace :waves do
|
45
45
|
|
46
|
-
desc "freeze src=<wherever> to ./waves"
|
47
|
-
task :freeze do
|
48
|
-
|
49
|
-
target = "#{Dir.pwd}/waves"
|
50
|
-
src = ENV['src']
|
51
|
-
raise "Please specify the location of waves using src=wherever" unless src
|
52
|
-
raise "No directory found at '#{src}'" unless File.directory?(src)
|
53
|
-
|
54
|
-
items = FileList["#{src}/*"]
|
55
|
-
puts "Freezing from: #{src}"
|
56
|
-
items.each do |item|
|
57
|
-
puts "copying #{item}"
|
58
|
-
cp_r item, target
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
46
|
desc "unfreeze (i.e. delete) the waves source at ./waves"
|
64
|
-
task :
|
47
|
+
task :thaw do
|
65
48
|
frozen = "#{Dir.pwd}/waves"
|
66
49
|
rm_r frozen if File.exist?(frozen)
|
67
50
|
end
|
68
51
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
52
|
+
namespace :freeze do
|
53
|
+
|
54
|
+
desc "freeze source=<wherever> to ./waves"
|
55
|
+
task :using do
|
56
|
+
|
57
|
+
target = "#{Dir.pwd}/waves"
|
58
|
+
src = ENV['source']
|
59
|
+
raise "Please specify the location of waves using src=wherever" unless src
|
60
|
+
raise "No directory found at '#{src}'" unless File.directory?(src)
|
61
|
+
|
62
|
+
items = FileList["#{src}/*"]
|
63
|
+
puts "Freezing from: #{src}"
|
64
|
+
items.each do |item|
|
65
|
+
puts "copying #{item}"
|
66
|
+
cp_r item, target
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
# Convenience task to allow you to freeze the current Waves
|
72
|
+
# source without knowing where it is. This task only gets
|
73
|
+
# defined when the Rakefile successfully loaded Waves and if
|
74
|
+
# there's nothing in the way at ./waves
|
75
|
+
if defined?(WAVES) && !File.exist?("#{Dir.pwd}/waves")
|
75
76
|
desc "freeze current Waves source to ./waves"
|
76
77
|
task :current do
|
77
78
|
target = "#{Dir.pwd}/waves"
|
@@ -82,9 +83,7 @@ namespace :waves do
|
|
82
83
|
puts "copying #{item}"
|
83
84
|
cp_r item, target
|
84
85
|
end
|
85
|
-
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
90
|
-
end
|
89
|
+
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module <%= @name %>
|
2
2
|
module Configurations
|
3
3
|
class Default < Waves::Configurations::Default
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
resource <%= @name %>::Resources::Server
|
5
|
+
reloadable [ <%= @name %> ]
|
6
|
+
host '127.0.0.1' ; port 3000 ; log :level => :debug
|
7
|
+
use Rack::Session::Pool, :expire_after => 1.day
|
8
|
+
use ::Rack::Static, :urls => %w( /css /images /javascript /favicon.ico ), :root => 'public'
|
9
|
+
dispatcher ::Waves::Dispatchers::Default
|
10
|
+
server Waves::Servers::Mongrel
|
11
|
+
dependencies []
|
7
12
|
end
|
8
13
|
end
|
9
14
|
end
|
@@ -1,26 +1,7 @@
|
|
1
1
|
module <%= @name %>
|
2
|
-
|
3
2
|
module Configurations
|
4
|
-
|
5
3
|
class Development < Default
|
6
|
-
|
7
|
-
database :adapter => 'sqlite', :database => '<%= @name.downcase %>'
|
8
|
-
|
9
|
-
reloadable [ <%= @name %> ]
|
10
|
-
log :level => :debug
|
11
|
-
host '127.0.0.1'
|
12
|
-
port 3000
|
13
|
-
dependencies []
|
14
|
-
|
15
|
-
application do
|
16
|
-
use ::Rack::ShowExceptions
|
17
|
-
use ::Rack::Static, :urls => [ '/css/', '/javascript/', '/favicon.ico' ], :root => 'public'
|
18
|
-
run ::Waves::Dispatchers::Default.new
|
19
|
-
end
|
20
|
-
|
21
|
-
server Waves::Servers::Mongrel
|
4
|
+
database :adapter => 'sqlite', :database => 'db/development'
|
22
5
|
end
|
23
|
-
|
24
6
|
end
|
25
|
-
|
26
7
|
end
|
@@ -1,29 +1,15 @@
|
|
1
1
|
module <%= @name %>
|
2
|
-
|
3
2
|
module Configurations
|
4
|
-
|
5
3
|
class Production < Default
|
6
|
-
|
7
|
-
|
4
|
+
database :host => 'localhost', :adapter => 'mysql',
|
5
|
+
:database => '<%= @name.downcase %>',
|
8
6
|
:user => 'root', :password => ''
|
9
|
-
|
10
7
|
reloadable []
|
11
|
-
|
12
8
|
log :level => :error,
|
13
9
|
:output => ( :log / "waves.#{$$}" ),
|
14
10
|
:rotation => :weekly
|
15
|
-
|
16
11
|
host '0.0.0.0'
|
17
|
-
|
18
12
|
port 80
|
19
|
-
|
20
|
-
application do
|
21
|
-
use ::Rack::Static, :urls => [ '/css/', '/javascript/', '/favicon.ico' ], :root => 'public'
|
22
|
-
run ::Waves::Dispatchers::Default.new
|
23
|
-
end
|
24
|
-
|
25
|
-
server Waves::Servers::Mongrel
|
26
|
-
|
27
13
|
end
|
28
14
|
end
|
29
15
|
end
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'foundations/classic'
|
1
|
+
require 'waves/foundations/classic'
|
2
2
|
<% if @orm %>
|
3
|
-
require 'layers/orm/providers/<%= @orm %>'
|
3
|
+
require 'waves/layers/orm/providers/<%= @orm %>'
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
module <%= @name %>
|
@@ -8,4 +8,4 @@ module <%= @name %>
|
|
8
8
|
<% if @orm %>
|
9
9
|
include Waves::Layers::ORM::<%= @orm.camel_case %>
|
10
10
|
<% end %>
|
11
|
-
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class <%= @name %>::Views::Pages < <%= @name %>::Views::Default
|
2
|
+
|
3
|
+
def welcome
|
4
|
+
layout {
|
5
|
+
h1 'Welcome To The Blog Application'
|
6
|
+
p {
|
7
|
+
raw "This is an empty Waves application. The good news is that Waves is " <<
|
8
|
+
"up and running just fine. Next, you should add your own resources. "
|
9
|
+
a "Find out how.", :href => 'http://rubywaves.com/'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'foundations/compact'
|
1
|
+
require 'waves/foundations/compact'
|
2
2
|
<% if @orm %>
|
3
|
-
require 'layers/orm/<%= @orm %>'
|
3
|
+
require 'waves/layers/orm/<%= @orm %>'
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
module <%= @name %>
|
@@ -8,4 +8,9 @@ module <%= @name %>
|
|
8
8
|
<% if @orm %>
|
9
9
|
include Waves::Layers::ORM::<%= @orm.camel_case %>
|
10
10
|
<% end %>
|
11
|
-
|
11
|
+
module Resources
|
12
|
+
class Server
|
13
|
+
on( true ) { 'Hello, from Waves!' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/ext/object.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../helpers.rb"
|
2
|
+
|
3
|
+
describe "Object#cache_method_missing" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
class A; end
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
Object.instance_eval { remove_const(:A) if const_defined?(:A) }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "defines the missing method" do
|
14
|
+
A.module_eval do
|
15
|
+
def method_missing(name, *args)
|
16
|
+
cache_method_missing name, "'hi'", *args
|
17
|
+
end
|
18
|
+
end
|
19
|
+
A.new.bar
|
20
|
+
A.new.should.respond_to :bar
|
21
|
+
end
|
22
|
+
|
23
|
+
it "passes along the args" do
|
24
|
+
A.module_eval do
|
25
|
+
def method_missing(name, *args, &block)
|
26
|
+
cache_method_missing name, "args.join('-')", *args
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
A.new.bar(1, 2, 3).should == "1-2-3"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "passes along the block" do
|
34
|
+
A.module_eval do
|
35
|
+
def method_missing(name, *args, &block)
|
36
|
+
cache_method_missing name, "block.call", *args, &block
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
A.new.bar { 'bye' }.should == 'bye'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "Object#instance_exec" do
|
46
|
+
|
47
|
+
before do
|
48
|
+
@block = lambda { |guy| "Howdy, #{guy}!" }
|
49
|
+
end
|
50
|
+
|
51
|
+
it "works like instance_eval, but it takes args and gives them to the block" do
|
52
|
+
instance_exec( "Steve", &@block ).should == "Howdy, Steve!"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../helpers.rb"
|
2
|
+
|
3
|
+
describe "Waves::Ext::String" do
|
4
|
+
it "defines / as syntactic sugar for File.join" do
|
5
|
+
( "lib" / "utilities" ).should == File.join( "lib", "utilities" )
|
6
|
+
( "lib" / :utilities ).should == File.join( "lib", "utilities" )
|
7
|
+
( "lib" / 3 ).should == File.join( "lib", "3" )
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "A monkeypatch to Symbol" do
|
12
|
+
|
13
|
+
it "defines / as syntactic sugar for File.join" do
|
14
|
+
( :lib / :utilities ).should == File.join( "lib", "utilities")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "Waves::Ext::Hash" do
|
20
|
+
|
21
|
+
it "adds a non-destructive method for converting all hash keys to strings" do
|
22
|
+
h = { :a => 1, 'b' => 2, 3 => 3}
|
23
|
+
h.stringify_keys.should == { 'a' => 1, 'b' => 2, '3' => 3}
|
24
|
+
h.should == { :a => 1, 'b' => 2, 3 => 3}
|
25
|
+
end
|
26
|
+
|
27
|
+
it "adds a destructive method for converting hash keys to symbols" do
|
28
|
+
h = { "two" => 2, :three => 3}
|
29
|
+
h.symbolize_keys!
|
30
|
+
h.should == { :two => 2, :three => 3 }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Waves::Ext::Integer" do
|
36
|
+
|
37
|
+
it "has an absolutely pedantic amount of helpers" do
|
38
|
+
1.kilobytes.should == "1_024".to_i
|
39
|
+
1.megabytes.should == "1_048_576".to_i
|
40
|
+
1.gigabytes.should == "1_073_741_824".to_i
|
41
|
+
1.terabytes.should == "1_099_511_627_776".to_i
|
42
|
+
1.petabytes.should == "1_125_899_906_842_624".to_i
|
43
|
+
1.exabytes.should == "1_152_921_504_606_846_976".to_i
|
44
|
+
1.zettabytes.should == "1_180_591_620_717_411_303_424".to_i
|
45
|
+
1.yottabytes.should == "1_208_925_819_614_629_174_706_176".to_i
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "Waves::Ext::Module" do
|
51
|
+
|
52
|
+
before do
|
53
|
+
module Eenie; module Meenie; module Miney; end; end ; end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "defines a basename method" do
|
57
|
+
Eenie::Meenie.basename.should == "Meenie"
|
58
|
+
Eenie::Meenie::Miney.basename.should == "Miney"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "defines [] for easy access to namespaced constants" do
|
62
|
+
Eenie[:Meenie].should == Eenie::Meenie
|
63
|
+
end
|
64
|
+
|
65
|
+
it "defines a method for obtaining the outermost constant name" do
|
66
|
+
Eenie::Meenie::Miney.rootname.should == "Eenie"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "defines a method for obtaining the outermost constant" do
|
70
|
+
Eenie::Meenie::Miney.root.should == Eenie
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|