katana 0.1.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.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ gem "heroku", ">= 1.0.0"
4
+
5
+ # Add dependencies to develop your gem here.
6
+ # Include everything needed to run rake, tests, features, etc.
7
+ group :development do
8
+ gem "rspec", "~> 2.1.0"
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.5.1"
11
+ gem "rcov", ">= 0"
12
+ end
@@ -0,0 +1,41 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ configuration (1.2.0)
5
+ diff-lcs (1.1.2)
6
+ git (1.2.5)
7
+ heroku (1.17.5)
8
+ json (~> 1.4.6)
9
+ launchy (~> 0.3.2)
10
+ rest-client (>= 1.4.0, < 1.7.0)
11
+ jeweler (1.5.2)
12
+ bundler (~> 1.0.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ json (1.4.6)
16
+ launchy (0.3.7)
17
+ configuration (>= 0.0.5)
18
+ rake (>= 0.8.1)
19
+ mime-types (1.16)
20
+ rake (0.8.7)
21
+ rcov (0.9.9)
22
+ rest-client (1.6.1)
23
+ mime-types (>= 1.16)
24
+ rspec (2.1.0)
25
+ rspec-core (~> 2.1.0)
26
+ rspec-expectations (~> 2.1.0)
27
+ rspec-mocks (~> 2.1.0)
28
+ rspec-core (2.1.0)
29
+ rspec-expectations (2.1.0)
30
+ diff-lcs (~> 1.1.2)
31
+ rspec-mocks (2.1.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 1.0.0)
38
+ heroku (>= 1.0.0)
39
+ jeweler (~> 1.5.1)
40
+ rcov
41
+ rspec (~> 2.1.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Andrew Kane
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.
@@ -0,0 +1,80 @@
1
+ # Katana
2
+
3
+ Simple multi-environment deployment for Heroku
4
+
5
+ This project was greatly inspired by [Capistrano](https://github.com/capistrano/capistrano) and [Heroku San](https://github.com/fastestforward/heroku_san).
6
+
7
+ ## Install
8
+
9
+ ### Rails 3
10
+
11
+ Add the following to your Gemfile.
12
+
13
+ group :development do
14
+ gem "katana"
15
+ end
16
+
17
+ and run
18
+
19
+ bundle install
20
+
21
+ You do not need to include the Heroku gem (it gets included as a dependency).
22
+
23
+ ### Rails 2 and other Ruby apps
24
+
25
+ gem install katana
26
+
27
+ ## Setup
28
+
29
+ To use Katana with an existing or future Heroku app, run:
30
+
31
+ kat init your-app-name
32
+
33
+ This will create a file in config/katana.yml.
34
+
35
+ ## Commands
36
+
37
+ You can run any Heroku command through Katana. Simply prefix the command with the environment. For instance:
38
+
39
+ heroku rake db:migrate
40
+
41
+ becomes
42
+
43
+ kat staging rake db:migrate
44
+
45
+ to run it on staging, and
46
+
47
+ kat production rake db:migrate
48
+
49
+ to run it on production.
50
+
51
+ ## Extras
52
+
53
+ Katana provides extra, Capistrano-like commands to make deployments easier.
54
+
55
+ ### deploy:setup
56
+
57
+ kat staging deploy:setup
58
+
59
+ Initializes a git repo (if necessary), removes the "heroku" remote, creates a remote for
60
+ the environment specified, and runs `update:config` and `update:stack` (see below for details).
61
+
62
+ ### deploy
63
+
64
+ kat staging deploy
65
+
66
+ Pushes the master branch to Heroku, runs your migrations, and restarts the app.
67
+
68
+ ### update:config
69
+
70
+ kat staging config:update
71
+
72
+ Runs `config:add` with all the vars listed in your configuration file.
73
+
74
+ ### update:stack
75
+
76
+ Runs `stack:migrate` with the stack listed in your configuration file.
77
+
78
+ ## Help make Katana better!
79
+
80
+ If you have suggestions or find a bug, create an issue at the top of the page. We also accept pull requests for those feeling adventurous...
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "katana"
16
+ gem.homepage = "http://github.com/ankane/katana"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Katana - Simple multi-environment deployment for Heroku}
19
+ gem.description = %Q{Katana is a wrapper for the Heroku gem to make multi-environment deployments simple.}
20
+ gem.email = "andrew@getformidable.com"
21
+ gem.authors = ["Andrew Kane"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'heroku', '>= 1.0.0'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "katana #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/kat ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "katana"
4
+ Katana.run
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{katana}
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 = ["Andrew Kane"]
12
+ s.date = %q{2011-01-14}
13
+ s.default_executable = %q{kat}
14
+ s.description = %q{Katana is a wrapper for the Heroku gem to make multi-environment deployments simple.}
15
+ s.email = %q{andrew@getformidable.com}
16
+ s.executables = ["kat"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/kat",
31
+ "katana.gemspec",
32
+ "lib/katana.rb",
33
+ "spec/katana_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = %q{http://github.com/ankane/katana}
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.7}
40
+ s.summary = %q{Katana - Simple multi-environment deployment for Heroku}
41
+ s.test_files = [
42
+ "spec/katana_spec.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<heroku>, [">= 1.0.0"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
55
+ s.add_development_dependency(%q<rcov>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<heroku>, [">= 1.0.0"])
58
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<heroku>, [">= 1.0.0"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ end
70
+ end
71
+
@@ -0,0 +1,135 @@
1
+ require "heroku"
2
+ require "yaml"
3
+ require "rake"
4
+
5
+ module Katana
6
+
7
+ CONFIG_PATH = "config/katana.yml"
8
+
9
+ class << self
10
+
11
+ def run
12
+ @env = ARGV.shift
13
+ if @env == "init"
14
+ init(ARGV.shift)
15
+ exit
16
+ end
17
+
18
+ unless File.exists?(CONFIG_PATH)
19
+ puts "Cannot find #{CONFIG_PATH}. Run \"kat init your-app-name\" to create it."
20
+ exit
21
+ end
22
+
23
+ @config = YAML.load_file(CONFIG_PATH)[@env]
24
+ if !@config
25
+ puts "Cannot find \"#{@env}\" environment in #{CONFIG_PATH}."
26
+ exit
27
+ end
28
+
29
+ command = ARGV.shift || ""
30
+ path = ARGV.join(" ")
31
+
32
+ case command
33
+ when "create"
34
+ lc("heroku create #{@config["app"]}")
35
+
36
+ when "deploy"
37
+ lc("git push #{@env} master")
38
+ hc("rake", "db:migrate")
39
+ hc("restart")
40
+
41
+ when "deploy:setup"
42
+ lc("git init") unless File.exists?(".git")
43
+
44
+ remotes = `git remote`.split("\n").select{|v| v == @env or v == "heroku"}
45
+ git_commands = remotes.map{|v| "git remote rm #{v}"}
46
+ git_commands << "git remote add #{@env} git@heroku.com:#{@config["app"]}.git"
47
+ lc(git_commands.join(" && "))
48
+
49
+ update_config
50
+ update_stack
51
+
52
+ when "config:update"
53
+ update_config
54
+
55
+ when "stack:update"
56
+ update_stack
57
+
58
+ when ""
59
+ puts "Please specify a command."
60
+
61
+ else
62
+ # pass the command to heroku
63
+ hc(command, path)
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def init(app)
70
+ if File.exists?(CONFIG_PATH)
71
+ puts "File #{CONFIG_PATH} already exists."
72
+ else
73
+ app = "your-app-name" if !app or app.empty?
74
+
75
+ config = <<CONFIG
76
+ # Heroku app configuration
77
+ # https://github.com/ankane/katana
78
+ #
79
+ # Commands: (for staging)
80
+ # kat staging config:update - adds the config vars below
81
+ # kat staging stack:update - migrates to the stack below
82
+
83
+
84
+ # shared settings
85
+
86
+ shared: &shared
87
+ stack: bamboo-mri-1.9.2
88
+ config: &config
89
+ BUNDLE_WITHOUT: "development:test"
90
+ # RACK_ENV is automatically added
91
+
92
+
93
+ # environments
94
+
95
+ production:
96
+ app: #{app}
97
+ <<: *shared
98
+
99
+ staging:
100
+ app: #{app}-staging
101
+ <<: *shared
102
+ CONFIG
103
+
104
+ Dir.mkdir("config") unless File.exists?("config")
105
+ File.open(CONFIG_PATH, "w") {|f| f.write(config) }
106
+
107
+ puts "Created config file at #{CONFIG_PATH}."
108
+ end
109
+ end
110
+
111
+ # heroku command
112
+ def hc(command, path="")
113
+ lc("heroku #{command} --app #{@config["app"]} #{path}")
114
+ end
115
+
116
+ # local command
117
+ def lc(command)
118
+ puts command
119
+ system(command)
120
+ puts
121
+ end
122
+
123
+ def update_config
124
+ vars = (@config["config"] || {}).merge({"RACK_ENV" => @env})
125
+ vars_str = vars.map{|k,v| "#{k}=#{v}"}.join(" ")
126
+ hc("config:add", vars_str)
127
+ end
128
+
129
+ def update_stack
130
+ hc("stack:migrate", @config["stack"]) if @config["stack"]
131
+ end
132
+
133
+ end
134
+
135
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Katana" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'katana'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: katana
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Andrew Kane
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-14 00:00:00 -08:00
18
+ default_executable: kat
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: heroku
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :runtime
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 2
44
+ - 1
45
+ - 0
46
+ version: 2.1.0
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: bundler
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 0
60
+ - 0
61
+ version: 1.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: jeweler
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 1
74
+ - 5
75
+ - 1
76
+ version: 1.5.1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: rcov
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id005
93
+ description: Katana is a wrapper for the Heroku gem to make multi-environment deployments simple.
94
+ email: andrew@getformidable.com
95
+ executables:
96
+ - kat
97
+ extensions: []
98
+
99
+ extra_rdoc_files:
100
+ - LICENSE.txt
101
+ - README.md
102
+ files:
103
+ - .document
104
+ - .rspec
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - VERSION
111
+ - bin/kat
112
+ - katana.gemspec
113
+ - lib/katana.rb
114
+ - spec/katana_spec.rb
115
+ - spec/spec_helper.rb
116
+ has_rdoc: true
117
+ homepage: http://github.com/ankane/katana
118
+ licenses:
119
+ - MIT
120
+ post_install_message:
121
+ rdoc_options: []
122
+
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: -230000859882304633
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ segments:
140
+ - 0
141
+ version: "0"
142
+ requirements: []
143
+
144
+ rubyforge_project:
145
+ rubygems_version: 1.3.7
146
+ signing_key:
147
+ specification_version: 3
148
+ summary: Katana - Simple multi-environment deployment for Heroku
149
+ test_files:
150
+ - spec/katana_spec.rb
151
+ - spec/spec_helper.rb