meataxe 0.1.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8afe1fdf1c5ad3cf43adc6a59ccbb6a01e40694
4
- data.tar.gz: 68afa1cf07882268ccf9c5a6ac94c575ec62d1de
3
+ metadata.gz: 6c283dfff495121cc09751b3b324b41548a14a38
4
+ data.tar.gz: 937a201757543961e2ca52682cd74773c8f84fad
5
5
  SHA512:
6
- metadata.gz: 1e2447deee51d7a3ffbcbc86e07cc17ee45fb83c30977ca142e205852ab5a8640f4877b279fbb148126860f71df995172436b301158969ae07338d44840c8118
7
- data.tar.gz: 57a06e0f7dfab2d867901cc8c360fee39fbcfe19bd5d7a3880fc56fd62f53b01df9cfa6880571bf3cd5e1195774c1c93a1afb834eb6ea14df227afee25d32917
6
+ metadata.gz: 2c219f3df6013d5560e06f531580c1e706df152dc872c8e64499bdcac414c8ba672907efb6c1f28ef128101aa272b089b1bc0fd7a4a75778cf3ccca9ac7023f2
7
+ data.tar.gz: 0ab1cfc0f1e5acc740e7a9a015afb3fc98d00256dda7cbda0a119002c65eba8d954e315a92d0c833d7861ddc3dfe4c5e166dd59000d6ceba1fbd5f9e617042ba
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ _site
19
+ .bak
20
+ *~
21
+ ~*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in meataxe.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Sourcey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Meataxe
2
+
3
+ Meataxe is a killer collection of Capistrano 3 deployment scripts.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```
10
+ gem 'meataxe', group: :development
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ $ gem install meataxe
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Add the following lines to your `Capfile`
28
+
29
+ ```ruby
30
+ require 'meataxe/capistrano'
31
+ ```
32
+
33
+ Then you can use ```cap -T``` to list available tasks.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ namespace :deploy do
2
+ desc "checks whether the currently checkout out revision matches the
3
+ remote one we're trying to deploy from"
4
+ task :check_revision do
5
+ branch = fetch(:branch)
6
+ unless `git rev-parse HEAD` == `git rev-parse origin/#{branch}`
7
+ puts "WARNING: HEAD is not the same as origin/#{branch}"
8
+ puts "Run `git push` to sync changes or make sure you've"
9
+ puts "checked out the branch: #{branch} as you can only deploy"
10
+ puts "if you've got the target branch checked out"
11
+ exit
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ namespace :deploy do
2
+ desc "compiles assets locally then rsyncs"
3
+ task :compile_assets_locally do
4
+ run_locally do
5
+ execute "RAILS_ENV=#{fetch(:rails_env)} bundle exec rake assets:precompile"
6
+ end
7
+ on roles(:app) do |role|
8
+ run_locally do
9
+ execute "rsync -av ./public/assets/ #{role.user}@#{role.hostname}:#{release_path}/public/assets/;"
10
+ end
11
+ sudo "chmod -R 755 #{release_path}/public/assets/"
12
+ end
13
+ run_locally do
14
+ execute "rm -rf ./public/assets"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ namespace :logs do
2
+ task :tail, :file do |t, args|
3
+ if args[:file]
4
+ on roles(:app) do
5
+ execute "tail -f #{shared_path}/log/#{args[:file]}.log"
6
+ end
7
+ else
8
+ puts "please specify a logfile e.g: 'rake logs:tail[logfile]"
9
+ puts "will tail 'shared_path/log/logfile.log'"
10
+ puts "remember if you use zsh you'll need to format it as:"
11
+ puts "rake 'logs:tail[logfile]' (single quotes)"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ namespace :monit do
2
+ %w(start stop restart).each do |task_name|
3
+ desc "#{task_name} Monit"
4
+ task task_name do
5
+ on roles(:app), in: :sequence, wait: 5 do
6
+ sudo "service monit #{task_name}"
7
+ end
8
+ end
9
+ end
10
+
11
+ desc "Reload Monit"
12
+ task 'reload' do
13
+ on roles(:app), in: :sequence, wait: 5 do
14
+ sudo "monit reload"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ namespace :nginx do
2
+ %w(start stop restart reload).each do |task_name|
3
+ desc "#{task } Nginx"
4
+ task task_name do
5
+ on roles(:app), in: :sequence, wait: 5 do
6
+ sudo "/etc/init.d/nginx #{task_name}"
7
+ end
8
+ end
9
+ end
10
+
11
+ desc "Remove default Nginx Virtual Host"
12
+ task "remove_default_vhost" do
13
+ on roles(:app) do
14
+ if test("[ -f /etc/nginx/sites-enabled/default ]")
15
+ sudo "rm /etc/nginx/sites-enabled/default"
16
+ puts "removed default Nginx Virtualhost"
17
+ else
18
+ puts "No default Nginx Virtualhost to remove"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ namespace :deploy do
2
+ desc "Runs test before deploying, can't deploy unless they pass"
3
+ task :run_tests do
4
+ test_log = "log/capistrano.test.log"
5
+ tests = fetch(:tests)
6
+ tests.each do |test|
7
+ puts "--> Running tests: '#{test}', please wait ..."
8
+ unless system "bundle exec rspec #{test} > #{test_log} 2>&1"
9
+ puts "--> Tests: '#{test}' failed. Results in: #{test_log} and below:"
10
+ system "cat #{test_log}"
11
+ exit;
12
+ end
13
+ puts "--> '#{test}' passed"
14
+ end
15
+ puts "--> All tests passed"
16
+ system "rm #{test_log}"
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ namespace :deploy do
2
+ task :setup_config do
3
+ on roles(:app) do
4
+ # make the config dir
5
+ execute :mkdir, "-p #{shared_path}/config"
6
+ full_app_name = fetch(:full_app_name)
7
+
8
+ # config files to be uploaded to shared/config, see the
9
+ # definition of smart_template for details of operation.
10
+ # Essentially looks for #{filename}.erb in deploy/#{full_app_name}/
11
+ # and if it isn't there, falls back to deploy/#{shared}. Generally
12
+ # everything should be in deploy/shared with params which differ
13
+ # set in the stage files
14
+ config_files = fetch(:config_files)
15
+ config_files.each do |file|
16
+ smart_template file
17
+ end
18
+
19
+ # which of the above files should be marked as executable
20
+ executable_files = fetch(:executable_config_files)
21
+ executable_files.each do |file|
22
+ execute :chmod, "+x #{shared_path}/config/#{file}"
23
+ end
24
+
25
+ # symlink stuff which should be... symlinked
26
+ symlinks = fetch(:symlinks)
27
+
28
+ symlinks.each do |symlink|
29
+ sudo "ln -nfs #{shared_path}/config/#{symlink[:source]} #{sub_strings(symlink[:link])}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,12 @@
1
+ namespace :tasks do
2
+ desc "Invoke rake task"
3
+ task :invoke do
4
+ on roles(:app) do
5
+ within release_path do
6
+ with rails_env: fetch(:rails_env) do
7
+ execute :rake, ENV['task']
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,51 @@
1
+ Dir.glob(File.join(File.dirname(__FILE__), 'capistrano/tasks/*.cap')).each { |r| load r }
2
+
3
+ # First try and copy the file `config/deploy/#{full_app_name}/#{from}.erb`
4
+ # to `shared/config/to`
5
+ #
6
+ # If the original source path doesn exist then it will search in:
7
+ # `config/deploy/shared/#{from}.erb`
8
+ # This allows files which are common to all enviros to come from a single
9
+ # source while allowing specific ones to be over-ridden.
10
+ # If the target file name is the same as the source then the second parameter
11
+ # can be left out.
12
+ def smart_template(from, to=nil)
13
+ to ||= from
14
+ full_to_path = "#{shared_path}/config/#{to}"
15
+ if from_erb_path = template_file(from)
16
+ from_erb = StringIO.new(ERB.new(File.read(from_erb_path)).result(binding))
17
+ upload! from_erb, full_to_path
18
+ info "copying: #{from_erb} to: #{full_to_path}"
19
+ else
20
+ error "error #{from} not found"
21
+ end
22
+ end
23
+
24
+ def template_file(name)
25
+ if File.exist?((file = "config/deploy/#{fetch(:full_app_name)}/#{name}.erb"))
26
+ return file
27
+ elsif File.exist?((file = "config/deploy/shared/#{name}.erb"))
28
+ return file
29
+ end
30
+ return nil
31
+ end
32
+
33
+ # We often want to refer to variables which are defined in subsequent stage
34
+ # files. This let's us use the {{var}} to represent fetch(:var) in strings
35
+ # which are only evaluated at runtime.
36
+ def sub_strings(input_string)
37
+ output_string = input_string
38
+ input_string.scan(/{{(\w*)}}/).each do |var|
39
+ output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym))
40
+ end
41
+ output_string
42
+ end
43
+
44
+ def host_architecture
45
+ capture("uname -m")
46
+ end
47
+
48
+ def update_repo(repo_url, target_path)
49
+ run "if [ -d #{target_path} ]; then (cd #{target_path} && git pull); else git clone #{repo_url} #{target_path}; fi"
50
+ #run "cd #{target_path} && if [ -d #{target_path} ]; then (git pull); else (cd #{target_path} && cd.. && git clone #{repo_url} #{target_path}); fi"
51
+ end
@@ -0,0 +1,3 @@
1
+ module Meataxe
2
+ VERSION = "0.5.0"
3
+ end
data/lib/meataxe.rb ADDED
@@ -0,0 +1,9 @@
1
+ # require_relative "meataxe/version"
2
+ #
3
+ # # Load custom tasks from `lib/capistrano/*` if you have any defined
4
+ # # Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
5
+ # # Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }
6
+ #
7
+ # module Meataxe
8
+ # # :)
9
+ # end
data/meataxe.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'meataxe/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "meataxe"
8
+ spec.version = Meataxe::VERSION
9
+ spec.authors = ["Kam Low"]
10
+ spec.email = ["hello@sourcey.com"]
11
+ spec.description = %q{Meataxe is a collection of killer Capistrano 3 deployment scripts.}
12
+ spec.summary = %q{Killer Capistrano 3 deployment scripts.}
13
+ spec.homepage = "http://github.com/sourcey/meataxe"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meataxe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kam Low
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-11 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,13 +38,30 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Meataxe is a collection of killer Capistrano deployment scripts.
41
+ description: Meataxe is a collection of killer Capistrano 3 deployment scripts.
42
42
  email:
43
43
  - hello@sourcey.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
- files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/meataxe.rb
54
+ - lib/meataxe/capistrano.rb
55
+ - lib/meataxe/capistrano/tasks/check_revision.cap
56
+ - lib/meataxe/capistrano/tasks/compile_assets_locally.cap
57
+ - lib/meataxe/capistrano/tasks/logs.cap
58
+ - lib/meataxe/capistrano/tasks/monit.cap
59
+ - lib/meataxe/capistrano/tasks/nginx.cap
60
+ - lib/meataxe/capistrano/tasks/run_tests.cap
61
+ - lib/meataxe/capistrano/tasks/setup_config.cap
62
+ - lib/meataxe/capistrano/tasks/tasks.cap
63
+ - lib/meataxe/version.rb
64
+ - meataxe.gemspec
48
65
  homepage: http://github.com/sourcey/meataxe
49
66
  licenses:
50
67
  - MIT
@@ -65,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
82
  version: '0'
66
83
  requirements: []
67
84
  rubyforge_project:
68
- rubygems_version: 2.4.5
85
+ rubygems_version: 2.5.1
69
86
  signing_key:
70
87
  specification_version: 4
71
- summary: Killer Capistrano deployment scripts.
88
+ summary: Killer Capistrano 3 deployment scripts.
72
89
  test_files: []