GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
genitorifying the app generator; copy and process working
automatthew (author)
Mon May 12 16:25:00 -0700 2008
commit  69686c13c2e656cc722fcd02358f32f8ee907f83
tree    66d89b0d87bbf8a21907ed332a853cc5e067afe9
parent  ef2d13ebd6690c4ceeb1aecbd9b2ce68f4e541d0
...
1
 
2
3
4
5
6
7
 
8
9
 
10
11
12
...
 
1
2
3
4
5
6
 
7
8
 
9
10
11
12
0
@@ -1,12 +1,12 @@
0
-module <%= name %>
0
+module <%= @name %>
0
 
0
   module Configurations
0
 
0
     class Development
0
 
0
- database :host => 'localhost', :adapter => 'sqlite', :database => '<%= name.downcase %>'
0
+ database :host => 'localhost', :adapter => 'sqlite', :database => '<%= @name.downcase %>'
0
 
0
- reloadable [ <%= name %> ]
0
+ reloadable [ <%= @name %> ]
0
 
0
       log :level => :debug
0
 
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-module <%= name %>
0
+module <%= @name %>
0
 
0
   module Configurations
0
 
...
1
 
2
3
4
5
6
7
 
8
9
10
...
 
1
2
3
4
5
6
 
7
8
9
10
0
@@ -1,10 +1,10 @@
0
-module <%= name %>
0
+module <%= @name %>
0
 
0
   module Configurations
0
 
0
     class Production < Default
0
 
0
- database :host => 'localhost', :adapter => 'mysql', :database => '<%= name.downcase %>',
0
+ database :host => 'localhost', :adapter => 'mysql', :database => '<%= @name.downcase %>',
0
         :user => 'root', :password => ''
0
 
0
       reloadable []
...
1
 
2
3
...
 
1
2
3
0
@@ -1,3 +1,3 @@
0
-module <%= name %>
0
+module <%= @name %>
0
   include Waves::Foundations::Default
0
 end
...
18
19
20
21
 
22
23
24
...
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
...
18
19
20
 
21
22
23
24
...
32
33
34
 
 
35
36
37
38
39
40
41
42
43
 
 
44
 
 
 
 
 
 
 
 
 
 
 
 
45
46
47
48
49
50
51
52
53
54
55
0
@@ -18,7 +18,7 @@ end
0
 
0
 
0
 require 'rubygems'
0
-require 'erubis'
0
+require 'genitor'
0
 require 'extensions/all'
0
 begin
0
   require 'utilities/string'
0
@@ -32,32 +32,24 @@ include FileUtils
0
 # are we calling this script from within the waves framework source?
0
 script_path = File.expand_path(__FILE__)
0
 WAVES_SRC = File.dirname(File.dirname(script_path))
0
-IN_WAVES_SRC = Dir.pwd.match(WAVES_SRC) ? true : false
0
-
0
 
0
 puts "** Creating new Waves application ..."
0
+
0
+# Determine path to template
0
 template = begin
0
   File.join File.dirname(File.readlink(__FILE__)), '..', 'app'
0
 rescue Exception
0
   File.join( File.dirname(__FILE__),'..','app')
0
 end
0
-mkdir(app_path)
0
-cp_r Dir["#{template}/*"], app_path
0
 
0
-# get rid of placeholder files left over from gem install
0
-Dir["#{app_path}/**/EMPTY"].each { |path| rm path }
0
-# Dir["#{app_path}/**/EMPTY"].each { |path| system "rm #{path}" }
0
-
0
-# next, process all template files ...
0
-Dir["#{app_path}/**/*.erb"].each do |path|
0
- unless path =~ %r{^#{app_path}/(schema/migrations/templates|templates)}
0
- name = app_name.camel_case
0
- File.write( path.gsub(/\.erb$/,''),
0
- Erubis::Eruby.new( File.read( path ) ).result( binding ) )
0
- rm path
0
- end
0
+generator = Genitor.new("waves:app") do |gen|
0
+ gen.source = template
0
+ gen.target = app_path
0
+ gen.template_assigns = {:name => app_name}
0
 end
0
 
0
+Rake::Task["waves:app"].invoke
0
+
0
 unless RUBY_PLATFORM =~ /mswin32/
0
   # make the scripts executable
0
   system "chmod ug+x #{app_path}/bin/waves-*"
...
3
4
5
6
 
7
8
9
...
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
...
3
4
5
 
6
7
8
9
...
12
13
14
15
16
17
18
19
 
20
21
22
23
24
25
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
28
29
30
0
@@ -3,7 +3,7 @@
0
 require File.join(File.dirname(__FILE__) , "helpers")
0
 
0
 
0
-describe "startup.rb in a generated app, without requiring rubygems" do
0
+describe "startup.rb in a generated app" do
0
   before do
0
     clobber_test_app(AppPath)
0
     generate_test_app(AppPath)
0
@@ -12,27 +12,19 @@ describe "startup.rb in a generated app, without requiring rubygems" do
0
   after do
0
     clobber_test_app(AppPath)
0
   end
0
+
0
+ it "should make the scripts executable" do
0
+ File.executable?(File.join(AppPath, "bin", "waves-console")).should.be.true
0
+ end
0
 
0
- it "should fail to find waves framework" do
0
+ it "should fail to find waves framework, if gem is not available" do
0
     Dir.chdir(AppPath) do
0
       stdin, stdout, stderr = Open3.popen3("ruby startup.rb")
0
       stderr.gets.should =~ %r{no such file to load -- waves \(LoadError\)}
0
     end
0
   end
0
 
0
-end
0
-
0
-describe "startup.rb in an app, without gems, but with WAVES defined" do
0
- before do
0
- clobber_test_app(AppPath)
0
- generate_test_app(AppPath)
0
- end
0
-
0
- after do
0
- clobber_test_app(AppPath)
0
- end
0
-
0
- it "should find and use waves framework source" do
0
+ it "should find and use waves framework source when WAVES is defined" do
0
     set_framework_path(AppPath)
0
     Dir.chdir(AppPath) do
0
       stdin, stdout, stderr = Open3.popen3("ruby startup.rb")

Comments

    No one has commented yet.