deploy_tasks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in deploy_tasks.gemspec
4
+ gemspec
data/README.markdown ADDED
@@ -0,0 +1,12 @@
1
+ Deploy Tasks
2
+ ============
3
+
4
+ To tell the tasks what is the name of your application, set a the constant
5
+ RAILS_APP like this:
6
+
7
+ RAILS_APP = 'my_fabulous_app'
8
+
9
+ License
10
+ =======
11
+
12
+ MIT License - Thomas Maurer
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "deploy_tasks"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "deploy_tasks"
7
+ s.version = DeployTasks::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Thomas Maurer"]
10
+ s.email = ["tma@freshbit.ch"]
11
+ s.homepage = ""
12
+ s.summary = %q{Common deploy tasks}
13
+ s.description = %q{Common deploy tasks}
14
+
15
+ s.rubyforge_project = "deploy_tasks"
16
+
17
+ s.add_dependency 'rails'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,11 @@
1
+ require 'rails/railtie'
2
+
3
+ module DeployTasks
4
+ VERSION = "0.1.0"
5
+
6
+ class Base < Rails::Railtie
7
+ rake_tasks do
8
+ Dir[File.join(File.dirname(__FILE__), 'tasks/*.rake')].each { |f| load f }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ # TODO
@@ -0,0 +1,60 @@
1
+ namespace :deploy do
2
+ desc 'Deploy to staging'
3
+ task :staging do
4
+ if Rake::Task['trans:fetch:all'].present?
5
+ message 'Pulling translations..'
6
+ Rake::Task['trans:fetch:all'].execute
7
+ end
8
+
9
+ if working_tree_dirty?
10
+ message 'Please clean your dirty tree!'; exit
11
+ end
12
+
13
+ push_to('staging')
14
+ migrate_database_of_app("#{RAILS_APP}-staging")
15
+ open_app("#{RAILS_APP}-staging")
16
+ end
17
+
18
+ desc 'Deploy to production'
19
+ task :production do
20
+ message '>> Are you sure to deploy to production? (type yes): ', true
21
+ if STDIN.gets.chomp == 'yes'
22
+ if Rake::Task['trans:fetch:all'].present?
23
+ message 'Pulling translations..'
24
+ Rake::Task['trans:fetch:all'].execute
25
+ end
26
+
27
+ if working_tree_dirty?
28
+ message 'Please clean your dirty tree!'; exit
29
+ end
30
+
31
+ push_to('production')
32
+ migrate_database_of_app('calculate')
33
+ open_app('calculate')
34
+ end
35
+ end
36
+
37
+ def working_tree_dirty?
38
+ `cd #{Rails.root} && git status --short -uno`.present?
39
+ end
40
+
41
+ def push_to(env)
42
+ message "Pushing to #{env}.."
43
+ `cd #{Rails.root} && git push #{env} master`
44
+ end
45
+
46
+ def migrate_database_of_app(heroku_app)
47
+ message "Migrate the database of #{heroku_app}.."
48
+ `cd #{Rails.root} && heroku rake db:migrate --app #{heroku_app}`
49
+ end
50
+
51
+ def open_app(heroku_app)
52
+ message 'Opening heroku app..'
53
+ `cd #{Rails.root} && heroku open --app #{heroku_app}`
54
+ end
55
+
56
+ def message(string, print = false)
57
+ s = "\e[0;33m\033[1m#{string}\e[0m"
58
+ print ? print(s) : puts(s)
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deploy_tasks
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Thomas Maurer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-03 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rails
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Common deploy tasks
36
+ email:
37
+ - tma@freshbit.ch
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README.markdown
48
+ - Rakefile
49
+ - deploy_tasks.gemspec
50
+ - lib/deploy_tasks.rb
51
+ - lib/tasks/capistrano.rake
52
+ - lib/tasks/heroku.rake
53
+ has_rdoc: true
54
+ homepage: ""
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: deploy_tasks
83
+ rubygems_version: 1.6.2
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Common deploy tasks
87
+ test_files: []
88
+