capistrano-scm-copy-command 0.1.5

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: d49a4d4f2da9bf2b1d3c5b84819095c091f67d22
4
+ data.tar.gz: 73555fea48e6f6f699cc05b63847b983f6f45e19
5
+ SHA512:
6
+ metadata.gz: 246202114b057701a7fb2402a28b9f0a2eac317daff76fc188e17dde61f01f7c8934ab966f5aa1c460d5cbc553ecedc6111e586a837a245faaf0af64da7d0cd4
7
+ data.tar.gz: 691ed38fdb021fdb019f100a73eec07e357d373b4d616edfbe7506ddd807159224ee90b917cb8af70e8c795ed3cdd50cc352cd734c8db7b67c65142c5f965dd7
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format Fuubar
2
+ --order rand
3
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,40 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'tmp/**/*'
4
+ DisplayCopNames: true
5
+
6
+ Metrics/AbcSize:
7
+ Max: 38
8
+
9
+ # Configuration parameters: AllowURI.
10
+ Metrics/LineLength:
11
+ Max: 225
12
+
13
+ # Configuration parameters: CountKeywordArgs.
14
+ Metrics/ParameterLists:
15
+ Max: 8
16
+
17
+ Style/CaseEquality:
18
+ Enabled: false
19
+
20
+ Metrics/BlockNesting:
21
+ Max: 4
22
+
23
+ # Configuration parameters: CountComments.
24
+ Metrics/ClassLength:
25
+ Max: 174
26
+
27
+ Metrics/CyclomaticComplexity:
28
+ Max: 7
29
+
30
+ # Configuration parameters: CountComments.
31
+ Metrics/MethodLength:
32
+ Max: 76
33
+
34
+ Metrics/PerceivedComplexity:
35
+ Max: 8
36
+
37
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
38
+ Style/MethodName:
39
+ Exclude:
40
+ - lib/proxy_pac_rb/environment.rb
data/.simplecov ADDED
@@ -0,0 +1,8 @@
1
+ SimpleCov.start do
2
+ add_filter "/features/"
3
+ add_filter "/spec/"
4
+ add_filter "/tmp"
5
+ add_filter "/vendor"
6
+
7
+ add_group "lib", "lib"
8
+ end
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ -o doc/yard
2
+ --verbose
3
+ -
4
+ LICENSE.md
5
+ README.md
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-scm-copy-command (0.1.5)
5
+ capistrano (~> 3)
6
+ rubyzip (~> 1.1.7)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ capistrano (3.4.0)
12
+ i18n
13
+ rake (>= 10.0.0)
14
+ sshkit (~> 1.3)
15
+ i18n (0.7.0)
16
+ net-scp (1.2.1)
17
+ net-ssh (>= 2.6.5)
18
+ net-ssh (3.0.2)
19
+ rake (10.4.2)
20
+ rubyzip (1.1.7)
21
+ sshkit (1.8.1)
22
+ net-scp (>= 1.1.2)
23
+ net-ssh (>= 2.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.7)
30
+ capistrano-scm-copy-command!
31
+
32
+ BUNDLED WITH
33
+ 1.10.5
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Max Meyer
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,81 @@
1
+ # capistrano-scm-copy-command
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/capistrano-scm-copy-command.svg)](http://badge.fury.io/rb/capistrano-scm-copy-command)
4
+
5
+ Deploy anything which can be generated with a command with the help of [`capistrano`](https://github.com/capistrano/capistrano) (Vers. 3):
6
+
7
+ I use this to deploy a site generated with Gulp, but you could use it to deploy all static sites, e.g. Jekyll, Grunt, even Middleman!
8
+
9
+ [`capistrano-scm-copy`](https://github.com/wercker/capistrano-middleman) was quite helpful as template for this gem. (I just changed 3 lines.)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's `Gemfile`:
14
+
15
+ ```ruby
16
+ gem 'capistrano-scm-copy-command', require: false
17
+ ```
18
+
19
+ and require it in your `Capfile`:
20
+
21
+ ```ruby
22
+ require 'capistrano-scm-copy-command'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install capistrano-scm-copy-command
32
+
33
+ ## Usage
34
+
35
+
36
+ ### Activate plugin
37
+
38
+ You just need to change `:scm` to `:scm_copy_command` in your `deploy.rb` and define your `:build_command`:
39
+
40
+ ```
41
+ set :scm, :scm_copy_command
42
+ set :build_command, [:gulp, :default, "--env=#{fetch(:stage)}"]
43
+ ```
44
+
45
+ ### Configuration
46
+
47
+ You can configure `capistrano-scm-copy-command` by using the following options:
48
+
49
+ ```ruby
50
+ # Local name of archive build
51
+ set :archive_name, 'archive.zip'
52
+
53
+ # Name of build_directory
54
+ set :build_dir, 'build'
55
+
56
+ # Keep permissions from filesystem
57
+ set :keep_filesystem_permissions, false
58
+
59
+ # Overwrite permissions of directories
60
+ set :directory_permissions, 2775
61
+
62
+ # Overwrite permissions of files
63
+ set :file_permissions, 0664
64
+ ```
65
+
66
+ ### Required Software
67
+
68
+ Machine running [`capistrano`](https://github.com/capistrano/capistrano): [capistrano 3](https://github.com/capistrano/capistrano)
69
+
70
+ Servers:
71
+
72
+ * mktemp
73
+ * unzip
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it ( https://github.com/siebertm/capistrano-scm-copy-command/fork )
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/scm_copy_command/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capistrano-scm-copy-command'
8
+ spec.version = Capistrano::ScmCopyCommand::VERSION
9
+ spec.authors = ['Michael Siebert', 'Max Meyer']
10
+ spec.email = ['siebertm85@googlemail.com', 'dev@fedux.org']
11
+ spec.summary = 'General "I have a command which generates things" deploy strategy for capistrano'
12
+ spec.homepage = 'https://github.com/siebertm/capistrano-scm_copy_command'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.7'
21
+
22
+ spec.add_runtime_dependency 'capistrano', '~> 3'
23
+ spec.add_runtime_dependency 'rubyzip', '~>1.1.7'
24
+ end
data/cucumber.yml ADDED
@@ -0,0 +1,2 @@
1
+ default: --tags @wip:3 --tags ~@broken --tags ~@broken-external
2
+ all: --tags ~@wip --tags ~@broken --tags ~@broken-external
@@ -0,0 +1,3 @@
1
+ # rubocop:disable Style/FileName
2
+ require 'capistrano/scm_copy_command/version'
3
+ # rubocop:enable Style/FileName
@@ -0,0 +1,7 @@
1
+ require 'zip'
2
+ require 'zip/filesystem'
3
+ require 'pathname'
4
+ require 'capistrano/scm_copy_command/utils'
5
+ require 'tempfile'
6
+
7
+ load File.expand_path('../tasks/scm_copy_command.rake', __FILE__)
@@ -0,0 +1,56 @@
1
+ module Capistrano
2
+ module ScmCopyCommand
3
+ # Utils
4
+ module Utils
5
+ # Create zip archive from source directory
6
+ #
7
+ # @param [String] source_directory
8
+ # The directory
9
+ # @param [String] destination_file
10
+ # Name of the zip file
11
+ # @param [String] prefix
12
+ # Prefix inside zip file
13
+ # @param [String] working_directory
14
+ # The directory where rubyzip should change to
15
+ # @param [Array] exclude_patterns
16
+ # Ignore files matching patterns
17
+ # @param [TrueClass, FalseClass] keep_filesystem_permissions
18
+ # Record permissions in file system
19
+ # @param [OctalNumber] file_permissions
20
+ # Permissions for files
21
+ # @param [OctalNumber] directory_permissions
22
+ # Permissions for directories
23
+ def zip(
24
+ source_directory,
25
+ destination_file,
26
+ prefix: nil,
27
+ working_directory: Dir.getwd,
28
+ exclude_patterns: [],
29
+ keep_filesystem_permissions: false,
30
+ file_permissions: 0664,
31
+ directory_permissions: 2775
32
+ )
33
+ list = Rake::FileList.new(File.join(source_directory, '**', '*'))
34
+ list.exclude { |f| !File.file? f }
35
+ exclude_patterns.each { |e| list.exclude e }
36
+
37
+ Zip::File.open(destination_file, Zip::File::CREATE) do |z|
38
+ list.uniq.each do |filename|
39
+ paths = []
40
+ paths << Pathname.new(prefix) unless prefix.nil? || prefix.empty?
41
+ paths << Pathname.new(filename).relative_path_from(Pathname.new(working_directory))
42
+
43
+ z.add(File.join(*paths), File.expand_path(filename))
44
+
45
+ next if keep_filesystem_permissions
46
+
47
+ z.file.chmod(file_permissions, File.join(*paths)) if z.file.file? File.join(*paths)
48
+ z.file.chmod(directory_permissions, File.join(*paths)) if z.file.directory? File.join(*paths)
49
+ end
50
+ end
51
+ end
52
+
53
+ module_function :zip
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ module Capistrano
3
+ module ScmCopyCommand
4
+ VERSION = '0.1.5'
5
+ end
6
+ end
@@ -0,0 +1,70 @@
1
+ require 'securerandom'
2
+ namespace :scm_copy_command do
3
+ archive_prefix = fetch :archive_prefix, 'archive'
4
+ archive_name = format('%s-%s.zip', archive_prefix, SecureRandom.hex)
5
+ build_dir = fetch :build_dir, 'build'
6
+ keep_filesystem_permissions = fetch :keep_filesystem_permissions, false
7
+ directory_permissions = fetch :directory_permissions, 2775
8
+ file_permissions = fetch :file_permissions, 0664
9
+
10
+ exclude_patterns = Array(fetch(:exclude_patterns))
11
+
12
+ tar_roles = fetch(:tar_roles, :all)
13
+ desc "Archive files to #{archive_name}"
14
+ file archive_name do |t|
15
+ run_locally do
16
+ execute(*fetch(:command))
17
+
18
+ Capistrano::ScmCopyCommand::Utils.zip(
19
+ build_dir,
20
+ t.name,
21
+ working_directory: build_dir,
22
+ exclude_patterns: exclude_patterns,
23
+ keep_filesystem_permissions: keep_filesystem_permissions,
24
+ directory_permissions: directory_permissions,
25
+ file_permissions: file_permissions
26
+ )
27
+ end
28
+ end
29
+
30
+ desc "Build #{archive_name} on localhost"
31
+ task build: archive_name do
32
+ run_locally do
33
+ info "Archive \"#{archive_name}\" created."
34
+ end
35
+ end
36
+
37
+ desc "Deploy #{archive_name} to release_path"
38
+ task create_release: archive_name do |t|
39
+ archive_file = t.prerequisites.first
40
+
41
+ on release_roles tar_roles do |host|
42
+ # Make sure the release directory exists
43
+ info "==> release_path: #{release_path} is created on #{tar_roles} roles for host #{host} <=="
44
+ execute :install, "-d -m #{directory_permissions}", release_path
45
+
46
+ # Create a temporary file on the server
47
+ tmp_file = capture('mktemp')
48
+
49
+ # Upload the archive, extract it and finally remove the tmp_file
50
+ upload!(archive_file, tmp_file)
51
+
52
+ # umask = capture('umask')
53
+ # debug "umask on remote system #{host} is #{umask}"
54
+
55
+ execute :unzip, '-o', tmp_file, '-d', release_path
56
+ execute :rm, '-f', tmp_file
57
+ end
58
+ end
59
+
60
+ desc 'Cleaning up deploy'
61
+ task :clean do |_t|
62
+ FileUtils.rm_rf build_dir
63
+ FileUtils.rm_rf Dir.glob(format('%s-%s.zip', archive_prefix, '*'))
64
+ end
65
+
66
+ after 'deploy:finished', 'scm_copy_command:clean'
67
+
68
+ task :check
69
+ task :set_current_revision
70
+ end
data/script/bootstrap ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ echo "Bootstrapping development environment for application.." >&2
4
+
5
+ gem install bundler && bundle install
data/script/test ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ bundle exec rake test:coveralls
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-scm-copy-command
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Michael Siebert
8
+ - Max Meyer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-01-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.7'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: capistrano
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rubyzip
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 1.1.7
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 1.1.7
56
+ description:
57
+ email:
58
+ - siebertm85@googlemail.com
59
+ - dev@fedux.org
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".rubocop.yml"
67
+ - ".simplecov"
68
+ - ".yardopts"
69
+ - Gemfile
70
+ - Gemfile.lock
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - capistrano-scm-copy-command.gemspec
75
+ - cucumber.yml
76
+ - lib/capistrano-scm-copy-command.rb
77
+ - lib/capistrano/scm_copy_command.rb
78
+ - lib/capistrano/scm_copy_command/utils.rb
79
+ - lib/capistrano/scm_copy_command/version.rb
80
+ - lib/capistrano/tasks/scm_copy_command.rake
81
+ - script/bootstrap
82
+ - script/test
83
+ homepage: https://github.com/siebertm/capistrano-scm_copy_command
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.5
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: General "I have a command which generates things" deploy strategy for capistrano
107
+ test_files: []