vanntastic-sinatra-gen 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +25 -0
- data/Manifest.txt +29 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +158 -0
- data/Rakefile +28 -0
- data/app_generators/sinatra_app/USAGE +8 -0
- data/app_generators/sinatra_app/sinatra_app_generator.rb +135 -0
- data/app_generators/sinatra_app/templates/Capfile +3 -0
- data/app_generators/sinatra_app/templates/Rakefile.erb +4 -0
- data/app_generators/sinatra_app/templates/app.rb.erb +28 -0
- data/app_generators/sinatra_app/templates/config.ru.erb +8 -0
- data/app_generators/sinatra_app/templates/config.yml +1 -0
- data/app_generators/sinatra_app/templates/config/deploy.rb.erb +13 -0
- data/app_generators/sinatra_app/templates/lib/app_helper.rb.erb +96 -0
- data/app_generators/sinatra_app/templates/lib/module.rb.erb +3 -0
- data/app_generators/sinatra_app/templates/test/test_app_bacon.rb.erb +20 -0
- data/app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb +19 -0
- data/app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb +32 -0
- data/app_generators/sinatra_app/templates/test/test_app_spec.rb.erb +20 -0
- data/app_generators/sinatra_app/templates/test/test_app_unit.rb.erb +18 -0
- data/app_generators/sinatra_app/templates/test/test_helper.rb.erb +21 -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/sinatra-gen.gemspec +45 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +3 -0
- data/test/test_sinatra_app_generator.rb +194 -0
- metadata +122 -0
data/History.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
== 0.2.1 2009-02-10
|
|
2
|
+
|
|
3
|
+
* Updated tests and templates for Sinatra 0.9
|
|
4
|
+
* Added support for test/bacon
|
|
5
|
+
* Fixed errors with latest rubigen where git commands were happening before file generation
|
|
6
|
+
* Updated rubigen dependency
|
|
7
|
+
|
|
8
|
+
== 0.2.0 2008-12-23
|
|
9
|
+
|
|
10
|
+
* 1 major enhancement
|
|
11
|
+
* application actions can now be specified
|
|
12
|
+
on the command line. See README for more info.
|
|
13
|
+
|
|
14
|
+
== 0.1.1 2008-12-16
|
|
15
|
+
|
|
16
|
+
* 1 major enhancement
|
|
17
|
+
* added --cap option for generating capistrano recipe
|
|
18
|
+
* 1 minor enhancement
|
|
19
|
+
* added empty config.yml on generation
|
|
20
|
+
|
|
21
|
+
== 0.1.0 2008-12-13
|
|
22
|
+
|
|
23
|
+
* 1 major enhancement:
|
|
24
|
+
* Initial release
|
|
25
|
+
* See README.rdoc for more info
|
data/Manifest.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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/Capfile
|
|
9
|
+
app_generators/sinatra_app/templates/Rakefile.erb
|
|
10
|
+
app_generators/sinatra_app/templates/app.rb.erb
|
|
11
|
+
app_generators/sinatra_app/templates/config.ru.erb
|
|
12
|
+
app_generators/sinatra_app/templates/config.yml
|
|
13
|
+
app_generators/sinatra_app/templates/config/deploy.rb.erb
|
|
14
|
+
app_generators/sinatra_app/templates/lib/module.rb.erb
|
|
15
|
+
app_generators/sinatra_app/templates/lib/app_helper.rb.erb
|
|
16
|
+
app_generators/sinatra_app/templates/test/test_app_bacon.rb.erb
|
|
17
|
+
app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb
|
|
18
|
+
app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb
|
|
19
|
+
app_generators/sinatra_app/templates/test/test_app_spec.rb.erb
|
|
20
|
+
app_generators/sinatra_app/templates/test/test_app_unit.rb.erb
|
|
21
|
+
app_generators/sinatra_app/templates/test/test_helper.rb.erb
|
|
22
|
+
app_generators/sinatra_app/templates/views/builder_index.erb
|
|
23
|
+
app_generators/sinatra_app/templates/views/erb_index.erb
|
|
24
|
+
app_generators/sinatra_app/templates/views/erb_layout.erb
|
|
25
|
+
app_generators/sinatra_app/templates/views/haml_index.erb
|
|
26
|
+
app_generators/sinatra_app/templates/views/haml_layout.erb
|
|
27
|
+
bin/sinatra-gen
|
|
28
|
+
lib/sinatra-gen.rb
|
|
29
|
+
sinatra-gen.gemspec
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
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://sinatrarb.com
|
|
9
|
+
|
|
10
|
+
!! NOW WITH SUPPORT FOR SINATRA 0.9 (02/10/09)
|
|
11
|
+
|
|
12
|
+
== SYNOPSIS:
|
|
13
|
+
|
|
14
|
+
sinatra-gen has a bunch of different options (based loosley on merb-gen) to try to not lock the
|
|
15
|
+
user into any specific frameworks/dev practices.
|
|
16
|
+
|
|
17
|
+
Run:
|
|
18
|
+
|
|
19
|
+
sinatra-gen [appname] [actions] [options]
|
|
20
|
+
|
|
21
|
+
e.g.
|
|
22
|
+
|
|
23
|
+
sinatra-gen mysinatrapp get:/ post:/:id --vendor --init --test=shoulda --views=haml
|
|
24
|
+
|
|
25
|
+
=== Actions
|
|
26
|
+
|
|
27
|
+
!! NEW as of 0.2.0 (12/23/08)
|
|
28
|
+
|
|
29
|
+
For even faster app development you specify actions to include in your app when generating.
|
|
30
|
+
Actions are written out as
|
|
31
|
+
|
|
32
|
+
http_method:path
|
|
33
|
+
|
|
34
|
+
And are seperated by spaces. For example:
|
|
35
|
+
|
|
36
|
+
get:/ post:/:id put:/update/*
|
|
37
|
+
|
|
38
|
+
Will be added you your app as:
|
|
39
|
+
|
|
40
|
+
get '/' do
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
post '/:id' do
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
put '/update/*' do
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
It will also generate test skeletons in the test framework of your choosing.
|
|
50
|
+
|
|
51
|
+
=== Options
|
|
52
|
+
|
|
53
|
+
(can also be obtained by running sinatra-gen with no arguments):
|
|
54
|
+
|
|
55
|
+
-v, --version Show the sinatra-gen version number and quit.
|
|
56
|
+
-d, --vendor Extract the latest sinatra to vendor/sinatra
|
|
57
|
+
--tiny Only create the minimal files.
|
|
58
|
+
--init Initialize a git repository
|
|
59
|
+
--cap Adds config directory with basic capistrano deploy.rb
|
|
60
|
+
--scripts Install the rubigen scripts (script/generate, script/destroy)
|
|
61
|
+
--git /path/to/git Specify a different path for 'git'
|
|
62
|
+
--test=test_framework Specify your testing framework (unit (default)/rspec/spec/shoulda/bacon)
|
|
63
|
+
--views=view_framework Specify your view framework (erb (default)/haml/builder)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
The --tiny option will create no directories. Just an app.rb, a Rakefile, and a config.ru (Rackup file)
|
|
67
|
+
|
|
68
|
+
== ERB Helpers:
|
|
69
|
+
|
|
70
|
+
Miss some of the erb helpers from ActionView? I've included some helpers that can help:
|
|
71
|
+
|
|
72
|
+
- image
|
|
73
|
+
Creates an img tag, very similar to rails' image_tag.
|
|
74
|
+
|
|
75
|
+
image src, options={}
|
|
76
|
+
|
|
77
|
+
EX:
|
|
78
|
+
|
|
79
|
+
image 'your_image.jpg', :title => "Your Image"
|
|
80
|
+
# => <img src='images/your_image.jpg' title='Your Image' />
|
|
81
|
+
|
|
82
|
+
- link_css
|
|
83
|
+
Creates a css link tag for a css file in the public/css directory, very similar to rails' stylesheet_link_tag
|
|
84
|
+
|
|
85
|
+
link_css srcs, options={}
|
|
86
|
+
|
|
87
|
+
EX:
|
|
88
|
+
|
|
89
|
+
# link to a single stylesheet
|
|
90
|
+
link_css 'app'
|
|
91
|
+
# => <link rel="stylesheet" href="/css/app.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
|
92
|
+
# link to multiple stylesheets
|
|
93
|
+
link_css "app, print"
|
|
94
|
+
|
|
95
|
+
- link_js
|
|
96
|
+
Creates a script tag for a javascript file in the public/js directory, similar to rails' javascript_include_tag
|
|
97
|
+
|
|
98
|
+
link_js srcs, options={}
|
|
99
|
+
|
|
100
|
+
EX:
|
|
101
|
+
|
|
102
|
+
# link to a single js file
|
|
103
|
+
link_js 'app'
|
|
104
|
+
# link to multiple js files
|
|
105
|
+
link_js 'jquery,app'
|
|
106
|
+
|
|
107
|
+
- link
|
|
108
|
+
Creates an anchor tag, similar to rails' link_to
|
|
109
|
+
|
|
110
|
+
link content, options={}
|
|
111
|
+
|
|
112
|
+
EX:
|
|
113
|
+
|
|
114
|
+
# link to google
|
|
115
|
+
link "Google", "http://google.com"
|
|
116
|
+
|
|
117
|
+
- tag
|
|
118
|
+
Creates an opening and closing html tag, similar to rails' content_tag
|
|
119
|
+
|
|
120
|
+
tag name, content, options={}
|
|
121
|
+
|
|
122
|
+
EX:
|
|
123
|
+
|
|
124
|
+
# create a header tag
|
|
125
|
+
tag :h1, "Shizam", :title => "Shizam"
|
|
126
|
+
# => <h1 title="Shizam">Shizam</h1>
|
|
127
|
+
|
|
128
|
+
- single_tag
|
|
129
|
+
Creates a single closing html tag, like img tags and link tags
|
|
130
|
+
|
|
131
|
+
single_tag name, options
|
|
132
|
+
|
|
133
|
+
EX:
|
|
134
|
+
|
|
135
|
+
# create an img tag
|
|
136
|
+
single_tag :img, :src => "my_img.jpg"
|
|
137
|
+
# => <img src="my_img.jpg" />
|
|
138
|
+
|
|
139
|
+
== ACKNOWLEDGEMENTS:
|
|
140
|
+
|
|
141
|
+
Big props to the Sinatra developers (http://github.com/bmizerany/sinatra/).
|
|
142
|
+
Also, thanks to Dr. Nic (http://github.com/drnic) for the Rubigen and Newgem libraries
|
|
143
|
+
|
|
144
|
+
== REQUIREMENTS:
|
|
145
|
+
|
|
146
|
+
To use the --vendor option, git must be installed.
|
|
147
|
+
To run the app without using the vendor option, the sinatra gem must be installed.
|
|
148
|
+
If you want to use the erb helpers, activesupport must be installed.
|
|
149
|
+
|
|
150
|
+
== INSTALL:
|
|
151
|
+
|
|
152
|
+
sudo gem install sinatra-gen
|
|
153
|
+
#or to install the ones with erb helpers
|
|
154
|
+
sudo gem install vanntastic-sinatra-gen -s http://gems.github.com
|
|
155
|
+
|
|
156
|
+
You can also install directly from github:
|
|
157
|
+
|
|
158
|
+
sudo gem install quirkey-sinatra-gen -s http://gems.github.com
|
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' # TODO remove if post-install message not required
|
|
10
|
+
p.rubyforge_name = 'quirkey'
|
|
11
|
+
p.extra_deps = [
|
|
12
|
+
['rubigen','>= 1.5.2'],
|
|
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,135 @@
|
|
|
1
|
+
class RubiGen::Commands::Create
|
|
2
|
+
|
|
3
|
+
def run(command, relative_path = '')
|
|
4
|
+
in_directory = destination_path(relative_path)
|
|
5
|
+
logger.run command
|
|
6
|
+
system("cd #{in_directory} && #{command}")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SinatraAppGenerator < RubiGen::Base
|
|
13
|
+
|
|
14
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
|
15
|
+
Config::CONFIG['ruby_install_name'])
|
|
16
|
+
|
|
17
|
+
SINATRA_GIT_URL = 'git://github.com/sinatra/sinatra.git'
|
|
18
|
+
|
|
19
|
+
default_options :author => nil
|
|
20
|
+
|
|
21
|
+
attr_accessor :app_name, :vendor, :tiny, :git, :git_init, :test_framework, :view_framework, :install_scripts, :cap, :actions
|
|
22
|
+
|
|
23
|
+
def initialize(runtime_args, runtime_options = {})
|
|
24
|
+
super
|
|
25
|
+
usage if args.empty?
|
|
26
|
+
@destination_root = File.expand_path(args.shift)
|
|
27
|
+
self.app_name = base_name
|
|
28
|
+
extract_options
|
|
29
|
+
parse_actions(args)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def manifest
|
|
33
|
+
record do |m|
|
|
34
|
+
# Ensure appropriate folder(s) exists
|
|
35
|
+
m.directory ''
|
|
36
|
+
|
|
37
|
+
if git_init
|
|
38
|
+
m.run("#{git} init")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
m.template 'config.ru.erb', 'config.ru'
|
|
42
|
+
m.template 'app.rb.erb' , "#{app_name}.rb"
|
|
43
|
+
m.template 'Rakefile.erb' , 'Rakefile'
|
|
44
|
+
|
|
45
|
+
unless tiny
|
|
46
|
+
BASEDIRS.each { |path| m.directory path }
|
|
47
|
+
m.file 'config.yml', 'config.yml'
|
|
48
|
+
m.template 'lib/module.rb.erb', "lib/#{app_name}.rb"
|
|
49
|
+
m.template 'lib/app_helper.rb.erb', 'lib/app_helper.rb'
|
|
50
|
+
m.template 'test/test_helper.rb.erb', 'test/test_helper.rb'
|
|
51
|
+
m.template "test/test_app_#{test_framework}.rb.erb", "test/test_#{app_name}.rb"
|
|
52
|
+
m.template "views/#{view_framework}_index.erb", "views/index.#{view_framework}"
|
|
53
|
+
m.template "views/#{view_framework}_layout.erb", "views/layout.#{view_framework}" unless view_framework == 'builder'
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if vendor
|
|
57
|
+
m.directory 'vendor'
|
|
58
|
+
if git_init || File.exists?(File.join(@destination_root, '.git'))
|
|
59
|
+
command = "#{git} submodule add #{SINATRA_GIT_URL} vendor/sinatra"
|
|
60
|
+
else
|
|
61
|
+
command = "#{git} clone #{SINATRA_GIT_URL} vendor/sinatra"
|
|
62
|
+
end
|
|
63
|
+
m.run(command)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if cap
|
|
67
|
+
m.directory 'config'
|
|
68
|
+
m.file 'Capfile', 'Capfile'
|
|
69
|
+
m.template 'config/deploy.rb.erb', 'config/deploy.rb'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
if install_scripts
|
|
73
|
+
m.dependency "install_rubigen_scripts", [destination_root, 'sinatra-gen'], :shebang => options[:shebang], :collision => :force
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
protected
|
|
79
|
+
def banner
|
|
80
|
+
<<-EOS
|
|
81
|
+
Creates the skeleton for a new sinatra app
|
|
82
|
+
|
|
83
|
+
USAGE: #{spec.name} app_name
|
|
84
|
+
EOS
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def add_options!(opts)
|
|
88
|
+
opts.separator ''
|
|
89
|
+
opts.separator 'Options:'
|
|
90
|
+
|
|
91
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
|
92
|
+
opts.on("-d", "--vendor", "Extract the latest sinatra to vendor/sinatra") {|o| options[:vendor] = o }
|
|
93
|
+
opts.on("--tiny", "Only create the minimal files.") {|o| options[:tiny] = o }
|
|
94
|
+
opts.on("--init", "Initialize a git repository") {|o| options[:init] = o }
|
|
95
|
+
opts.on("--cap", "Adds config directory with basic capistrano deploy.rb") {|o| options[:cap] = o }
|
|
96
|
+
opts.on("--scripts", "Install the rubigen scripts (script/generate, script/destroy)") {|o| options[:scripts] = o }
|
|
97
|
+
opts.on("--git /path/to/git", "Specify a different path for 'git'") {|o| options[:git] = o }
|
|
98
|
+
opts.on("--test=test_framework", String, "Specify your testing framework (unit (default)/rspec/spec/shoulda/bacon)") {|o| options[:test_framework] = o }
|
|
99
|
+
opts.on("--views=view_framework", "Specify your view framework (erb (default)/haml/builder)") {|o| options[:view_framework] = o }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def extract_options
|
|
103
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
|
104
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
|
105
|
+
# raw instance variable value.
|
|
106
|
+
self.vendor = options[:vendor]
|
|
107
|
+
self.tiny = options[:tiny]
|
|
108
|
+
self.cap = options[:cap]
|
|
109
|
+
self.git = options[:git] || `which git`.strip
|
|
110
|
+
self.git_init = options[:init] || false
|
|
111
|
+
self.test_framework = options[:test_framework] || 'unit'
|
|
112
|
+
self.view_framework = options[:view_framework] || 'erb'
|
|
113
|
+
self.install_scripts = options[:scripts] || false
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def klass_name
|
|
117
|
+
app_name.classify
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def parse_actions(*action_args)
|
|
121
|
+
@actions = action_args.flatten.collect { |a| a.split(':', 2) }
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Installation skeleton. Intermediate directories are automatically
|
|
125
|
+
# created so don't sweat their absence here.
|
|
126
|
+
BASEDIRS = %w(
|
|
127
|
+
lib
|
|
128
|
+
test
|
|
129
|
+
public
|
|
130
|
+
public/js
|
|
131
|
+
public/css
|
|
132
|
+
public/images
|
|
133
|
+
views
|
|
134
|
+
)
|
|
135
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
require 'activesupport'
|
|
9
|
+
|
|
10
|
+
<%- unless tiny -%>
|
|
11
|
+
require File.join(File.dirname(__FILE__), 'lib', '<%= app_name %>')
|
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'app_helper')
|
|
13
|
+
|
|
14
|
+
set :public, 'public'
|
|
15
|
+
set :views, 'views'
|
|
16
|
+
<%- end -%>
|
|
17
|
+
|
|
18
|
+
<%- unless actions.empty? -%>
|
|
19
|
+
<%- actions.each do |meth, path| -%>
|
|
20
|
+
<%= meth %> '<%= path %>' do
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
<%- end -%>
|
|
24
|
+
<%- else -%>
|
|
25
|
+
get '/' do
|
|
26
|
+
<%= view_framework -%> :index
|
|
27
|
+
end
|
|
28
|
+
<%- end -%>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
---
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
set :application, "<%= app_name %>"
|
|
2
|
+
set :deploy_via, :remote_cache
|
|
3
|
+
set :user, 'SERVER_USER_NAME'
|
|
4
|
+
set :runner, user
|
|
5
|
+
|
|
6
|
+
set :scm, :git
|
|
7
|
+
set :repository, "git@github.com:GITHUB_USER_NAME/#{application}.git"
|
|
8
|
+
set :branch, 'master'
|
|
9
|
+
set :git_enable_submodules, 1
|
|
10
|
+
set :keep_releases, 3
|
|
11
|
+
set :deploy_to, "/var/www/apps/#{application}"
|
|
12
|
+
|
|
13
|
+
server "YOUR_DOMAIN", :web, :app, :db, :primary => true
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module AppHelper
|
|
2
|
+
|
|
3
|
+
helpers do
|
|
4
|
+
|
|
5
|
+
# helper for image_tags
|
|
6
|
+
# EX : image 'logo.jpg'
|
|
7
|
+
# => <img src="images/logo.jpg" />
|
|
8
|
+
def image(src,options={})
|
|
9
|
+
options[:src] = "/images/#{src}"
|
|
10
|
+
single_tag(:img, options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# css link helper
|
|
14
|
+
# EX : link_css 'default'
|
|
15
|
+
# => <link rel="stylesheet" href="/css/default.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
|
16
|
+
def link_css(srcs,options={})
|
|
17
|
+
srcs_length = srcs.split(",").length
|
|
18
|
+
options[:media] ||= "screen"
|
|
19
|
+
options[:type] ||= "text/css"
|
|
20
|
+
options[:rel] ||= "stylesheet"
|
|
21
|
+
content = ""
|
|
22
|
+
if srcs_length == 1
|
|
23
|
+
options[:href] = "/css/#{srcs}.css"
|
|
24
|
+
content = single_tag(:link, options)
|
|
25
|
+
else
|
|
26
|
+
srcs.split(",").each do |src|
|
|
27
|
+
options[:href] = "/css/#{src}.css"
|
|
28
|
+
content << single_tag(:link, options)
|
|
29
|
+
content << "\n"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
content
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# js link helper
|
|
36
|
+
# EX : link_js 'app'
|
|
37
|
+
# => <script src="/js/app.js" type="text/javascript" />
|
|
38
|
+
# EX : link_js "app,jquery"
|
|
39
|
+
# => <script src="/js/app.js" type="text/javascript" />
|
|
40
|
+
# => <script src="/js/jquery.js" type="text/javascript" />
|
|
41
|
+
def link_js(srcs,options={})
|
|
42
|
+
srcs_length = srcs.split(",").length
|
|
43
|
+
content = ""
|
|
44
|
+
if srcs_length == 1
|
|
45
|
+
content = single_tag(:script, :src => "/js/#{srcs}.js",
|
|
46
|
+
:type => "text/javascript")
|
|
47
|
+
else
|
|
48
|
+
srcs.split(",").each do |src|
|
|
49
|
+
content << single_tag(:script, :src => "/js/#{src}.js",
|
|
50
|
+
:type => "text/javascript")
|
|
51
|
+
content << "\n"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
content
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# standard anchor links, like rails' link_to
|
|
58
|
+
# EX : link "google", "http://google.com"
|
|
59
|
+
# => <a href="http://google.com">google</a>
|
|
60
|
+
def link(content,href,options={})
|
|
61
|
+
options.update :href => href
|
|
62
|
+
tag :a, content, options
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# standard open and close tags
|
|
66
|
+
# EX : tag :h1, "shizam", :title => "shizam"
|
|
67
|
+
# => <h1 title="shizam">shizam</h1>
|
|
68
|
+
def tag(name,content,options={})
|
|
69
|
+
with_opts = "<#{name.to_s} #{options.to_html_attrs}>#{content}</#{name}>"
|
|
70
|
+
no_opts = "<#{name.to_s}>#{content}</#{name}>"
|
|
71
|
+
options.blank? ? no_opts : with_opts
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# standard single closing tags
|
|
75
|
+
# single_tag :img, :src => "images/google.jpg"
|
|
76
|
+
# => <img src="images/google.jpg" />
|
|
77
|
+
def single_tag(name,options={})
|
|
78
|
+
options ||= options.stringify_keys
|
|
79
|
+
"<#{name.to_s} #{options.to_html_attrs} />"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Hash
|
|
87
|
+
|
|
88
|
+
def to_html_attrs
|
|
89
|
+
html_attrs = ""
|
|
90
|
+
self.stringify_keys.each do |key, val|
|
|
91
|
+
html_attrs << "#{key}='#{val}' "
|
|
92
|
+
end
|
|
93
|
+
html_attrs.chop
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe '<%= klass_name %>' do
|
|
4
|
+
|
|
5
|
+
<%- unless actions.empty? -%>
|
|
6
|
+
<% actions.each do |meth, path| %>
|
|
7
|
+
it 'should <%= meth %> <%= path %>' do
|
|
8
|
+
<%= meth %> '<%= path %>'
|
|
9
|
+
should.be.ok
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
<%- end -%>
|
|
13
|
+
<%- else -%>
|
|
14
|
+
it 'should load the index' do
|
|
15
|
+
get '/'
|
|
16
|
+
should.be.ok
|
|
17
|
+
end
|
|
18
|
+
<%- end -%>
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe '<%= klass_name %>' do
|
|
4
|
+
|
|
5
|
+
<%- unless actions.empty? -%>
|
|
6
|
+
<% actions.each do |meth, path| %>
|
|
7
|
+
it 'should <%= meth %> <%= path %>' do
|
|
8
|
+
<%= meth %> '<%= path %>'
|
|
9
|
+
@response.should be_ok
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
<%- end -%>
|
|
13
|
+
<%- else -%>
|
|
14
|
+
it 'should load the index' do
|
|
15
|
+
get '/'
|
|
16
|
+
@response.should be_ok
|
|
17
|
+
end
|
|
18
|
+
<%- end -%>
|
|
19
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= klass_name -%>Test < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
context "<%= klass_name -%>" do
|
|
6
|
+
<%- unless actions.empty? -%>
|
|
7
|
+
<% actions.each do |meth, path| %>
|
|
8
|
+
context "<%= meth %> <%= path %>" do
|
|
9
|
+
setup do
|
|
10
|
+
<%= meth %> '<%= path %>'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
should "respond" do
|
|
14
|
+
assert @response.body
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
<%- end -%>
|
|
19
|
+
<%- else -%>
|
|
20
|
+
context "getting the index" do
|
|
21
|
+
setup do
|
|
22
|
+
get '/'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "respond" do
|
|
26
|
+
assert @response.body
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
<%- end -%>
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe '<%= klass_name %>' do
|
|
4
|
+
|
|
5
|
+
<%- unless actions.empty? -%>
|
|
6
|
+
<% actions.each do |meth, path| %>
|
|
7
|
+
it 'should <%= meth %> <%= path %>' do
|
|
8
|
+
<%= meth %> '<%= path %>'
|
|
9
|
+
should.be.ok
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
<%- end -%>
|
|
13
|
+
<%- else -%>
|
|
14
|
+
it 'should load the index' do
|
|
15
|
+
get '/'
|
|
16
|
+
should.be.ok
|
|
17
|
+
end
|
|
18
|
+
<%- end -%>
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class <%= klass_name -%>Test < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
<%- unless actions.empty? -%>
|
|
6
|
+
<% actions.each do |meth, path| %>
|
|
7
|
+
def test_<%= meth %>_<%= path.to_s.gsub(/[^a-z0-9\_]/, '') %>_should
|
|
8
|
+
<%= meth %> '<%= path %>'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
<%- end -%>
|
|
12
|
+
<%- else -%>
|
|
13
|
+
def test_my_default
|
|
14
|
+
get '/'
|
|
15
|
+
end
|
|
16
|
+
<%- end -%>
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%- if vendor -%>
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'vendor', 'sinatra', 'lib')
|
|
3
|
+
require 'sinatra'
|
|
4
|
+
<%- else -%>
|
|
5
|
+
require 'sinatra'
|
|
6
|
+
<%- end -%>
|
|
7
|
+
<%- case test_framework -%>
|
|
8
|
+
<%- when 'rspec' -%>
|
|
9
|
+
require 'spec'
|
|
10
|
+
require 'sinatra/test/rspec'
|
|
11
|
+
<%- when 'bacon' -%>
|
|
12
|
+
require 'sinatra/test/bacon'
|
|
13
|
+
<%- when 'spec' -%>
|
|
14
|
+
require 'sinatra/test/spec'
|
|
15
|
+
<%- when 'shoulda' -%>
|
|
16
|
+
require 'sinatra/test/unit'
|
|
17
|
+
require 'shoulda'
|
|
18
|
+
<%- when 'unit' -%>
|
|
19
|
+
require 'sinatra/test/unit'
|
|
20
|
+
<%- end -%>
|
|
21
|
+
require File.join(File.dirname(__FILE__), '..', '<%= app_name %>.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 File.join(File.dirname(__FILE__), '..', 'lib', '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
data/sinatra-gen.gemspec
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{sinatra-gen}
|
|
5
|
+
s.version = "0.2.2"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["Aaron Quint","Vann Ek"]
|
|
9
|
+
s.date = %q{2009-03-25}
|
|
10
|
+
s.default_executable = %q{sinatra-gen}
|
|
11
|
+
s.description = %q{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://sinatrarb.com !! NOW WITH SUPPORT FOR SINATRA 0.9 (02/10/09)}
|
|
12
|
+
s.email = ["aaron@quirkey.com","ek.vann@gmail.com"]
|
|
13
|
+
s.executables = ["sinatra-gen"]
|
|
14
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
|
15
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "app_generators/sinatra_app/USAGE", "app_generators/sinatra_app/sinatra_app_generator.rb", "app_generators/sinatra_app/templates/Capfile", "app_generators/sinatra_app/templates/Rakefile.erb", "app_generators/sinatra_app/templates/app.rb.erb", "app_generators/sinatra_app/templates/config.ru.erb", "app_generators/sinatra_app/templates/config.yml", "app_generators/sinatra_app/templates/config/deploy.rb.erb", "app_generators/sinatra_app/templates/lib/module.rb.erb",
|
|
16
|
+
"app_generators/sinatra_app/templates/lib/app_helper.rb.erb", "app_generators/sinatra_app/templates/test/test_app_bacon.rb.erb", "app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb", "app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb", "app_generators/sinatra_app/templates/test/test_app_spec.rb.erb", "app_generators/sinatra_app/templates/test/test_app_unit.rb.erb", "app_generators/sinatra_app/templates/test/test_helper.rb.erb", "app_generators/sinatra_app/templates/views/builder_index.erb", "app_generators/sinatra_app/templates/views/erb_index.erb", "app_generators/sinatra_app/templates/views/erb_layout.erb", "app_generators/sinatra_app/templates/views/haml_index.erb", "app_generators/sinatra_app/templates/views/haml_layout.erb", "bin/sinatra-gen", "lib/sinatra-gen.rb", "sinatra-gen.gemspec", "test/test_generator_helper.rb", "test/test_helper.rb", "test/test_sinatra_app_generator.rb"]
|
|
17
|
+
s.has_rdoc = true
|
|
18
|
+
s.homepage = %q{http://github.com/quirkey/sinatra-gen}
|
|
19
|
+
s.post_install_message = %q{PostInstall.txt}
|
|
20
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
|
21
|
+
s.require_paths = ["lib"]
|
|
22
|
+
s.rubyforge_project = %q{quirkey}
|
|
23
|
+
s.rubygems_version = %q{1.3.1}
|
|
24
|
+
s.summary = %q{sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework}
|
|
25
|
+
s.test_files = ["test/test_generator_helper.rb", "test/test_helper.rb", "test/test_sinatra_app_generator.rb"]
|
|
26
|
+
|
|
27
|
+
if s.respond_to? :specification_version then
|
|
28
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
29
|
+
s.specification_version = 2
|
|
30
|
+
|
|
31
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
32
|
+
s.add_runtime_dependency(%q<rubigen>, [">= 1.5.2"])
|
|
33
|
+
s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
|
|
34
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
|
35
|
+
else
|
|
36
|
+
s.add_dependency(%q<rubigen>, [">= 1.5.2"])
|
|
37
|
+
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
|
38
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
|
39
|
+
end
|
|
40
|
+
else
|
|
41
|
+
s.add_dependency(%q<rubigen>, [">= 1.5.2"])
|
|
42
|
+
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
|
43
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -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,194 @@
|
|
|
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
|
+
def test_generate_app_without_options
|
|
15
|
+
run_generator('sinatra_app', [APP_ROOT], sources)
|
|
16
|
+
assert_basic_paths_and_files
|
|
17
|
+
assert_generated_file 'views/layout.erb'
|
|
18
|
+
assert_generated_file 'views/index.erb'
|
|
19
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
|
20
|
+
assert_match(/def test/, test_contents)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_generate_app_with_vendor_option
|
|
25
|
+
run_generator('sinatra_app', [APP_ROOT, '--vendor'], sources)
|
|
26
|
+
assert_basic_paths_and_files
|
|
27
|
+
assert_directory_exists 'vendor/sinatra/lib'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_generate_app_with_tiny_option
|
|
31
|
+
run_generator('sinatra_app', [APP_ROOT, '--tiny'], sources)
|
|
32
|
+
assert_generated_file 'config.ru'
|
|
33
|
+
assert_generated_file "#{app_name}.rb"
|
|
34
|
+
assert_generated_file 'Rakefile'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_generate_app_with_init_option
|
|
38
|
+
run_generator('sinatra_app', [APP_ROOT, '-i'], sources)
|
|
39
|
+
assert_basic_paths_and_files
|
|
40
|
+
assert_directory_exists '.git'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_generate_app_with_cap_option
|
|
44
|
+
run_generator('sinatra_app', [APP_ROOT, '--cap'], sources)
|
|
45
|
+
assert_basic_paths_and_files
|
|
46
|
+
assert_directory_exists 'config'
|
|
47
|
+
assert_generated_file 'Capfile'
|
|
48
|
+
assert_generated_file 'config/deploy.rb' do |deploy_contents|
|
|
49
|
+
assert_match(/set \:application, "#{app_name}"/, deploy_contents)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_generate_app_with_rspect_test_option
|
|
54
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=rspec'], sources)
|
|
55
|
+
assert_basic_paths_and_files
|
|
56
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
|
57
|
+
assert_match(/sinatra\/test\/rspec/, helper_contents)
|
|
58
|
+
end
|
|
59
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
|
60
|
+
assert_match(/describe/, test_contents)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_generate_app_with_spec_test_option
|
|
65
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=spec'], sources)
|
|
66
|
+
assert_basic_paths_and_files
|
|
67
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
|
68
|
+
assert_match(/sinatra\/test\/spec/, helper_contents)
|
|
69
|
+
end
|
|
70
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
|
71
|
+
assert_match(/describe/, test_contents)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_generate_app_with_shoulda_test_option
|
|
76
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=shoulda'], sources)
|
|
77
|
+
assert_basic_paths_and_files
|
|
78
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
|
79
|
+
assert_match(/sinatra\/test\/unit/, helper_contents)
|
|
80
|
+
assert_match(/shoulda/, helper_contents)
|
|
81
|
+
end
|
|
82
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
|
83
|
+
assert_match(/context/, test_contents)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_generate_app_with_test_unit_option
|
|
88
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=unit'], sources)
|
|
89
|
+
assert_basic_paths_and_files
|
|
90
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
|
91
|
+
assert_match(/sinatra\/test\/unit/, helper_contents)
|
|
92
|
+
end
|
|
93
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
|
94
|
+
assert_match(/def test/, test_contents)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_generate_app_with_test_bacon_option
|
|
99
|
+
run_generator('sinatra_app', [APP_ROOT, '--test=bacon'], sources)
|
|
100
|
+
assert_basic_paths_and_files
|
|
101
|
+
assert_generated_file 'test/test_helper.rb' do |helper_contents|
|
|
102
|
+
assert_match(/sinatra\/test\/bacon/, helper_contents)
|
|
103
|
+
end
|
|
104
|
+
assert_generated_file "test/test_#{app_name}.rb" do |test_contents|
|
|
105
|
+
assert_match(/describe/, test_contents)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_generate_app_with_views_haml_option
|
|
110
|
+
run_generator('sinatra_app', [APP_ROOT, '--views=erb'], sources)
|
|
111
|
+
assert_basic_paths_and_files
|
|
112
|
+
assert_generated_file "#{app_name}.rb" do |app_contents|
|
|
113
|
+
assert_match(/erb \:index/, app_contents)
|
|
114
|
+
end
|
|
115
|
+
assert_generated_file 'views/layout.erb'
|
|
116
|
+
assert_generated_file 'views/index.erb'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_generate_app_with_views_haml_option
|
|
120
|
+
run_generator('sinatra_app', [APP_ROOT, '--views=haml'], sources)
|
|
121
|
+
assert_basic_paths_and_files
|
|
122
|
+
assert_generated_file "#{app_name}.rb" do |app_contents|
|
|
123
|
+
assert_match(/haml \:index/, app_contents)
|
|
124
|
+
end
|
|
125
|
+
assert_generated_file 'views/layout.haml'
|
|
126
|
+
assert_generated_file 'views/index.haml'
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_generate_app_with_views_builder_option
|
|
130
|
+
run_generator('sinatra_app', [APP_ROOT, '--views=builder'], sources)
|
|
131
|
+
assert_basic_paths_and_files
|
|
132
|
+
assert_generated_file "#{app_name}.rb" do |app_contents|
|
|
133
|
+
assert_match(/builder \:index/, app_contents)
|
|
134
|
+
end
|
|
135
|
+
assert_generated_file 'views/index.builder'
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_generate_app_with_scripts_option
|
|
139
|
+
run_generator('sinatra_app', [APP_ROOT, '--scripts'], sources)
|
|
140
|
+
assert_basic_paths_and_files
|
|
141
|
+
assert_directory_exists 'script'
|
|
142
|
+
assert_generated_file 'script/destroy'
|
|
143
|
+
assert_generated_file 'script/generate'
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_generate_app_with_actions_and_no_options
|
|
147
|
+
run_generator('sinatra_app', [APP_ROOT, 'get:/', 'post:/users/:id', 'put:/users/*'], sources)
|
|
148
|
+
assert_basic_paths_and_files
|
|
149
|
+
assert_generated_file "#{app_name}.rb" do |app_contents|
|
|
150
|
+
assert_match(/get '\/' do/, app_contents)
|
|
151
|
+
assert_match(/post '\/users\/\:id' do/, app_contents)
|
|
152
|
+
assert_match(/put '\/users\/\*' do/, app_contents)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_generate_app_with_actions_and_options
|
|
157
|
+
run_generator('sinatra_app', [APP_ROOT, 'get:/', 'post:/users/:id', '--tiny', 'put:/users/*'], sources)
|
|
158
|
+
assert_generated_file 'config.ru'
|
|
159
|
+
assert_generated_file "#{app_name}.rb"
|
|
160
|
+
assert_generated_file 'Rakefile'
|
|
161
|
+
assert_generated_file "#{app_name}.rb" do |app_contents|
|
|
162
|
+
assert_match(/get '\/' do/, app_contents)
|
|
163
|
+
assert_match(/post '\/users\/\:id' do/, app_contents)
|
|
164
|
+
assert_match(/put '\/users\/\*' do/, app_contents)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
private
|
|
169
|
+
def assert_basic_paths_and_files
|
|
170
|
+
assert_directory_exists 'lib'
|
|
171
|
+
assert_directory_exists 'test'
|
|
172
|
+
assert_directory_exists 'public'
|
|
173
|
+
assert_directory_exists 'views'
|
|
174
|
+
assert_generated_file 'config.ru'
|
|
175
|
+
assert_generated_file "#{app_name}.rb"
|
|
176
|
+
assert_generated_file 'Rakefile'
|
|
177
|
+
assert_generated_file 'config.yml'
|
|
178
|
+
assert_generated_module "lib/#{app_name}"
|
|
179
|
+
assert_generated_file "lib/app_helper.rb"
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def sources
|
|
184
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def app_name
|
|
188
|
+
File.basename(APP_ROOT)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def generator_path
|
|
192
|
+
"app_generators"
|
|
193
|
+
end
|
|
194
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vanntastic-sinatra-gen
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Aaron Quint
|
|
8
|
+
- Vann Ek
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2009-03-25 00:00:00 -07:00
|
|
14
|
+
default_executable: sinatra-gen
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: rubigen
|
|
18
|
+
type: :runtime
|
|
19
|
+
version_requirement:
|
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
21
|
+
requirements:
|
|
22
|
+
- - ">="
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: 1.5.2
|
|
25
|
+
version:
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: newgem
|
|
28
|
+
type: :development
|
|
29
|
+
version_requirement:
|
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: 1.2.3
|
|
35
|
+
version:
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: hoe
|
|
38
|
+
type: :development
|
|
39
|
+
version_requirement:
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: 1.8.0
|
|
45
|
+
version:
|
|
46
|
+
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://sinatrarb.com !! NOW WITH SUPPORT FOR SINATRA 0.9 (02/10/09)
|
|
47
|
+
email:
|
|
48
|
+
- aaron@quirkey.com
|
|
49
|
+
- ek.vann@gmail.com
|
|
50
|
+
executables:
|
|
51
|
+
- sinatra-gen
|
|
52
|
+
extensions: []
|
|
53
|
+
|
|
54
|
+
extra_rdoc_files:
|
|
55
|
+
- History.txt
|
|
56
|
+
- Manifest.txt
|
|
57
|
+
- PostInstall.txt
|
|
58
|
+
- README.rdoc
|
|
59
|
+
files:
|
|
60
|
+
- History.txt
|
|
61
|
+
- Manifest.txt
|
|
62
|
+
- PostInstall.txt
|
|
63
|
+
- README.rdoc
|
|
64
|
+
- Rakefile
|
|
65
|
+
- app_generators/sinatra_app/USAGE
|
|
66
|
+
- app_generators/sinatra_app/sinatra_app_generator.rb
|
|
67
|
+
- app_generators/sinatra_app/templates/Capfile
|
|
68
|
+
- app_generators/sinatra_app/templates/Rakefile.erb
|
|
69
|
+
- app_generators/sinatra_app/templates/app.rb.erb
|
|
70
|
+
- app_generators/sinatra_app/templates/config.ru.erb
|
|
71
|
+
- app_generators/sinatra_app/templates/config.yml
|
|
72
|
+
- app_generators/sinatra_app/templates/config/deploy.rb.erb
|
|
73
|
+
- app_generators/sinatra_app/templates/lib/module.rb.erb
|
|
74
|
+
- app_generators/sinatra_app/templates/lib/app_helper.rb.erb
|
|
75
|
+
- app_generators/sinatra_app/templates/test/test_app_bacon.rb.erb
|
|
76
|
+
- app_generators/sinatra_app/templates/test/test_app_rspec.rb.erb
|
|
77
|
+
- app_generators/sinatra_app/templates/test/test_app_shoulda.rb.erb
|
|
78
|
+
- app_generators/sinatra_app/templates/test/test_app_spec.rb.erb
|
|
79
|
+
- app_generators/sinatra_app/templates/test/test_app_unit.rb.erb
|
|
80
|
+
- app_generators/sinatra_app/templates/test/test_helper.rb.erb
|
|
81
|
+
- app_generators/sinatra_app/templates/views/builder_index.erb
|
|
82
|
+
- app_generators/sinatra_app/templates/views/erb_index.erb
|
|
83
|
+
- app_generators/sinatra_app/templates/views/erb_layout.erb
|
|
84
|
+
- app_generators/sinatra_app/templates/views/haml_index.erb
|
|
85
|
+
- app_generators/sinatra_app/templates/views/haml_layout.erb
|
|
86
|
+
- bin/sinatra-gen
|
|
87
|
+
- lib/sinatra-gen.rb
|
|
88
|
+
- sinatra-gen.gemspec
|
|
89
|
+
- test/test_generator_helper.rb
|
|
90
|
+
- test/test_helper.rb
|
|
91
|
+
- test/test_sinatra_app_generator.rb
|
|
92
|
+
has_rdoc: true
|
|
93
|
+
homepage: http://github.com/quirkey/sinatra-gen
|
|
94
|
+
post_install_message: PostInstall.txt
|
|
95
|
+
rdoc_options:
|
|
96
|
+
- --main
|
|
97
|
+
- README.rdoc
|
|
98
|
+
require_paths:
|
|
99
|
+
- lib
|
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: "0"
|
|
105
|
+
version:
|
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: "0"
|
|
111
|
+
version:
|
|
112
|
+
requirements: []
|
|
113
|
+
|
|
114
|
+
rubyforge_project: quirkey
|
|
115
|
+
rubygems_version: 1.2.0
|
|
116
|
+
signing_key:
|
|
117
|
+
specification_version: 2
|
|
118
|
+
summary: sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework
|
|
119
|
+
test_files:
|
|
120
|
+
- test/test_generator_helper.rb
|
|
121
|
+
- test/test_helper.rb
|
|
122
|
+
- test/test_sinatra_app_generator.rb
|