rsync_deploy 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +5 -0
- data/README.md +17 -0
- data/Rakefile +1 -0
- data/bin/rsync_deploy +5 -0
- data/lib/colorize_bold_mode_hack.rb +6 -0
- data/lib/rsync_deploy/config.rb +31 -0
- data/lib/rsync_deploy/runner.rb +52 -0
- data/lib/rsync_deploy/version.rb +3 -0
- data/lib/rsync_deploy.rb +4 -0
- data/rsync_deploy.gemspec +24 -0
- metadata +111 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Rsync Deploy
|
2
|
+
============
|
3
|
+
|
4
|
+
Simple deploy tool that is using rsync
|
5
|
+
|
6
|
+
You need to create a config file named `rsync_deploy.rb` in the root of your project with contents:
|
7
|
+
|
8
|
+
``` ruby
|
9
|
+
set :deploy_to, "user@host.com:/path/to/project"
|
10
|
+
set :targets, %w(
|
11
|
+
first/directory
|
12
|
+
second/directory
|
13
|
+
)
|
14
|
+
```
|
15
|
+
|
16
|
+
Then just run `rsync_deploy` and it will sync your targets
|
17
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/rsync_deploy
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module RsyncDeploy
|
2
|
+
class Config
|
3
|
+
attr_accessor :config
|
4
|
+
|
5
|
+
class MissingConfigError < StandardError ; end
|
6
|
+
|
7
|
+
def initialize(file)
|
8
|
+
if File.exists? file
|
9
|
+
@config = {}
|
10
|
+
instance_eval File.read(file)
|
11
|
+
else
|
12
|
+
raise MissingConfigError, "Missing config file - #{file}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def set(key, value)
|
17
|
+
@config[key] = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(method_sym, *arguments, &block)
|
21
|
+
if @config.has_key?(method_sym)
|
22
|
+
self.class.send(:define_method, method_sym) do
|
23
|
+
@config[method_sym]
|
24
|
+
end
|
25
|
+
@config[method_sym]
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'colorize'
|
3
|
+
require 'shell-spinner'
|
4
|
+
|
5
|
+
module RsyncDeploy
|
6
|
+
class Runner
|
7
|
+
def self.run(config = nil)
|
8
|
+
config = RsyncDeploy::Config.new(config || 'rsync_deploy.rb')
|
9
|
+
|
10
|
+
rsync = "rsync -r -v --progress --delete -c -z -s"
|
11
|
+
rsync_dry_run = rsync + " -n"
|
12
|
+
|
13
|
+
updated = []
|
14
|
+
|
15
|
+
puts "Dry run first!".bold.green
|
16
|
+
|
17
|
+
config.targets.each do |target|
|
18
|
+
result = nil
|
19
|
+
ShellSpinner "checking #{target}".green do
|
20
|
+
result = `#{rsync_dry_run} #{target} #{config.deploy_to}/#{target}`
|
21
|
+
end
|
22
|
+
if result.lines.count > 4
|
23
|
+
updated << target
|
24
|
+
puts "!".bold.red + " Updated files:".bold.blue
|
25
|
+
puts result.split("\n")[1..-4]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if updated.empty?
|
30
|
+
puts "~ Everything is up to date! Nothing to do!".bold.green
|
31
|
+
else
|
32
|
+
print "\nIs it ok to deploy? [y/n]: ".bold.green
|
33
|
+
system "stty raw -echo"
|
34
|
+
yesno = STDIN.getc
|
35
|
+
system "stty -raw -echo"
|
36
|
+
puts
|
37
|
+
|
38
|
+
if yesno.downcase == 'y'
|
39
|
+
updated.each do |target|
|
40
|
+
system "#{rsync} #{target} #{config.deploy_to}/#{target}"
|
41
|
+
end
|
42
|
+
puts "~ Done!".bold.green
|
43
|
+
else
|
44
|
+
puts "~ Finished".bold.green
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue RsyncDeploy::Config::MissingConfigError => e
|
48
|
+
puts "Error: ".bold.red + e.message
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/lib/rsync_deploy.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rsync_deploy/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rsync_deploy"
|
7
|
+
s.version = RsyncDeploy::VERSION
|
8
|
+
s.authors = ["Anton Dieterle"]
|
9
|
+
s.email = ["antondie@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/adie/rsync_deploy"
|
11
|
+
s.summary = %q{Deploy tool using rsync}
|
12
|
+
s.description = %q{Deploy tool using rsync}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rsync_deploy"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_runtime_dependency "colorize"
|
23
|
+
s.add_runtime_dependency "shell-spinner"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rsync_deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anton Dieterle
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: colorize
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: shell-spinner
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Deploy tool using rsync
|
63
|
+
email:
|
64
|
+
- antondie@gmail.com
|
65
|
+
executables:
|
66
|
+
- rsync_deploy
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- bin/rsync_deploy
|
75
|
+
- lib/colorize_bold_mode_hack.rb
|
76
|
+
- lib/rsync_deploy.rb
|
77
|
+
- lib/rsync_deploy/config.rb
|
78
|
+
- lib/rsync_deploy/runner.rb
|
79
|
+
- lib/rsync_deploy/version.rb
|
80
|
+
- rsync_deploy.gemspec
|
81
|
+
homepage: http://github.com/adie/rsync_deploy
|
82
|
+
licenses: []
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
hash: -987552655
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
hash: -987552655
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project: rsync_deploy
|
107
|
+
rubygems_version: 1.8.21
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Deploy tool using rsync
|
111
|
+
test_files: []
|