waw 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/LICENCE.rdoc +25 -0
  2. data/README.rdoc +32 -0
  3. data/bin/waw +32 -0
  4. data/bin/waw-profile +26 -0
  5. data/bin/waw-start +26 -0
  6. data/bin/wspec +33 -0
  7. data/layouts/empty/Rakefile +14 -0
  8. data/layouts/empty/config.ru +5 -0
  9. data/layouts/empty/config/commons.cfg +31 -0
  10. data/layouts/empty/config/devel.cfg +21 -0
  11. data/layouts/empty/ignore +7 -0
  12. data/layouts/empty/logs/dontforgetme +0 -0
  13. data/layouts/empty/resources/messages.rs +1 -0
  14. data/layouts/empty/test/wspec/site_respond.wspec +3 -0
  15. data/layouts/empty/test/wspec/test_all.rb +13 -0
  16. data/layouts/empty/waw.deploy +1 -0
  17. data/layouts/empty/waw.routing +6 -0
  18. data/layouts/static/dependencies +1 -0
  19. data/layouts/static/public/.wawaccess +18 -0
  20. data/layouts/static/public/css/style.css +0 -0
  21. data/layouts/static/public/images/dontforgetme +0 -0
  22. data/layouts/static/public/js/project.js +0 -0
  23. data/layouts/static/public/pages/.wawaccess +30 -0
  24. data/layouts/static/public/pages/404.wtpl +1 -0
  25. data/layouts/static/public/pages/index.wtpl +5 -0
  26. data/layouts/static/public/templates/.wawaccess +9 -0
  27. data/layouts/static/public/templates/layout.wtpl +17 -0
  28. data/layouts/static/test/wspec/static_pages_are_served.wspec +21 -0
  29. data/layouts/static/waw.routing +8 -0
  30. data/lib/waw.rb +99 -0
  31. data/lib/waw/commands/command.rb +115 -0
  32. data/lib/waw/commands/profile_command.rb +66 -0
  33. data/lib/waw/commands/start_command.rb +59 -0
  34. data/lib/waw/config.rb +110 -0
  35. data/lib/waw/controller.rb +25 -0
  36. data/lib/waw/controllers/action/action.rb +91 -0
  37. data/lib/waw/controllers/action/action_utils.rb +30 -0
  38. data/lib/waw/controllers/action/js_generation.rb +116 -0
  39. data/lib/waw/controllers/action_controller.rb +133 -0
  40. data/lib/waw/controllers/error/backtrace.rb +54 -0
  41. data/lib/waw/controllers/error_handler.rb +62 -0
  42. data/lib/waw/controllers/json_controller.rb +31 -0
  43. data/lib/waw/controllers/no_cache.rb +22 -0
  44. data/lib/waw/controllers/static/match.rb +80 -0
  45. data/lib/waw/controllers/static/waw_access.rb +235 -0
  46. data/lib/waw/controllers/static/waw_access_dsl.rb +48 -0
  47. data/lib/waw/controllers/static_controller.rb +37 -0
  48. data/lib/waw/default_config.cfg +14 -0
  49. data/lib/waw/environment_utils.rb +57 -0
  50. data/lib/waw/errors.rb +4 -0
  51. data/lib/waw/ext.rb +3 -0
  52. data/lib/waw/ext/core.rb +4 -0
  53. data/lib/waw/ext/core/hash.rb +47 -0
  54. data/lib/waw/ext/core/logger.rb +10 -0
  55. data/lib/waw/ext/core/module.rb +20 -0
  56. data/lib/waw/ext/core/object.rb +29 -0
  57. data/lib/waw/ext/rack.rb +19 -0
  58. data/lib/waw/ext/rack/builder.rb +43 -0
  59. data/lib/waw/ext/rack/delegator.rb +51 -0
  60. data/lib/waw/ext/rack/urlmap.rb +55 -0
  61. data/lib/waw/ext/wlang.rb +1 -0
  62. data/lib/waw/ext/wlang/hosted_language.rb +21 -0
  63. data/lib/waw/fullstate.rb +8 -0
  64. data/lib/waw/fullstate/on_class.rb +37 -0
  65. data/lib/waw/fullstate/on_instance.rb +27 -0
  66. data/lib/waw/fullstate/variable.rb +36 -0
  67. data/lib/waw/kern.rb +6 -0
  68. data/lib/waw/kern/app.rb +48 -0
  69. data/lib/waw/kern/empty/waw.deploy +0 -0
  70. data/lib/waw/kern/empty/waw.routing +1 -0
  71. data/lib/waw/kern/freezed_state.rb +32 -0
  72. data/lib/waw/kern/hooks.rb +53 -0
  73. data/lib/waw/kern/lifecycle.rb +248 -0
  74. data/lib/waw/kern/living_state.rb +87 -0
  75. data/lib/waw/kern/utils.rb +27 -0
  76. data/lib/waw/resource_collection.rb +100 -0
  77. data/lib/waw/restart.rb +32 -0
  78. data/lib/waw/routing.rb +43 -0
  79. data/lib/waw/routing/action_routing.rb +78 -0
  80. data/lib/waw/routing/dsl.rb +45 -0
  81. data/lib/waw/routing/feedback.rb +23 -0
  82. data/lib/waw/routing/form_validation_feedback.rb +36 -0
  83. data/lib/waw/routing/javascript.rb +17 -0
  84. data/lib/waw/routing/redirect.rb +26 -0
  85. data/lib/waw/routing/refresh.rb +17 -0
  86. data/lib/waw/routing/routing_rule.rb +16 -0
  87. data/lib/waw/scope_utils.rb +69 -0
  88. data/lib/waw/session.rb +51 -0
  89. data/lib/waw/testing.rb +1 -0
  90. data/lib/waw/tools/mail.rb +4 -0
  91. data/lib/waw/tools/mail/mail.rb +119 -0
  92. data/lib/waw/tools/mail/mail_agent.rb +123 -0
  93. data/lib/waw/tools/mail/mailbox.rb +62 -0
  94. data/lib/waw/tools/mail/template.rb +38 -0
  95. data/lib/waw/utils/dsl_helper.rb +116 -0
  96. data/lib/waw/validation.rb +175 -0
  97. data/lib/waw/validation/and_validator.rb +27 -0
  98. data/lib/waw/validation/array_validations.rb +38 -0
  99. data/lib/waw/validation/boolean_validator.rb +32 -0
  100. data/lib/waw/validation/comparison_validations.rb +45 -0
  101. data/lib/waw/validation/date_validator.rb +31 -0
  102. data/lib/waw/validation/default_validator.rb +30 -0
  103. data/lib/waw/validation/dsl_ruby_extensions.rb +11 -0
  104. data/lib/waw/validation/errors.rb +17 -0
  105. data/lib/waw/validation/ext.rb +3 -0
  106. data/lib/waw/validation/file_validator.rb +30 -0
  107. data/lib/waw/validation/float_validator.rb +19 -0
  108. data/lib/waw/validation/helpers.rb +67 -0
  109. data/lib/waw/validation/integer_validator.rb +16 -0
  110. data/lib/waw/validation/isin_validator.rb +24 -0
  111. data/lib/waw/validation/mandatory_validator.rb +17 -0
  112. data/lib/waw/validation/missing_validator.rb +17 -0
  113. data/lib/waw/validation/not_validator.rb +20 -0
  114. data/lib/waw/validation/or_validator.rb +34 -0
  115. data/lib/waw/validation/regexp_validator.rb +29 -0
  116. data/lib/waw/validation/same_validator.rb +16 -0
  117. data/lib/waw/validation/signature.rb +157 -0
  118. data/lib/waw/validation/size_validations.rb +44 -0
  119. data/lib/waw/validation/string_validator.rb +15 -0
  120. data/lib/waw/validation/validator.rb +48 -0
  121. data/lib/waw/wawgen.rb +2 -0
  122. data/lib/waw/wawgen/create.rb +166 -0
  123. data/lib/waw/wawgen/project.rb +25 -0
  124. data/lib/waw/wspec.rb +5 -0
  125. data/lib/waw/wspec/browser.rb +240 -0
  126. data/lib/waw/wspec/dsl.rb +201 -0
  127. data/lib/waw/wspec/html_analysis.rb +136 -0
  128. data/lib/waw/wspec/html_analysis/tag.rb +56 -0
  129. data/lib/waw/wspec/runner.rb +70 -0
  130. data/lib/waw/wspec/scenario.rb +35 -0
  131. data/lib/waw/wspec/suite.rb +54 -0
  132. data/test/bricks/error_handler/config/test.cfg +2 -0
  133. data/test/bricks/error_handler/logs/webapp.log +1411 -0
  134. data/test/bricks/error_handler/test/error_handler.wspec +16 -0
  135. data/test/bricks/error_handler/waw.deploy +1 -0
  136. data/test/bricks/error_handler/waw.routing +27 -0
  137. data/test/integration/waw_create_integration_test.rb +24 -0
  138. data/test/spec/assumptions_spec.rb +30 -0
  139. data/test/spec/controllers/action_controller_spec.rb +14 -0
  140. data/test/spec/controllers/static/waw_access_spec.rb +112 -0
  141. data/test/spec/environment_utils_spec.rb +15 -0
  142. data/test/spec/ext/core/hash_spec.rb +58 -0
  143. data/test/spec/fixtures.rb +41 -0
  144. data/test/spec/fixtures/action/config/default.cfg +2 -0
  145. data/test/spec/fixtures/action/lib/action_controller_test.rb +12 -0
  146. data/test/spec/fixtures/action/waw.deploy +1 -0
  147. data/test/spec/fixtures/action/waw.routing +6 -0
  148. data/test/spec/fixtures/empty/waw.deploy +0 -0
  149. data/test/spec/fixtures/empty/waw.routing +0 -0
  150. data/test/spec/fullstate/on_class_spec.rb +59 -0
  151. data/test/spec/fullstate/on_instance_spec.rb +59 -0
  152. data/test/spec/fullstate/session_spec.rb +43 -0
  153. data/test/spec/fullstate/variable_spec.rb +55 -0
  154. data/test/spec/resource_collection_spec.rb +50 -0
  155. data/test/spec/test_all.rb +9 -0
  156. data/test/spec/tools/mail/mail_agent_spec.rb +116 -0
  157. data/test/spec/tools/mail/mail_spec.rb +56 -0
  158. data/test/spec/tools/mail/mailbox_spec.rb +57 -0
  159. data/test/spec/tools/mail/template_spec.rb +47 -0
  160. data/test/spec/validation/array_validation_spec.rb +63 -0
  161. data/test/spec/validation/array_validator_spec.rb +17 -0
  162. data/test/spec/validation/date_validation_spec.rb +35 -0
  163. data/test/spec/validation/default_validation_spec.rb +37 -0
  164. data/test/spec/validation/disjuctive_validation_spec.rb +33 -0
  165. data/test/spec/validation/errors_spec.rb +37 -0
  166. data/test/spec/validation/file_validator_spec.rb +34 -0
  167. data/test/spec/validation/mail_validation_spec.rb +51 -0
  168. data/test/spec/validation/missing_validation_spec.rb +43 -0
  169. data/test/spec/validation/same_validation_spec.rb +24 -0
  170. data/test/spec/validation/signature_intuition_spec.rb +37 -0
  171. data/test/spec/validation/signature_spec.rb +164 -0
  172. data/test/spec/validation/validation_spec.rb +28 -0
  173. data/test/spec/wspec/html_analysis/tag_spec.rb +38 -0
  174. data/test/spec/wspec/html_analysis_spec.rb +170 -0
  175. data/test/unit/test_all.rb +8 -0
  176. data/test/unit/waw/app_test.rb +126 -0
  177. data/test/unit/waw/app_test/config/commons.cfg +2 -0
  178. data/test/unit/waw/app_test/config/devel.cfg +1 -0
  179. data/test/unit/waw/config_test.rb +54 -0
  180. data/test/unit/waw/controllers/action_controller_test.rb +76 -0
  181. data/test/unit/waw/controllers/action_test.rb +35 -0
  182. data/test/unit/waw/controllers/example_action_controller_test.rb +24 -0
  183. data/test/unit/waw/controllers/multiple_action_controller_test.rb +78 -0
  184. data/test/unit/waw/controllers/static/example/css/example.css +1 -0
  185. data/test/unit/waw/controllers/static/example/index.html +1 -0
  186. data/test/unit/waw/controllers/static/example/js/example.js +1 -0
  187. data/test/unit/waw/controllers/static/example/pages/hello.wtpl +1 -0
  188. data/test/unit/waw/controllers/static/waw_access_test.rb +76 -0
  189. data/test/unit/waw/ext/rack_test.rb +74 -0
  190. data/test/unit/waw/resource_collection_test.rb +49 -0
  191. data/test/unit/waw/resources.txt +4 -0
  192. data/test/unit/waw/routing/routing_test.rb +26 -0
  193. data/test/unit/waw/utils/dsl_helper_test.rb +79 -0
  194. data/test/unit/waw/utils/dsl_helper_test_extensions1.rb +4 -0
  195. data/test/unit/waw/validation/signature_test.rb +193 -0
  196. data/test/unit/waw/validation_test.rb +319 -0
  197. data/test/unit/waw/wspec/html_analysis_test.html +81 -0
  198. data/test/unit/waw/wspec/html_analysis_test.rb +26 -0
  199. metadata +272 -0
@@ -0,0 +1,25 @@
1
+ = Licence
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2009 Bernard & Louis Lambeau and the University of Louvain
6
+ (Universite Catholique de Louvain, Louvain-la-Neuve, Belgium)
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
@@ -0,0 +1,32 @@
1
+ = Waw, making web applications simple
2
+
3
+ Waw is a web framework written in Ruby. It provides an alternative to Rails and other frameworks
4
+ written in Ruby as well. It is designed to be somewhere in the middle between Rails (sometimes a
5
+ bit too heavy) and Rack (not really a framework, sometimes too low-level).
6
+
7
+ == Main features
8
+
9
+ Waw basically provides an overall architecture for web sites and/or applications. Its main
10
+ features are
11
+
12
+ - It proposes the development of secure web applications, avoiding code injection as much
13
+ as possible and enforcing validation of both input data (coming from formularies, for example)
14
+ and application state (user authentification or administration level for invoking specific
15
+ services or to access specific pages)
16
+
17
+ - A simple but powerful templating engine, not restricted to HTML... Creating XML files for AJAX
18
+ services, creating text reports and so on are all as easy as generating html.
19
+
20
+ - Invoking webservices through AJAX is made declarative. The javascript code is automatically
21
+ generated!
22
+
23
+ - When things become too restrictive for you (you don't fit the architecture exactly) you can
24
+ access lower stages ... edit the underlying Rack configuration and install your own services
25
+ in a few minutes, bypassing waw when needed!
26
+
27
+ == Dependencies
28
+
29
+ Waw requires the following ruby gems
30
+
31
+ - rack >= 1.1.0 (provided through <code>gem install rack</code>)
32
+ - wlang >= 0.9.0 (provided in the vendors folder)
data/bin/waw ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Waw - making web development simple
4
+ # (see lib/waw/waw.rb for more information)
5
+ #
6
+ # Copyright (c) 2010 University of Louvain, Bernard & Louis Lambeau
7
+ # Released under a MIT or Ruby licence
8
+ #
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ require 'waw'
11
+ require 'waw/wawgen'
12
+
13
+ begin
14
+ if ARGV.size < 1
15
+ puts "Usage: waw create [options] ProjectName"
16
+ elsif ARGV[0] != 'create'
17
+ puts "Unknown command #{ARGV[0]}"
18
+ puts "Usage: waw create [options] ProjectName"
19
+ else
20
+ r = Waw::Wawgen::Create.new.run ARGV[1..-1]
21
+ end
22
+ rescue Interrupt => e
23
+ $stderr.puts
24
+ $stderr.puts "Interrupted"
25
+ raise e
26
+ rescue OptionParser::ParseError => e
27
+ $stderr.puts e.message
28
+ raise e
29
+ rescue => e
30
+ $stderr.puts e.message
31
+ raise e
32
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Waw - making web development simple
4
+ # (see lib/waw/waw.rb for more information)
5
+ #
6
+ # Copyright (c) 2010 University of Louvain, Bernard & Louis Lambeau
7
+ # Released under a MIT or Ruby licence
8
+ #
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ require 'waw'
11
+ require 'waw/commands/command'
12
+ require 'waw/commands/profile_command'
13
+
14
+ begin
15
+ r = Waw::Commands::ProfileCommand.new.run '.', ARGV
16
+ rescue Interrupt => e
17
+ $stderr.puts
18
+ $stderr.puts "Interrupted"
19
+ raise e
20
+ rescue OptionParser::ParseError => e
21
+ $stderr.puts e.message
22
+ raise e
23
+ rescue => e
24
+ $stderr.puts e.message
25
+ raise e
26
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Waw - making web development simple
4
+ # (see lib/waw/waw.rb for more information)
5
+ #
6
+ # Copyright (c) 2010 University of Louvain, Bernard & Louis Lambeau
7
+ # Released under a MIT or Ruby licence
8
+ #
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ require 'waw'
11
+ require 'waw/commands/command'
12
+ require 'waw/commands/start_command'
13
+
14
+ begin
15
+ r = Waw::Commands::StartCommand.new.run '.', ARGV
16
+ rescue Interrupt => e
17
+ $stderr.puts
18
+ $stderr.puts "Interrupted"
19
+ raise e
20
+ rescue OptionParser::ParseError => e
21
+ $stderr.puts e.message
22
+ raise e
23
+ rescue => e
24
+ $stderr.puts e.message
25
+ raise e
26
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # WSpec - Executes wspec waw tests
4
+ # (see lib/waw/waw.rb for more information)
5
+ #
6
+ # Copyright (c) 2010 University of Louvain, Bernard & Louis Lambeau
7
+ # Released under a MIT or Ruby licence
8
+ #
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ require 'waw'
11
+
12
+ # Abord execution
13
+ def abord(message, code)
14
+ puts message
15
+ exit(code)
16
+ end
17
+
18
+ unless ARGV.size == 1
19
+ abord("Usage: wspec a_test.wspec", 0)
20
+ else
21
+ # Checks that the test exists
22
+ wspec_file = ARGV[0]
23
+ abord("Unable to find .wspec file #{wspec_file}", -1) unless File.exists?(wspec_file)
24
+
25
+ # Load the waw application for having configuration
26
+ app = Waw.autoload(wspec_file)
27
+ raise "Tests cannot be run in production mode, to avoid modifying real database "\
28
+ "or sending spam mails to real users." unless app.config.deploy_mode=='devel'
29
+
30
+ # Load the wspec runner now
31
+ require 'waw/wspec/runner'
32
+ load(wspec_file)
33
+ end
@@ -0,0 +1,14 @@
1
+ require "rake/rdoctask"
2
+ require "rake/testtask"
3
+ require "rubygems"
4
+ require "waw"
5
+
6
+ task :default => [:test]
7
+
8
+ desc "Launches all wspec tests"
9
+ task :wspec do
10
+ require('test/wspec/test_all.rb')
11
+ end
12
+
13
+ desc "Launches all tests"
14
+ task :test => [:wspec]
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env rackup
2
+ require "rubygems"
3
+ gem 'waw', '>= +(Waw::VERSION)'
4
+ require "waw"
5
+ run Waw.autoload(__FILE__)
@@ -0,0 +1,31 @@
1
+ # The following paths will be automatically added to the $LOAD_PATH
2
+ # ruby global variable when the web application is loaded.
3
+ # load_path 'lib'
4
+
5
+ # The following names will be ruby-required when the web application
6
+ # is loaded.
7
+ # requires '+(project.lowname)'
8
+
9
+ # A simple ruby name for the web application. This name is used in
10
+ # different part of the waw architecture (including code generation).
11
+ # It MUST respect [a-z][a-z_]*, to avoid strange behaviors.
12
+ application_name '+(project.lowname)'
13
+
14
+ # Deployment mode; accepted values are 'devel', 'test' 'acceptation'
15
+ # and 'production'. The deployment mode drives the way critical code is
16
+ # executed. Your wspec tests cannot be run in production mode, for example,
17
+ # to avoid modifying your production database, sending mails to real people,
18
+ # and so on.
19
+ #
20
+ # This is set to 'devel' by default, to avoid waw failures for developers
21
+ # forgetting to set this configuration parameter. It should be overrided
22
+ # on producion and test environments.
23
+ deploy_mode 'devel'
24
+
25
+ # Generate javascript (and additional) code at startup? By default, code
26
+ # is generated at startup time in devel mode only.
27
+ code_at_startup { deploy_mode=='devel' }
28
+
29
+ # About the Rack session
30
+ rack_session true
31
+ rack_session_expire 60 * 60 * 24 * 265
@@ -0,0 +1,21 @@
1
+ # Deployment mode; accepted values are 'devel', 'test' 'acceptation'
2
+ # and 'production'. The deployment mode drives the way critical code is
3
+ # executed. Your wspec tests cannot be run in production mode, for example,
4
+ # to avoid modifying your production database, sending mails to real people,
5
+ # and so on.
6
+ deploy_mode 'devel'
7
+
8
+ # Web domain, web port and web base. The later is the url to put in
9
+ # <base href=""/>. This url should always include http:// and should not
10
+ # contain the index.html suffix.
11
+ web_domain '127.0.0.1'
12
+ web_port 9292
13
+ web_base "http://#{web_domain}:#{web_port}/"
14
+
15
+ # Logger configuration. Follows what ruby Logger class expects.
16
+ #log_io STDOUT
17
+ log_dir 'logs'
18
+ log_file "#{application_name}.log"
19
+ log_frequency 'weekly'
20
+ log_level Logger::DEBUG
21
+
@@ -0,0 +1,7 @@
1
+ # This file helps you developing your web application with a version-control
2
+ # system like Git or Subversion. The following waw files should always be ignored
3
+ # to avoid overriding configuration of other developers or production deployments
4
+ waw.deploy
5
+ config/*.cfg
6
+ tmp
7
+ logs
File without changes
@@ -0,0 +1 @@
1
+ # Messages that the waw application use
@@ -0,0 +1,3 @@
1
+ requirement("The web server should at least be reachable") do
2
+ i_reach index_page
3
+ end
@@ -0,0 +1,13 @@
1
+ # Requires
2
+ require 'rubygems'
3
+ gem 'waw', '>= +(Waw::VERSION)'
4
+ require 'waw/wspec/runner'
5
+
6
+ # Load the waw application for having configuration
7
+ app = Waw.autoload(__FILE__)
8
+ raise "Tests cannot be run in production mode, to avoid modifying real database "\
9
+ "or sending spam mails to real users." unless ['devel', 'test'].include\?(app.config.deploy_mode\)
10
+
11
+ # Load all tests now
12
+ test_files = Dir[File.join(File.dirname(__FILE__), '**/*.wspec')]
13
+ test_files.each { |file| load(file) }
@@ -0,0 +1 @@
1
+ commons devel
@@ -0,0 +1,6 @@
1
+ Waw.rack do
2
+ use ::Rack::CommonLogger, Waw.logger
3
+ use ::Rack::Session::Pool, :domain => Waw.config.web_domain,
4
+ :expire_after => Waw.config.rack_session_expire
5
+ run lambda {|env| [200, {'Content-Type' => 'text/plain'}, 'OK']}
6
+ end
@@ -0,0 +1 @@
1
+ empty
@@ -0,0 +1,18 @@
1
+ wawaccess do
2
+
3
+ # .wawaccess files are never served
4
+ match /.wawaccess$/ do
5
+ deny
6
+ end
7
+
8
+ # We serve all as static file by default
9
+ match file do
10
+ static
11
+ end
12
+
13
+ # When something is not found, we look in the pages wawaccess
14
+ match true do
15
+ apply "/pages/#{served_file}"
16
+ end
17
+
18
+ end
File without changes
File without changes
@@ -0,0 +1,30 @@
1
+ wawaccess do
2
+
3
+ # We don't inherits static configuration
4
+ inherits false
5
+
6
+ # .wawaccess files are never served
7
+ match /.wawaccess$/ do
8
+ deny
9
+ end
10
+
11
+ # When a folder is requested, find the associated index file
12
+ match directory do
13
+ apply "#{served_file}/index.wtpl"
14
+ end
15
+
16
+ # We match .wtpl files using wlang
17
+ match file(:extension => '.wtpl') do
18
+ wlang '../templates/layout.wtpl'
19
+ end
20
+
21
+ # When the file cannot be found
22
+ match true do
23
+ if /\.wtpl$/ =~ served_file
24
+ apply "pages/404.wtpl", 404
25
+ else
26
+ apply "#{served_file}.wtpl"
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1 @@
1
+ <p>404 not found, the requested page does not exists</p>
@@ -0,0 +1,5 @@
1
+ <h1>Hello !</h1>
2
+
3
+ <p>This is the layout-ed index page of your waw-driven website</p>
4
+
5
+ <p>Enjoy!</p>
@@ -0,0 +1,9 @@
1
+ wawaccess do
2
+ strategy :deny_all
3
+ inherits false
4
+
5
+ match true do
6
+ deny
7
+ end
8
+
9
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
5
+ <base href="{config.web_base}"/>
6
+ <title>+(project.upname)</title>
7
+ *{css_files as css}{
8
+ <link rel="stylesheet" type="text/css" href="{css}" />
9
+ }
10
+ *{js_files as js}{
11
+ <script type="text/javascript" src="{js}"></script>
12
+ }
13
+ </head>
14
+ <body>
15
+ <<+{../${served_file} share all}
16
+ </body>
17
+ </html>
@@ -0,0 +1,21 @@
1
+ scenario __FILE__ do
2
+ because("The root website URL is correctly served") {
3
+ i_reach index_page
4
+ i_see "Hello !"
5
+ }
6
+ because("Static files (css, js, images, ...) are correctly served") {
7
+ i_reach index_page + 'css/style.css'
8
+ i_reach index_page + 'js/+(project.lowname).js'
9
+ }
10
+ because(".wawaccess files are correctly written") {
11
+ i_may_not_reach index_page + '.wawaccess'
12
+ i_may_not_reach index_page + 'pages/.wawaccess'
13
+ i_may_not_reach index_page + 'templates/.wawaccess'
14
+ i_may_not_reach index_page + 'templates/layout.wtpl'
15
+ }
16
+ because("the default wlang context is correct") {
17
+ i_reach index_page
18
+ i_see_tag "link", {:rel => "stylesheet", :type => "text/css", :href => /^.*\.css/}
19
+ i_see_tag "script", {:type => "text/javascript", :src => /^.*\.js$/}
20
+ }
21
+ end
@@ -0,0 +1,8 @@
1
+ Waw.rack do
2
+ use ::Rack::CommonLogger, Waw.logger
3
+ use ::Rack::Session::Pool, :domain => Waw.config.web_domain,
4
+ :expire_after => Waw.config.rack_session_expire
5
+ map '/' do
6
+ run ::Waw::StaticController.new(:root => 'public')
7
+ end
8
+ end
@@ -0,0 +1,99 @@
1
+ $waw_deprecated_io = nil
2
+ require 'singleton'
3
+ require 'waw/ext/core'
4
+ require 'waw/ext/rack'
5
+ #
6
+ # Main waw module, providing the strict micro kernel of waw loader
7
+ #
8
+ module Waw
9
+
10
+ # Requirements on gems for this version
11
+ GEM_REQUIREMENTS = {
12
+ :rack => '>= 1.1.0',
13
+ :wlang => '>= 0.9.0',
14
+ :json => '>= 1.1.9'
15
+ }
16
+
17
+ # Waw version
18
+ VERSION = "0.2.2".freeze
19
+
20
+ # Waw loading mutex
21
+ WAW_KERNELS_LOCK = Mutex.new
22
+
23
+ # Loaded kernels
24
+ KERNELS = []
25
+
26
+ # Autoloads and returns a waw application
27
+ def self.autoload(from)
28
+ WAW_KERNELS_LOCK.synchronize {
29
+ KERNELS << (app = ::Waw::Kern::App.new)
30
+ app.autoload(from)
31
+ }
32
+ end
33
+
34
+ # Loads a rack application
35
+ def self.rack(&block)
36
+ ::Rack::Builder.new(&block).to_app
37
+ end
38
+
39
+ # Returns the last loaded waw kernel
40
+ deprecated "Waw.kernel will be removed in version 0.3.0"
41
+ def self.kernel
42
+ KERNELS.last
43
+ end
44
+
45
+ # Sets the current kernel
46
+ deprecated "Waw.kernel= will be removed in version 0.3.0"
47
+ def self.kernel=(kernel)
48
+ KERNELS << kernel
49
+ end
50
+
51
+ # Install a logger on waw itself
52
+ def self.logger=(logger)
53
+ @logger = logger
54
+ end
55
+
56
+ # Returns the waw logger, which always works on STDOUT
57
+ def self.logger
58
+ @logger || (self.kernel && self.kernel.logger) || Logger.new(STDOUT)
59
+ end
60
+
61
+ # Install other deprecated methods now
62
+ def self.method_missing(name, *args, &block)
63
+ k = self.kernel
64
+ if k and k.respond_to?(name)
65
+ $waw_deprecated_io << "Waw.#{name} will be removed in version 0.3.0. "\
66
+ "Please use the current kernel instance instead." if $waw_deprecated_io
67
+ k.send(name, *args, &block)
68
+ else
69
+ super(name, *args, &block)
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ # Now, make ruby requires
76
+ require 'rubygems'
77
+ Waw::GEM_REQUIREMENTS.each_pair {|name, version|
78
+ gem(name.to_s, version)
79
+ require(name.to_s)
80
+ }
81
+ require 'waw/errors'
82
+ require 'waw/scope_utils'
83
+ require 'waw/ext'
84
+ require 'waw/utils/dsl_helper'
85
+ require 'waw/resource_collection'
86
+ require 'waw/config'
87
+ require 'waw/kern'
88
+ require 'waw/validation'
89
+ require 'waw/environment_utils'
90
+ require 'waw/fullstate'
91
+ require 'waw/session'
92
+ require 'waw/controller'
93
+ require 'waw/restart'
94
+ require 'waw/controllers/json_controller'
95
+ require 'waw/controllers/action_controller'
96
+ require 'waw/controllers/static_controller'
97
+ require 'waw/controllers/no_cache'
98
+ require 'waw/controllers/error_handler'
99
+ require 'waw/routing'