public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
Search Repo:
waves / bin / waves
100755 65 lines (53 sloc) 1.671 kb
1
2
3
4
5
6
7
8
9
10
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env ruby
require 'rubygems'
require 'choice'
require 'rakegen'
 
# if we're in the waves source, prepend it to the load path
waves_lib = File.expand_path( "#{File.dirname(__FILE__)}/../../waves/lib" )
$:.unshift waves_lib if File.exist?(waves_lib)
require 'waves'
 
begin
  require 'utilities/string'
rescue LoadError
  require File.join(File.dirname(__FILE__), '..', 'lib', 'utilities', 'string')
end
 
Choice.options do
  banner 'Usage: waves path/to/app [-h]'
  option :help do
    long '--help'
    desc 'Show this message'
  end
  
  option :orm do
    short '-o'
    long '--orm=ORM'
    desc "Select an ORM (e.g. active_record, sequel, none)"
    default "sequel"
  end
  
end
 
orm = Choice.choices.orm.snake_case
orm_require, orm_include = case orm
when 'sequel'
  ["require 'layers/orm/sequel'", "include Waves::Layers::ORM::Sequel"]
when 'active_record'
  ["require 'layers/orm/active_record'", "include Waves::Layers::ORM::ActiveRecord"]
when 'none'
  ['', '# This app was generated without an ORM layer']
end
 
app_path = ARGV[0]
app_name = File.basename(app_path)
if app_name =~ /[^\w\d_]/
  raise ArgumentError, <<-TEXT
Unusable name: \"#{app_name}\"
Application names may contain only letters, numbers, and underscores."
TEXT
end
 
template = "#{WAVES}/app"
 
generator = Rakegen.new("waves:app") do |gen|
  gen.source = template
  gen.target = app_path
  gen.template_assigns = {:name => app_name.camel_case, :orm_require => orm_require, :orm_include => orm_include }
  gen.executables = %w{ bin/waves-console bin/waves-server}
end
 
puts "** Creating new Waves application ..."
 
Rake::Task["waves:app"].invoke
 
puts "** Application created!"