heroku_deployment 0.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/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/deploy_test +18 -0
- data/lib/heroku_deployment/config.rb +22 -0
- data/lib/heroku_deployment/git.rb +39 -0
- data/lib/heroku_deployment/hoptoad.rb +9 -0
- data/lib/heroku_deployment/packer.rb +50 -0
- data/lib/heroku_deployment.rb +47 -0
- data/spec/heroku_deployment_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +152 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.1.0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.1"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.5.1)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.8.7)
|
11
|
+
rcov (0.9.9)
|
12
|
+
rspec (2.1.0)
|
13
|
+
rspec-core (~> 2.1.0)
|
14
|
+
rspec-expectations (~> 2.1.0)
|
15
|
+
rspec-mocks (~> 2.1.0)
|
16
|
+
rspec-core (2.1.0)
|
17
|
+
rspec-expectations (2.1.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.1.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.0.0)
|
26
|
+
jeweler (~> 1.5.1)
|
27
|
+
rcov
|
28
|
+
rspec (~> 2.1.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Mooktakim Ahmed
|
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,19 @@
|
|
1
|
+
= heroku_deployment
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to heroku_deployment
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Mooktakim Ahmed. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
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 = "heroku_deployment"
|
16
|
+
gem.homepage = "http://github.com/mooktakim/heroku_deployment"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Tools to automate deployment to Heroku}
|
19
|
+
gem.description = %Q{Tools to automate deployment to Heroku. Heroku is already automatic, but if you like to compile all your SASS and compress all your CSS&JS files before committing to Heroku, this tool is great for that}
|
20
|
+
gem.email = "Mooktakim@fluxter.co.uk"
|
21
|
+
gem.authors = ["Mooktakim Ahmed"]
|
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 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
gem.add_dependency 'yui-compressor'
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rspec/core'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
|
+
end
|
35
|
+
|
36
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
37
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
38
|
+
spec.rcov = true
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :spec
|
42
|
+
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "heroku_deployment #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/deploy_test
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "heroku_deployment"
|
4
|
+
|
5
|
+
HerokuDeployment::Config.setup do |config|
|
6
|
+
config.app = "blahblah"
|
7
|
+
config.remote = "heroku"
|
8
|
+
config.generate_url = "/generate_js_and_css"
|
9
|
+
config.js_files = ["all.js"]
|
10
|
+
config.css_files = ["all.css"]
|
11
|
+
config.compress_js = true
|
12
|
+
config.compress_css = true
|
13
|
+
config.migrate = true
|
14
|
+
config.hoptoad = true
|
15
|
+
end
|
16
|
+
|
17
|
+
app = HerokuDeployment::Rails.new
|
18
|
+
app.deploy
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module HerokuDeployment
|
2
|
+
class Config
|
3
|
+
class << self
|
4
|
+
def setup &block
|
5
|
+
yield self
|
6
|
+
end
|
7
|
+
|
8
|
+
[:app, :remote, :generate_url, :js_files, :css_files, :commit_files, :compress_js, :compress_css, :migrate, :hoptoad].each do |meth|
|
9
|
+
class_eval <<-END
|
10
|
+
@@#{meth} = nil
|
11
|
+
def #{meth}
|
12
|
+
@@#{meth}
|
13
|
+
end
|
14
|
+
def #{meth}=(val)
|
15
|
+
@@#{meth} = val
|
16
|
+
end
|
17
|
+
END
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module HerokuDeployment
|
2
|
+
class Git
|
3
|
+
class << self
|
4
|
+
def current_version
|
5
|
+
`git show HEAD | head -n 1`.split(" ").last.strip
|
6
|
+
end
|
7
|
+
|
8
|
+
def push
|
9
|
+
system %(git push >/dev/null 2>&1)
|
10
|
+
end
|
11
|
+
|
12
|
+
def pull
|
13
|
+
system %(git pull >/dev/null 2>&1)
|
14
|
+
end
|
15
|
+
|
16
|
+
def push_remote
|
17
|
+
create_heroku_remote
|
18
|
+
system %(git push #{HerokuDeployment::Config.remote} master)
|
19
|
+
end
|
20
|
+
|
21
|
+
def pull_remote
|
22
|
+
system %(git pull #{HerokuDeployment::Config.remote} master >/dev/null 2>&1)
|
23
|
+
end
|
24
|
+
|
25
|
+
def commit
|
26
|
+
system %(git commit -m "Heroku deployment" -o #{HerokuDeployment::Config.commit_files.join(" ")} >/dev/null 2>&1)
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_heroku_remote
|
30
|
+
remote = HerokuDeployment::Config.remote
|
31
|
+
app = HerokuDeployment::Config.app
|
32
|
+
if `git remote | grep #{remote}`.to_s == ""
|
33
|
+
puts "Couldn't find '#{remote}' remote, added one now"
|
34
|
+
system %(git remote add #{remote} git@heroku.com:#{app}.git)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "yui/compressor"
|
2
|
+
|
3
|
+
module HerokuDeployment
|
4
|
+
class Packer
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def compress_js(file)
|
8
|
+
new(file, :js).compress
|
9
|
+
end
|
10
|
+
|
11
|
+
def compress_css(file)
|
12
|
+
new(file, :css).compress
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :file, :compressor
|
17
|
+
|
18
|
+
def initialize(f, t)
|
19
|
+
@file = f
|
20
|
+
if t == :js
|
21
|
+
@compressor = YUI::JavaScriptCompressor.new(:munge => true)
|
22
|
+
elsif t == :css
|
23
|
+
@compressor = YUI::CssCompressor.new
|
24
|
+
else
|
25
|
+
raise "File type '#{t}' is not supported"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def compress
|
30
|
+
compressed_content = compressor.compress(readfile)
|
31
|
+
writefile(compressed_content)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def readfile
|
37
|
+
f = File.open(file, "r")
|
38
|
+
content = f.readlines.join("\n")
|
39
|
+
f.close
|
40
|
+
content
|
41
|
+
end
|
42
|
+
|
43
|
+
def writefile(content)
|
44
|
+
f = File.open(file, "w")
|
45
|
+
f.write(content)
|
46
|
+
f.close
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Dir["#{File.dirname(__FILE__)}/heroku_deployment/**/*.rb"].each {|f| require f}
|
2
|
+
|
3
|
+
module HerokuDeployment
|
4
|
+
class Rails
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
HerokuDeployment::Config.commit_files = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate_css_and_js
|
11
|
+
puts "Generating all the Javascripts and CSS as production"
|
12
|
+
# system %(rm #{(js_files.collect{|j| "public/javascripts/#{j}"} + css_files.collect{|c| "public/stylesheets/#{c}"}).join(" ")} 2> /dev/null)
|
13
|
+
HerokuDeployment::Config.commit_files << 'public/javascripts/'
|
14
|
+
HerokuDeployment::Config.commit_files << 'public/stylesheets/'
|
15
|
+
!!system(%(RAILS_ENV=production ./script/rails runner "require 'rails/console/app' ; app.get '#{HerokuDeployment::Config.generate_url}'"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def db_migrate
|
19
|
+
system %(heroku rake db:migrate --app #{HerokuDeployment::Config.app})
|
20
|
+
end
|
21
|
+
|
22
|
+
def deploy
|
23
|
+
HerokuDeployment::Git.push
|
24
|
+
unless HerokuDeployment::Config.generate_url.to_s == ""
|
25
|
+
raise "JS & CSS generation failed" unless generate_css_and_js
|
26
|
+
end
|
27
|
+
if HerokuDeployment::Config.compress_js
|
28
|
+
HerokuDeployment::Config.js_files.each do |js|
|
29
|
+
HerokuDeployment::Packer.compress_js("public/javascripts/#{js}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
if HerokuDeployment::Config.compress_css
|
33
|
+
HerokuDeployment::Config.css_files.each do |css|
|
34
|
+
HerokuDeployment::Packer.compress_css("public/stylesheets/#{css}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
HerokuDeployment::Git.commit
|
38
|
+
HerokuDeployment::Git.push_remote
|
39
|
+
HerokuDeployment::Git.pull_remote
|
40
|
+
HerokuDeployment::Git.push
|
41
|
+
HerokuDeployment::Git.pull
|
42
|
+
db_migrate if HerokuDeployment::Config.migrate
|
43
|
+
HerokuDeployment::Hoptoad.deployed! if HerokuDeployment::Config.hoptoad
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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 'heroku_deployment'
|
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,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_deployment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Mooktakim Ahmed
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-16 00:00:00 +00:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
version: 2.1.0
|
32
|
+
type: :development
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bundler
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 0
|
45
|
+
- 0
|
46
|
+
version: 1.0.0
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: jeweler
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 5
|
60
|
+
- 1
|
61
|
+
version: 1.5.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: rcov
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: yui-compressor
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *id005
|
91
|
+
description: Tools to automate deployment to Heroku. Heroku is already automatic, but if you like to compile all your SASS and compress all your CSS&JS files before committing to Heroku, this tool is great for that
|
92
|
+
email: Mooktakim@fluxter.co.uk
|
93
|
+
executables: []
|
94
|
+
|
95
|
+
extensions: []
|
96
|
+
|
97
|
+
extra_rdoc_files:
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.rdoc
|
100
|
+
files:
|
101
|
+
- .document
|
102
|
+
- .rspec
|
103
|
+
- Gemfile
|
104
|
+
- Gemfile.lock
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.rdoc
|
107
|
+
- Rakefile
|
108
|
+
- VERSION
|
109
|
+
- deploy_test
|
110
|
+
- lib/heroku_deployment.rb
|
111
|
+
- lib/heroku_deployment/config.rb
|
112
|
+
- lib/heroku_deployment/git.rb
|
113
|
+
- lib/heroku_deployment/hoptoad.rb
|
114
|
+
- lib/heroku_deployment/packer.rb
|
115
|
+
- spec/heroku_deployment_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
has_rdoc: true
|
118
|
+
homepage: http://github.com/mooktakim/heroku_deployment
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 1681758980790419334
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
version: "0"
|
143
|
+
requirements: []
|
144
|
+
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.3.7
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: Tools to automate deployment to Heroku
|
150
|
+
test_files:
|
151
|
+
- spec/heroku_deployment_spec.rb
|
152
|
+
- spec/spec_helper.rb
|