spiderfw 0.6.23 → 0.6.24
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -1
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/apps/config_editor/_init.rb +1 -2
- data/apps/config_editor/controllers/config_editor_controller.rb +1 -7
- data/apps/core/admin/controllers/admin_controller.rb +1 -1
- data/apps/core/admin/public/css/sass/admin.css +35 -31
- data/apps/core/admin/public/sass/admin.scss +6 -1
- data/apps/core/components/widgets/crud/crud.shtml +2 -2
- data/apps/core/components/widgets/table/table.rb +5 -5
- data/apps/core/forms/tags/element_row.erb +15 -10
- data/apps/core/forms/widgets/form/form.rb +35 -22
- data/apps/core/forms/widgets/inputs/checkbox/checkbox.shtml +2 -2
- data/apps/core/forms/widgets/inputs/date_time/date_time.shtml +2 -2
- data/apps/core/forms/widgets/inputs/file_input/file_input.shtml +2 -2
- data/apps/core/forms/widgets/inputs/html_area/html_area.shtml +2 -2
- data/apps/core/forms/widgets/inputs/input/input.shtml +2 -2
- data/apps/core/forms/widgets/inputs/password/password.shtml +2 -2
- data/apps/core/forms/widgets/inputs/search_select/search_select.shtml +1 -1
- data/apps/core/forms/widgets/inputs/select/select.shtml +2 -2
- data/apps/core/forms/widgets/inputs/text/text.shtml +2 -2
- data/apps/core/forms/widgets/inputs/text_area/text_area.shtml +2 -2
- data/apps/core/forms/widgets/inputs/time_span/time_span.shtml +1 -1
- data/blueprints/home/config.ru +8 -0
- data/lib/spiderfw/app.rb +416 -224
- data/lib/spiderfw/cmd/commands/app.rb +243 -239
- data/lib/spiderfw/cmd/commands/cert.rb +421 -417
- data/lib/spiderfw/cmd/commands/config.rb +85 -82
- data/lib/spiderfw/cmd/commands/console.rb +64 -40
- data/lib/spiderfw/cmd/commands/content.rb +29 -25
- data/lib/spiderfw/cmd/commands/create.rb +58 -54
- data/lib/spiderfw/cmd/commands/model.rb +118 -114
- data/lib/spiderfw/cmd/commands/setup.rb +55 -51
- data/lib/spiderfw/cmd/commands/test.rb +63 -59
- data/lib/spiderfw/cmd/commands/webserver.rb +56 -51
- data/lib/spiderfw/config/options/spider.rb +4 -3
- data/lib/spiderfw/controller/controller.rb +2 -0
- data/lib/spiderfw/controller/http_controller.rb +1 -2
- data/lib/spiderfw/controller/mixins/static_content.rb +3 -3
- data/lib/spiderfw/controller/mixins/visual.rb +30 -15
- data/lib/spiderfw/controller/response.rb +84 -0
- data/lib/spiderfw/controller/session/file_session.rb +2 -2
- data/lib/spiderfw/http/adapters/rack.rb +12 -13
- data/lib/spiderfw/http/server.rb +80 -46
- data/lib/spiderfw/i18n/cldr.rb +6 -9
- data/lib/spiderfw/model/base_model.rb +103 -23
- data/lib/spiderfw/model/condition.rb +110 -25
- data/lib/spiderfw/model/mappers/db_mapper.rb +14 -6
- data/lib/spiderfw/model/mappers/mapper.rb +440 -197
- data/lib/spiderfw/model/model.rb +105 -21
- data/lib/spiderfw/model/model_hash.rb +9 -1
- data/lib/spiderfw/model/query.rb +50 -9
- data/lib/spiderfw/model/query_set.rb +211 -44
- data/lib/spiderfw/model/request.rb +28 -21
- data/lib/spiderfw/model/storage/base_storage.rb +125 -10
- data/lib/spiderfw/model/storage/db/db_storage.rb +7 -4
- data/lib/spiderfw/model/storage.rb +8 -1
- data/lib/spiderfw/setup/spider_setup_wizard.rb +9 -7
- data/lib/spiderfw/spider.rb +270 -43
- data/lib/spiderfw/templates/layout.rb +9 -4
- data/lib/spiderfw/templates/resources/sass.rb +3 -2
- data/lib/spiderfw/templates/template.rb +1 -0
- data/lib/spiderfw/utils/annotations.rb +3 -1
- data/lib/spiderfw/utils/logger.rb +1 -1
- data/lib/spiderfw/utils/monkey/symbol.rb +4 -2
- data/lib/spiderfw/utils/shared_store/file_shared_store.rb +2 -2
- data/lib/spiderfw/utils/thread_out.rb +3 -1
- data/public/css/error_page.css +83 -0
- data/public/js/error_page.js +5 -0
- data/spider.gemspec +4 -1
- data/templates/email/error.erb +9 -0
- metadata +28 -12
- data/apps/config_editor/widgets/edit_bool/edit_bool.rb +0 -8
- data/apps/config_editor/widgets/edit_bool/edit_bool.shtml +0 -5
@@ -1,135 +1,139 @@
|
|
1
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
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
|
-
|
57
|
+
|
48
58
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
Spider
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
apps
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
collector
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
test_env
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
46
|
+
apps.each{ |app| Spider.load_app_at_path app }
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
|