Permalink
Browse files

fixing the groove generator

  • Loading branch information...
1 parent cd07869 commit d258a19bc559e6cdb6c2282c332ce8f9f366546a @croaky committed Dec 31, 2009
Showing with 66 additions and 64 deletions.
  1. +11 −5 README.md
  2. +4 −3 Rakefile
  3. +44 −52 bin/groove
  4. +6 −4 groove.gemspec
  5. +1 −0 install.rb
View
16 README.md
@@ -1,22 +1,29 @@
Groove
======
-A web application stack composed of Sinatra, MongoDB, Effigy, and Hoptoad.
+Generator to create a Sinatra, MongoDB, Effigy, and Hoptoad web app.
Usage
-----
-thor groove weekapaug
+groove weekapaug
+
+ create weekapaug/config.ru
+ create weekapaug/app.rb
+ create weekapaug/templates/index.html
+ create weekapaug/views/index.rb
+
+cd weekapaug
vim templates/index.html
<!DOCTYPE html>
<html>
<head>
- <title>weekapaug groove</title>
+ <title>weekapaug</title>
</head>
<body>
- <h1>sharing in the weekapaug groove</h1>
+ <h1>weekapaug</h1>
</body>
</html>
@@ -38,4 +45,3 @@ heroku config
DATABASE_USER => user
DATABASE_PASSWORD => password
HOPTOAD => apikey123
-
View
7 Rakefile
@@ -2,19 +2,20 @@ require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "groove"
- gem.summary = "A web application stack composed of Sinatra, MongoDB, Effigy, and Hoptoad."
- gem.description = "A web application stack composed of Sinatra, MongoDB, Effigy, and Hoptoad."
+ gem.summary = "Generator to create a Sinatra, MongoDB, Effigy, and Hoptoad web app."
+ gem.description = "Generator to create a Sinatra, MongoDB, Effigy, and Hoptoad web app."
gem.email = "dcroak@thoughtbot.com"
gem.homepage = "http://github.com/dancroak/groove"
gem.authors = ["Dan Croak"]
gem.bindir = "bin"
gem.executables = ["groove"]
- gem.add_dependency('x')
gem.add_dependency('sinatra')
gem.add_dependency('mongo')
gem.add_dependency('effigy')
gem.add_dependency('rack_hoptoad')
+ gem.add_dependency('x')
+ gem.add_dependency('thor')
end
Jeweler::GemcutterTasks.new
View
96 bin/groove
@@ -1,71 +1,63 @@
#!/usr/bin/env ruby
-# -*- mode: ruby -*-
+require 'rubygems'
require 'thor'
+module Grooove
+ Rackup = <<-RUBY
+Groove.config = { :db => ENV['DATABASE'] || '#{name}',
+ :db_url => ENV['DATABASE_URL'] || 'localhost',
+ :db_user => ENV['DATABASE_USER'],
+ :db_password => ENV['DATABASE_PASSWORD'],
+ :hoptoad => ENV['HOPTOAD'] }
+RUBY
+
+ App = <<-RUBY
+get '/' do
+ effigy :index
+end
+RUBY
+
+ Template = <<-HTML
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>#{name}</title>
+ </head>
+ <body>
+ <h1>#{name}</h1>
+ </body>
+</html>
+HTML
+
+ View = <<-RUBY
+class IndexView < Effigy::View
+ def transform
+ end
+end
+RUBY
+end
+
class Groove < Thor::Group
include Thor::Actions
argument :name
- def create_directory
- directory(name)
- end
-
def create_rackup
- create_file("#{name}/config.ru") do
- <<-RUBY
- Groove.config = { :db => ENV['DATABASE'] || '#{name}',
- :db_url => ENV['DATABASE_URL'] || 'localhost',
- :db_user => ENV['DATABASE_USER'],
- :db_password => ENV['DATABASE_PASSWORD'],
- :hoptoad => ENV['HOPTOAD'] }
- RUBY
- end
+ create_file("#{name}/config.ru") { Grooove::Rackup }
end
def create_app
- create_file("#{name}/app.rb") do
- <<-RUBY
- get '/' do
- effigy :index
- end
- RUBY
- end
- end
-
- def create_templates_directory
- directory("#{name}/templates")
+ create_file("#{name}/app.rb") { Grooove::App }
end
- def create_index_template
- create_file("#{name}/templates/index.html") do
- <<-HTML
- <!DOCTYPE html>
- <html>
- <head>
- <title>#{name}</title>
- </head>
- <body>
- <h1>#{name}</h1>
- </body>
- </html>
- HTML
- end
+ def create_template
+ create_file("#{name}/templates/index.html") { Grooove::Template }
end
- def create_views_directory
- directory("#{name}/views")
- end
-
- def create_index_template
- create_file("#{name}/views/index.rb") do
- <<-RUBY
- class IndexView < Effigy::View
- def transform
- end
- end
- RUBY
- end
+ def create_view
+ create_file("#{name}/views/index.rb") { Grooove::View }
end
end
+
+Groove.start
View
10 groove.gemspec
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
"README.md",
"Rakefile",
"VERSION",
- "bin/groove",
"groove.gemspec",
"lib/groove.rb",
"lib/groove/effigy.rb",
@@ -41,24 +40,27 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<x>, [">= 0"])
s.add_runtime_dependency(%q<sinatra>, [">= 0"])
s.add_runtime_dependency(%q<mongo>, [">= 0"])
s.add_runtime_dependency(%q<effigy>, [">= 0"])
s.add_runtime_dependency(%q<rack_hoptoad>, [">= 0"])
+ s.add_runtime_dependency(%q<x>, [">= 0"])
+ s.add_runtime_dependency(%q<thor>, [">= 0"])
else
- s.add_dependency(%q<x>, [">= 0"])
s.add_dependency(%q<sinatra>, [">= 0"])
s.add_dependency(%q<mongo>, [">= 0"])
s.add_dependency(%q<effigy>, [">= 0"])
s.add_dependency(%q<rack_hoptoad>, [">= 0"])
+ s.add_dependency(%q<x>, [">= 0"])
+ s.add_dependency(%q<thor>, [">= 0"])
end
else
- s.add_dependency(%q<x>, [">= 0"])
s.add_dependency(%q<sinatra>, [">= 0"])
s.add_dependency(%q<mongo>, [">= 0"])
s.add_dependency(%q<effigy>, [">= 0"])
s.add_dependency(%q<rack_hoptoad>, [">= 0"])
+ s.add_dependency(%q<x>, [">= 0"])
+ s.add_dependency(%q<thor>, [">= 0"])
end
end
View
1 install.rb
@@ -0,0 +1 @@
+thor install "http://github.com/cypher/thor-git/tree/master/git.thor?raw=true"

0 comments on commit d258a19

Please sign in to comment.