spiderfw 0.6.23 → 0.6.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +10 -1
  2. data/README.rdoc +1 -1
  3. data/VERSION +1 -1
  4. data/apps/config_editor/_init.rb +1 -2
  5. data/apps/config_editor/controllers/config_editor_controller.rb +1 -7
  6. data/apps/core/admin/controllers/admin_controller.rb +1 -1
  7. data/apps/core/admin/public/css/sass/admin.css +35 -31
  8. data/apps/core/admin/public/sass/admin.scss +6 -1
  9. data/apps/core/components/widgets/crud/crud.shtml +2 -2
  10. data/apps/core/components/widgets/table/table.rb +5 -5
  11. data/apps/core/forms/tags/element_row.erb +15 -10
  12. data/apps/core/forms/widgets/form/form.rb +35 -22
  13. data/apps/core/forms/widgets/inputs/checkbox/checkbox.shtml +2 -2
  14. data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +2 -2
  15. data/apps/core/forms/widgets/inputs/file_input/file_input.shtml +2 -2
  16. data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +2 -2
  17. data/apps/core/forms/widgets/inputs/input/input.shtml +2 -2
  18. data/apps/core/forms/widgets/inputs/password/password.shtml +2 -2
  19. data/apps/core/forms/widgets/inputs/search_select/search_select.shtml +1 -1
  20. data/apps/core/forms/widgets/inputs/select/select.shtml +2 -2
  21. data/apps/core/forms/widgets/inputs/text/text.shtml +2 -2
  22. data/apps/core/forms/widgets/inputs/text_area/text_area.shtml +2 -2
  23. data/apps/core/forms/widgets/inputs/time_span/time_span.shtml +1 -1
  24. data/blueprints/home/config.ru +8 -0
  25. data/lib/spiderfw/app.rb +416 -224
  26. data/lib/spiderfw/cmd/commands/app.rb +243 -239
  27. data/lib/spiderfw/cmd/commands/cert.rb +421 -417
  28. data/lib/spiderfw/cmd/commands/config.rb +85 -82
  29. data/lib/spiderfw/cmd/commands/console.rb +64 -40
  30. data/lib/spiderfw/cmd/commands/content.rb +29 -25
  31. data/lib/spiderfw/cmd/commands/create.rb +58 -54
  32. data/lib/spiderfw/cmd/commands/model.rb +118 -114
  33. data/lib/spiderfw/cmd/commands/setup.rb +55 -51
  34. data/lib/spiderfw/cmd/commands/test.rb +63 -59
  35. data/lib/spiderfw/cmd/commands/webserver.rb +56 -51
  36. data/lib/spiderfw/config/options/spider.rb +4 -3
  37. data/lib/spiderfw/controller/controller.rb +2 -0
  38. data/lib/spiderfw/controller/http_controller.rb +1 -2
  39. data/lib/spiderfw/controller/mixins/static_content.rb +3 -3
  40. data/lib/spiderfw/controller/mixins/visual.rb +30 -15
  41. data/lib/spiderfw/controller/response.rb +84 -0
  42. data/lib/spiderfw/controller/session/file_session.rb +2 -2
  43. data/lib/spiderfw/http/adapters/rack.rb +12 -13
  44. data/lib/spiderfw/http/server.rb +80 -46
  45. data/lib/spiderfw/i18n/cldr.rb +6 -9
  46. data/lib/spiderfw/model/base_model.rb +103 -23
  47. data/lib/spiderfw/model/condition.rb +110 -25
  48. data/lib/spiderfw/model/mappers/db_mapper.rb +14 -6
  49. data/lib/spiderfw/model/mappers/mapper.rb +440 -197
  50. data/lib/spiderfw/model/model.rb +105 -21
  51. data/lib/spiderfw/model/model_hash.rb +9 -1
  52. data/lib/spiderfw/model/query.rb +50 -9
  53. data/lib/spiderfw/model/query_set.rb +211 -44
  54. data/lib/spiderfw/model/request.rb +28 -21
  55. data/lib/spiderfw/model/storage/base_storage.rb +125 -10
  56. data/lib/spiderfw/model/storage/db/db_storage.rb +7 -4
  57. data/lib/spiderfw/model/storage.rb +8 -1
  58. data/lib/spiderfw/setup/spider_setup_wizard.rb +9 -7
  59. data/lib/spiderfw/spider.rb +270 -43
  60. data/lib/spiderfw/templates/layout.rb +9 -4
  61. data/lib/spiderfw/templates/resources/sass.rb +3 -2
  62. data/lib/spiderfw/templates/template.rb +1 -0
  63. data/lib/spiderfw/utils/annotations.rb +3 -1
  64. data/lib/spiderfw/utils/logger.rb +1 -1
  65. data/lib/spiderfw/utils/monkey/symbol.rb +4 -2
  66. data/lib/spiderfw/utils/shared_store/file_shared_store.rb +2 -2
  67. data/lib/spiderfw/utils/thread_out.rb +3 -1
  68. data/public/css/error_page.css +83 -0
  69. data/public/js/error_page.js +5 -0
  70. data/spider.gemspec +4 -1
  71. data/templates/email/error.erb +9 -0
  72. metadata +28 -12
  73. data/apps/config_editor/widgets/edit_bool/edit_bool.rb +0 -8
  74. data/apps/config_editor/widgets/edit_bool/edit_bool.shtml +0 -5
@@ -1,135 +1,139 @@
1
- class ModelCommand < CmdParse::Command
1
+ module Spider::CommandLine
2
2
 
3
+ class ModelCommand < CmdParse::Command
3
4
 
4
- def initialize
5
- super( 'model', true, true )
6
- @short_desc = _("Manage models")
7
- @apps = []
8
- @force = false
9
- @no_fkc = true
10
5
 
11
- sync_cmd = CmdParse::Command.new( 'sync', false )
12
- sync_cmd.short_desc = _("Sync models")
13
- sync_cmd.options = CmdParse::OptionParserWrapper.new do |opt|
14
- opt.on("--force", _("Force syncing"), "-f"){ |f|
15
- @force = true
16
- }
17
- opt.on("--drop-columns", _("Drop unused columns"), "-d"){ |d| @drop = true}
18
- opt.on("--drop-tables [PREFIX]", _("Drop unused tables")){ |dt|
19
- dt = true if dt == '*'
20
- @drop_tables = dt
21
- }
22
- opt.on("--update-sequences", _("Update current sequences to max db value"), "-s"){ |s|
23
- @update_sequences = true
24
- }
25
- opt.on("--non-managed", _("Process also non managed models"), "-m"){ |m| @non_managed = true}
26
- opt.on("--no-fk-constraints", _("Don't create foreign key constraints"), "-c"){ |c| @no_fkc = true }
27
- opt.on("--fk-constraints", _("Create foreign key constraints"), "-C" ){ |c| @no_fkc = false }
28
- end
29
-
30
- sync_cmd.set_execution_block do |req_models|
31
- require 'spiderfw/init'
32
- require 'spiderfw/model/mappers/db_mapper'
33
- req_models || []
34
- unsafe_fields = {}
35
- req_models = Spider.apps.values if (req_models.empty?)
36
- req_models.each do |model_or_app|
37
- models = []
38
- mod = model_or_app.is_a?(Module) ? model_or_app : const_get_full(model_or_app)
39
- if (mod.is_a?(Module) && mod.include?(Spider::App))
40
- mod.models.each do |m|
41
- unless @non_managed || m < Spider::Model::Managed
42
- unless m < Spider::Model::InlineModel || m.attributes[:sub_model]
43
- Spider.logger.warn("Skipping #{m} because it's non managed (use -m to override)")
6
+ def initialize
7
+ super( 'model', true, true )
8
+ @short_desc = _("Manage models")
9
+ @apps = []
10
+ @force = false
11
+ @no_fkc = true
12
+
13
+ sync_cmd = CmdParse::Command.new( 'sync', false )
14
+ sync_cmd.short_desc = _("Sync models")
15
+ sync_cmd.options = CmdParse::OptionParserWrapper.new do |opt|
16
+ opt.on("--force", _("Force syncing"), "-f"){ |f|
17
+ @force = true
18
+ }
19
+ opt.on("--drop-columns", _("Drop unused columns"), "-d"){ |d| @drop = true}
20
+ opt.on("--drop-tables [PREFIX]", _("Drop unused tables")){ |dt|
21
+ dt = true if dt == '*'
22
+ @drop_tables = dt
23
+ }
24
+ opt.on("--update-sequences", _("Update current sequences to max db value"), "-s"){ |s|
25
+ @update_sequences = true
26
+ }
27
+ opt.on("--non-managed", _("Process also non managed models"), "-m"){ |m| @non_managed = true}
28
+ opt.on("--no-fk-constraints", _("Don't create foreign key constraints"), "-c"){ |c| @no_fkc = true }
29
+ opt.on("--fk-constraints", _("Create foreign key constraints"), "-C" ){ |c| @no_fkc = false }
30
+ end
31
+
32
+ sync_cmd.set_execution_block do |req_models|
33
+ require 'spiderfw/init'
34
+ require 'spiderfw/model/mappers/db_mapper'
35
+ req_models || []
36
+ unsafe_fields = {}
37
+ req_models = Spider.apps.values if (req_models.empty?)
38
+ req_models.each do |model_or_app|
39
+ models = []
40
+ mod = model_or_app.is_a?(Module) ? model_or_app : const_get_full(model_or_app)
41
+ if (mod.is_a?(Module) && mod.include?(Spider::App))
42
+ mod.models.each do |m|
43
+ unless @non_managed || m < Spider::Model::Managed
44
+ unless m < Spider::Model::InlineModel || m.attributes[:sub_model]
45
+ Spider.logger.warn("Skipping #{m} because it's non managed (use -m to override)")
46
+ end
47
+ next
44
48
  end
45
- next
49
+ models << m
50
+ end
51
+ elsif (mod.subclass_of?(Spider::Model::BaseModel))
52
+ if @non_managed || mod < Spider::Model::Managed
53
+ models << mod
54
+ else
55
+ Spider.logger.warn("Skipping #{mod} because it's non managed (use -m to override)")
46
56
  end
47
- models << m
57
+
48
58
  end
49
- elsif (mod.subclass_of?(Spider::Model::BaseModel))
50
- if @non_managed || mod < Spider::Model::Managed
51
- models << mod
52
- else
53
- Spider.logger.warn("Skipping #{mod} because it's non managed (use -m to override)")
59
+ models.each do |model|
60
+ begin
61
+ Spider::Model.sync_schema(model, @force,
62
+ :drop_fields => @drop, :update_sequences => @update_sequences, :no_foreign_key_constraints => @no_fkc)
63
+ rescue Spider::Model::Mappers::SchemaSyncUnsafeConversion => exc
64
+ unsafe_fields[model] = exc.fields
65
+ end
54
66
  end
55
-
56
- end
57
- models.each do |model|
58
- begin
59
- Spider::Model.sync_schema(model, @force,
60
- :drop_fields => @drop, :update_sequences => @update_sequences, :no_foreign_key_constraints => @no_fkc)
61
- rescue Spider::Model::Mappers::SchemaSyncUnsafeConversion => exc
62
- unsafe_fields[model] = exc.fields
63
- end
64
- end
65
- if (@drop_tables)
66
- begin
67
- Spider::Model.sync_schema(mod, false, :no_sync => true, :drop_tables => @drop_tables)
68
- rescue Spider::Model::Mappers::SchemaSyncUnsafeConversion => exc
69
- puts _("The following tables are about to be dropped: \n%s") % exc.fields.join(', ')
70
- puts _("Continue? yes/NO: ")
71
- r = STDIN.gets.chomp.downcase
72
- yes_chr = _("yes")[0].chr
73
- no_chr = _("no")[0].chr
74
- if (r == _("yes") || (yes_chr != no_chr && r == yes_chr))
75
- Spider::Model.sync_schema(mod, true, :no_sync => true, :drop_tables => @drop_tables)
67
+ if (@drop_tables)
68
+ begin
69
+ Spider::Model.sync_schema(mod, false, :no_sync => true, :drop_tables => @drop_tables)
70
+ rescue Spider::Model::Mappers::SchemaSyncUnsafeConversion => exc
71
+ puts _("The following tables are about to be dropped: \n%s") % exc.fields.join(', ')
72
+ puts _("Continue? yes/NO: ")
73
+ r = STDIN.gets.chomp.downcase
74
+ yes_chr = _("yes")[0].chr
75
+ no_chr = _("no")[0].chr
76
+ if (r == _("yes") || (yes_chr != no_chr && r == yes_chr))
77
+ Spider::Model.sync_schema(mod, true, :no_sync => true, :drop_tables => @drop_tables)
78
+ end
76
79
  end
80
+
81
+
77
82
  end
78
-
79
-
83
+ end
84
+ unless unsafe_fields.empty?
85
+ puts _("Unable to modify the following fields:")
86
+ puts unsafe_fields.inspect
87
+ puts _("(use -f to force)")
80
88
  end
81
89
  end
82
- unless unsafe_fields.empty?
83
- puts _("Unable to modify the following fields:")
84
- puts unsafe_fields.inspect
85
- puts _("(use -f to force)")
90
+ self.add_command(sync_cmd)
91
+
92
+ dump_cmd = CmdParse::Command.new( 'dump', false )
93
+ dump_cmd.short_desc = _("Dump models")
94
+ dump_cmd.options = CmdParse::OptionParserWrapper.new do |opt|
95
+ opt.on("--force", _("Overwrite existing files"), "-f"){ |f|
96
+ @force = true
97
+ }
98
+ opt.on("--path [PATH]", _("Specify dump path"), "-p"){ |p|
99
+ @dump_path = p
100
+ }
86
101
  end
87
- end
88
- self.add_command(sync_cmd)
89
-
90
- dump_cmd = CmdParse::Command.new( 'dump', false )
91
- dump_cmd.short_desc = _("Dump models")
92
- dump_cmd.options = CmdParse::OptionParserWrapper.new do |opt|
93
- opt.on("--force", _("Overwrite existing files"), "-f"){ |f|
94
- @force = true
95
- }
96
- opt.on("--path [PATH]", _("Specify dump path"), "-p"){ |p|
97
- @dump_path = p
98
- }
99
- end
100
- dump_cmd.set_execution_block do |req_models|
101
- require 'spiderfw/init'
102
- req_models || []
103
- req_models.each do |model_or_app|
104
- models = []
105
- mod = model_or_app.is_a?(Module) ? model_or_app : const_get_full(model_or_app)
106
- if (mod.is_a?(Module) && mod.include?(Spider::App))
107
- mod.models.each do |m|
108
- models << m
109
- end
110
- elsif (mod.subclass_of?(Spider::Model::BaseModel))
111
- models << mod if @non_managed || mod < Spider::Model::Managed
112
- end
113
- Spider.logger.warn("Nothing to do") if models.empty?
114
- models.each do |model|
115
- dest = @dump_path || model.app.models_path
116
- FileUtils.mkdir_p(dest)
117
- file_name = "#{model.short_name}.rb"
118
- path = "#{dest}/#{file_name}"
119
- if (File.exist?(path) && !@force)
120
- Spider.logger.warn("File #{path} exists, skipping #{model}")
121
- next
102
+ dump_cmd.set_execution_block do |req_models|
103
+ require 'spiderfw/init'
104
+ req_models || []
105
+ req_models.each do |model_or_app|
106
+ models = []
107
+ mod = model_or_app.is_a?(Module) ? model_or_app : const_get_full(model_or_app)
108
+ if (mod.is_a?(Module) && mod.include?(Spider::App))
109
+ mod.models.each do |m|
110
+ models << m
111
+ end
112
+ elsif (mod.subclass_of?(Spider::Model::BaseModel))
113
+ models << mod if @non_managed || mod < Spider::Model::Managed
122
114
  end
123
- code = model.to_code
124
- File.open(path, "w") do |f|
125
- f << code
115
+ Spider.logger.warn("Nothing to do") if models.empty?
116
+ models.each do |model|
117
+ dest = @dump_path || model.app.models_path
118
+ FileUtils.mkdir_p(dest)
119
+ file_name = "#{model.short_name}.rb"
120
+ path = "#{dest}/#{file_name}"
121
+ if (File.exist?(path) && !@force)
122
+ Spider.logger.warn("File #{path} exists, skipping #{model}")
123
+ next
124
+ end
125
+ code = model.to_code
126
+ File.open(path, "w") do |f|
127
+ f << code
128
+ end
126
129
  end
127
130
  end
128
131
  end
129
- end
130
- self.add_command(dump_cmd)
132
+ self.add_command(dump_cmd)
131
133
 
132
134
 
135
+ end
136
+
133
137
  end
134
138
 
135
139
  end
@@ -1,61 +1,65 @@
1
- class SetupCommand < CmdParse::Command
2
-
3
-
4
- def initialize
5
- super( 'setup', false, true )
6
- @short_desc = _("Setup an application")
7
- # @description = _("")
8
- @apps = []
9
-
10
- self.options = CmdParse::OptionParserWrapper.new do |opt|
11
- # TODO
12
- opt.on("--from [VERSION]", _("Assume a specific version is installed"), "-f"){ |from|
13
- @from = Gem::Version.new(from)
14
- }
15
- opt.on("--to [VERSION]", _("Setup to a specific version"), "-t"){ |to|
16
- @to = Gem::Version.new(to)
17
- }
18
- opt.on("--version [VERSION]", _("Only run the setup script for the given version"), "-v"){ |v|
19
- @version = Gem::Version.new(v)
20
- }
21
- opt.on("--all", _("Setup all active apps")){ |all|
22
- @all = true
23
- }
24
- opt.on("--no-cleanup", _("Don't cleanup"), "-C"){ |no_cleanup| @no_cleanup = true }
25
- end
1
+ module Spider::CommandLine
26
2
 
27
- set_execution_block do |apps|
28
- $SPIDER_INTERACTIVE = true
29
- require 'spiderfw/spider'
30
- Spider.init_base
31
- apps = Spider.apps.keys if @all
32
- if (apps.length > 1) && (@to || @from || @version)
33
- raise "Can't use --from, --to or --version with multiple apps"
34
- end
35
- if apps.length == 0
36
- require 'lib/spiderfw/setup/spider_setup_wizard'
37
- wizard = Spider::SpiderSetupWizard.new
38
- wizard.implementation(Spider::ConsoleWizard)
39
- wizard.run
40
-
41
- end
42
- tasks = []
43
- apps.each do |name|
44
- require 'spiderfw/setup/app_manager'
45
- tasks += Spider::AppManager.new(:interactive => true).setup(name, @from, @to)
3
+ class SetupCommand < CmdParse::Command
4
+
5
+
6
+ def initialize
7
+ super( 'setup', false, true )
8
+ @short_desc = _("Setup an application")
9
+ # @description = _("")
10
+ @apps = []
11
+
12
+ self.options = CmdParse::OptionParserWrapper.new do |opt|
13
+ # TODO
14
+ opt.on("--from [VERSION]", _("Assume a specific version is installed"), "-f"){ |from|
15
+ @from = Gem::Version.new(from)
16
+ }
17
+ opt.on("--to [VERSION]", _("Setup to a specific version"), "-t"){ |to|
18
+ @to = Gem::Version.new(to)
19
+ }
20
+ opt.on("--version [VERSION]", _("Only run the setup script for the given version"), "-v"){ |v|
21
+ @version = Gem::Version.new(v)
22
+ }
23
+ opt.on("--all", _("Setup all active apps")){ |all|
24
+ @all = true
25
+ }
26
+ opt.on("--no-cleanup", _("Don't cleanup"), "-C"){ |no_cleanup| @no_cleanup = true }
46
27
  end
47
- unless @no_cleanup
48
- tasks.each do |t|
49
- begin
50
- t.do_cleanup
51
- rescue => exc
52
- Spider.logger.error(exc)
28
+
29
+ set_execution_block do |apps|
30
+ $SPIDER_INTERACTIVE = true
31
+ require 'spiderfw/spider'
32
+ Spider.init_base
33
+ apps = Spider.apps.keys if @all
34
+ if (apps.length > 1) && (@to || @from || @version)
35
+ raise "Can't use --from, --to or --version with multiple apps"
36
+ end
37
+ if apps.length == 0
38
+ require 'lib/spiderfw/setup/spider_setup_wizard'
39
+ wizard = Spider::SpiderSetupWizard.new
40
+ wizard.implementation(Spider::ConsoleWizard)
41
+ wizard.run
42
+
43
+ end
44
+ tasks = []
45
+ apps.each do |name|
46
+ require 'spiderfw/setup/app_manager'
47
+ tasks += Spider::AppManager.new(:interactive => true).setup(name, @from, @to)
48
+ end
49
+ unless @no_cleanup
50
+ tasks.each do |t|
51
+ begin
52
+ t.do_cleanup
53
+ rescue => exc
54
+ Spider.logger.error(exc)
55
+ end
53
56
  end
54
57
  end
55
58
  end
56
- end
57
59
 
58
60
 
61
+ end
62
+
59
63
  end
60
64
 
61
65
  end
@@ -1,72 +1,76 @@
1
- class TestCommand < CmdParse::Command
1
+ module Spider::CommandLine
2
2
 
3
+ class TestCommand < CmdParse::Command
3
4
 
4
- def initialize
5
- super( 'test', true, true )
6
- @short_desc = _("Manage tests")
7
- # @description = _("")
8
- @apps = []
9
5
 
10
- run_cmd = CmdParse::Command.new( 'run', false )
11
- run_cmd.short_desc = _("Run tests")
12
- # run.options = CmdParse::OptionParserWrapper.new do |opt|
13
- # opt.on("--app",
14
- # _("Run tests only for an app"),
15
- # "-a"){ |app|
16
- # @apps << app
17
- # }
18
- # end
19
- run_cmd.set_execution_block do |apps|
20
- require 'test/unit/collector/dir'
21
- require 'test/unit'
22
- apps = Spider.apps.keys if (!apps || apps.length < 1)
23
- collector = Test::Unit::Collector::Dir.new()
24
- apps.each do |name|
25
- next unless File.exist?(Spider.apps[name].test_path)
26
- collector.collect(Spider.apps[name].test_path)
6
+ def initialize
7
+ super( 'test', true, true )
8
+ @short_desc = _("Manage tests")
9
+ # @description = _("")
10
+ @apps = []
11
+
12
+ run_cmd = CmdParse::Command.new( 'run', false )
13
+ run_cmd.short_desc = _("Run tests")
14
+ # run.options = CmdParse::OptionParserWrapper.new do |opt|
15
+ # opt.on("--app",
16
+ # _("Run tests only for an app"),
17
+ # "-a"){ |app|
18
+ # @apps << app
19
+ # }
20
+ # end
21
+ run_cmd.set_execution_block do |apps|
22
+ require 'test/unit/collector/dir'
23
+ require 'test/unit'
24
+ apps = Spider.apps.keys if (!apps || apps.length < 1)
25
+ collector = Test::Unit::Collector::Dir.new()
26
+ apps.each do |name|
27
+ next unless File.exist?(Spider.apps[name].test_path)
28
+ collector.collect(Spider.apps[name].test_path)
29
+ end
27
30
  end
28
- end
29
- self.add_command(run_cmd)
30
-
31
- self_cmd = CmdParse::Command.new('self', false)
32
- self_cmd.short_desc = _("Run framework tests")
33
- self_cmd.set_execution_block do
34
- require 'test/unit/collector/dir'
35
- require 'test/unit'
36
- $SPIDER_RUNMODE = 'test'
37
- require 'spiderfw/init'
38
- test_env = "#{$SPIDER_PATH}/test"
39
- # Dir.cwd(test_env)
40
- $:.push(test_env)
41
- apps = Spider.find_apps_in_folder("#{test_env}/apps")
42
- Spider.apps.clear
31
+ self.add_command(run_cmd)
32
+
33
+ self_cmd = CmdParse::Command.new('self', false)
34
+ self_cmd.short_desc = _("Run framework tests")
35
+ self_cmd.set_execution_block do
36
+ require 'test/unit/collector/dir'
37
+ require 'test/unit'
38
+ $SPIDER_RUNMODE = 'test'
39
+ require 'spiderfw/init'
40
+ test_env = "#{$SPIDER_PATH}/test"
41
+ # Dir.cwd(test_env)
42
+ $:.push(test_env)
43
+ apps = Spider.find_apps_in_folder("#{test_env}/apps")
44
+ Spider.apps.clear
43
45
 
44
- apps.each{ |app| Spider.load_app_at_path app }
46
+ apps.each{ |app| Spider.load_app_at_path app }
45
47
 
46
- Spider._test_setup
47
- collector = Test::Unit::Collector::Dir.new()
48
- collector.collect("#{test_env}/tests")
49
- Spider._test_teardown
50
- end
51
- self.add_command(self_cmd)
48
+ Spider._test_setup
49
+ collector = Test::Unit::Collector::Dir.new()
50
+ collector.collect("#{test_env}/tests")
51
+ Spider._test_teardown
52
+ end
53
+ self.add_command(self_cmd)
52
54
 
53
- issue = CmdParse::Command.new('issue', false)
54
- issue.short_desc = _("Test for an issue")
55
- issue.set_execution_block do |args|
56
- id = args.first
57
- require 'spiderfw/spider'
58
- require 'spiderfw/test'
59
-
60
- test_path = File.join($SPIDER_PATH, 'test', 'issues')
61
- issue_no = id.rjust(5, "0")
62
- Dir.glob(File.join(test_path, "#{issue_no}-*")).each do |f|
63
- require f
55
+ issue = CmdParse::Command.new('issue', false)
56
+ issue.short_desc = _("Test for an issue")
57
+ issue.set_execution_block do |args|
58
+ id = args.first
59
+ require 'spiderfw/spider'
60
+ require 'spiderfw/test'
61
+
62
+ test_path = File.join($SPIDER_PATH, 'test', 'issues')
63
+ issue_no = id.rjust(5, "0")
64
+ Dir.glob(File.join(test_path, "#{issue_no}-*")).each do |f|
65
+ require f
66
+ end
67
+
64
68
  end
65
-
66
- end
67
- self.add_command(issue)
69
+ self.add_command(issue)
68
70
 
69
71
 
72
+ end
73
+
70
74
  end
71
75
 
72
76
  end
@@ -1,63 +1,68 @@
1
1
  require 'spiderfw/http/http'
2
2
 
3
- class WebServerCommand < CmdParse::Command
3
+ module Spider::CommandLine
4
4
 
5
+ class WebServerCommand < CmdParse::Command
5
6
 
6
- def initialize
7
- super( 'webserver', true, true )
8
- @short_desc = _("Manage internal webserver")
9
- # @description = _("")
10
-
11
- servers = {
12
- 'webrick' => :WEBrick,
13
- 'mongrel' => :Mongrel,
14
- 'thin' => :Thin
15
- }
16
7
 
17
- # start
18
- start = CmdParse::Command.new( 'start', false )
19
- start.short_desc = "Start web server"
20
- start.options = CmdParse::OptionParserWrapper.new do |opt|
21
- opt.on("--port N", _("The port the webserver should listen on"), "-p") { |port|
22
- @port = port
23
- }
24
- opt.on("--server name", _("Which webserver to use; the choices are 'webrick', 'mongrel' and 'thin'"), "-s"){ |server_name|
25
- raise CmdParse::InvalidArgumentError, _("The webserver %s is not supported") % server_name unless servers[server_name]
26
- @server_name = server_name
27
- }
28
- opt.on("--daemonize [daemon_name]", _("Detach server process"), "-d"){ |daemon_name| @daemonize = daemon_name || true }
29
- opt.on("--cgi", _("Serve each request spawning a CGI subprocess. Useful in developement."), "-c"){
30
- @cgi = true
31
- }
32
- opt.on("--ssl [PORT]", _("Listen to SSL requests"), "-S"){ |port|
33
- @ssl = port || 443
8
+ def initialize
9
+ super( 'webserver', true, true )
10
+ @short_desc = _("Manage internal webserver")
11
+ # @description = _("")
12
+
13
+ servers = {
14
+ 'webrick' => :WEBrick,
15
+ 'mongrel' => :Mongrel,
16
+ 'thin' => :Thin
34
17
  }
35
- opt.on("--cert CERT", _("SSL certificate")){ |cert| @ssl_cert = cert }
36
- opt.on("--key key", _("SSL private key")){ |key| @ssl_key = key }
37
- end
38
- start.set_execution_block do |args|
39
- require 'spiderfw/spider'
40
- raise "Can't use cgi mode with SSL" if @ssl && @cgi
41
- if @ssl && @server_name != 'webrick'
42
- puts _("Note: Using WEBrick as a webserver, since SSL was requested")
43
- @server_name = 'webrick'
18
+
19
+ # start
20
+ start = CmdParse::Command.new( 'start', false )
21
+ start.short_desc = "Start web server"
22
+ start.options = CmdParse::OptionParserWrapper.new do |opt|
23
+ opt.on("--port N", _("The port the webserver should listen on"), "-p") { |port|
24
+ @port = port
25
+ }
26
+ opt.on("--server name", _("Which webserver to use; the choices are 'webrick', 'mongrel' and 'thin'"), "-s"){ |server_name|
27
+ raise CmdParse::InvalidArgumentError, _("The webserver %s is not supported") % server_name unless servers[server_name]
28
+ @server_name = server_name
29
+ }
30
+ opt.on("--daemonize [daemon_name]", _("Detach server process"), "-d"){ |daemon_name| @daemonize = daemon_name || true }
31
+ opt.on("--cgi", _("Serve each request spawning a CGI subprocess. Useful in developement."), "-c"){
32
+ @cgi = true
33
+ }
34
+ opt.on("--ssl [PORT]", _("Listen to SSL requests"), "-S"){ |port|
35
+ @ssl = port || 443
36
+ }
37
+ opt.on("--cert CERT", _("SSL certificate")){ |cert| @ssl_cert = cert }
38
+ opt.on("--key key", _("SSL private key")){ |key| @ssl_key = key }
44
39
  end
45
- options = {
46
- :verbose => $verbose,
47
- :ssl => @ssl,
48
- :ssl_cert => @ssl_cert,
49
- :ssl_key => @ssl_key,
50
- :cgi => @cgi,
51
- :daemonize => @daemonize
52
- }
53
- Spider::HTTP::Server.start(@server_name, @port, options)
54
-
55
-
56
- end
57
- self.add_command( start )
40
+ start.set_execution_block do |args|
41
+ require 'spiderfw/spider'
42
+ raise "Can't use cgi mode with SSL" if @ssl && @cgi
43
+ if @ssl && @server_name != 'webrick'
44
+ puts _("Note: Using WEBrick as a webserver, since SSL was requested")
45
+ @server_name = 'webrick'
46
+ end
47
+ options = {
48
+ :port => @port,
49
+ :verbose => $verbose,
50
+ :ssl => @ssl,
51
+ :ssl_cert => @ssl_cert,
52
+ :ssl_key => @ssl_key,
53
+ :cgi => @cgi,
54
+ :daemonize => @daemonize
55
+ }
56
+ Spider::HTTP::Server.start(@server_name, options)
57
+
58
+
59
+ end
60
+ self.add_command( start )
61
+
62
+ # stop
58
63
 
59
- # stop
60
64
 
65
+ end
61
66
 
62
67
  end
63
68