This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Adding support for Gemfile generation

  • Loading branch information...
lucasmazza committed Nov 15, 2010
1 parent ec7fb2a commit 8148da6fe2d152977968e655ab5f8e2251c0b750
View
@@ -3,7 +3,7 @@ class Generator < Thor::Group
include Thor::Actions
argument :name, :optional => true, :default => '.', :desc => "Your application folder"
- class_option :heroku, :type => :boolean, :desc => "builds a .gems file for heroku usage."
+ class_option :gemfile, :type => :boolean, :desc => "Create a Gemfile inside your application folder."
class_option :views, :type => :boolean, :desc => "creates the public/javascripts and public/stylesheets folders, and a sample index.erb view."
def self.banner
@@ -31,12 +31,14 @@ def create_lib_folder
end
def create_spec_folder_and_helper
- directory("spec", "#{name}/spec")
+ empty_directory("#{name}/spec")
+ template("spec/spec_helper.rb", "#{name}/spec/spec_helper.rb")
+ template("spec/application_spec.rb", "#{name}/spec/application_spec.rb")
end
- def create_gem_dependency_strategy
- if options.heroku?
- template(".gems", "#{name}/.gems")
+ def create_gemfile
+ if options.gemfile?
+ template("Gemfile", "#{name}/Gemfile")
end
end
@@ -1 +0,0 @@
-sinatra
@@ -0,0 +1,6 @@
+gem 'sinatra'
+
+group :test do
+ gem 'rspec'
+ gem 'rack-test', :require => 'rack/test'
+end
@@ -1,6 +1,3 @@
-require 'rubygems'
-require 'sinatra'
-
get '/' do
<% if options.views? %>
@text = "Hello world!"
@@ -1,12 +1,13 @@
-require 'application'
-
-<% unless options.heroku? %>
-root_dir = File.dirname(__FILE__)
+<% if options.gemfile? %>
+require 'rubygems'
+require 'bundler'
-set :environment, ENV['RACK_ENV'].to_sym
-set :root, root_dir
-set :app_file, File.join(root_dir, 'application.rb')
-disable :run
+Bundler.require
+<% else %>
+require 'rubygems'
+require 'sinatra'
<% end %>
+require 'application'
+
run Sinatra::Application
@@ -1,7 +1,11 @@
require File.join(File.dirname(__FILE__), '..', 'application.rb')
+<% if options.gemfile? %>
+Bundler.require :test
+<% else %>
require 'rspec'
require 'rack/test'
+<% end %>
RSpec.configure do |config|
config.include Rack::Test::Methods
View
@@ -22,15 +22,15 @@
end
end
- context "with the --heroku option" do
+ context "with the --gemfile option" do
before(:each) do
- @path = invoke!("some_heroku_app", "--heroku")
+ @path = invoke!("app", "--gemfile")
end
- it "creates the .gems file for deployment" do
+ it "creates a basic Gemfile" do
inside(@path) do
verify_expected_files!
- File.exists?(".gems").should be_true
+ File.exists?("Gemfile").should be_true
end
end
end

0 comments on commit 8148da6

Please sign in to comment.