sinatra-gen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +23 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +48 -0
- data/Rakefile +28 -0
- data/app_generators/sinatra_app/USAGE +8 -0
- data/app_generators/sinatra_app/sinatra_app_generator.rb +105 -0
- data/app_generators/sinatra_app/templates/Rakefile.erb +4 -0
- data/app_generators/sinatra_app/templates/app.rb.erb +17 -0
- data/app_generators/sinatra_app/templates/config.ru.erb +8 -0
- data/app_generators/sinatra_app/templates/lib/module.rb.erb +3 -0
- data/app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb +10 -0
- data/app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb +17 -0
- data/app_generators/sinatra_app/templates/test/test_app_spec.rb.erb +10 -0
- data/app_generators/sinatra_app/templates/test/test_app_unit.rb.erb +9 -0
- data/app_generators/sinatra_app/templates/test/test_helper.rb.erb +20 -0
- data/app_generators/sinatra_app/templates/views/builder_index.erb +4 -0
- data/app_generators/sinatra_app/templates/views/erb_index.erb +2 -0
- data/app_generators/sinatra_app/templates/views/erb_layout.erb +15 -0
- data/app_generators/sinatra_app/templates/views/haml_index.erb +2 -0
- data/app_generators/sinatra_app/templates/views/haml_layout.erb +6 -0
- data/bin/sinatra-gen +17 -0
- data/lib/sinatra-gen.rb +6 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +3 -0
- data/test/test_sinatra_app_generator.rb +163 -0
- metadata +111 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
app_generators/sinatra_app/USAGE
|
7
|
+
app_generators/sinatra_app/sinatra_app_generator.rb
|
8
|
+
app_generators/sinatra_app/templates/Rakefile.erb
|
9
|
+
app_generators/sinatra_app/templates/app.rb.erb
|
10
|
+
app_generators/sinatra_app/templates/config.ru.erb
|
11
|
+
app_generators/sinatra_app/templates/lib/module.rb.erb
|
12
|
+
app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb
|
13
|
+
app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb
|
14
|
+
app_generators/sinatra_app/templates/test/test_app_spec.rb.erb
|
15
|
+
app_generators/sinatra_app/templates/test/test_app_unit.rb.erb
|
16
|
+
app_generators/sinatra_app/templates/test/test_helper.rb.erb
|
17
|
+
app_generators/sinatra_app/templates/views/builder_index.erb
|
18
|
+
app_generators/sinatra_app/templates/views/erb_index.erb
|
19
|
+
app_generators/sinatra_app/templates/views/erb_layout.erb
|
20
|
+
app_generators/sinatra_app/templates/views/haml_index.erb
|
21
|
+
app_generators/sinatra_app/templates/views/haml_layout.erb
|
22
|
+
bin/sinatra-gen
|
23
|
+
lib/sinatra-gen.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= sinatra-gen
|
2
|
+
|
3
|
+
http://github.com/quirkey/sinatra-gen
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework.
|
8
|
+
For more information on sinatra, check out http://sinatra.rubyforge.org
|
9
|
+
|
10
|
+
== SYNOPSIS:
|
11
|
+
|
12
|
+
sinatra-gen has a bunch of different options (based loosley on merb-gen) to try to not lock the
|
13
|
+
user into any specific frameworks/dev practices.
|
14
|
+
|
15
|
+
Run:
|
16
|
+
|
17
|
+
sinatra-gen [appname] [options]
|
18
|
+
|
19
|
+
e.g.
|
20
|
+
|
21
|
+
sinatra-gen mysinatrapp --vendor -i --test=shoulda --views=haml
|
22
|
+
|
23
|
+
Options (can also be obtained by running sinatra-gen with no arguments):
|
24
|
+
|
25
|
+
-v, --version Show the sinatra-gen version number and quit.
|
26
|
+
-d, --vendor Extract the latest sinatra to vendor/sinatra
|
27
|
+
-t, --tiny Only create the minimal files.
|
28
|
+
-s, --scripts Install the rubigen scripts (script/generate, script/destroy)
|
29
|
+
-i, --init Initialize a git repository
|
30
|
+
--git /path/to/git Specify a different path for 'git'
|
31
|
+
--test=test_framework Specify your testing framework (unit (default)/rspec/spec/shoulda)
|
32
|
+
--views=view_framework Specify your view framework (erb (default)/haml/builder)
|
33
|
+
|
34
|
+
The --tiny option will create no directories. Just an app.rb, a Rakefile, and a config.ru (Rackup file)
|
35
|
+
|
36
|
+
== ACKNOWLEDGEMENTS:
|
37
|
+
|
38
|
+
Big props to the Sinatra developers (http://github.com/bmizerany/sinatra/).
|
39
|
+
Also, thanks to Dr. Nic (http://github.com/drnic) for the Rubigen and Newgem libraries
|
40
|
+
|
41
|
+
== REQUIREMENTS:
|
42
|
+
|
43
|
+
To use the --vendor option, git must be installed.
|
44
|
+
To run the app without using the vendor option, the sinatra gem must be installed.
|
45
|
+
|
46
|
+
== INSTALL:
|
47
|
+
|
48
|
+
sudo gem install sintra-gen
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/sinatra-gen'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('sinatra-gen', SinatraGen::VERSION) do |p|
|
7
|
+
p.developer('Aaron Quint', 'aaron@quirkey.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message = 'PostInstall.txt'
|
10
|
+
p.rubyforge_name = "quirkey"
|
11
|
+
p.extra_deps = [
|
12
|
+
['rubigen','>= 1.3.3'],
|
13
|
+
]
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
+
]
|
17
|
+
|
18
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
19
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
20
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
21
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
25
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
26
|
+
|
27
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
28
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class SinatraAppGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
|
+
Config::CONFIG['ruby_install_name'])
|
5
|
+
|
6
|
+
default_options :author => nil
|
7
|
+
|
8
|
+
attr_accessor :app_name, :vendor, :tiny, :git, :git_init, :test_framework, :view_framework, :install_scripts
|
9
|
+
|
10
|
+
def initialize(runtime_args, runtime_options = {})
|
11
|
+
super
|
12
|
+
usage if args.empty?
|
13
|
+
@destination_root = File.expand_path(args.shift)
|
14
|
+
self.app_name = base_name
|
15
|
+
extract_options
|
16
|
+
end
|
17
|
+
|
18
|
+
def manifest
|
19
|
+
record do |m|
|
20
|
+
# Ensure appropriate folder(s) exists
|
21
|
+
m.directory ''
|
22
|
+
|
23
|
+
if git_init
|
24
|
+
`cd #{@destination_root} && #{git} init`
|
25
|
+
end
|
26
|
+
|
27
|
+
m.template 'config.ru.erb', 'config.ru'
|
28
|
+
m.template 'app.rb.erb' , 'app.rb'
|
29
|
+
m.template 'Rakefile.erb' , 'Rakefile'
|
30
|
+
|
31
|
+
unless tiny
|
32
|
+
BASEDIRS.each { |path| m.directory path }
|
33
|
+
m.template 'lib/module.rb.erb', "lib/#{app_name}.rb"
|
34
|
+
m.template 'test/test_helper.rb.erb', 'test/test_helper.rb'
|
35
|
+
m.template "test/test_app_#{test_framework}.rb.erb", "test/test_#{app_name}.rb"
|
36
|
+
m.template "views/#{view_framework}_index.erb", "views/index.#{view_framework}"
|
37
|
+
m.template "views/#{view_framework}_layout.erb", "views/layout.#{view_framework}" unless view_framework == 'builder'
|
38
|
+
end
|
39
|
+
|
40
|
+
if vendor
|
41
|
+
m.directory 'vendor'
|
42
|
+
if git_init || File.exists?(File.join(@destination_root, '.git'))
|
43
|
+
command = "cd #{@destination_root} && #{git} submodule add git://github.com/bmizerany/sinatra.git vendor/sinatra"
|
44
|
+
else
|
45
|
+
command = "cd #{@destination_root} && #{git} clone git://github.com/bmizerany/sinatra.git vendor/sinatra"
|
46
|
+
end
|
47
|
+
`#{command}`
|
48
|
+
end
|
49
|
+
|
50
|
+
if install_scripts
|
51
|
+
m.dependency "install_rubigen_scripts", [destination_root, 'sinatra-gen'], :shebang => options[:shebang], :collision => :force
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
protected
|
57
|
+
def banner
|
58
|
+
<<-EOS
|
59
|
+
Creates the skeleton for a new sinatra app
|
60
|
+
|
61
|
+
USAGE: #{spec.name} app_name
|
62
|
+
EOS
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_options!(opts)
|
66
|
+
opts.separator ''
|
67
|
+
opts.separator 'Options:'
|
68
|
+
|
69
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
70
|
+
opts.on("-d", "--vendor", "Extract the latest sinatra to vendor/sinatra") {|o| options[:vendor] = o }
|
71
|
+
opts.on("-t", "--tiny", "Only create the minimal files.") {|o| options[:tiny] = o }
|
72
|
+
opts.on("-i", "--init", "Initialize a git repository") {|o| options[:init] = o }
|
73
|
+
opts.on("-s", "--scripts", "Install the rubigen scripts (script/generate, script/destroy)") {|o| options[:scripts] = o }
|
74
|
+
opts.on("--git /path/to/git", "Specify a different path for 'git'") {|o| options[:git] = o }
|
75
|
+
opts.on("--test=test_framework", String, "Specify your testing framework (unit (default)/rspec/spec/shoulda)") {|o| options[:test_framework] = o }
|
76
|
+
opts.on("--views=view_framework", "Specify your view framework (erb (default)/haml/builder)") {|o| options[:view_framework] = o }
|
77
|
+
end
|
78
|
+
|
79
|
+
def extract_options
|
80
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
81
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
82
|
+
# raw instance variable value.
|
83
|
+
self.vendor = options[:vendor]
|
84
|
+
self.tiny = options[:tiny]
|
85
|
+
self.git = options[:git] || `which git`.strip
|
86
|
+
self.git_init = options[:init]
|
87
|
+
self.test_framework = options[:test_framework] || 'unit'
|
88
|
+
self.view_framework = options[:view_framework] || 'erb'
|
89
|
+
self.install_scripts = options[:scripts] || false
|
90
|
+
end
|
91
|
+
|
92
|
+
def klass_name
|
93
|
+
app_name.classify
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# Installation skeleton. Intermediate directories are automatically
|
98
|
+
# created so don't sweat their absence here.
|
99
|
+
BASEDIRS = %w(
|
100
|
+
lib
|
101
|
+
test
|
102
|
+
public
|
103
|
+
views
|
104
|
+
)
|
105
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
<%- if vendor -%>
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), 'vendor', 'sinatra', 'lib')
|
4
|
+
require 'sinatra'
|
5
|
+
<%- else -%>
|
6
|
+
require 'sinatra'
|
7
|
+
<%- end -%>
|
8
|
+
<%- unless tiny -%>
|
9
|
+
require File.join(File.dirname(__FILE__), 'lib', '<%= app_name %>')
|
10
|
+
|
11
|
+
set :public, 'public'
|
12
|
+
set :views, 'views'
|
13
|
+
<%- end -%>
|
14
|
+
|
15
|
+
get '/' do
|
16
|
+
<%= view_framework -%> :index
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class <%= klass_name -%>Test < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "<%= klass_name -%>" do
|
6
|
+
context "getting the index" do
|
7
|
+
setup do
|
8
|
+
get_it '/'
|
9
|
+
end
|
10
|
+
|
11
|
+
should "respond" do
|
12
|
+
assert @response.body
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
<%- if vendor -%>
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra', 'lib')
|
4
|
+
require 'sinatra'
|
5
|
+
<%- else -%>
|
6
|
+
require 'sinatra'
|
7
|
+
<%- end -%>
|
8
|
+
<%- case test_framework -%>
|
9
|
+
<%- when 'rspec' -%>
|
10
|
+
require 'spec'
|
11
|
+
require 'sinatra/test/rspec'
|
12
|
+
<%- when 'spec' -%>
|
13
|
+
require 'sinatra/test/spec'
|
14
|
+
<%- when 'shoulda' -%>
|
15
|
+
require 'sinatra/test/unit'
|
16
|
+
require 'shoulda'
|
17
|
+
<%- when 'unit' -%>
|
18
|
+
require 'sinatra/test/unit'
|
19
|
+
<%- end -%>
|
20
|
+
require File.join(File.dirname(__FILE__), '..', 'app.rb')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
|
8
|
+
<title><%= app_name %></title>
|
9
|
+
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
data/bin/sinatra-gen
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require 'sinatra-gen'
|
8
|
+
puts "#{File.basename($0)} #{SinatraGen::VERSION}"
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
source = RubiGen::PathSource.new(:application,
|
14
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
+
RubiGen::Base.reset_sources
|
16
|
+
RubiGen::Base.append_sources source
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'sinatra_app')
|
data/lib/sinatra-gen.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
|
+
rescue LoadError
|
4
|
+
require 'test/unit'
|
5
|
+
end
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
# Must set before requiring generator libs.
|
9
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
10
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
11
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
12
|
+
if defined?(APP_ROOT)
|
13
|
+
APP_ROOT.replace(app_root)
|
14
|
+
else
|
15
|
+
APP_ROOT = app_root
|
16
|
+
end
|
17
|
+
if defined?(RAILS_ROOT)
|
18
|
+
RAILS_ROOT.replace(app_root)
|
19
|
+
else
|
20
|
+
RAILS_ROOT = app_root
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'rubigen'
|
25
|
+
rescue LoadError
|
26
|
+
require 'rubygems'
|
27
|
+
require 'rubigen'
|
28
|
+
end
|
29
|
+
require 'rubigen/helpers/generator_test_helper'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
class TestSinatraAppGenerator < Test::Unit::TestCase
|
4
|
+
include RubiGen::GeneratorTestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
bare_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
bare_teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
# Some generator-related assertions:
|
15
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
16
|
+
# assert_directory_exists(name)
|
17
|
+
# assert_generated_class(name, &block)
|
18
|
+
# assert_generated_module(name, &block)
|
19
|
+
# assert_generated_test_for(name, &block)
|
20
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
21
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
22
|
+
#
|
23
|
+
# Other helper methods are:
|
24
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
25
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
26
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
27
|
+
|
28
|
+
def test_generate_app_without_options
|
29
|
+
run_generator('sinatra_app', [APP_ROOT], sources)
|
30
|
+
assert_basic_paths_and_files
|
31
|
+
assert_generated_file 'views/layout.erb'
|
32
|
+
assert_generated_file 'views/index.erb'
|
33
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
34
|
+
assert_match(/def test/, test_contents)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_generate_app_with_vendor_option
|
39
|
+
run_generator('sinatra_app', [APP_ROOT, '--vendor'], sources)
|
40
|
+
assert_basic_paths_and_files
|
41
|
+
assert_directory_exists 'vendor/sinatra/lib'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_generate_app_with_tiny_option
|
45
|
+
run_generator('sinatra_app', [APP_ROOT, '--tiny'], sources)
|
46
|
+
assert_generated_file 'config.ru'
|
47
|
+
assert_generated_file 'app.rb'
|
48
|
+
assert_generated_file 'Rakefile'
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_generate_app_with_init_option
|
52
|
+
run_generator('sinatra_app', [APP_ROOT, '-i'], sources)
|
53
|
+
assert_basic_paths_and_files
|
54
|
+
assert_directory_exists '.git'
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_generate_app_with_rspect_test_option
|
58
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=rspec'], sources)
|
59
|
+
assert_basic_paths_and_files
|
60
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
61
|
+
assert_match(/sinatra\/test\/rspec/, helper_contents)
|
62
|
+
end
|
63
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
64
|
+
assert_match(/describe/, test_contents)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_generate_app_with_spec_test_option
|
69
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=spec'], sources)
|
70
|
+
assert_basic_paths_and_files
|
71
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
72
|
+
assert_match(/sinatra\/test\/spec/, helper_contents)
|
73
|
+
end
|
74
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
75
|
+
assert_match(/describe/, test_contents)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_generate_app_with_shoulda_test_option
|
80
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=shoulda'], sources)
|
81
|
+
assert_basic_paths_and_files
|
82
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
83
|
+
assert_match(/sinatra\/test\/unit/, helper_contents)
|
84
|
+
assert_match(/shoulda/, helper_contents)
|
85
|
+
end
|
86
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
87
|
+
assert_match(/context/, test_contents)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_generate_app_with_test_unit_option
|
92
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=unit'], sources)
|
93
|
+
assert_basic_paths_and_files
|
94
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
95
|
+
assert_match(/sinatra\/test\/unit/, helper_contents)
|
96
|
+
end
|
97
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
98
|
+
assert_match(/def test/, test_contents)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_generate_app_with_views_haml_option
|
103
|
+
run_generator('sinatra_app', [APP_ROOT, '--views=erb'], sources)
|
104
|
+
assert_basic_paths_and_files
|
105
|
+
assert_generated_file 'app.rb' do |app_contents|
|
106
|
+
assert_match(/erb \:index/, app_contents)
|
107
|
+
end
|
108
|
+
assert_generated_file 'views/layout.erb'
|
109
|
+
assert_generated_file 'views/index.erb'
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_generate_app_with_views_haml_option
|
113
|
+
run_generator('sinatra_app', [APP_ROOT, '--views=haml'], sources)
|
114
|
+
assert_basic_paths_and_files
|
115
|
+
assert_generated_file 'app.rb' do |app_contents|
|
116
|
+
assert_match(/haml \:index/, app_contents)
|
117
|
+
end
|
118
|
+
assert_generated_file 'views/layout.haml'
|
119
|
+
assert_generated_file 'views/index.haml'
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_generate_app_with_views_builder_option
|
123
|
+
run_generator('sinatra_app', [APP_ROOT, '--views=builder'], sources)
|
124
|
+
assert_basic_paths_and_files
|
125
|
+
assert_generated_file 'app.rb' do |app_contents|
|
126
|
+
assert_match(/builder \:index/, app_contents)
|
127
|
+
end
|
128
|
+
assert_generated_file 'views/index.builder'
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_generate_app_with_scripts_option
|
132
|
+
run_generator('sinatra_app', [APP_ROOT, '--scripts'], sources)
|
133
|
+
assert_basic_paths_and_files
|
134
|
+
assert_directory_exists 'script'
|
135
|
+
assert_generated_file 'script/destroy'
|
136
|
+
assert_generated_file 'script/generate'
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
def assert_basic_paths_and_files
|
141
|
+
assert_directory_exists 'lib'
|
142
|
+
assert_directory_exists 'test'
|
143
|
+
assert_directory_exists 'public'
|
144
|
+
assert_directory_exists 'views'
|
145
|
+
assert_generated_file 'config.ru'
|
146
|
+
assert_generated_file 'app.rb'
|
147
|
+
assert_generated_file 'Rakefile'
|
148
|
+
assert_generated_module "lib/#{app_name}"
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
def sources
|
153
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))]
|
154
|
+
end
|
155
|
+
|
156
|
+
def app_name
|
157
|
+
File.basename(APP_ROOT)
|
158
|
+
end
|
159
|
+
|
160
|
+
def generator_path
|
161
|
+
"app_generators"
|
162
|
+
end
|
163
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-gen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Quint
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-13 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rubigen
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.3.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: newgem
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: hoe
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.0
|
44
|
+
version:
|
45
|
+
description: sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework. For more information on sinatra, check out http://sinatra.rubyforge.org
|
46
|
+
email:
|
47
|
+
- aaron@quirkey.com
|
48
|
+
executables:
|
49
|
+
- sinatra-gen
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
- PostInstall.txt
|
56
|
+
- README.rdoc
|
57
|
+
files:
|
58
|
+
- History.txt
|
59
|
+
- Manifest.txt
|
60
|
+
- PostInstall.txt
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- app_generators/sinatra_app/USAGE
|
64
|
+
- app_generators/sinatra_app/sinatra_app_generator.rb
|
65
|
+
- app_generators/sinatra_app/templates/Rakefile.erb
|
66
|
+
- app_generators/sinatra_app/templates/app.rb.erb
|
67
|
+
- app_generators/sinatra_app/templates/config.ru.erb
|
68
|
+
- app_generators/sinatra_app/templates/lib/module.rb.erb
|
69
|
+
- app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb
|
70
|
+
- app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb
|
71
|
+
- app_generators/sinatra_app/templates/test/test_app_spec.rb.erb
|
72
|
+
- app_generators/sinatra_app/templates/test/test_app_unit.rb.erb
|
73
|
+
- app_generators/sinatra_app/templates/test/test_helper.rb.erb
|
74
|
+
- app_generators/sinatra_app/templates/views/builder_index.erb
|
75
|
+
- app_generators/sinatra_app/templates/views/erb_index.erb
|
76
|
+
- app_generators/sinatra_app/templates/views/erb_layout.erb
|
77
|
+
- app_generators/sinatra_app/templates/views/haml_index.erb
|
78
|
+
- app_generators/sinatra_app/templates/views/haml_layout.erb
|
79
|
+
- bin/sinatra-gen
|
80
|
+
- lib/sinatra-gen.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: http://github.com/quirkey/sinatra-gen
|
83
|
+
post_install_message: PostInstall.txt
|
84
|
+
rdoc_options:
|
85
|
+
- --main
|
86
|
+
- README.rdoc
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: "0"
|
94
|
+
version:
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: "0"
|
100
|
+
version:
|
101
|
+
requirements: []
|
102
|
+
|
103
|
+
rubyforge_project: quirkey
|
104
|
+
rubygems_version: 1.3.1
|
105
|
+
signing_key:
|
106
|
+
specification_version: 2
|
107
|
+
summary: sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework
|
108
|
+
test_files:
|
109
|
+
- test/test_generator_helper.rb
|
110
|
+
- test/test_helper.rb
|
111
|
+
- test/test_sinatra_app_generator.rb
|