capistrano-simple-htaccess 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,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a464b8aa46ba161ef149c046e1b14e4455247d42ec4fd7bea9ef1d2ade3e0226
4
+ data.tar.gz: fcd557a7a566d6d7126004e3c8dce8a8aa077a0fa86f351d4d159b7ffbf9a845
5
+ SHA512:
6
+ metadata.gz: 0423c3ada361983fcc420772bdc0a5399a13368505c72c6c288545529b4483ad98b856247814d802cb167db3f18936b7217d04ff709eda74e3f1c08cc0bab593
7
+ data.tar.gz: eb5bd182873fbeea5e7039cf520b7be14a653527bffd259e180c68e4158a54b194493ba33a17a32fe0f0a4843fd8afbbd04faab68a872a3ef5052d352f1b8d67
@@ -0,0 +1,19 @@
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
+ /vendor/ruby
19
+ .idea
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ### master
4
+
5
+ ### v0.1.0, 2019-03-06
6
+
7
+ - Initial version
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 DaMoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,60 @@
1
+ # Capistrano::SimpleHtaccess
2
+
3
+ Capistrano task for including a simple apache .htaccess file for redirects on deploy.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-simple-htaccess'
11
+ ```
12
+
13
+ Then add it to your `Capfile`:
14
+
15
+ ```ruby
16
+ require 'capistrano/simple_htaccess'
17
+ ```
18
+
19
+ And then:
20
+
21
+ ```sh
22
+ $ bundle install
23
+ ```
24
+
25
+ ## How it works
26
+
27
+ This gem hooks into Capistrano's flow by executing an `upload` task after the `deploy:updated` portion of Capistrano's
28
+ [flow](https://capistranorb.com/documentation/getting-started/flow/). See the source for more details
29
+
30
+ ## The default .htaccess file
31
+
32
+ Found as a HEREDOC string in `lib/capistrano/tasks/simple_htaccess.rake`, but also here for your convenience:
33
+
34
+ ```apache
35
+ <IfModule mod_rewrite.c>
36
+ Options +FollowSymLinks
37
+
38
+ RewriteEngine On
39
+ RewriteCond %{REQUEST_URI} !/current/
40
+ RewriteRule ^(.*)$ current/$1 [L]
41
+ </IfModule>
42
+ ```
43
+
44
+ ## Configuration
45
+
46
+ If you want a different .htaccess uploaded, just change the `:HTACCESS` variable as part of your deploy config. Ex:
47
+
48
+ ```ruby
49
+ set(:HTACCESS), <<HTACCESS
50
+ # Put your .htaccess config here
51
+ HTACCESS
52
+ ```
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome!
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "capistrano/simple_htaccess/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-simple-htaccess"
8
+ spec.version = Capistrano::SimpleHtaccess::VERSION
9
+ spec.authors = ["DaMoo"]
10
+ spec.email = ["git@damoo.zone"]
11
+
12
+ spec.summary = %q{Capistrano task for including a simple apache .htaccess file for redirects on deploy}
13
+ spec.homepage = "https://github.com/da-moo/capistrano-simple-htaccess"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "capistrano", "~> 3.11"
23
+
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/simple_htaccess.rake', __FILE__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module SimpleHtaccess
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :redirect_OK, false
4
+ set :HTACCESS, <<HTACCESS
5
+ <IfModule mod_rewrite.c>
6
+ Options +FollowSymLinks
7
+
8
+ RewriteEngine On
9
+ RewriteCond %{REQUEST_URI} !/current/
10
+ RewriteRule ^(.*)$ current/$1 [L]
11
+ </IfModule>
12
+
13
+ HTACCESS
14
+ end
15
+ end
16
+
17
+ namespace :deploy do
18
+ namespace :simple_htaccess do
19
+
20
+ task :create_htaccess do
21
+ on roles :web do
22
+ upload! StringIO.new(fetch :HTACCESS), "#{deploy_to}/.htaccess" unless fetch(:redirect_OK)
23
+ end
24
+ end
25
+
26
+ task :ensure_htaccess do
27
+ on roles :web do
28
+ path = "#{deploy_to}/.htaccess"
29
+ if test("[ -f #{path} ]")
30
+ existing_text = capture :cat, path
31
+ set :redirect_OK, (existing_text.strip == fetch(:HTACCESS).strip)
32
+ else
33
+ execute :touch, path
34
+ end
35
+ end
36
+ end
37
+
38
+ desc "Ensures basic .htaccess redirects are properly setup for Capistrano deployment"
39
+ task ensure: [:ensure_htaccess, :create_htaccess]
40
+ end
41
+ end
42
+
43
+ after "deploy:updated", "deploy:simple_htaccess:ensure"
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-simple-htaccess
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - DaMoo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - git@damoo.zone
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - capistrano-simple-htaccess.gemspec
69
+ - lib/capistrano/simple_htaccess.rb
70
+ - lib/capistrano/simple_htaccess/version.rb
71
+ - lib/capistrano/tasks/simple_htaccess.rake
72
+ homepage: https://github.com/da-moo/capistrano-simple-htaccess
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Capistrano task for including a simple apache .htaccess file for redirects
95
+ on deploy
96
+ test_files: []