waves 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/bin/waves +4 -3
  2. data/doc/VERSION +1 -1
  3. data/lib/waves.rb +52 -40
  4. data/lib/{caches → waves/caches}/file.rb +3 -1
  5. data/lib/waves/caches/memcached.rb +56 -0
  6. data/lib/{caches → waves/caches}/simple.rb +6 -7
  7. data/lib/{caches → waves/caches}/synchronized.rb +15 -1
  8. data/lib/{commands → waves/commands}/console.rb +4 -4
  9. data/lib/{commands → waves/commands}/generate.rb +6 -5
  10. data/lib/{commands → waves/commands}/help.rb +0 -0
  11. data/lib/{commands → waves/commands}/server.rb +1 -1
  12. data/lib/{dispatchers → waves/dispatchers}/base.rb +17 -31
  13. data/lib/waves/dispatchers/default.rb +19 -0
  14. data/lib/{ext → waves/ext}/float.rb +0 -0
  15. data/lib/{ext → waves/ext}/hash.rb +0 -0
  16. data/lib/{ext → waves/ext}/integer.rb +16 -1
  17. data/lib/{ext → waves/ext}/kernel.rb +3 -7
  18. data/lib/{ext → waves/ext}/module.rb +3 -3
  19. data/lib/{ext → waves/ext}/object.rb +2 -0
  20. data/lib/waves/ext/string.rb +73 -0
  21. data/lib/{ext → waves/ext}/symbol.rb +0 -1
  22. data/lib/{ext → waves/ext}/tempfile.rb +0 -0
  23. data/lib/waves/ext/time.rb +5 -0
  24. data/lib/{foundations → waves/foundations}/classic.rb +9 -21
  25. data/lib/{foundations → waves/foundations}/compact.rb +15 -20
  26. data/lib/waves/foundations/rest.rb +311 -0
  27. data/lib/waves/helpers/basic.rb +13 -0
  28. data/lib/{helpers → waves/helpers}/doc_type.rb +3 -0
  29. data/lib/waves/helpers/form.rb +94 -0
  30. data/lib/waves/helpers/formatting.rb +14 -0
  31. data/lib/waves/layers/mvc.rb +65 -0
  32. data/lib/{layers → waves/layers}/mvc/controllers.rb +0 -0
  33. data/lib/{layers → waves/layers}/mvc/extensions.rb +23 -11
  34. data/lib/{layers → waves/layers}/orm/migration.rb +0 -0
  35. data/lib/{layers → waves/layers}/orm/providers/active_record.rb +2 -5
  36. data/lib/{layers → waves/layers}/orm/providers/active_record/migrations/empty.rb.erb +0 -0
  37. data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/generate.rb +1 -1
  38. data/lib/{layers → waves/layers}/orm/providers/active_record/tasks/schema.rb +1 -1
  39. data/lib/{layers → waves/layers}/orm/providers/data_mapper.rb +0 -0
  40. data/lib/{layers → waves/layers}/orm/providers/filebase.rb +0 -0
  41. data/lib/{layers → waves/layers}/orm/providers/sequel.rb +28 -29
  42. data/lib/{layers → waves/layers}/orm/providers/sequel/migrations/empty.rb.erb +0 -0
  43. data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/generate.rb +1 -1
  44. data/lib/{layers → waves/layers}/orm/providers/sequel/tasks/schema.rb +2 -0
  45. data/lib/waves/layers/rack/rack_cache.rb +32 -0
  46. data/lib/waves/layers/renderers/erubis.rb +52 -0
  47. data/lib/waves/layers/renderers/haml.rb +67 -0
  48. data/lib/waves/layers/renderers/markaby.rb +41 -0
  49. data/lib/waves/layers/text/inflect/english.rb +42 -0
  50. data/lib/waves/matchers/accept.rb +47 -0
  51. data/lib/waves/matchers/ext.rb +27 -0
  52. data/lib/waves/matchers/path.rb +72 -0
  53. data/lib/waves/matchers/query.rb +43 -0
  54. data/lib/waves/matchers/request.rb +86 -0
  55. data/lib/waves/matchers/requested.rb +31 -0
  56. data/lib/{matchers → waves/matchers}/resource.rb +8 -1
  57. data/lib/waves/matchers/traits.rb +30 -0
  58. data/lib/waves/matchers/uri.rb +69 -0
  59. data/lib/waves/media/mime_types.rb +542 -0
  60. data/lib/waves/renderers/mixin.rb +9 -0
  61. data/lib/waves/request/accept.rb +92 -0
  62. data/lib/{runtime → waves/request}/request.rb +77 -61
  63. data/lib/waves/resources/file_mixin.rb +11 -0
  64. data/lib/{resources → waves/resources}/mixin.rb +42 -44
  65. data/lib/waves/resources/paths.rb +132 -0
  66. data/lib/waves/response/client_errors.rb +10 -0
  67. data/lib/waves/response/packaged.rb +19 -0
  68. data/lib/waves/response/redirects.rb +35 -0
  69. data/lib/{runtime → waves/response}/response.rb +29 -11
  70. data/lib/{runtime → waves/response}/response_mixin.rb +30 -17
  71. data/lib/waves/runtime/applications.rb +18 -0
  72. data/lib/{runtime → waves/runtime}/configuration.rb +31 -25
  73. data/lib/waves/runtime/console.rb +24 -0
  74. data/lib/{runtime → waves/runtime}/logger.rb +3 -3
  75. data/lib/{runtime → waves/runtime}/mocks.rb +2 -2
  76. data/lib/waves/runtime/rackup.rb +37 -0
  77. data/lib/waves/runtime/runtime.rb +48 -0
  78. data/lib/waves/runtime/server.rb +33 -0
  79. data/lib/{servers → waves/servers}/base.rb +0 -0
  80. data/lib/{servers → waves/servers}/mongrel.rb +0 -0
  81. data/lib/{servers → waves/servers}/webrick.rb +0 -0
  82. data/lib/{tasks → waves/tasks}/gem.rb +0 -0
  83. data/lib/{tasks → waves/tasks}/generate.rb +0 -0
  84. data/lib/waves/views/cassy.rb +173 -0
  85. data/lib/{views → waves/views}/errors.rb +8 -7
  86. data/lib/waves/views/mixin.rb +23 -0
  87. data/lib/waves/views/templated.rb +40 -0
  88. data/samples/basic/basic_startup.rb +70 -0
  89. data/samples/basic/config.ru +9 -0
  90. data/samples/blog/configurations/development.rb +17 -16
  91. data/samples/blog/configurations/production.rb +0 -11
  92. data/samples/blog/resources/entry.rb +3 -3
  93. data/samples/blog/resources/map.rb +10 -3
  94. data/samples/blog/startup.rb +4 -3
  95. data/templates/classic/Rakefile +28 -29
  96. data/templates/classic/configurations/default.rb.erb +8 -3
  97. data/templates/classic/configurations/development.rb.erb +1 -20
  98. data/templates/classic/configurations/production.rb.erb +2 -16
  99. data/templates/classic/public/images/favicon.ico +0 -0
  100. data/templates/classic/resources/server.rb.erb +9 -0
  101. data/templates/classic/startup.rb.erb +3 -3
  102. data/templates/classic/views/css.rb.erb +14 -0
  103. data/templates/classic/views/default.rb.erb +17 -0
  104. data/templates/classic/views/errors.rb.erb +10 -0
  105. data/templates/classic/views/pages.rb.erb +14 -0
  106. data/templates/compact/startup.rb.erb +8 -3
  107. data/test/ext/object.rb +55 -0
  108. data/test/ext/shortcuts.rb +73 -0
  109. data/test/helpers.rb +17 -0
  110. data/test/match/accept.rb +78 -0
  111. data/test/match/ext.rb +156 -0
  112. data/test/match/methods.rb +22 -0
  113. data/test/match/params.rb +33 -0
  114. data/test/match/path.rb +106 -0
  115. data/test/match/query.rb +60 -0
  116. data/test/match/request.rb +91 -0
  117. data/test/match/requested.rb +149 -0
  118. data/test/match/uri.rb +136 -0
  119. data/test/process/request.rb +75 -0
  120. data/test/process/resource.rb +53 -0
  121. data/test/resources/path.rb +166 -0
  122. data/test/runtime/configurations.rb +19 -0
  123. data/test/runtime/request.rb +63 -0
  124. data/test/runtime/response.rb +85 -0
  125. data/test/views/views.rb +40 -0
  126. metadata +243 -157
  127. data/lib/caches/memcached.rb +0 -40
  128. data/lib/dispatchers/default.rb +0 -25
  129. data/lib/ext/string.rb +0 -20
  130. data/lib/helpers/basic.rb +0 -11
  131. data/lib/helpers/extended.rb +0 -21
  132. data/lib/helpers/form.rb +0 -42
  133. data/lib/helpers/formatting.rb +0 -30
  134. data/lib/helpers/layouts.rb +0 -37
  135. data/lib/helpers/model.rb +0 -37
  136. data/lib/helpers/view.rb +0 -22
  137. data/lib/layers/inflect/english.rb +0 -67
  138. data/lib/layers/mvc.rb +0 -54
  139. data/lib/layers/renderers/erubis.rb +0 -60
  140. data/lib/layers/renderers/haml.rb +0 -47
  141. data/lib/layers/renderers/markaby.rb +0 -29
  142. data/lib/matchers/accept.rb +0 -21
  143. data/lib/matchers/base.rb +0 -30
  144. data/lib/matchers/content_type.rb +0 -17
  145. data/lib/matchers/path.rb +0 -67
  146. data/lib/matchers/query.rb +0 -21
  147. data/lib/matchers/request.rb +0 -27
  148. data/lib/matchers/traits.rb +0 -19
  149. data/lib/matchers/uri.rb +0 -20
  150. data/lib/renderers/mixin.rb +0 -36
  151. data/lib/resources/paths.rb +0 -34
  152. data/lib/runtime/console.rb +0 -23
  153. data/lib/runtime/mime_types.rb +0 -536
  154. data/lib/runtime/monitor.rb +0 -32
  155. data/lib/runtime/runtime.rb +0 -67
  156. data/lib/runtime/server.rb +0 -20
  157. data/lib/runtime/session.rb +0 -27
  158. data/lib/runtime/worker.rb +0 -86
  159. data/lib/views/mixin.rb +0 -62
  160. data/samples/blog/blog.db +0 -0
  161. data/samples/blog/log/waves.production +0 -3
  162. data/templates/classic/resources/map.rb.erb +0 -8
  163. data/templates/classic/templates/errors/not_found_404.mab +0 -7
  164. data/templates/classic/templates/errors/server_error_500.mab +0 -7
  165. data/templates/classic/templates/layouts/default.mab +0 -14
  166. 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
- view.show( :entry => controller.find( captured.name ) )
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
- class Map < Waves::Resources::Base
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
@@ -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
@@ -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 :unfreeze do
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
- # Convenience task to allow you to freeze the current Waves
70
- # source without knowing where it is. This task only gets
71
- # defined when the Rakefile successfully loaded Waves and if
72
- # there's nothing in the way at ./waves
73
- if defined?(WAVES) && !File.exist?("#{Dir.pwd}/waves")
74
- namespace :freeze do
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
- resource <%= @name %>::Resources::Map
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
- database :host => 'localhost', :adapter => 'mysql', :database => '<%= @name.downcase %>',
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
@@ -0,0 +1,9 @@
1
+ module <%= @name %>
2
+ module Resources
3
+ class Server < <%= @name%>::Resources::Default
4
+ def get
5
+ view(:pages).welcome
6
+ end
7
+ end
8
+ end
9
+ end
@@ -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
+ require 'waves/views/cassy'
2
+ class <%= @name %>::Views::Css < Cassy
3
+
4
+ include Waves::Views::Mixin
5
+
6
+ def default
7
+ body {
8
+ font_family 'sans-serif'
9
+ width '800px'
10
+ margin '20px auto'
11
+ }
12
+ end
13
+
14
+ end
@@ -0,0 +1,17 @@
1
+ class <%= @name %>::Views::Default
2
+
3
+ include Waves::Views::Mixin
4
+
5
+ def stylesheet
6
+ style { view(:css).default }
7
+ end
8
+
9
+ def layout
10
+ doctype
11
+ html {
12
+ head { stylesheet }
13
+ body { yield }
14
+ }
15
+ end
16
+
17
+ end
@@ -0,0 +1,10 @@
1
+ class <%= @name %>::Views::Errors < <%= @name %>::Views::Default
2
+
3
+ def not_found_404
4
+ layout {
5
+ h1 'Sorry, But We Can't Find That'
6
+ p "This URL cannot be resolved by this server."
7
+ }
8
+ end
9
+
10
+ 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
- end
11
+ module Resources
12
+ class Server
13
+ on( true ) { 'Hello, from Waves!' }
14
+ end
15
+ end
16
+ end
@@ -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