waw 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/bin/waw-crawl +26 -0
  2. data/lib/waw.rb +3 -3
  3. data/lib/waw/commands/command.rb +12 -4
  4. data/lib/waw/commands/crawl_command.rb +46 -0
  5. data/lib/waw/commands/profile_command.rb +5 -1
  6. data/lib/waw/controllers/action/action.rb +11 -0
  7. data/lib/waw/controllers/action/js_generation.rb +11 -2
  8. data/lib/waw/controllers/static/match.rb +4 -1
  9. data/lib/waw/controllers/static/matcher.rb +35 -0
  10. data/lib/waw/controllers/static/waw_access.rb +28 -15
  11. data/lib/waw/controllers/static/waw_access_dsl.rb +9 -0
  12. data/lib/waw/controllers/static_controller.rb +5 -2
  13. data/lib/waw/crawler.rb +176 -0
  14. data/lib/waw/crawler/crawler_listener.rb +64 -0
  15. data/lib/waw/crawler/crawler_options.rb +42 -0
  16. data/lib/waw/kern/living_state.rb +93 -0
  17. data/lib/waw/scope_utils.rb +1 -0
  18. data/lib/waw/tools/mail/mail_agent.rb +1 -1
  19. data/lib/waw/validation.rb +3 -0
  20. data/lib/waw/validation/datetime_validator.rb +53 -0
  21. data/lib/waw/wspec/browser.rb +4 -2
  22. data/test/bricks/error_handler/test/test_all.rb +20 -0
  23. data/test/bricks/static_controller/config/test.cfg +2 -0
  24. data/test/bricks/static_controller/logs/webapp.log +84 -0
  25. data/test/bricks/static_controller/test/static_controller.wspec +12 -0
  26. data/test/bricks/static_controller/test/test_all.rb +20 -0
  27. data/test/bricks/static_controller/waw.deploy +1 -0
  28. data/test/bricks/static_controller/waw.routing +5 -0
  29. data/test/bricks/test_all.rb +8 -0
  30. data/test/spec/controllers/static/waw_access_spec.rb +3 -3
  31. data/test/spec/test_all.rb +0 -2
  32. data/test/spec/validation/datetime_validation_spec.rb +92 -0
  33. data/test/unit/test_all.rb +1 -0
  34. data/test/unit/waw/controllers/static/logs/webapp.log +22 -0
  35. metadata +23 -6
@@ -0,0 +1,20 @@
1
+ # Requires
2
+ begin
3
+ top = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib'))
4
+ $LOAD_PATH.unshift(top)
5
+ require 'waw'
6
+ rescue LoadError => ex
7
+ require 'rubygems'
8
+ gem 'waw', '>= 0.2.0'
9
+ require 'waw'
10
+ end
11
+ require 'waw/wspec/runner'
12
+
13
+ # Load the waw application for having configuration
14
+ app = Waw.autoload(__FILE__)
15
+ raise "Tests cannot be run in production mode, to avoid modifying real database "\
16
+ "or sending spam mails to real users." unless ['devel', 'test'].include?(app.config.deploy_mode)
17
+
18
+ # Load all tests now
19
+ test_files = Dir[File.join(File.dirname(__FILE__), '**/*.wspec')]
20
+ test_files.each { |file| load(file) }
@@ -0,0 +1,5 @@
1
+ Waw.rack do
2
+ map '/' do
3
+ run Waw::StaticController.new(:public => 'views')
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ here = File.dirname(__FILE__)
2
+ top = File.join(here, '..', 'lib')
3
+ Dir["#{here}/**/test_all.rb"].each do |test|
4
+ next if File.expand_path(test) == File.expand_path(__FILE__)
5
+ puts
6
+ puts "Executing #{test} example..."
7
+ puts `ruby -I#{top} #{test}`
8
+ end
@@ -69,9 +69,9 @@ describe ::Waw::StaticController::WawAccess do
69
69
  match(true) { :is404 }
70
70
  end
71
71
  EOF
72
- wa.apply_rules('waw_access_spec.rb').should == :file
73
- wa.apply_rules('').should == :directory
74
- wa.apply_rules('nothing/at/all').should == :is404
72
+ wa.do_path_serve('waw_access_spec.rb').should == :file
73
+ wa.do_path_serve('').should == :directory
74
+ wa.do_path_serve('nothing/at/all').should == :is404
75
75
  end
76
76
 
77
77
  it "should not provide block conflict between validators and matching rules" do
@@ -1,9 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
2
2
  require 'waw'
3
- require 'spec/autorun'
4
3
  require File.join(File.dirname(__FILE__), 'fixtures')
5
4
  test_files = Dir[File.join(File.dirname(__FILE__), '**/*_spec.rb')]
6
5
  test_files.each { |file|
7
6
  require(file)
8
7
  }
9
-
@@ -0,0 +1,92 @@
1
+ describe "datetime proposed validation" do
2
+
3
+ describe "with default options" do
4
+
5
+ let(:date){
6
+ @date_validator ||= ::Waw::Validation.signature {
7
+ validation [:date, :time], datetime, :bad_date
8
+ }
9
+ }
10
+
11
+ it "should block missing values" do
12
+ date.blocks?(:date => nil).should be_true
13
+ date.blocks?(:date => "").should be_true
14
+ date.blocks?(:date => " ").should be_true
15
+ end
16
+
17
+ it "should be robust to strange values" do
18
+ date.blocks?(:date => nil).should be_true
19
+ date.blocks?(:date => 12).should be_true
20
+ date.blocks?(:date => self).should be_true
21
+ date.blocks?(:date => Class).should be_true
22
+ date.blocks?(:date => self).should be_true
23
+ date.blocks?(:date => "hello", :time => "12:16").should be_true
24
+ end
25
+
26
+ it "should allow valid date/time pairs" do
27
+ date.allows?({:date => "2010/04/25", :time => "12:15"}).should be_true
28
+ date.allows?({:date => "2010/04/25", :time => "00:00"}).should be_true
29
+ end
30
+
31
+ it 'should correctly convert date/time pairs' do
32
+ result, converted = date.apply({:date => "2010/04/25", :time => "12:15"})
33
+ converted.should == {:date => Date.parse("2010/04/25"), :time => Time.parse("2010/04/25 12:15")}
34
+ end
35
+
36
+ it "should block invalid dates" do
37
+ date.blocks?(:date => "65/12/2010", :time => "12:16").should be_true
38
+ date.blocks?(:date => "2010/10/12", :time => "28:16").should be_true
39
+ end
40
+
41
+ end
42
+
43
+ describe "when a specific date format has been set" do
44
+
45
+ let(:date){
46
+ @date_validator ||= ::Waw::Validation.signature {
47
+ validation [:date, :time], datetime(:date_format => "%d/%m/%y"), :bad_date
48
+ }
49
+ }
50
+
51
+ it "should block non-conforming dates" do
52
+ date.blocks?(:date => "2010/12/1", :time => "12:16").should be_true
53
+ end
54
+
55
+ it "should allow conforming dates" do
56
+ date.allows?(:date => "2/12/10", :time => "12:16").should be_true
57
+ end
58
+
59
+ it 'should correctly convert date/time pairs' do
60
+ result, converted = date.apply({:date => "25/04/10", :time => "11:00"})
61
+ converted.should == {:date => Date.parse("2010/04/25"), :time => Time.parse("2010/04/25 11:00")}
62
+ end
63
+
64
+ end
65
+
66
+ describe "when a default time should be provided" do
67
+
68
+ let(:date){
69
+ @date_validator ||= ::Waw::Validation.signature {
70
+ validation :time, regexp(/^\d{2}:\d{2}$/) | default('12:15'), :bad_time
71
+ validation [:date, :time], datetime, :bad_date
72
+ }
73
+ }
74
+
75
+ it 'should correctly convert date/time pairs' do
76
+ result, converted = date.apply({:date => "2010/04/25", :time => "11:00"})
77
+ converted.should == {:date => Date.parse("2010/04/25"), :time => Time.parse("2010/04/25 11:00")}
78
+ end
79
+
80
+ it 'should correctly convert when time is missing' do
81
+ result, converted = date.apply({:date => "2010/04/25"})
82
+ converted.should == {:date => Date.parse("2010/04/25"), :time => Time.parse("2010/04/25 12:15")}
83
+ end
84
+
85
+ it "should block invalid date/time pairs" do
86
+ date.blocks?(:date => "65/12/2010", :time => "12:16").should be_true
87
+ date.blocks?(:date => "2010/10/12", :time => "28:16").should be_true
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..'))
2
3
  require 'waw'
3
4
  require 'test/unit'
4
5
  test_files = Dir[File.join(File.dirname(__FILE__), '**/*_test.rb')]
@@ -0,0 +1,22 @@
1
+ # Logfile created on Wed Oct 27 13:52:01 +0200 2010 by logger.rb/22283
2
+ I, [2010-10-27T13:52:01.566158 #37241] INFO -- : Waw::Kern::App: load stage 1 sucessfull ()
3
+ I, [2010-10-27T13:52:01.566260 #37241] INFO -- : Waw::Kern::App: load stage 2 sucessfull
4
+ W, [2010-10-27T13:52:01.566376 #37241] WARN -- : Ignoring the resources folder (not readable)... something will probably fail later!
5
+ I, [2010-10-27T13:52:01.566446 #37241] INFO -- : Waw::Kern::App: load stage 3 sucessfull (resources)
6
+ I, [2010-10-27T13:52:01.566585 #37241] INFO -- : Waw::Kern::App: load stage 4 sucessfull (using waw.routing)
7
+ I, [2010-10-27T13:52:01.566813 #37241] INFO -- : Waw::Kern::App: load stage 5 sucessfull (load hooks executed)
8
+ I, [2010-10-27T13:52:01.566875 #37241] INFO -- : Waw::Kern::App: application loaded successfully, enjoy!
9
+ I, [2010-10-27T13:52:01.567830 #37241] INFO -- : Waw::Kern::App: load stage 1 sucessfull ()
10
+ I, [2010-10-27T13:52:01.567898 #37241] INFO -- : Waw::Kern::App: load stage 2 sucessfull
11
+ W, [2010-10-27T13:52:01.568062 #37241] WARN -- : Ignoring the resources folder (not readable)... something will probably fail later!
12
+ I, [2010-10-27T13:52:01.568136 #37241] INFO -- : Waw::Kern::App: load stage 3 sucessfull (resources)
13
+ I, [2010-10-27T13:52:01.568496 #37241] INFO -- : Waw::Kern::App: load stage 4 sucessfull (using waw.routing)
14
+ I, [2010-10-27T13:52:01.568690 #37241] INFO -- : Waw::Kern::App: load stage 5 sucessfull (load hooks executed)
15
+ I, [2010-10-27T13:52:01.568754 #37241] INFO -- : Waw::Kern::App: application loaded successfully, enjoy!
16
+ I, [2010-10-27T13:52:01.569518 #37241] INFO -- : Waw::Kern::App: load stage 1 sucessfull ()
17
+ I, [2010-10-27T13:52:01.569585 #37241] INFO -- : Waw::Kern::App: load stage 2 sucessfull
18
+ W, [2010-10-27T13:52:01.569661 #37241] WARN -- : Ignoring the resources folder (not readable)... something will probably fail later!
19
+ I, [2010-10-27T13:52:01.569722 #37241] INFO -- : Waw::Kern::App: load stage 3 sucessfull (resources)
20
+ I, [2010-10-27T13:52:01.569835 #37241] INFO -- : Waw::Kern::App: load stage 4 sucessfull (using waw.routing)
21
+ I, [2010-10-27T13:52:01.570080 #37241] INFO -- : Waw::Kern::App: load stage 5 sucessfull (load hooks executed)
22
+ I, [2010-10-27T13:52:01.570144 #37241] INFO -- : Waw::Kern::App: application loaded successfully, enjoy!
metadata CHANGED
@@ -2,12 +2,12 @@
2
2
  name: waw
3
3
  version: !ruby/object:Gem::Version
4
4
  hash: 19
5
- prerelease: false
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernard Lambeau
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-01 00:00:00 +02:00
18
+ date: 2011-01-29 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -33,6 +33,7 @@ extra_rdoc_files:
33
33
  - LICENCE.rdoc
34
34
  files:
35
35
  - lib/waw/commands/command.rb
36
+ - lib/waw/commands/crawl_command.rb
36
37
  - lib/waw/commands/profile_command.rb
37
38
  - lib/waw/commands/start_command.rb
38
39
  - lib/waw/config.rb
@@ -46,9 +47,13 @@ files:
46
47
  - lib/waw/controllers/json_controller.rb
47
48
  - lib/waw/controllers/no_cache.rb
48
49
  - lib/waw/controllers/static/match.rb
50
+ - lib/waw/controllers/static/matcher.rb
49
51
  - lib/waw/controllers/static/waw_access.rb
50
52
  - lib/waw/controllers/static/waw_access_dsl.rb
51
53
  - lib/waw/controllers/static_controller.rb
54
+ - lib/waw/crawler/crawler_listener.rb
55
+ - lib/waw/crawler/crawler_options.rb
56
+ - lib/waw/crawler.rb
52
57
  - lib/waw/default_config.cfg
53
58
  - lib/waw/environment_utils.rb
54
59
  - lib/waw/errors.rb
@@ -102,6 +107,7 @@ files:
102
107
  - lib/waw/validation/boolean_validator.rb
103
108
  - lib/waw/validation/comparison_validations.rb
104
109
  - lib/waw/validation/date_validator.rb
110
+ - lib/waw/validation/datetime_validator.rb
105
111
  - lib/waw/validation/default_validator.rb
106
112
  - lib/waw/validation/dsl_ruby_extensions.rb
107
113
  - lib/waw/validation/errors.rb
@@ -137,8 +143,16 @@ files:
137
143
  - test/bricks/error_handler/config/test.cfg
138
144
  - test/bricks/error_handler/logs/webapp.log
139
145
  - test/bricks/error_handler/test/error_handler.wspec
146
+ - test/bricks/error_handler/test/test_all.rb
140
147
  - test/bricks/error_handler/waw.deploy
141
148
  - test/bricks/error_handler/waw.routing
149
+ - test/bricks/static_controller/config/test.cfg
150
+ - test/bricks/static_controller/logs/webapp.log
151
+ - test/bricks/static_controller/test/static_controller.wspec
152
+ - test/bricks/static_controller/test/test_all.rb
153
+ - test/bricks/static_controller/waw.deploy
154
+ - test/bricks/static_controller/waw.routing
155
+ - test/bricks/test_all.rb
142
156
  - test/integration/waw_create_integration_test.rb
143
157
  - test/spec/assumptions_spec.rb
144
158
  - test/spec/controllers/action_controller_spec.rb
@@ -165,6 +179,7 @@ files:
165
179
  - test/spec/validation/array_validation_spec.rb
166
180
  - test/spec/validation/array_validator_spec.rb
167
181
  - test/spec/validation/date_validation_spec.rb
182
+ - test/spec/validation/datetime_validation_spec.rb
168
183
  - test/spec/validation/default_validation_spec.rb
169
184
  - test/spec/validation/disjuctive_validation_spec.rb
170
185
  - test/spec/validation/errors_spec.rb
@@ -190,6 +205,7 @@ files:
190
205
  - test/unit/waw/controllers/static/example/index.html
191
206
  - test/unit/waw/controllers/static/example/js/example.js
192
207
  - test/unit/waw/controllers/static/example/pages/hello.wtpl
208
+ - test/unit/waw/controllers/static/logs/webapp.log
193
209
  - test/unit/waw/controllers/static/waw_access_test.rb
194
210
  - test/unit/waw/ext/rack_test.rb
195
211
  - test/unit/waw/resource_collection_test.rb
@@ -202,6 +218,7 @@ files:
202
218
  - test/unit/waw/wspec/html_analysis_test.html
203
219
  - test/unit/waw/wspec/html_analysis_test.rb
204
220
  - bin/waw
221
+ - bin/waw-crawl
205
222
  - bin/waw-profile
206
223
  - bin/waw-start
207
224
  - bin/wspec
@@ -264,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
281
  requirements: []
265
282
 
266
283
  rubyforge_project:
267
- rubygems_version: 1.3.7
284
+ rubygems_version: 1.4.2
268
285
  signing_key:
269
286
  specification_version: 3
270
287
  summary: Waw - making web applications simple