quirkey-sinatra-gen 0.2.1 → 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/README.rdoc +1 -4
- data/Rakefile +1 -0
- data/app_generators/sinatra_app/sinatra_app_generator.rb +83 -66
- data/lib/sinatra-gen.rb +1 -1
- data/sinatra-gen.gemspec +8 -3
- data/test/test_sinatra_app_generator.rb +9 -0
- metadata +16 -3
data/README.rdoc
CHANGED
@@ -7,8 +7,6 @@ http://github.com/quirkey/sinatra-gen
|
|
7
7
|
sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework.
|
8
8
|
For more information on sinatra, check out http://sinatrarb.com
|
9
9
|
|
10
|
-
!! NOW WITH SUPPORT FOR SINATRA 0.9 (02/10/09)
|
11
|
-
|
12
10
|
== SYNOPSIS:
|
13
11
|
|
14
12
|
sinatra-gen has a bunch of different options (based loosley on merb-gen) to try to not lock the
|
@@ -24,8 +22,6 @@ e.g.
|
|
24
22
|
|
25
23
|
=== Actions
|
26
24
|
|
27
|
-
!! NEW as of 0.2.0 (12/23/08)
|
28
|
-
|
29
25
|
For even faster app development you specify actions to include in your app when generating.
|
30
26
|
Actions are written out as
|
31
27
|
|
@@ -56,6 +52,7 @@ It will also generate test skeletons in the test framework of your choosing.
|
|
56
52
|
-d, --vendor Extract the latest sinatra to vendor/sinatra
|
57
53
|
--tiny Only create the minimal files.
|
58
54
|
--init Initialize a git repository
|
55
|
+
--heroku Create a Heroku app (also runs 'git init'). Optionally, specify the path to the heroku bin
|
59
56
|
--cap Adds config directory with basic capistrano deploy.rb
|
60
57
|
--scripts Install the rubigen scripts (script/generate, script/destroy)
|
61
58
|
--git /path/to/git Specify a different path for 'git'
|
data/Rakefile
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
class RubiGen::Commands::Create
|
2
|
-
|
2
|
+
|
3
3
|
def run(command, relative_path = '')
|
4
4
|
in_directory = destination_path(relative_path)
|
5
5
|
logger.run command
|
6
6
|
system("cd #{in_directory} && #{command}")
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
end
|
10
10
|
|
11
11
|
|
12
12
|
class SinatraAppGenerator < RubiGen::Base
|
13
13
|
|
14
14
|
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
15
|
-
|
15
|
+
Config::CONFIG['ruby_install_name'])
|
16
16
|
|
17
17
|
SINATRA_GIT_URL = 'git://github.com/sinatra/sinatra.git'
|
18
18
|
|
19
19
|
default_options :author => nil
|
20
20
|
|
21
|
-
attr_accessor :app_name,
|
21
|
+
attr_accessor :app_name,
|
22
|
+
:vendor,
|
23
|
+
:tiny,
|
24
|
+
:git,
|
25
|
+
:git_init,
|
26
|
+
:heroku,
|
27
|
+
:test_framework,
|
28
|
+
:view_framework,
|
29
|
+
:install_scripts,
|
30
|
+
:cap,
|
31
|
+
:actions
|
22
32
|
|
23
33
|
def initialize(runtime_args, runtime_options = {})
|
24
34
|
super
|
@@ -33,15 +43,15 @@ class SinatraAppGenerator < RubiGen::Base
|
|
33
43
|
record do |m|
|
34
44
|
# Ensure appropriate folder(s) exists
|
35
45
|
m.directory ''
|
36
|
-
|
46
|
+
|
37
47
|
if git_init
|
38
48
|
m.run("#{git} init")
|
39
|
-
end
|
40
|
-
|
49
|
+
end
|
50
|
+
|
41
51
|
m.template 'config.ru.erb', 'config.ru'
|
42
52
|
m.template 'app.rb.erb' , "#{app_name}.rb"
|
43
53
|
m.template 'Rakefile.erb' , 'Rakefile'
|
44
|
-
|
54
|
+
|
45
55
|
unless tiny
|
46
56
|
BASEDIRS.each { |path| m.directory path }
|
47
57
|
m.file 'config.yml', 'config.yml'
|
@@ -51,81 +61,88 @@ class SinatraAppGenerator < RubiGen::Base
|
|
51
61
|
m.template "views/#{view_framework}_index.erb", "views/index.#{view_framework}"
|
52
62
|
m.template "views/#{view_framework}_layout.erb", "views/layout.#{view_framework}" unless view_framework == 'builder'
|
53
63
|
end
|
54
|
-
|
64
|
+
|
55
65
|
if vendor
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
m.run(command)
|
66
|
+
m.directory 'vendor'
|
67
|
+
if git_init || File.exists?(File.join(@destination_root, '.git'))
|
68
|
+
command = "#{git} submodule add #{SINATRA_GIT_URL} vendor/sinatra"
|
69
|
+
else
|
70
|
+
command = "#{git} clone #{SINATRA_GIT_URL} vendor/sinatra"
|
63
71
|
end
|
64
|
-
|
72
|
+
m.run(command)
|
73
|
+
end
|
74
|
+
|
65
75
|
if cap
|
66
76
|
m.directory 'config'
|
67
77
|
m.file 'Capfile', 'Capfile'
|
68
78
|
m.template 'config/deploy.rb.erb', 'config/deploy.rb'
|
69
79
|
end
|
70
|
-
|
80
|
+
|
71
81
|
if install_scripts
|
72
82
|
m.dependency "install_rubigen_scripts", [destination_root, 'sinatra-gen'], :shebang => options[:shebang], :collision => :force
|
73
83
|
end
|
84
|
+
|
85
|
+
if heroku
|
86
|
+
m.run("#{heroku} create #{app_name}")
|
87
|
+
end
|
88
|
+
|
74
89
|
end
|
75
90
|
end
|
76
91
|
|
77
92
|
protected
|
78
|
-
|
79
|
-
|
80
|
-
Creates the skeleton for a new sinatra app
|
93
|
+
def banner
|
94
|
+
<<-EOS
|
95
|
+
Creates the skeleton for a new sinatra app
|
81
96
|
|
82
|
-
USAGE: #{spec.name} app_name
|
83
|
-
EOS
|
84
|
-
|
97
|
+
USAGE: #{spec.name} app_name
|
98
|
+
EOS
|
99
|
+
end
|
85
100
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
91
|
-
opts.on("-d", "--vendor", "Extract the latest sinatra to vendor/sinatra") {|o| options[:vendor] = o }
|
92
|
-
opts.on("--tiny", "Only create the minimal files.") {|o| options[:tiny] = o }
|
93
|
-
opts.on("--init", "Initialize a git repository") {|o| options[:init] = o }
|
94
|
-
opts.on("--cap", "Adds config directory with basic capistrano deploy.rb") {|o| options[:cap] = o }
|
95
|
-
opts.on("--scripts", "Install the rubigen scripts (script/generate, script/destroy)") {|o| options[:scripts] = o }
|
96
|
-
opts.on("--git /path/to/git", "Specify a different path for 'git'") {|o| options[:git] = o }
|
97
|
-
opts.on("--test=test_framework", String, "Specify your testing framework (unit (default)/rspec/spec/shoulda/bacon)") {|o| options[:test_framework] = o }
|
98
|
-
opts.on("--views=view_framework", "Specify your view framework (erb (default)/haml/builder)") {|o| options[:view_framework] = o }
|
99
|
-
end
|
101
|
+
def add_options!(opts)
|
102
|
+
opts.separator ''
|
103
|
+
opts.separator 'Options:'
|
100
104
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
self.install_scripts = options[:scripts] || false
|
113
|
-
end
|
105
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
106
|
+
opts.on("-d", "--vendor", "Extract the latest sinatra to vendor/sinatra") {|o| options[:vendor] = o }
|
107
|
+
opts.on("--tiny", "Only create the minimal files.") {|o| options[:tiny] = o }
|
108
|
+
opts.on("--init", "Initialize a git repository") {|o| options[:init] = o }
|
109
|
+
opts.on("--heroku", "Create a Heroku app (also runs 'git init'). Optionally, specify the path to the heroku bin") { |o| options[:heroku] = o }
|
110
|
+
opts.on("--cap", "Adds config directory with basic capistrano deploy.rb") {|o| options[:cap] = o }
|
111
|
+
opts.on("--scripts", "Install the rubigen scripts (script/generate, script/destroy)") {|o| options[:scripts] = o }
|
112
|
+
opts.on("--git /path/to/git", "Specify a different path for 'git'") {|o| options[:git] = o }
|
113
|
+
opts.on("--test=test_framework", String, "Specify your testing framework (unit (default)/rspec/spec/shoulda/bacon)") {|o| options[:test_framework] = o }
|
114
|
+
opts.on("--views=view_framework", "Specify your view framework (erb (default)/haml/builder)") {|o| options[:view_framework] = o }
|
115
|
+
end
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
def extract_options
|
118
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
119
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
120
|
+
# raw instance variable value.
|
121
|
+
self.vendor = options[:vendor]
|
122
|
+
self.tiny = options[:tiny]
|
123
|
+
self.cap = options[:cap]
|
124
|
+
self.git = options[:git] || `which git`.strip
|
125
|
+
self.heroku = options[:heroku] ? `which heroku`.strip : false
|
126
|
+
self.git_init = options[:init] || !!heroku || false
|
127
|
+
self.test_framework = options[:test_framework] || 'unit'
|
128
|
+
self.view_framework = options[:view_framework] || 'erb'
|
129
|
+
self.install_scripts = options[:scripts] || false
|
130
|
+
end
|
131
|
+
|
132
|
+
def klass_name
|
133
|
+
app_name.classify
|
134
|
+
end
|
135
|
+
|
136
|
+
def parse_actions(*action_args)
|
137
|
+
@actions = action_args.flatten.collect { |a| a.split(':', 2) }
|
138
|
+
end
|
122
139
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
140
|
+
# Installation skeleton. Intermediate directories are automatically
|
141
|
+
# created so don't sweat their absence here.
|
142
|
+
BASEDIRS = %w(
|
143
|
+
lib
|
144
|
+
test
|
145
|
+
public
|
146
|
+
views
|
147
|
+
)
|
131
148
|
end
|
data/lib/sinatra-gen.rb
CHANGED
data/sinatra-gen.gemspec
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = %q{sinatra-gen}
|
3
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.2"
|
4
6
|
|
5
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
8
|
s.authors = ["Aaron Quint"]
|
7
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-03-27}
|
8
10
|
s.default_executable = %q{sinatra-gen}
|
9
|
-
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://
|
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}
|
10
12
|
s.email = ["aaron@quirkey.com"]
|
11
13
|
s.executables = ["sinatra-gen"]
|
12
14
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
@@ -27,15 +29,18 @@ Gem::Specification.new do |s|
|
|
27
29
|
|
28
30
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
31
|
s.add_runtime_dependency(%q<rubigen>, [">= 1.5.2"])
|
32
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.0"])
|
30
33
|
s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
|
31
34
|
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
32
35
|
else
|
33
36
|
s.add_dependency(%q<rubigen>, [">= 1.5.2"])
|
37
|
+
s.add_dependency(%q<sinatra>, [">= 0.9.0"])
|
34
38
|
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
35
39
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
36
40
|
end
|
37
41
|
else
|
38
42
|
s.add_dependency(%q<rubigen>, [">= 1.5.2"])
|
43
|
+
s.add_dependency(%q<sinatra>, [">= 0.9.0"])
|
39
44
|
s.add_dependency(%q<newgem>, [">= 1.2.3"])
|
40
45
|
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
41
46
|
end
|
@@ -39,6 +39,15 @@ class TestSinatraAppGenerator < Test::Unit::TestCase
|
|
39
39
|
assert_basic_paths_and_files
|
40
40
|
assert_directory_exists '.git'
|
41
41
|
end
|
42
|
+
|
43
|
+
def test_generate_app_with_heroku_option
|
44
|
+
run_generator('sinatra_app', [APP_ROOT, '--heroku'], sources)
|
45
|
+
assert_basic_paths_and_files
|
46
|
+
assert_directory_exists '.git'
|
47
|
+
assert_generated_file '.git/config' do |config_contents|
|
48
|
+
assert_match(/\[remote "heroku"\]/, config_contents)
|
49
|
+
end
|
50
|
+
end
|
42
51
|
|
43
52
|
def test_generate_app_with_cap_option
|
44
53
|
run_generator('sinatra_app', [APP_ROOT, '--cap'], sources)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quirkey-sinatra-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Quint
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-03-27 00:00:00 -07:00
|
13
13
|
default_executable: sinatra-gen
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubigen
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -21,8 +22,19 @@ dependencies:
|
|
21
22
|
- !ruby/object:Gem::Version
|
22
23
|
version: 1.5.2
|
23
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sinatra
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.9.0
|
34
|
+
version:
|
24
35
|
- !ruby/object:Gem::Dependency
|
25
36
|
name: newgem
|
37
|
+
type: :development
|
26
38
|
version_requirement:
|
27
39
|
version_requirements: !ruby/object:Gem::Requirement
|
28
40
|
requirements:
|
@@ -32,6 +44,7 @@ dependencies:
|
|
32
44
|
version:
|
33
45
|
- !ruby/object:Gem::Dependency
|
34
46
|
name: hoe
|
47
|
+
type: :development
|
35
48
|
version_requirement:
|
36
49
|
version_requirements: !ruby/object:Gem::Requirement
|
37
50
|
requirements:
|
@@ -39,7 +52,7 @@ dependencies:
|
|
39
52
|
- !ruby/object:Gem::Version
|
40
53
|
version: 1.8.0
|
41
54
|
version:
|
42
|
-
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://
|
55
|
+
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
|
43
56
|
email:
|
44
57
|
- aaron@quirkey.com
|
45
58
|
executables:
|