Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
23 lib/jeweler/generator.rb
@@ -47,6 +47,7 @@ class Generator
:should_use_cucumber, :should_setup_gemcutter,
:should_setup_rubyforge, :should_use_reek, :should_use_roodi,
:development_dependencies,
+ :use_sinatra,
:options
def initialize(options = {})
@@ -86,6 +87,13 @@ def initialize(options = {})
self.should_setup_gemcutter = options[:gemcutter]
self.should_setup_rubyforge = options[:rubyforge]
+ self.use_sinatra = options[:use_sinatra]
+
+ if use_sinatra
+ development_dependencies << ["rack-test", ">= 0"] << ["racksh", ">= 0"] << ["shotgun", ">= 0"]
+ end
+
+
development_dependencies << ["cucumber", ">= 0"] if should_use_cucumber
self.user_name = options[:user_name]
@@ -163,8 +171,19 @@ def create_files
output_template_in_target 'README.rdoc'
output_template_in_target '.document'
+ if use_sinatra
+ output_template_in_target File.join('sinatra', 'config.ru'), 'config.ru'
+ mkdir_in_target 'bin'
+ output_template_in_target File.join('sinatra', 'bin'), File.join('bin', project_name)
+ FileUtils.chmod 0755, File.join(target_dir, 'bin', project_name)
+ end
+
mkdir_in_target lib_dir
- touch_in_target File.join(lib_dir, lib_filename)
+ if use_sinatra
+ output_template_in_target File.join('sinatra', 'main.rb'), File.join(lib_dir, lib_filename)
+ else
+ touch_in_target File.join(lib_dir, lib_filename)
+ end
mkdir_in_target test_dir
output_template_in_target File.join(testing_framework.to_s, 'helper.rb'),
@@ -190,6 +209,8 @@ def create_files
touch_in_target File.join(features_steps_dir, steps_filename)
end
+
+
end
def render_template(source)
View
8 lib/jeweler/generator/options.rb
@@ -137,6 +137,14 @@ def initialize(args)
self[:documentation_framework] = :rdoc
end
+ o.separator ""
+
+ o.on('--sinatra', 'generate a sinatra skeleton') do
+ self[:use_sinatra] = true
+ end
+
+ o.separator ""
+
o.on_tail('-h', '--help', 'display this help and exit') do
self[:show_help] = true
end
View
10 lib/jeweler/templates/other_tasks.erb
@@ -115,3 +115,13 @@ rescue LoadError
end
end
<% end %>
+
+<% if use_sinatra %>
+task :server do
+ sh 'shotgun'
+end
+
+task :console do
+ sh 'racksh'
+end
+<% end %>
View
6 lib/jeweler/templates/sinatra/bin
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
+
+require '<%= lib_filename %>'
+
+Sinatra::Application.run!
View
3 lib/jeweler/templates/sinatra/config.ru
@@ -0,0 +1,3 @@
+$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
+require '<%= require_name %>'
+run Sinatra::Application
View
1 lib/jeweler/templates/sinatra/main.rb
@@ -0,0 +1 @@
+require 'sinatra'
View
11 lib/jeweler/templates/testunit/helper.rb
@@ -1,9 +1,20 @@
require 'rubygems'
require 'test/unit'
+<% if use_sinatra %>
+require 'rack/test'
+<% end %>
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require '<%= require_name %>'
class Test::Unit::TestCase
+<% if use_sinatra %>
+ include Rack::Test::Methods
+
+ def app
+ Sinatra::Application
+ end
+
+<% end %>
end

No commit comments for this range

Something went wrong with that request. Please try again.