bonio-capistrano-rails 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ec68e87c4a849a521aabdadb683299061958225
4
+ data.tar.gz: 5e326ceb319b35e53e1e76e40fb0d01856f95af0
5
+ SHA512:
6
+ metadata.gz: 87643016e0288a1f6e4b91a54122e4d7ff7a016ab8f0244ef6484795acf414dcca8ed23efc4a3f2be9c488c9be43cd6721584efa428c6f5bcf571d26f6714445
7
+ data.tar.gz: 5c0e0f361bffdb70fd91990d518c56a4ce6b4b158143ba2bde36ef843150a9b8fc83aea9c9e1ad8756aa9beee7fcc43a55789b4ce63ad83986fa005544b9bac9
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/CHANGELOG.md ADDED
@@ -0,0 +1,57 @@
1
+ # master
2
+
3
+ * Your contribution here!
4
+
5
+ # 1.1.8 (Sep 13 2016)
6
+
7
+ * Handle arrays passed into `normalize_asset_timestamps` correctly (#184)
8
+
9
+ # 1.1.7 (Jun 10 2016)
10
+
11
+ * call `Array#uniq` in `deploy:set_linked_dirs` task to remove duplicated :linked_dirs
12
+ * Add `migration_servers` configuration (#168)
13
+
14
+ # 1.1.6 (Jan 19 2016)
15
+
16
+ * Add `rake assets:clobber` task from Rails (#149)
17
+ * Make `assets:clean` capable with zsh (#150)
18
+ * Split `deploy:migrate` to allow for finer hook-control (#148)
19
+ * Fix for parsing ls output in detect_manifest_path (#133)
20
+
21
+ # 1.1.5 (Oct 15 2015)
22
+
23
+ * Disable `deploy:cleanup_assets` by default due to undesirable behavior in Rails 3. Use `set :keep_assets, 2` to explicitly enable this feature for Rails 4.
24
+
25
+ # 1.1.4 (Oct 10 2015)
26
+
27
+ * Fixing bug with normalize_assets typo #138
28
+ * Cleanup assets after:updated (#136)
29
+ * Fixed linked_dirs containing default value of assets_prefix (#125)
30
+
31
+ # 1.1.3 (Apr 18 2015)
32
+
33
+ * Fixed no_release behaviour (https://github.com/capistrano/rails/pull/95)
34
+ * Allow assets manifest backup with folder "manifests" (https://github.com/capistrano/rails/pull/92)
35
+ * Handle Sprocket 3 manifest filename
36
+
37
+ # 1.1.2 (Sep 1 2014)
38
+
39
+ * rails_env is set before deploy (https://github.com/capistrano/rails/pull/66)
40
+ * with `conditionally_migrate` option enabled you can skip `db:migrate` if there were no new migrations (https://github.com/capistrano/rails/pull/71)
41
+ * Allow early overriding of assets_* parameters (https://github.com/capistrano/rails/pull/73)
42
+
43
+ # 1.1.1
44
+
45
+ * New `asset_roles` options: https://github.com/capistrano/rails/pull/30
46
+ * normalized task spelling: 'deploy:normalise_assets' is now 'deploy:normalize_assets'
47
+ * depend on capistrano 3.1 to support multiple role arguments
48
+
49
+ # 1.1.0
50
+
51
+ * set rails_env even if capistrano-rails was required partly
52
+ * depend on capistrano-bundler
53
+ * require bundler with capistrano-rails/all
54
+
55
+ # 1.0.0
56
+
57
+ Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tom Clements
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,113 @@
1
+ # Capistrano::Rails
2
+
3
+ Rails specific tasks for Capistrano v3:
4
+
5
+ - `cap deploy:migrate`
6
+ - `cap deploy:compile_assets`
7
+
8
+ ## Installation
9
+
10
+ Add these lines to your application's Gemfile:
11
+
12
+ ```ruby
13
+ group :development do
14
+ gem 'capistrano', '~> 3.6'
15
+ gem 'capistrano-rails', '~> 1.1'
16
+ end
17
+ ```
18
+
19
+ Run the following command to install the gems:
20
+
21
+ ```
22
+ bundle install
23
+ ```
24
+
25
+ Then run the generator to create a basic set of configuration files:
26
+
27
+ ```
28
+ bundle exec cap install
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Require everything (`bundler`, `rails/assets` and `rails/migrations`):
34
+
35
+ ```ruby
36
+ # Capfile
37
+ require 'capistrano/rails'
38
+ ```
39
+
40
+ Or require just what you need manually:
41
+
42
+ ```ruby
43
+ # Capfile
44
+ require 'capistrano/bundler' # Rails needs Bundler, right?
45
+ require 'capistrano/rails/assets'
46
+ require 'capistrano/rails/migrations'
47
+ ```
48
+
49
+ Please note that any `require`s should be placed in `Capfile`, not in `config/deploy.rb`.
50
+
51
+ You can tweak some Rails-specific options in `config/deploy.rb`:
52
+
53
+ ```ruby
54
+ # If the environment differs from the stage name
55
+ set :rails_env, 'staging'
56
+
57
+ # Defaults to :db role
58
+ set :migration_role, :db
59
+
60
+ # Defaults to the primary :db server
61
+ set :migration_servers, -> { primary(fetch(:migration_role)) }
62
+
63
+ # Defaults to false
64
+ # Skip migration if files in db/migrate were not modified
65
+ set :conditionally_migrate, true
66
+
67
+ # Defaults to [:web]
68
+ set :assets_roles, [:web, :app]
69
+
70
+ # Defaults to 'assets'
71
+ # This should match config.assets.prefix in your rails config/application.rb
72
+ set :assets_prefix, 'prepackaged-assets'
73
+
74
+ # If you need to touch public/images, public/javascripts, and public/stylesheets on each deploy
75
+ set :normalize_asset_timestamps, %w{public/images public/javascripts public/stylesheets}
76
+
77
+ # Defaults to nil (no asset cleanup is performed)
78
+ # If you use Rails 4+ and you'd like to clean up old assets after each deploy,
79
+ # set this to the number of versions to keep
80
+ set :keep_assets, 2
81
+ ```
82
+
83
+ ### Symlinks
84
+
85
+ You'll probably want to symlink Rails shared files and directories like `log`, `tmp` and `public/uploads`.
86
+ Make sure you enable it by setting `linked_dirs` and `linked_files` options:
87
+
88
+ ```ruby
89
+ # deploy.rb
90
+ set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
91
+ set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
92
+ ```
93
+
94
+ ### Recommendations
95
+
96
+ While migrations looks like a concern of the database layer, Rails migrations
97
+ are strictly related to the framework. Therefore, it's recommended to set the
98
+ role to `:app` instead of `:db` like:
99
+
100
+ ```ruby
101
+ set :migration_role, :app
102
+ ```
103
+
104
+ The advantage is you won't need to deploy your application to your database
105
+ server, and overall a better separation of concerns.
106
+
107
+ ## Contributing
108
+
109
+ 1. Fork it
110
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
111
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
112
+ 4. Push to the branch (`git push origin my-new-feature`)
113
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "bonio-capistrano-rails"
7
+ gem.version = '1.1.8'
8
+ gem.authors = ["Tom Clements", "Lee Hambley", "Kir Shatrov"]
9
+ gem.email = ["seenmyfate@gmail.com", "lee.hambley@gmail.com", "shatrov@me.com"]
10
+ gem.description = %q{Rails specific Capistrano tasks}
11
+ gem.summary = %q{Rails specific Capistrano tasks}
12
+ gem.homepage = "https://github.com/BonioTw/capistrano-rails"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.add_dependency 'capistrano', '~> 3.1'
19
+ gem.add_dependency 'capistrano-bundler', '~> 1.1'
20
+
21
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ require 'capistrano/bundler'
2
+ require 'capistrano/rails/assets'
3
+ require 'capistrano/rails/migrations'
@@ -0,0 +1 @@
1
+ load File.expand_path("../../tasks/assets.rake", __FILE__)
@@ -0,0 +1 @@
1
+ load File.expand_path("../../tasks/migrations.rake", __FILE__)
@@ -0,0 +1,134 @@
1
+ load File.expand_path("../set_rails_env.rake", __FILE__)
2
+
3
+ module Capistrano
4
+ class FileNotFound < StandardError
5
+ end
6
+ end
7
+
8
+ namespace :deploy do
9
+ desc 'Normalize asset timestamps'
10
+ task :normalize_assets => [:set_rails_env] do
11
+ on release_roles(fetch(:assets_roles)) do
12
+ assets = Array(fetch(:normalize_asset_timestamps, []))
13
+ if assets.any?
14
+ within release_path do
15
+ execute :find, "#{assets.join(' ')} -exec touch -t #{asset_timestamp} {} ';'; true"
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ desc 'Compile assets'
22
+ task :compile_assets => [:set_rails_env] do
23
+ invoke 'deploy:assets:precompile'
24
+ invoke 'deploy:assets:backup_manifest'
25
+ end
26
+
27
+ desc 'Cleanup expired assets'
28
+ task :cleanup_assets => [:set_rails_env] do
29
+ next unless fetch(:keep_assets)
30
+ on release_roles(fetch(:assets_roles)) do
31
+ within release_path do
32
+ with rails_env: fetch(:rails_env) do
33
+ execute :rake, "'assets:clean[#{fetch(:keep_assets)}]'"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ desc 'Clobber assets'
40
+ task :clobber_assets => [:set_rails_env] do
41
+ on release_roles(fetch(:assets_roles)) do
42
+ within release_path do
43
+ with rails_env: fetch(:rails_env) do
44
+ execute :rake, "assets:clobber"
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ desc 'Rollback assets'
51
+ task :rollback_assets => [:set_rails_env] do
52
+ begin
53
+ invoke 'deploy:assets:restore_manifest'
54
+ rescue Capistrano::FileNotFound
55
+ invoke 'deploy:compile_assets'
56
+ end
57
+ end
58
+
59
+ after 'deploy:updated', 'deploy:compile_assets'
60
+ after 'deploy:updated', 'deploy:cleanup_assets'
61
+ after 'deploy:updated', 'deploy:normalize_assets'
62
+ after 'deploy:reverted', 'deploy:rollback_assets'
63
+
64
+ namespace :assets do
65
+ task :precompile do
66
+ on release_roles(fetch(:assets_roles)) do
67
+ within release_path do
68
+ with rails_env: fetch(:rails_env) do
69
+ execute :rake, "assets:precompile:primary RAILS_GROUPS=assets --trace"
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ task :backup_manifest do
76
+ on release_roles(fetch(:assets_roles)) do
77
+ within release_path do
78
+ backup_path = release_path.join('assets_manifest_backup')
79
+
80
+ execute :mkdir, '-p', backup_path
81
+ execute :cp,
82
+ detect_manifest_path,
83
+ backup_path
84
+ end
85
+ end
86
+ end
87
+
88
+ task :restore_manifest do
89
+ on release_roles(fetch(:assets_roles)) do
90
+ within release_path do
91
+ target = detect_manifest_path
92
+ source = release_path.join('assets_manifest_backup', File.basename(target))
93
+ if test "[[ -f #{source} && -f #{target} ]]"
94
+ execute :cp, source, target
95
+ else
96
+ msg = 'Rails assets manifest file (or backup file) not found.'
97
+ warn msg
98
+ fail Capistrano::FileNotFound, msg
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ def detect_manifest_path
105
+ %w(
106
+ .sprockets-manifest*
107
+ manifest*.*
108
+ ).each do |pattern|
109
+ candidate = release_path.join('public', fetch(:assets_prefix), pattern)
110
+ return capture(:ls, candidate).strip.gsub(/(\r|\n)/,' ') if test(:ls, candidate)
111
+ end
112
+ msg = 'Rails assets manifest file not found.'
113
+ warn msg
114
+ fail Capistrano::FileNotFound, msg
115
+ end
116
+ end
117
+ end
118
+
119
+ # we can't set linked_dirs in load:defaults,
120
+ # as assets_prefix will always have a default value
121
+ namespace :deploy do
122
+ task :set_linked_dirs do
123
+ set :linked_dirs, fetch(:linked_dirs, []).push("public/#{fetch(:assets_prefix)}").uniq
124
+ end
125
+ end
126
+
127
+ after 'deploy:set_rails_env', 'deploy:set_linked_dirs'
128
+
129
+ namespace :load do
130
+ task :defaults do
131
+ set :assets_roles, fetch(:assets_roles, [:web])
132
+ set :assets_prefix, fetch(:assets_prefix, 'assets')
133
+ end
134
+ end
@@ -0,0 +1,39 @@
1
+ load File.expand_path("../set_rails_env.rake", __FILE__)
2
+
3
+ namespace :deploy do
4
+
5
+ desc 'Runs rake db:migrate if migrations are set'
6
+ task :migrate => [:set_rails_env] do
7
+ on fetch(:migration_servers) do
8
+ conditionally_migrate = fetch(:conditionally_migrate)
9
+ info '[deploy:migrate] Checking changes in /db/migrate' if conditionally_migrate
10
+ if conditionally_migrate && test("diff -q #{release_path}/db/migrate #{current_path}/db/migrate")
11
+ info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db/migrate)'
12
+ else
13
+ info '[deploy:migrate] Run `rake db:migrate`'
14
+ invoke :'deploy:migrating'
15
+ end
16
+ end
17
+ end
18
+
19
+ desc 'Runs rake db:migrate'
20
+ task migrating: [:set_rails_env] do
21
+ on fetch(:migration_servers) do
22
+ within release_path do
23
+ with rails_env: fetch(:rails_env) do
24
+ execute :rake, 'db:migrate'
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ after 'deploy:updated', 'deploy:migrate'
31
+ end
32
+
33
+ namespace :load do
34
+ task :defaults do
35
+ set :conditionally_migrate, fetch(:conditionally_migrate, false)
36
+ set :migration_role, fetch(:migration_role, :db)
37
+ set :migration_servers, -> { primary(fetch(:migration_role)) }
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ namespace :deploy do
2
+ task :set_rails_env do
3
+ set :rails_env, (fetch(:rails_env) || fetch(:stage))
4
+ end
5
+ end
6
+
7
+ Capistrano::DSL.stages.each do |stage|
8
+ after stage, 'deploy:set_rails_env'
9
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bonio-capistrano-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.8
5
+ platform: ruby
6
+ authors:
7
+ - Tom Clements
8
+ - Lee Hambley
9
+ - Kir Shatrov
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-12-09 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '3.1'
29
+ - !ruby/object:Gem::Dependency
30
+ name: capistrano-bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.1'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.1'
43
+ description: Rails specific Capistrano tasks
44
+ email:
45
+ - seenmyfate@gmail.com
46
+ - lee.hambley@gmail.com
47
+ - shatrov@me.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - ".gitignore"
53
+ - CHANGELOG.md
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - capistrano-rails.gemspec
59
+ - lib/capistrano-rails.rb
60
+ - lib/capistrano/rails.rb
61
+ - lib/capistrano/rails/assets.rb
62
+ - lib/capistrano/rails/migrations.rb
63
+ - lib/capistrano/tasks/assets.rake
64
+ - lib/capistrano/tasks/migrations.rake
65
+ - lib/capistrano/tasks/set_rails_env.rake
66
+ homepage: https://github.com/BonioTw/capistrano-rails
67
+ licenses: []
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.2.5
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Rails specific Capistrano tasks
89
+ test_files: []