appleseed 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ryan Alyn Porter
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,111 @@
1
+ = Appleseed
2
+
3
+ Appleseed provides a generator for creating a new web site project with Rails 3, adding things
4
+ like HAML and Compass to the new project, creating a Git repository for the new project, pushing
5
+ that repository to GitHub, and then deploying the site to Heroku. All with one command.
6
+
7
+ This utility is designed to assist graphic designers in rapidly creating new web sites, for
8
+ high-volume web shops. A graphic designer can create a site, push the code to GitHub, and deploy
9
+ the site to Heroku without the assistance of a developer. Then a developer can easily join the
10
+ project to build out the back-end and assist the graphic designer with the front-end.
11
+
12
+ = Usage
13
+
14
+ == Step 1: Install Appleseed
15
+
16
+ Open a Terminal window and copy the following command into the window:
17
+
18
+ gem install appleseed
19
+
20
+ == Step 2: Generate Web Application Project
21
+
22
+ In that same terminal, go to your local projects folder:
23
+
24
+ cd ~/projects
25
+
26
+ Then generate a new project by giving Appleseed the name of your new project:
27
+
28
+ appleseed my-new-rails-app
29
+
30
+ Appleseed will create the following:
31
+
32
+ * A Rails 3 web application project in ~/projects/my-new-rails-app
33
+ * A GitHub repository at git@github.com:[you]/my-new-rails-app.git
34
+ * A Heroku app at http://my-new-rails-app.heroku.com
35
+
36
+ == Step 3: Run The Web Site
37
+
38
+ Your new web application is already running on Heroku. But for you to make changes, you'll have
39
+ to be able to run the web site on your local computer. You might want to open a new tab in your
40
+ Terminal window for the server. Then change to the new project folder in your Terminal window:
41
+
42
+ cd ~/projects/my-new-rails-app
43
+
44
+ Then run the Rails server with:
45
+
46
+ rails server
47
+
48
+ Then go to http://localhost:3000 in a web browser, and you should see your new web site.
49
+
50
+ == Step 4: Make Changes
51
+
52
+ After you make changes to your web site project, use these Terminal commands to push the changes
53
+ to GitHub and Heroku:
54
+
55
+ git add .
56
+ git commit -m "Update."
57
+ git push github master
58
+ git push heroku master
59
+
60
+ If the "git push" operation produces an error, then it probably means that somebody else has made
61
+ a change to the same web site and you need to merge your update with their update before you can
62
+ push your update. Do this:
63
+
64
+ git pull github master
65
+
66
+ Then after Git pulls the other person's update and merges it with your update, proceed with the
67
+ "git push github master", above.
68
+
69
+ If Git reports that there has been a conflict, then commit the conflict and push it to GitHub,
70
+ but do NOT push to Heroku:
71
+
72
+ git add .
73
+ git commit -m "Conflict."
74
+ git push github master
75
+
76
+ = Final Product
77
+
78
+ Appleseed generates a web application that's more than just the default generated Rails 3 template.
79
+ Instead of just a default working Rails application, you also get a default ("root") controller
80
+ and a root route to a home page. You get a layout based on HAML, and the Blueprint CSS framework
81
+ provided by Compass. You get the RSpec and Cucumber testing frameworks and sample tests. The
82
+ final product is ready for new HTML/CSS files from graphic designers.
83
+
84
+ The final product does NOT contain any database models, or an administrative back-end. It only
85
+ includes a default controller so that graphic designers can easily add HTML files.
86
+
87
+ = Options
88
+
89
+ == --no-github
90
+
91
+ You can use the --no-github option to tell Appleseed NOT to create a new project at GitHub.
92
+
93
+ == --no-heroku
94
+
95
+ You can use the --no-heroku option to tell Appleseed NOT to deploy your new web application to Heroku.
96
+
97
+ == --template
98
+
99
+ By default, the template in http://github.com/endymion/appleseed/raw/master/templates/default.rb
100
+ will be applied to the new project. You can tell Appleseed to use your own custom template with
101
+ the --template option. For example:
102
+
103
+ appleseed --template ~/templates/my-template.txt new-web-application
104
+
105
+ A simple way to customize the Rails template that Appleseed uses is to fork the Appleseed project
106
+ on GitHub and then edit the lib/appleseed/generator.rb file to use your forked project's
107
+ default template URL instead of http://github.com/endymion/appleseed/raw/master/templates/default.rb
108
+
109
+ == Copyright
110
+
111
+ Copyright (c) 2010 Ryan Alyn Porter. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "appleseed"
8
+ gem.summary = %Q{Kick-start a Rails 3 project, push it to GitHub, deploy it to Heroku.}
9
+ gem.description = %Q{Generator for a Rails 3 app that will also push the project to GitHub and Heroku.}
10
+ gem.homepage = "http://github.com/endymion/appleseed"
11
+ gem.authors = ["Ryan Alyn Porter"]
12
+ gem.add_development_dependency "rspec", ">= 1.2.9"
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'spec/rake/spectask'
21
+ Spec::Rake::SpecTask.new(:spec) do |spec|
22
+ spec.libs << 'lib' << 'spec'
23
+ spec.spec_files = FileList['spec/**/*_spec.rb']
24
+ end
25
+
26
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
27
+ spec.libs << 'lib' << 'spec'
28
+ spec.pattern = 'spec/**/*_spec.rb'
29
+ spec.rcov = true
30
+ end
31
+
32
+ task :spec => :check_dependencies
33
+
34
+ task :default => :spec
35
+
36
+ require 'rake/rdoctask'
37
+ Rake::RDocTask.new do |rdoc|
38
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
39
+
40
+ rdoc.rdoc_dir = 'rdoc'
41
+ rdoc.title = "appleseed #{version}"
42
+ rdoc.rdoc_files.include('README*')
43
+ rdoc.rdoc_files.include('lib/**/*.rb')
44
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/appleseed.gemspec ADDED
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{appleseed}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Alyn Porter"]
12
+ s.date = %q{2010-08-28}
13
+ s.default_executable = %q{appleseed}
14
+ s.description = %q{Generator for a Rails 3 app that will also push the project to GitHub and Heroku.}
15
+ s.executables = ["appleseed"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "appleseed.gemspec",
28
+ "bin/appleseed",
29
+ "lib/appleseed.rb",
30
+ "lib/appleseed/application.rb",
31
+ "lib/appleseed/errors.rb",
32
+ "lib/appleseed/generator.rb",
33
+ "lib/appleseed/generator/github_mixin.rb",
34
+ "lib/appleseed/options.rb",
35
+ "spec/appleseed_spec.rb",
36
+ "spec/spec.opts",
37
+ "spec/spec_helper.rb",
38
+ "templates/compass.rb",
39
+ "templates/cucumber.rb",
40
+ "templates/default.rb",
41
+ "templates/gitignore.rb",
42
+ "templates/haml.rb",
43
+ "templates/jquery.rb",
44
+ "templates/remove_prototype.rb",
45
+ "templates/root_controller.rb",
46
+ "templates/rspec.rb"
47
+ ]
48
+ s.homepage = %q{http://github.com/endymion/appleseed}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubygems_version = %q{1.3.7}
52
+ s.summary = %q{Kick-start a Rails 3 project, push it to GitHub, deploy it to Heroku.}
53
+ s.test_files = [
54
+ "spec/appleseed_spec.rb",
55
+ "spec/spec_helper.rb"
56
+ ]
57
+
58
+ if s.respond_to? :specification_version then
59
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
64
+ else
65
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
69
+ end
70
+ end
71
+
data/bin/appleseed ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'appleseed'
4
+ require 'appleseed/options'
5
+ require 'appleseed/application'
6
+
7
+ exit Appleseed::Generator::Application.run!(*ARGV)
data/lib/appleseed.rb ADDED
@@ -0,0 +1,36 @@
1
+ require 'pathname'
2
+ require 'date'
3
+
4
+ class Appleseed
5
+ require 'appleseed/errors'
6
+ # require 'rubygems/user_interaction'
7
+
8
+ autoload :Generator, 'appleseed/generator'
9
+
10
+ attr_reader :gemspec, :gemspec_helper, :version_helper
11
+ attr_accessor :base_dir, :output, :repo, :commit
12
+
13
+ def initialize(base_dir = '.')
14
+
15
+ @base_dir = base_dir
16
+ @repo = Git.open(git_base_dir) if in_git_repo?
17
+ @output = $stdout
18
+ @commit = true
19
+ end
20
+
21
+ def git_base_dir(base_dir = nil)
22
+ if base_dir
23
+ base_dir = File.dirname(base_dir)
24
+ else
25
+ base_dir = File.expand_path(self.base_dir || ".")
26
+ end
27
+ return nil if base_dir==File.dirname("/")
28
+ return base_dir if File.exists?(File.join(base_dir, '.git'))
29
+ return git_base_dir(base_dir)
30
+ end
31
+
32
+ def in_git_repo?
33
+ git_base_dir
34
+ end
35
+
36
+ end
@@ -0,0 +1,52 @@
1
+ class Appleseed
2
+ class Generator
3
+ class Application
4
+ class << self
5
+ def run!(*arguments)
6
+ env_opts = if ENV['APPLESEED_OPTS']
7
+ Appleseed::Generator::Options.new(ENV['APPLESEED_OPTS'].split(' '))
8
+ end
9
+ options = Appleseed::Generator::Options.new(arguments)
10
+ options = options.merge(env_opts) if env_opts
11
+
12
+ if options[:invalid_argument]
13
+ $stderr.puts options[:invalid_argument]
14
+ options[:show_help] = true
15
+ end
16
+
17
+ if options[:show_help]
18
+ $stderr.puts options.opts
19
+ return 1
20
+ end
21
+
22
+ if options[:project_name].nil? || options[:project_name].squeeze.strip == ""
23
+ $stderr.puts options.opts
24
+ return 1
25
+ end
26
+
27
+ begin
28
+ generator = Appleseed::Generator.new(options)
29
+ generator.run
30
+ return 0
31
+ rescue Appleseed::NoGitUserName
32
+ $stderr.puts %Q{No user.name found in ~/.gitconfig. Please tell git about yourself (see http://help.github.com/git-email-settings/ for details). For example: git config --global user.name "mad voo"}
33
+ return 1
34
+ rescue Appleseed::NoGitUserEmail
35
+ $stderr.puts %Q{No user.email found in ~/.gitconfig. Please tell git about yourself (see http://help.github.com/git-email-settings/ for details). For example: git config --global user.email mad.vooo@gmail.com}
36
+ return 1
37
+ rescue Appleseed::NoGitHubUser
38
+ $stderr.puts %Q{No github.user found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.user defunkt}
39
+ return 1
40
+ rescue Appleseed::NoGitHubToken
41
+ $stderr.puts %Q{No github.token found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.token 6ef8395fecf207165f1a82178ae1b984}
42
+ return 1
43
+ rescue Appleseed::FileInTheWay
44
+ $stderr.puts "The directory #{options[:project_name]} already exists. Maybe move it out of the way before continuing?"
45
+ return 1
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,8 @@
1
+ class Appleseed
2
+ # Gemspec related error
3
+ class GemspecError < StandardError
4
+ end
5
+
6
+ class VersionYmlError < StandardError
7
+ end
8
+ end
@@ -0,0 +1,208 @@
1
+ require 'rubygems'
2
+ require 'git'
3
+ require 'erb'
4
+
5
+ require 'net/http'
6
+ require 'uri'
7
+
8
+ require 'fileutils'
9
+ require 'pathname'
10
+
11
+ class Appleseed
12
+ class NoGitUserName < StandardError
13
+ end
14
+ class NoGitUserEmail < StandardError
15
+ end
16
+ class FileInTheWay < StandardError
17
+ end
18
+ class NoGitHubRepoNameGiven < StandardError
19
+ end
20
+ class NoGitHubUser < StandardError
21
+ end
22
+ class NoGitHubToken < StandardError
23
+ end
24
+ class GitInitFailed < StandardError
25
+ end
26
+
27
+ class Generator
28
+
29
+ require 'appleseed/generator/github_mixin'
30
+
31
+ attr_accessor :target_dir, :user_name, :user_email, :summary, :homepage,
32
+ :description, :project_name,
33
+ :repo, :should_create_github_repository,
34
+ :should_create_heroku_deployment,
35
+ :testing_framework, :documentation_framework,
36
+ :should_use_cucumber, :should_use_bundler,
37
+ :should_setup_rubyforge, :should_use_reek, :should_use_roodi,
38
+ :development_dependencies,
39
+ :options,
40
+ :git_remote,
41
+ :template_url
42
+
43
+ def initialize(options = {})
44
+ self.options = options
45
+
46
+ self.project_name = options[:project_name]
47
+ if self.project_name.nil? || self.project_name.squeeze.strip == ""
48
+ raise NoGitHubRepoNameGiven
49
+ end
50
+
51
+ self.target_dir = self.project_name
52
+
53
+ self.summary = options[:summary] || 'TODO: one-line summary of your gem'
54
+ self.description = options[:description] || 'TODO: longer description of your gem'
55
+
56
+ # self.template_url = options[:template_url] || 'http://github.com/endymion/appleseed/raw/master/templates/default.rb'
57
+ self.template_url = options[:template_url] || 'http://localhost/projects/appleseed/templates/default.rb'
58
+
59
+ self.user_name = options[:user_name]
60
+ self.user_email = options[:user_email]
61
+ self.homepage = options[:homepage]
62
+
63
+ self.git_remote = options[:git_remote]
64
+
65
+ raise NoGitUserName unless self.user_name
66
+ raise NoGitUserEmail unless self.user_email
67
+
68
+ extend GithubMixin
69
+
70
+ self.should_create_heroku_deployment = !options[:no_heroku]
71
+
72
+ end
73
+
74
+ def run
75
+ create_files
76
+ create_version_control
77
+ $stdout.puts "Appleseed has prepared your new web application project in #{target_dir}"
78
+ if should_create_github_repository
79
+ create_and_push_repo
80
+ $stdout.puts "Appleseed has pushed your git repository to #{git_remote}"
81
+ end
82
+ if should_create_heroku_deployment
83
+ create_and_push_deployment
84
+ $stdout.puts "Appleseed has pushed your web application to heroku"
85
+ end
86
+ end
87
+
88
+ def constant_name
89
+ self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join
90
+ end
91
+
92
+ def lib_filename
93
+ "#{project_name}.rb"
94
+ end
95
+
96
+ def require_name
97
+ self.project_name
98
+ end
99
+
100
+ def file_name_prefix
101
+ self.project_name.gsub('-', '_')
102
+ end
103
+
104
+ def lib_dir
105
+ 'lib'
106
+ end
107
+
108
+ def feature_filename
109
+ "#{project_name}.feature"
110
+ end
111
+
112
+ def steps_filename
113
+ "#{project_name}_steps.rb"
114
+ end
115
+
116
+ def features_dir
117
+ 'features'
118
+ end
119
+
120
+ def features_support_dir
121
+ File.join(features_dir, 'support')
122
+ end
123
+
124
+ def features_steps_dir
125
+ File.join(features_dir, 'step_definitions')
126
+ end
127
+
128
+ private
129
+
130
+ def create_files
131
+ if File.exists?(target_dir) || File.directory?(target_dir)
132
+ raise FileInTheWay, "The directory #{target_dir} already exists, aborting. Maybe move it out of the way before continuing?"
133
+ end
134
+
135
+ create_rails_application target_dir
136
+
137
+ end
138
+
139
+ def render_template(source)
140
+ template_contents = File.read(File.join(template_dir, source))
141
+ template = ERB.new(template_contents, nil, '<>')
142
+
143
+ # squish extraneous whitespace from some of the conditionals
144
+ template.result(binding).gsub(/\n\n\n+/, "\n\n")
145
+ end
146
+
147
+ def template_dir
148
+ File.join(File.dirname(__FILE__), 'templates')
149
+ end
150
+
151
+ def create_rails_application(target_dir)
152
+ result = system("rails new #{self.project_name} --template #{self.template_url}")
153
+
154
+ $stdout.puts "\tgenerate rails app\t#{target_dir}"
155
+ end
156
+
157
+ def create_version_control
158
+ Dir.chdir(target_dir) do
159
+ begin
160
+ @repo = Git.init()
161
+ rescue Git::GitExecuteError => e
162
+ raise GitInitFailed, "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
163
+ end
164
+
165
+ begin
166
+ @repo.add('.')
167
+ rescue Git::GitExecuteError => e
168
+ #raise GitAddFailed, "There was some problem adding this directory to the git changeset"
169
+ raise
170
+ end
171
+
172
+ begin
173
+ @repo.commit "Initial commit to #{project_name}."
174
+ rescue Git::GitExecuteError => e
175
+ raise
176
+ end
177
+
178
+ begin
179
+ @repo.add_remote('github', git_remote)
180
+ rescue Git::GitExecuteError => e
181
+ puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
182
+ raise
183
+ end
184
+ end
185
+ end
186
+
187
+ def create_and_push_repo
188
+ Net::HTTP.post_form URI.parse('http://github.com/api/v2/yaml/repos/create'),
189
+ 'login' => github_username,
190
+ 'token' => github_token,
191
+ 'description' => description,
192
+ 'name' => project_name
193
+ # TODO do a HEAD request to see when it's ready?
194
+ @repo.push('github')
195
+ end
196
+
197
+ def create_and_push_deployment
198
+ # Try to create a Heroku project with the given name, but fail over to a Heroku-assigned
199
+ # name if necessary.
200
+ unless system("heroku create #{project_name}")
201
+ result = system("heroku create")
202
+ end
203
+
204
+ @repo.push('heroku')
205
+ end
206
+
207
+ end
208
+ end
@@ -0,0 +1,31 @@
1
+ class Appleseed
2
+ class Generator
3
+ module GithubMixin
4
+ def self.extended(generator)
5
+ attr_accessor :github_username, :github_token
6
+
7
+ generator.github_username = generator.options[:github_username]
8
+ generator.github_token = generator.options[:github_token]
9
+ generator.should_create_github_repository = !generator.options[:no_github]
10
+
11
+ unless generator.github_username
12
+ raise NoGitHubUser
13
+ end
14
+
15
+ if generator.should_create_github_repository
16
+ unless generator.github_token
17
+ raise NoGitHubToken
18
+ end
19
+ end
20
+ end
21
+
22
+ def git_remote
23
+ @git_remote ||= "git@github.com:#{github_username}/#{project_name}.git"
24
+ end
25
+
26
+ def homepage
27
+ @homepage ||= "http://github.com/#{github_username}/#{project_name}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,80 @@
1
+ class Appleseed
2
+ class Generator
3
+ class Options < Hash
4
+ attr_reader :opts, :orig_args
5
+
6
+ def initialize(args)
7
+ super()
8
+
9
+ @orig_args = args.clone
10
+
11
+ git_config = if Pathname.new("~/.gitconfig").expand_path.exist?
12
+ Git.global_config
13
+ else
14
+ {}
15
+ end
16
+ self[:user_name] = ENV['GIT_AUTHOR_NAME'] || ENV['GIT_COMMITTER_NAME'] || git_config['user.name']
17
+ self[:user_email] = ENV['GIT_AUTHOR_EMAIL'] || ENV['GIT_COMMITTER_EMAIL'] || git_config['user.email']
18
+ self[:github_username] = git_config['github.user']
19
+ self[:github_token] = git_config['github.token']
20
+
21
+ require 'optparse'
22
+ @opts = OptionParser.new do |o|
23
+ o.banner = "Usage: #{File.basename($0)} [options] web-app-name\ne.g. #{File.basename($0)} new-years-2011"
24
+
25
+ o.separator ""
26
+
27
+ o.on('--description [DESCRIPTION]', 'specify a description of the project') do |description|
28
+ self[:description] = description
29
+ end
30
+
31
+ o.separator ""
32
+
33
+ o.on('--github-username [GITHUB_USERNAME]', "name of the user on GitHub to set the project up under") do |github_username|
34
+ self[:github_username] = github_username
35
+ end
36
+
37
+ o.on('--github-token [GITHUB_TOKEN]', "GitHub token to use for interacting with the GitHub API") do |github_token|
38
+ self[:github_token] = github_token
39
+ end
40
+
41
+ o.on('--git-remote [GIT_REMOTE]', 'URI to set the git origin remote to') do |git_remote|
42
+ self[:git_remote] = git_remote
43
+ end
44
+
45
+ o.on('--no-github', 'don\'t create the repository on GitHub') do
46
+ self[:no_github] = true
47
+ end
48
+
49
+ o.on('--no-heroku', 'don\'t create a deployment on Heroku') do
50
+ self[:no_heroku] = true
51
+ end
52
+
53
+ o.separator ""
54
+
55
+ o.on('--template [template_url]', "the URL or path for a custom Rails template file") do |template_url|
56
+ self[:template_url] = template_url
57
+ end
58
+
59
+ o.separator ""
60
+
61
+ o.on_tail('-h', '--help', 'display this help and exit') do
62
+ self[:show_help] = true
63
+ end
64
+ end
65
+
66
+ begin
67
+ @opts.parse!(args)
68
+ self[:project_name] = args.shift
69
+ rescue OptionParser::InvalidOption => e
70
+ self[:invalid_argument] = e.message
71
+ end
72
+ end
73
+
74
+ def merge(other)
75
+ self.class.new(@orig_args + other.orig_args)
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Appleseed" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'appleseed'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
@@ -0,0 +1,14 @@
1
+ gem "compass"
2
+
3
+ run 'bundle install'
4
+
5
+ run 'compass init rails . --using blueprint --sass-dir app/stylesheets --css-dir public/stylesheets/compiled'
6
+
7
+ run 'compass compile'
8
+
9
+ gsub_file 'config/environments/production.rb', /^end$/, %{
10
+ end
11
+
12
+ # Don't generate CSS from SCSS in production, because Heroku can't.
13
+ Sass::Plugin.options[:never_update] = true
14
+ }
@@ -0,0 +1,8 @@
1
+ gem 'cucumber'
2
+ gem 'cucumber-rails'
3
+ gem 'capybara'
4
+
5
+ run 'bundle install'
6
+
7
+ # Generate Cucumber infrastructure.
8
+ run 'rails generate cucumber:install --rspec --capybara'
@@ -0,0 +1,17 @@
1
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/gitignore.rb'
2
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/haml.rb'
3
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/compass.rb'
4
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/remove_prototype.rb'
5
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/jquery.rb'
6
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/rspec.rb'
7
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/cucumber.rb'
8
+ #apply 'http://github.com/endymion/appleseed/raw/master/templates/root_controller.rb'
9
+
10
+ apply 'http://localhost/projects/appleseed/templates/gitignore.rb'
11
+ apply 'http://localhost/projects/appleseed/templates/haml.rb'
12
+ apply 'http://localhost/projects/appleseed/templates/compass.rb'
13
+ apply 'http://localhost/projects/appleseed/templates/remove_prototype.rb'
14
+ apply 'http://localhost/projects/appleseed/templates/jquery.rb'
15
+ apply 'http://localhost/projects/appleseed/templates/rspec.rb'
16
+ apply 'http://localhost/projects/appleseed/templates/cucumber.rb'
17
+ apply 'http://localhost/projects/appleseed/templates/root_controller.rb'
@@ -0,0 +1,11 @@
1
+ run 'rm .gitignore'
2
+ file '.gitignore', <<-END
3
+ design
4
+ .bundle
5
+ .DS_Store
6
+ log/*.log
7
+ tmp/**/*
8
+ db/*.sqlite3
9
+ END
10
+
11
+ run 'mkdir design'
data/templates/haml.rb ADDED
@@ -0,0 +1,33 @@
1
+ gem 'haml'
2
+
3
+ run 'bundle install'
4
+
5
+ run 'haml --rails .'
6
+
7
+ run 'git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml'
8
+
9
+ gsub_file 'config/application.rb', /\send\nend/, %{
10
+ config.generators do |g|
11
+ g.template_engine :haml
12
+ end
13
+
14
+ end
15
+ end
16
+ }
17
+
18
+ run 'rm app/views/layouts/application.html.erb'
19
+ file 'app/views/layouts/application.html.haml', <<-END
20
+ !!!
21
+ %html
22
+ %head
23
+ %title [INSERT TITLE HERE]
24
+ = stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
25
+ = stylesheet_link_tag 'compiled/print.css', :media => 'print'
26
+ /[if lt IE 8]
27
+ = stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
28
+ = javascript_include_tag :defaults
29
+ = csrf_meta_tag
30
+ %body.bp.two-col
31
+ #container
32
+ = yield
33
+ END
@@ -0,0 +1,6 @@
1
+ # Install JQuery 1.4.2.
2
+ run "curl -L http://code.jquery.com/jquery-1.4.2.min.js > public/javascripts/jquery.js"
3
+ get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "public/javascripts/jquery-ui.js"
4
+
5
+ run 'rm public/javascripts/rails.js'
6
+ get "http://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
@@ -0,0 +1,5 @@
1
+ # Remove default JavaScript files that use Prototype.
2
+ run "rm public/javascripts/controls.js"
3
+ run "rm public/javascripts/dragdrop.js"
4
+ run "rm public/javascripts/effects.js"
5
+ run "rm public/javascripts/prototype.js"
@@ -0,0 +1,11 @@
1
+ run 'rm public/index.html'
2
+ run 'rm public/images/rails.png'
3
+
4
+ generate :controller, 'root', 'root'
5
+ route "root :to => 'root#root'"
6
+
7
+ run 'rm app/views/root/root.html.haml'
8
+ file 'app/views/root/root.html.haml', <<-END
9
+ #hello
10
+ Hello from your new app!
11
+ END
@@ -0,0 +1,10 @@
1
+ gem "rspec-rails", ">= 2.0.0.beta.17"
2
+ gem "factory_girl"
3
+
4
+ generate("rspec")
5
+
6
+ gsub_file 'config/application.rb', /^\s*config.generators do \|g\|$/, %{
7
+ config.generators do |g|
8
+ g.test_framework :rspec, :fixture => true, :views => false
9
+ g.integration_tool :rspec, :fixture => true, :views => true
10
+ }
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appleseed
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Ryan Alyn Porter
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-28 00:00:00 -04:00
19
+ default_executable: appleseed
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: Generator for a Rails 3 app that will also push the project to GitHub and Heroku.
38
+ email:
39
+ executables:
40
+ - appleseed
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.rdoc
46
+ files:
47
+ - .document
48
+ - .gitignore
49
+ - LICENSE
50
+ - README.rdoc
51
+ - Rakefile
52
+ - VERSION
53
+ - appleseed.gemspec
54
+ - bin/appleseed
55
+ - lib/appleseed.rb
56
+ - lib/appleseed/application.rb
57
+ - lib/appleseed/errors.rb
58
+ - lib/appleseed/generator.rb
59
+ - lib/appleseed/generator/github_mixin.rb
60
+ - lib/appleseed/options.rb
61
+ - spec/appleseed_spec.rb
62
+ - spec/spec.opts
63
+ - spec/spec_helper.rb
64
+ - templates/compass.rb
65
+ - templates/cucumber.rb
66
+ - templates/default.rb
67
+ - templates/gitignore.rb
68
+ - templates/haml.rb
69
+ - templates/jquery.rb
70
+ - templates/remove_prototype.rb
71
+ - templates/root_controller.rb
72
+ - templates/rspec.rb
73
+ has_rdoc: true
74
+ homepage: http://github.com/endymion/appleseed
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --charset=UTF-8
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.7
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Kick-start a Rails 3 project, push it to GitHub, deploy it to Heroku.
107
+ test_files:
108
+ - spec/appleseed_spec.rb
109
+ - spec/spec_helper.rb