waves 0.7.3 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/Rakefile +11 -19
- data/app/bin/waves-console +3 -5
- data/app/bin/waves-server +3 -5
- data/app/configurations/development.rb.erb +19 -11
- data/app/configurations/mapping.rb.erb +4 -5
- data/app/configurations/production.rb.erb +18 -13
- data/app/{doc/EMTPY → controllers/.gitignore} +0 -0
- data/app/{public/css/EMPTY → doc/.gitignore} +0 -0
- data/app/{public/flash/EMPTY → helpers/.gitignore} +0 -0
- data/app/lib/application.rb.erb +4 -51
- data/app/{public/images/EMPTY → lib/tasks/.gitignore} +0 -0
- data/app/{public/javascript/EMPTY → log/.gitignore} +0 -0
- data/app/{tmp/sessions/EMPTY → models/.gitignore} +0 -0
- data/app/public/css/.gitignore +0 -0
- data/app/public/flash/.gitignore +0 -0
- data/app/public/images/.gitignore +0 -0
- data/app/public/javascript/.gitignore +0 -0
- data/app/schema/migrations/.gitignore +0 -0
- data/app/startup.rb +5 -0
- data/app/templates/layouts/default.mab +2 -2
- data/app/tmp/sessions/.gitignore +0 -0
- data/app/views/.gitignore +0 -0
- data/bin/waves +38 -27
- data/bin/waves-console +3 -25
- data/bin/waves-server +4 -45
- data/lib/commands/waves-console.rb +21 -0
- data/lib/commands/waves-server.rb +55 -0
- data/lib/controllers/base.rb +11 -0
- data/lib/controllers/mixin.rb +130 -102
- data/lib/dispatchers/base.rb +65 -50
- data/lib/dispatchers/default.rb +79 -52
- data/lib/foundations/default.rb +26 -0
- data/lib/foundations/simple.rb +30 -0
- data/lib/helpers/common.rb +60 -56
- data/lib/helpers/default.rb +13 -0
- data/lib/helpers/form.rb +39 -38
- data/lib/helpers/formatting.rb +11 -11
- data/lib/helpers/model.rb +12 -12
- data/lib/helpers/view.rb +13 -13
- data/lib/layers/default_errors.rb +29 -0
- data/lib/layers/mvc.rb +58 -0
- data/lib/layers/orm/active_record.rb +41 -0
- data/lib/layers/orm/active_record/migrations/empty.rb.erb +9 -0
- data/lib/layers/orm/active_record/tasks/schema.rb +30 -0
- data/lib/layers/orm/data_mapper.rb +42 -0
- data/lib/layers/orm/filebase.rb +22 -0
- data/lib/layers/orm/migration.rb +70 -0
- data/lib/layers/orm/sequel.rb +82 -0
- data/lib/layers/orm/sequel/migrations/empty.rb.erb +9 -0
- data/lib/layers/orm/sequel/tasks/schema.rb +24 -0
- data/lib/layers/simple.rb +39 -0
- data/lib/layers/simple_errors.rb +26 -0
- data/lib/mapping/mapping.rb +222 -120
- data/lib/mapping/pretty_urls.rb +42 -41
- data/lib/renderers/erubis.rb +54 -31
- data/lib/renderers/markaby.rb +28 -28
- data/lib/renderers/mixin.rb +49 -52
- data/lib/runtime/application.rb +66 -48
- data/lib/runtime/blackboard.rb +57 -0
- data/lib/runtime/configuration.rb +117 -101
- data/lib/runtime/console.rb +19 -20
- data/lib/runtime/debugger.rb +9 -0
- data/lib/runtime/logger.rb +43 -37
- data/lib/runtime/mime_types.rb +19 -19
- data/lib/runtime/request.rb +72 -46
- data/lib/runtime/response.rb +37 -37
- data/lib/runtime/response_mixin.rb +26 -23
- data/lib/runtime/response_proxy.rb +25 -24
- data/lib/runtime/server.rb +99 -80
- data/lib/runtime/session.rb +63 -53
- data/lib/tasks/cluster.rb +26 -0
- data/lib/tasks/gem.rb +31 -0
- data/lib/tasks/generate.rb +80 -0
- data/lib/utilities/hash.rb +22 -0
- data/lib/utilities/inflect.rb +194 -0
- data/lib/utilities/integer.rb +15 -12
- data/lib/utilities/kernel.rb +32 -32
- data/lib/utilities/module.rb +11 -4
- data/lib/utilities/object.rb +5 -5
- data/lib/utilities/proc.rb +10 -0
- data/lib/utilities/string.rb +44 -38
- data/lib/utilities/symbol.rb +4 -4
- data/lib/views/base.rb +9 -0
- data/lib/views/mixin.rb +91 -89
- data/lib/waves.rb +29 -9
- metadata +52 -26
- data/app/configurations/default.rb.erb +0 -8
- data/app/controllers/default.rb.erb +0 -29
- data/app/helpers/default.rb.erb +0 -13
- data/app/lib/startup.rb.erb +0 -3
- data/app/lib/tasks/cluster.rb +0 -24
- data/app/lib/tasks/generate.rb +0 -15
- data/app/lib/tasks/schema.rb +0 -29
- data/app/models/default.rb.erb +0 -13
- data/app/schema/migrations/templates/empty.rb.erb +0 -9
- data/app/views/default.rb.erb +0 -13
data/app/Rakefile
CHANGED
@@ -1,22 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
#
|
3
|
+
# Warning: This file is clobbered when you update your
|
4
|
+
# application with the waves script. Accordingly, you may
|
5
|
+
# wish to keep your tasks in .rb or .rake files in lib/tasks
|
6
|
+
require 'startup'
|
7
|
+
Waves::Console.load(:mode => ENV['mode'])
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
puts "Can't find waves gem or ./waves/lib directory. try rake symlink waves=/path/to/waves/"
|
12
|
-
end
|
9
|
+
# load tasks from waves framework
|
10
|
+
%w( cluster generate gem ).each { |task| require "tasks/#{task}.rb" }
|
11
|
+
|
12
|
+
# load tasks from this app's lib/tasks
|
13
|
+
Dir["lib/tasks/*.{rb,rake}"].each { |task| require task }
|
13
14
|
|
14
|
-
desc "Create lib and bin symlinks using waves=<path>"
|
15
|
-
task :symlink do
|
16
|
-
waves = ENV['waves']
|
17
|
-
system "mkdir waves"
|
18
|
-
libdir = File.join(waves, 'lib')
|
19
|
-
bindir = File.join(waves, 'bin')
|
20
|
-
system(cmd = "ln -s #{libdir} waves/") && puts(cmd)
|
21
|
-
system(cmd = "ln -s #{bindir} waves/") && puts(cmd)
|
22
|
-
end
|
data/app/bin/waves-console
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
load File.join(waves_src, 'bin', 'waves-console')
|
2
|
+
require 'rubygems'
|
3
|
+
require 'startup'
|
4
|
+
require 'commands/waves-console'
|
data/app/bin/waves-server
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
load File.join(waves_src, 'bin', 'waves-server')
|
2
|
+
require 'rubygems'
|
3
|
+
require 'startup'
|
4
|
+
require 'commands/waves-server'
|
@@ -1,22 +1,30 @@
|
|
1
|
-
module <%= name %>
|
1
|
+
module <%= @name %>
|
2
|
+
|
2
3
|
module Configurations
|
4
|
+
|
3
5
|
class Development < Default
|
4
|
-
|
6
|
+
|
7
|
+
database :adapter => 'sqlite', :database => '<%= @name.downcase %>'
|
8
|
+
|
9
|
+
reloadable [ <%= @name %> ]
|
10
|
+
|
11
|
+
log :level => :debug
|
12
|
+
|
5
13
|
host '127.0.0.1'
|
6
14
|
|
7
15
|
port 3000
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
|
17
|
+
handler ::Rack::Handler::Mongrel, :Host => host, :Port => port
|
18
|
+
# handler ::Rack::Handler::WEBrick, :BindAddress => host, :Port => port
|
19
|
+
# handler ::Rack::Handler::Thin, :Host => host, :Port => port
|
12
20
|
|
13
21
|
application do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
22
|
+
use ::Rack::ShowExceptions
|
23
|
+
run ::Waves::Dispatchers::Default.new
|
24
|
+
end
|
25
|
+
|
18
26
|
end
|
19
|
-
end
|
20
|
-
end
|
21
27
|
|
28
|
+
end
|
22
29
|
|
30
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
module <%= name %>
|
2
|
-
|
1
|
+
module <%= @name %>
|
2
|
+
|
3
3
|
module Configurations
|
4
|
-
|
4
|
+
|
5
5
|
module Mapping
|
6
|
-
extend Waves::Mapping
|
7
6
|
# your custom rules go here
|
8
7
|
include Waves::Mapping::PrettyUrls::RestRules
|
9
8
|
include Waves::Mapping::PrettyUrls::GetRules
|
@@ -11,4 +10,4 @@ module <%= name %>
|
|
11
10
|
|
12
11
|
end
|
13
12
|
|
14
|
-
end
|
13
|
+
end
|
@@ -1,25 +1,30 @@
|
|
1
|
-
module <%= name %>
|
1
|
+
module <%= @name %>
|
2
2
|
|
3
3
|
module Configurations
|
4
|
-
|
4
|
+
|
5
5
|
class Production < Default
|
6
|
-
|
6
|
+
|
7
|
+
database :host => 'localhost', :adapter => 'mysql', :database => '<%= @name.downcase %>',
|
8
|
+
:user => 'root', :password => ''
|
9
|
+
|
10
|
+
reloadable []
|
11
|
+
|
12
|
+
log :level => :error,
|
13
|
+
:output => ( :log / "waves.#{$$}" ),
|
14
|
+
:rotation => :weekly
|
15
|
+
|
7
16
|
host '0.0.0.0'
|
8
17
|
|
9
18
|
port 80
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
:output => ( :log / "waves.#{$$}" ),
|
15
|
-
:rotation => :weekly
|
20
|
+
handler ::Rack::Handler::Mongrel, :Host => host, :Port => port
|
21
|
+
# handler ::Rack::Handler::WEBrick, :BindAddress => host, :Port => port
|
22
|
+
# handler ::Rack::Handler::Thin, :Host => host, :Port => port
|
16
23
|
|
17
24
|
application do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
25
|
+
run ::Waves::Dispatchers::Default.new
|
26
|
+
end
|
22
27
|
|
28
|
+
end
|
23
29
|
end
|
24
|
-
|
25
30
|
end
|
File without changes
|
File without changes
|
File without changes
|
data/app/lib/application.rb.erb
CHANGED
@@ -1,52 +1,5 @@
|
|
1
|
-
require 'sequel'
|
2
|
-
module <%= name %>
|
3
|
-
|
4
|
-
|
5
|
-
autoload true; directories :lib
|
6
|
-
|
7
|
-
[ :Configurations, :Models, :Views, :Controllers, :Helpers ].each do | name |
|
8
|
-
autocreate( name, Module.new ) do
|
9
|
-
|
10
|
-
# dynamically access module constants
|
11
|
-
def self.[]( cname )
|
12
|
-
eval("#{name}::#{cname.to_s.camel_case}")
|
13
|
-
end
|
14
|
-
|
15
|
-
# first try to load and only create if that fails
|
16
|
-
# which means install autoload *after* autocreate
|
17
|
-
extend Autocreate; extend Autoload
|
18
|
-
|
19
|
-
# autoload any files in appropriately named directories
|
20
|
-
# exampe: models/blog.rb for Blog
|
21
|
-
autoload true; directories name.to_s.snake_case
|
22
|
-
|
23
|
-
# autocreate declarations ...
|
24
|
-
case name
|
25
|
-
# don't autocreate configs
|
26
|
-
when :Configurations then nil
|
27
|
-
# set the dataset for Models
|
28
|
-
when :Models
|
29
|
-
autocreate true, eval("<%= name %>::Models::Default") do
|
30
|
-
set_dataset <%= name %>.database[ basename.snake_case.plural.intern ]
|
31
|
-
end
|
32
|
-
# everything else just use the exemplar
|
33
|
-
else
|
34
|
-
autocreate true, eval("<%= name %>::#{name}::Default")
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
# accessor methods for modules and other key application objects ...
|
42
|
-
class << self
|
43
|
-
def config ; Waves::Server.config rescue nil || Waves::Console.config ; end
|
44
|
-
def database ; @database ||= Sequel.open( config.database ) ; end
|
45
|
-
def configurations ; <%= name %>::Configurations ; end
|
46
|
-
def controllers ; <%= name %>::Controllers ; end
|
47
|
-
def models ; <%= name %>::Models ; end
|
48
|
-
def helpers ; <%= name %>::Helpers ; end
|
49
|
-
def views ; <%= name %>::Views ; end
|
50
|
-
end
|
51
|
-
|
1
|
+
require 'layers/orm/sequel'
|
2
|
+
module <%= @name %>
|
3
|
+
include Waves::Foundations::Default
|
4
|
+
include Waves::Layers::ORM::Sequel
|
52
5
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/app/startup.rb
ADDED
File without changes
|
File without changes
|
data/bin/waves
CHANGED
@@ -1,38 +1,49 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'choice'
|
4
|
+
require 'rakegen'
|
5
|
+
|
6
|
+
# if we're in the waves source, prepend it to the load path
|
7
|
+
waves_lib = File.expand_path( "#{File.dirname(__FILE__)}/../../waves/lib" )
|
8
|
+
$:.unshift waves_lib if File.exist?(waves_lib)
|
9
|
+
require 'waves'
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'utilities/string'
|
13
|
+
rescue LoadError
|
14
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'utilities', 'string')
|
6
15
|
end
|
7
16
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
17
|
+
Choice.options do
|
18
|
+
banner 'Usage: waves path/to/app [-h]'
|
19
|
+
option :help do
|
20
|
+
long '--help'
|
21
|
+
desc 'Show this message'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
12
25
|
|
13
|
-
puts "** Creating new Waves application ..."
|
14
26
|
app_path = ARGV[0]
|
15
27
|
app_name = File.basename(app_path)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
if app_name =~ /[^\w\d_]/
|
29
|
+
raise ArgumentError, <<-TEXT
|
30
|
+
Unusable name: \"#{app_name}\"
|
31
|
+
Application names may contain only letters, numbers, and underscores."
|
32
|
+
TEXT
|
33
|
+
end
|
34
|
+
|
35
|
+
template = "#{WAVES}/app"
|
36
|
+
|
37
|
+
generator = Rakegen.new("waves:app") do |gen|
|
38
|
+
gen.source = template
|
39
|
+
gen.target = app_path
|
40
|
+
gen.template_assigns = {:name => app_name.camel_case}
|
41
|
+
gen.executables = %w{ bin/waves-console bin/waves-server}
|
30
42
|
end
|
31
43
|
|
32
|
-
|
33
|
-
system "chmod ug+x #{app_path}/bin/waves-*"
|
44
|
+
puts "** Creating new Waves application ..."
|
34
45
|
|
35
|
-
|
36
|
-
system "mv #{app_path}/lib/application.rb #{app_path}/lib/#{app_name}.rb"
|
46
|
+
Rake::Task["waves:app"].invoke
|
37
47
|
|
38
48
|
puts "** Application created!"
|
49
|
+
|
data/bin/waves-console
CHANGED
@@ -1,26 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
|
5
|
-
Choice.options do
|
6
|
-
header 'Run a waves application server.'
|
7
|
-
header ''
|
8
|
-
option :mode do
|
9
|
-
short '-c'
|
10
|
-
long '--config=CONFIG'
|
11
|
-
desc 'Configuration to use.'
|
12
|
-
desc 'Defaults to development.'
|
13
|
-
cast Symbol
|
14
|
-
end
|
15
|
-
separator ''
|
16
|
-
option :directory do
|
17
|
-
short '-D'
|
18
|
-
long '--dir=DIR'
|
19
|
-
desc 'Directory containing the application.'
|
20
|
-
desc 'Defaults to the current directory.'
|
21
|
-
end
|
22
|
-
separator ''
|
23
|
-
end
|
24
|
-
|
25
|
-
Waves::Console.load( Choice.choices )
|
26
|
-
require 'irb'; IRB.start
|
2
|
+
require 'rubygems'
|
3
|
+
require 'startup'
|
4
|
+
require 'commands/waves-console'
|
data/bin/waves-server
CHANGED
@@ -1,45 +1,4 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
header 'Run a waves application server.'
|
6
|
-
header ''
|
7
|
-
option :port do
|
8
|
-
short '-p'
|
9
|
-
long '--port=PORT'
|
10
|
-
desc 'Port to listen on.'
|
11
|
-
desc 'Defaults to value given in configuration.'
|
12
|
-
cast Integer
|
13
|
-
end
|
14
|
-
separator ''
|
15
|
-
option :host do
|
16
|
-
short '-h'
|
17
|
-
long '--host=HOST'
|
18
|
-
desc 'Host or IP address of the host to bind.'
|
19
|
-
desc 'Defaults to value given in configuration.'
|
20
|
-
end
|
21
|
-
separator ''
|
22
|
-
option :mode do
|
23
|
-
short '-c'
|
24
|
-
long '--config=CONFIG'
|
25
|
-
desc 'Configuration to use.'
|
26
|
-
desc 'Defaults to development.'
|
27
|
-
cast Symbol
|
28
|
-
end
|
29
|
-
separator ''
|
30
|
-
option :directory do
|
31
|
-
short '-D'
|
32
|
-
long '--dir=DIR'
|
33
|
-
desc 'Directory containing the application.'
|
34
|
-
desc 'Defaults to the current directory.'
|
35
|
-
end
|
36
|
-
separator ''
|
37
|
-
option :daemon do
|
38
|
-
short '-d'
|
39
|
-
long '--daemon'
|
40
|
-
desc 'Run as a daemon.'
|
41
|
-
end
|
42
|
-
separator ''
|
43
|
-
end
|
44
|
-
|
45
|
-
Waves::Server.run( Choice.choices )
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'startup'
|
4
|
+
require 'commands/waves-server'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'choice'
|
2
|
+
|
3
|
+
Choice.options do
|
4
|
+
header 'Run waves in console mode.'
|
5
|
+
header ''
|
6
|
+
option :mode do
|
7
|
+
short '-c'
|
8
|
+
long '--config=CONFIG'
|
9
|
+
desc 'Configuration to use.'
|
10
|
+
desc 'Defaults to development.'
|
11
|
+
cast Symbol
|
12
|
+
end
|
13
|
+
separator ''
|
14
|
+
end
|
15
|
+
|
16
|
+
console = Waves::Console.load( Choice.choices )
|
17
|
+
Object.send(:define_method, :waves) { console }
|
18
|
+
require 'irb'
|
19
|
+
require 'irb/completion'
|
20
|
+
ARGV.clear
|
21
|
+
IRB.start
|