appsta 1.0.0
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 +4 -0
- data/Manifest.txt +20 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +62 -0
- data/Rakefile +28 -0
- data/bin/appsta +35 -0
- data/lib/appsta.rb +28 -0
- data/lib/appsta/git.rb +10 -0
- data/lib/appsta/github.rb +26 -0
- data/lib/appsta/heroku.rb +51 -0
- data/lib/template.rb +45 -0
- data/resources/README.erb +20 -0
- data/resources/index.html.erb +25 -0
- data/script/console +7 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_appsta.rb +31 -0
- data/test/test_git.rb +37 -0
- data/test/test_github.rb +44 -0
- data/test/test_helper.rb +6 -0
- data/test/test_heroku.rb +65 -0
- metadata +122 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
bin/appsta
|
7
|
+
lib/appsta.rb
|
8
|
+
lib/appsta/heroku.rb
|
9
|
+
lib/appsta/github.rb
|
10
|
+
lib/appsta/git.rb
|
11
|
+
lib/template.rb
|
12
|
+
resources/README.erb
|
13
|
+
resources/index.html.erb
|
14
|
+
script/console
|
15
|
+
script/destroy
|
16
|
+
script/generate
|
17
|
+
test/test_heroku.rb
|
18
|
+
test/test_github.rb
|
19
|
+
test/test_git.rb
|
20
|
+
test/test_helper.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
= appsta
|
2
|
+
|
3
|
+
* http://appsta.com
|
4
|
+
* http://github.com/edraper/appsta
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
* Appsta is designed to make bootstrapping new Rails applications much easier.
|
9
|
+
|
10
|
+
== FEATURES:
|
11
|
+
|
12
|
+
* It provides a helper library for writing Rails templates, to quickly setup your projects on Heroku, GitHub, and other things to get your app up and running quickly.
|
13
|
+
* It also provides a command line tool to quickly create applications using a default template that uses the Appsta helper library to get you up to speed nice and quickly.
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
* You can create a new applicaion using the default Appsta template by running the following from the command line:
|
18
|
+
|
19
|
+
appsta <app_name>
|
20
|
+
|
21
|
+
* You can also use the Appsta helper methods in your own templates, by requiring the Appsta library and loading it within the template:
|
22
|
+
|
23
|
+
require "appsta"
|
24
|
+
Appsta.load
|
25
|
+
|
26
|
+
* For an idea of the functionality available within the template helpers, look at the default template that the Appsta command line tool uses.
|
27
|
+
|
28
|
+
== REQUIREMENTS:
|
29
|
+
|
30
|
+
* heroku
|
31
|
+
* rest_client
|
32
|
+
|
33
|
+
== INSTALL:
|
34
|
+
|
35
|
+
* To install, just run the following:
|
36
|
+
|
37
|
+
sudo gem install appsta
|
38
|
+
|
39
|
+
== LICENSE:
|
40
|
+
|
41
|
+
(The MIT License)
|
42
|
+
|
43
|
+
Copyright (c) 2009 Elliott Draper
|
44
|
+
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
46
|
+
a copy of this software and associated documentation files (the
|
47
|
+
'Software'), to deal in the Software without restriction, including
|
48
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
49
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
50
|
+
permit persons to whom the Software is furnished to do so, subject to
|
51
|
+
the following conditions:
|
52
|
+
|
53
|
+
The above copyright notice and this permission notice shall be
|
54
|
+
included in all copies or substantial portions of the Software.
|
55
|
+
|
56
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
57
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
58
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
59
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
60
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
61
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
62
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
2
|
+
%w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
3
|
+
require File.dirname(__FILE__) + '/lib/appsta'
|
4
|
+
|
5
|
+
# Generate all the Rake tasks
|
6
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
7
|
+
$hoe = Hoe.new('appsta', Appsta::VERSION) do |p|
|
8
|
+
p.developer('Elliott Draper', 'el@ejdraper.com')
|
9
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
10
|
+
p.post_install_message = 'PostInstall.txt'
|
11
|
+
p.rubyforge_name = p.name
|
12
|
+
p.extra_deps = [
|
13
|
+
['heroku'], ['rest-client']
|
14
|
+
]
|
15
|
+
p.extra_dev_deps = [
|
16
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
17
|
+
]
|
18
|
+
|
19
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
20
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
21
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
22
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'newgem/tasks'
|
26
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
data/bin/appsta
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Load what we need
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
5
|
+
require "rubygems"
|
6
|
+
require "appsta"
|
7
|
+
|
8
|
+
# Display the Appsta version
|
9
|
+
def display_version
|
10
|
+
puts "Appsta (#{Appsta::VERSION})"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Handle the help command, also display it when no arguments are specified
|
14
|
+
if ARGV.empty? || ARGV[0] == "-h" || ARGV[0] == "--help"
|
15
|
+
display_version
|
16
|
+
puts " -h, --help : display this help message"
|
17
|
+
puts " -v, --version : display the Appsta version"
|
18
|
+
puts " appsta <name> : create a Rails application using Appsta with the specified name"
|
19
|
+
puts ""
|
20
|
+
puts "By default, Appsta will initialize a local Git repository, setup your application"
|
21
|
+
puts "on Heroku with two environments (production and staging) and will also setup your"
|
22
|
+
puts "project repository on GitHub. It will also setup some useful gems and libraries."
|
23
|
+
elsif ARGV[0] == "-v" || ARGV[0] == "--version"
|
24
|
+
# This displays the Appsta version
|
25
|
+
display_version
|
26
|
+
elsif ARGV[0][0...1] == "-"
|
27
|
+
# This handles unknown commands
|
28
|
+
display_version
|
29
|
+
puts "Unknown command #{ARGV[0]}"
|
30
|
+
else
|
31
|
+
# This actually creates the application specified
|
32
|
+
display_version
|
33
|
+
puts "Creating application #{ARGV[0]}"
|
34
|
+
Kernel.system "rails -m #{File.join(File.dirname(__FILE__), "..", "lib", "template.rb")} #{ARGV[0]}"
|
35
|
+
end
|
data/lib/appsta.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "appsta", "heroku")
|
2
|
+
require File.join(File.dirname(__FILE__), "appsta", "github")
|
3
|
+
require File.join(File.dirname(__FILE__), "appsta", "git")
|
4
|
+
|
5
|
+
module Appsta
|
6
|
+
VERSION = "1.0.0"
|
7
|
+
|
8
|
+
include Appsta::Heroku
|
9
|
+
include Appsta::GitHub
|
10
|
+
include Appsta::Git
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# This loads Appsta so that it's methods are available to the template runner
|
14
|
+
def load
|
15
|
+
Rails::TemplateRunner.send(:include, Appsta)
|
16
|
+
end
|
17
|
+
|
18
|
+
# This returns the template path for Appsta
|
19
|
+
def template_path
|
20
|
+
File.expand_path(File.join(File.dirname(__FILE__), "template.rb"))
|
21
|
+
end
|
22
|
+
|
23
|
+
# This returns the resources path for Appsta
|
24
|
+
def resources_path
|
25
|
+
File.expand_path(File.join(File.dirname(__FILE__), "..", "resources"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/appsta/git.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
gem "rest-client"
|
2
|
+
require "rest_client"
|
3
|
+
|
4
|
+
module Appsta
|
5
|
+
module GitHub
|
6
|
+
# This creates a repository on GitHub for the project
|
7
|
+
def github
|
8
|
+
# This grabs the app name
|
9
|
+
name = File.basename(Dir.pwd)
|
10
|
+
# Ask the user for the GitHub username and password
|
11
|
+
github_username = ask("GitHub Username:")
|
12
|
+
github_password = ask("GitHub Password:")
|
13
|
+
# Create the GitHub client object
|
14
|
+
client = RestClient::Resource.new("http://github.com", github_username, github_password)["/api/v2/yaml/repos/create"]
|
15
|
+
# Post to GitHub, and examine the response for any error
|
16
|
+
response = YAML::load(client.post(:name => name, :public => false))
|
17
|
+
raise response["error"].first["error"] if response.keys.include?("error")
|
18
|
+
# Add the git remote for GitHub
|
19
|
+
git(:remote => "add origin git@github.com:#{github_username}/#{name}.git")
|
20
|
+
# Push the code up to GitHub
|
21
|
+
git(:push => "origin master")
|
22
|
+
# Return the information for the GitHub repo
|
23
|
+
"http://github.com/#{github_username}/#{name} - git@github.com:#{github_username}/#{name}.git"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
gem "heroku"
|
2
|
+
require "heroku"
|
3
|
+
|
4
|
+
module Appsta
|
5
|
+
module Heroku
|
6
|
+
# This creates a Heroku app for the application, with the specified environment
|
7
|
+
def heroku(environment = :production)
|
8
|
+
# This builds the Heroku app name, based on the app name and the environment
|
9
|
+
name = "#{File.basename(Dir.pwd)}-#{environment}".gsub("_", "-").gsub("-production", "")
|
10
|
+
# Ask the user for the Heroku username and password
|
11
|
+
@@heroku_username ||= ask("Heroku Username:")
|
12
|
+
@@heroku_password ||= ask("Heroku Password:")
|
13
|
+
# Create the Heroku client object
|
14
|
+
client = ::Heroku::Client.new(@@heroku_username, @@heroku_password)
|
15
|
+
# Create the app on Heroku
|
16
|
+
client.create(name, {})
|
17
|
+
# Add the git remote for the app
|
18
|
+
git(:remote => "add #{environment} git@heroku.com:#{name}.git")
|
19
|
+
# Push the code up to Heroku for the initial deploy
|
20
|
+
git(:push => "#{environment} master")
|
21
|
+
# Return the Heroku information for this app
|
22
|
+
"http://#{name}.heroku.com - git@heroku.com:#{name}.git"
|
23
|
+
end
|
24
|
+
|
25
|
+
# This creates the gems manifest for Heroku based on a hash of gem
|
26
|
+
# information, and adds the gem to the project
|
27
|
+
def heroku_gems(gems)
|
28
|
+
# This will hold the manifest
|
29
|
+
gem_manifest = ""
|
30
|
+
# Loop through all supplied gems
|
31
|
+
gems.each do |g|
|
32
|
+
# Remove the name from the hash and use that to start the line
|
33
|
+
name = g.delete :name
|
34
|
+
gem_line = name.dup
|
35
|
+
# Then add the source and version from the hash to the gems manifest (if present)
|
36
|
+
g.each_pair do |key, value|
|
37
|
+
# Ignore anything other than source or version
|
38
|
+
next unless key == :source || key == :version
|
39
|
+
# Add the value to the line
|
40
|
+
gem_line << " --#{key} #{value}"
|
41
|
+
end
|
42
|
+
# Add the line to the manifest
|
43
|
+
gem_manifest << "#{gem_line}\n"
|
44
|
+
# Install the gem
|
45
|
+
gem name, g
|
46
|
+
end
|
47
|
+
# Write the manifest to file
|
48
|
+
file ".gems", gem_manifest
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/template.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "appsta"
|
2
|
+
Appsta.load
|
3
|
+
|
4
|
+
# This works out the name of the app
|
5
|
+
name = File.basename(Dir.pwd)
|
6
|
+
|
7
|
+
# Remove certain files
|
8
|
+
["README", "public/index.html", "public/favicon.ico", "public/javascripts/*"].each do |path|
|
9
|
+
run "rm -f #{path}"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Grab jQuery for use in the app
|
13
|
+
run "curl -s -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js > public/javascripts/jquery.js"
|
14
|
+
|
15
|
+
# Setup the gems we want, including the creation of the Heroku gem manifest
|
16
|
+
gems = [
|
17
|
+
{:name => "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com"},
|
18
|
+
{:name => "mocha"},
|
19
|
+
{:name => "cucumber"},
|
20
|
+
{:name => "hpricot"},
|
21
|
+
{:name => "authlogic"}
|
22
|
+
]
|
23
|
+
heroku_gems gems
|
24
|
+
|
25
|
+
# Install all the gems we need
|
26
|
+
rake "gems:install", :sudo => true
|
27
|
+
|
28
|
+
# Setup the Git repo
|
29
|
+
git_setup
|
30
|
+
|
31
|
+
# Setup the app on Heroku
|
32
|
+
heroku_urls = []
|
33
|
+
[:production, :staging].each { |env| heroku_urls << heroku(env) }
|
34
|
+
|
35
|
+
# Setup the project repo on GitHub
|
36
|
+
github_url = github
|
37
|
+
|
38
|
+
# Setup the index.html and README files that Appsta auto-generates
|
39
|
+
file "README", ERB.new(File.read(File.join(Appsta.resources_path, "README.erb"))).result(binding)
|
40
|
+
file "public/index.html", ERB.new(File.read(File.join(Appsta.resources_path, "index.html.erb"))).result(binding)
|
41
|
+
|
42
|
+
# Update the git repo with our changes and push them
|
43
|
+
git :add => "."
|
44
|
+
git :commit => "-a -m 'added README and public/index.html'"
|
45
|
+
[:origin, :production, :staging].each { |remote| git(:push => "#{remote} master") }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%= name %> - created by Appsta
|
2
|
+
|
3
|
+
Your Rails application has been built by Appsta, and is now ready for development!
|
4
|
+
|
5
|
+
The application has been setup on Heroku:
|
6
|
+
<% heroku_urls.each do |heroku_url| %>
|
7
|
+
<%= heroku_url %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
A project repository has also been setup on GitHub:
|
11
|
+
<%= github_url %>
|
12
|
+
|
13
|
+
The following has been setup in your application:
|
14
|
+
|
15
|
+
jQuery
|
16
|
+
Shoulda
|
17
|
+
Mocha
|
18
|
+
Cucumber
|
19
|
+
Hpricot
|
20
|
+
Authlogic
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title><%= name %> - created by Appsta</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<h1><%= name %> - created by Appsta</h1>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
Your Rails application has been built by Appsta, and is now ready for development!
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p>
|
13
|
+
The following has been setup in your application:
|
14
|
+
<br />
|
15
|
+
<ul>
|
16
|
+
<li>jQuery</li>
|
17
|
+
<li>Shoulda</li>
|
18
|
+
<li>Mocha</li>
|
19
|
+
<li>Cucumber</li>
|
20
|
+
<li>Hpricot</li>
|
21
|
+
<li>Authlogic</li>
|
22
|
+
</ul>
|
23
|
+
</p>
|
24
|
+
</body>
|
25
|
+
</html>
|
data/script/console
ADDED
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_appsta.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
# Dummy template runner just for the specs, so we can be sure Appsta is calling the right method
|
4
|
+
module Rails
|
5
|
+
class TemplateRunner
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class TestAppsta < Test::Unit::TestCase
|
10
|
+
context "Loading Appsta" do
|
11
|
+
setup do
|
12
|
+
Rails::TemplateRunner.expects(:send).with(:include, Appsta)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "try to include the Appsta module on the Rails template runner" do
|
16
|
+
Appsta.load
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "Grabbing Appsta template path" do
|
21
|
+
should "return the right path" do
|
22
|
+
assert_equal File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "template.rb")), Appsta.template_path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "Grabbing Appsta resources path" do
|
27
|
+
should "return the right path" do
|
28
|
+
assert_equal File.expand_path(File.join(File.dirname(__FILE__), "..", "resources")), Appsta.resources_path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/test/test_git.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class RunGit
|
4
|
+
include Appsta::Git
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestGit < Test::Unit::TestCase
|
8
|
+
context "Setting up Git repo" do
|
9
|
+
setup do
|
10
|
+
setup_base_mocks
|
11
|
+
RunGit.any_instance.expects(:git).with(:commit => "-a -m 'initial commit by Appsta'")
|
12
|
+
end
|
13
|
+
|
14
|
+
should "not fail" do
|
15
|
+
assert true, RunGit.new.git_setup
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Setting up Git repo with a custom commit message" do
|
20
|
+
CUSTOM_MESSAGE = "my test commit message"
|
21
|
+
|
22
|
+
setup do
|
23
|
+
setup_base_mocks
|
24
|
+
RunGit.any_instance.expects(:git).with(:commit => "-a -m '#{CUSTOM_MESSAGE}'")
|
25
|
+
end
|
26
|
+
|
27
|
+
should "not fail" do
|
28
|
+
assert true, RunGit.new.git_setup(CUSTOM_MESSAGE)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# This sets up the mocks common to all contexts
|
33
|
+
def setup_base_mocks
|
34
|
+
RunGit.any_instance.expects(:git).with(:init)
|
35
|
+
RunGit.any_instance.expects(:git).with(:add => ".")
|
36
|
+
end
|
37
|
+
end
|
data/test/test_github.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class RunGitHub
|
4
|
+
include Appsta::GitHub
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestGitHub < Test::Unit::TestCase
|
8
|
+
context "Setting up GitHub" do
|
9
|
+
setup do
|
10
|
+
post = setup_base_mocks
|
11
|
+
post.expects(:post).with(:name => "appsta", :public => false).returns("{}")
|
12
|
+
RunGitHub.any_instance.expects(:git).with(:remote => "add origin git@github.com:github_username/appsta.git")
|
13
|
+
RunGitHub.any_instance.expects(:git).with(:push => "origin master")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "not fail" do
|
17
|
+
assert_equal "http://github.com/github_username/appsta - git@github.com:github_username/appsta.git", RunGitHub.new.github
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "Setting up GitHub and handling an error" do
|
22
|
+
setup do
|
23
|
+
post = setup_base_mocks
|
24
|
+
post.expects(:post).with(:name => "appsta", :public => false).returns("--- \nerror: \n- error: repository creation failed\n")
|
25
|
+
end
|
26
|
+
|
27
|
+
should "raise an exception" do
|
28
|
+
assert_raise RuntimeError do
|
29
|
+
RunGitHub.new.github
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# This sets up the mocks common to all contexts, and returns the client posting mock
|
35
|
+
def setup_base_mocks
|
36
|
+
RunGitHub.any_instance.expects(:ask).with("GitHub Username:").returns("github_username")
|
37
|
+
RunGitHub.any_instance.expects(:ask).with("GitHub Password:").returns("github_password")
|
38
|
+
client = mock("RestClient::Resource")
|
39
|
+
RestClient::Resource.expects(:new).with("http://github.com", "github_username", "github_password").returns(client)
|
40
|
+
post = mock("RestClient::Resource")
|
41
|
+
client.expects(:[]).with("/api/v2/yaml/repos/create").returns(post)
|
42
|
+
post
|
43
|
+
end
|
44
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/test_heroku.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class RunHeroku
|
4
|
+
include Appsta::Heroku
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestHeroku < Test::Unit::TestCase
|
8
|
+
context "Setting up Heroku" do
|
9
|
+
setup do
|
10
|
+
client = setup_base_mocks
|
11
|
+
client.expects(:create).with("appsta", {})
|
12
|
+
RunHeroku.any_instance.expects(:git).with(:remote => "add production git@heroku.com:appsta.git")
|
13
|
+
RunHeroku.any_instance.expects(:git).with(:push => "production master")
|
14
|
+
end
|
15
|
+
|
16
|
+
should "not fail and should ask for Heroku credentials first time around" do
|
17
|
+
RunHeroku.any_instance.expects(:ask).with("Heroku Username:").returns("heroku_username")
|
18
|
+
RunHeroku.any_instance.expects(:ask).with("Heroku Password:").returns("heroku_password")
|
19
|
+
assert_equal "http://appsta.heroku.com - git@heroku.com:appsta.git", RunHeroku.new.heroku
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "Setting up Heroku with a custom environment" do
|
24
|
+
setup do
|
25
|
+
client = setup_base_mocks
|
26
|
+
client.expects(:create).with("appsta-test", {})
|
27
|
+
RunHeroku.any_instance.expects(:git).with(:remote => "add test git@heroku.com:appsta-test.git")
|
28
|
+
RunHeroku.any_instance.expects(:git).with(:push => "test master")
|
29
|
+
end
|
30
|
+
|
31
|
+
should "not fail and should not ask for Heroku credentials second time around" do
|
32
|
+
assert_equal "http://appsta-test.heroku.com - git@heroku.com:appsta-test.git", RunHeroku.new.heroku(:test)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# This sets up the base mocks common to all contexts, and returns the client mock
|
37
|
+
def setup_base_mocks
|
38
|
+
client = mock("Heroku::Client")
|
39
|
+
Heroku::Client.expects(:new).with("heroku_username", "heroku_password").returns(client)
|
40
|
+
client
|
41
|
+
end
|
42
|
+
|
43
|
+
context "Setting up Heroku gems manifest" do
|
44
|
+
setup do
|
45
|
+
@gems = [{:name => "hpricot"}, {:name => "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com"}]
|
46
|
+
@gem_manifest =<<EOF
|
47
|
+
hpricot
|
48
|
+
thoughtbot-shoulda --source http://gems.github.com
|
49
|
+
EOF
|
50
|
+
end
|
51
|
+
|
52
|
+
should "create a valid gem manifest file" do
|
53
|
+
RunHeroku.any_instance.stubs(:gem)
|
54
|
+
RunHeroku.any_instance.expects(:file).with(".gems", @gem_manifest)
|
55
|
+
RunHeroku.new.heroku_gems(@gems)
|
56
|
+
end
|
57
|
+
|
58
|
+
should "handle calls to install the gems" do
|
59
|
+
RunHeroku.any_instance.stubs(:file)
|
60
|
+
RunHeroku.any_instance.expects(:gem).with("hpricot", {})
|
61
|
+
RunHeroku.any_instance.expects(:gem).with("thoughtbot-shoulda", {:lib => "shoulda", :source => "http://gems.github.com"})
|
62
|
+
RunHeroku.new.heroku_gems(@gems)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appsta
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elliott Draper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-13 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: heroku
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rest-client
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: newgem
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.4.1
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: hoe
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.0
|
54
|
+
version:
|
55
|
+
description: "* Appsta is designed to make bootstrapping new Rails applications much easier."
|
56
|
+
email:
|
57
|
+
- el@ejdraper.com
|
58
|
+
executables:
|
59
|
+
- appsta
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files:
|
63
|
+
- History.txt
|
64
|
+
- Manifest.txt
|
65
|
+
- PostInstall.txt
|
66
|
+
- README.rdoc
|
67
|
+
files:
|
68
|
+
- History.txt
|
69
|
+
- Manifest.txt
|
70
|
+
- PostInstall.txt
|
71
|
+
- README.rdoc
|
72
|
+
- Rakefile
|
73
|
+
- bin/appsta
|
74
|
+
- lib/appsta.rb
|
75
|
+
- lib/appsta/heroku.rb
|
76
|
+
- lib/appsta/github.rb
|
77
|
+
- lib/appsta/git.rb
|
78
|
+
- lib/template.rb
|
79
|
+
- resources/README.erb
|
80
|
+
- resources/index.html.erb
|
81
|
+
- script/console
|
82
|
+
- script/destroy
|
83
|
+
- script/generate
|
84
|
+
- test/test_heroku.rb
|
85
|
+
- test/test_github.rb
|
86
|
+
- test/test_git.rb
|
87
|
+
- test/test_helper.rb
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://appsta.com
|
90
|
+
licenses: []
|
91
|
+
|
92
|
+
post_install_message: PostInstall.txt
|
93
|
+
rdoc_options:
|
94
|
+
- --main
|
95
|
+
- README.rdoc
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: "0"
|
103
|
+
version:
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: "0"
|
109
|
+
version:
|
110
|
+
requirements: []
|
111
|
+
|
112
|
+
rubyforge_project: appsta
|
113
|
+
rubygems_version: 1.3.2
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: "* Appsta is designed to make bootstrapping new Rails applications much easier."
|
117
|
+
test_files:
|
118
|
+
- test/test_appsta.rb
|
119
|
+
- test/test_git.rb
|
120
|
+
- test/test_github.rb
|
121
|
+
- test/test_helper.rb
|
122
|
+
- test/test_heroku.rb
|