production-sync 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/Readme +2 -0
- data/bin/production-sync +7 -0
- data/lib/production-sync.rb +90 -0
- metadata +57 -0
data/Readme
ADDED
data/bin/production-sync
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'yaml'
|
6
|
+
require 'date'
|
7
|
+
require 'rdoc/usage'
|
8
|
+
|
9
|
+
class ProductionSync
|
10
|
+
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@options = OpenStruct.new
|
15
|
+
@options.rsync = "/usr/bin/rsync" #Our Default
|
16
|
+
@options.debug = false
|
17
|
+
@options.file = false
|
18
|
+
@options.site_name = ARGV.shift
|
19
|
+
parse_cli_options
|
20
|
+
parse_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def sync_files
|
24
|
+
#Build Command
|
25
|
+
command = "%s -avz --delete --exclude '.git' --exclude '.gitignore' --exclude-from %s %s %s@%s:%s" % [
|
26
|
+
@options.rsync,
|
27
|
+
@options.source + ".gitignore",
|
28
|
+
@options.source,
|
29
|
+
@options.user,
|
30
|
+
@options.server,
|
31
|
+
@options.destination
|
32
|
+
]
|
33
|
+
#puts command
|
34
|
+
if not @options.debug
|
35
|
+
exec command
|
36
|
+
else
|
37
|
+
puts "Command to run - " + command
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def usage
|
42
|
+
RDoc::usage()
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def parse_cli_options
|
48
|
+
begin
|
49
|
+
opts = OptionParser.new do |opts|
|
50
|
+
opts.on("-f","--file CONFIG_FILE","Config File to use") { |file| @options.file = file }
|
51
|
+
opts.on_tail("-h","--help","Show this message") { |help| puts opts; exit}
|
52
|
+
end.parse!(ARGV)
|
53
|
+
rescue OptionParser::ParseError => e
|
54
|
+
puts e
|
55
|
+
puts opts
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
true #Return true if the parser was successful
|
59
|
+
end
|
60
|
+
|
61
|
+
def parse_file
|
62
|
+
|
63
|
+
#Default configuration file
|
64
|
+
@options.file = "~/.production-sync.yml" unless @options.file
|
65
|
+
|
66
|
+
config_file = YAML::load(File.open(File.expand_path(@options.file)))
|
67
|
+
#Check global settings
|
68
|
+
if config_file['global']
|
69
|
+
@options.rsync = config_file['global']['rsync'] if config_file['global']['rsync']
|
70
|
+
end
|
71
|
+
|
72
|
+
if not config_file[@options.site_name]
|
73
|
+
puts "Can't find site description in configuration file for - '#{@options.site_name}'"
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
@options.debug = true if config_file[@options.site_name]['debug']
|
77
|
+
@options.destination = config_file[@options.site_name]['destination'][-1,1] == "/" ? config_file[@options.site_name]['destination'] : config_file[@options.site_name]['destination'] + "/"
|
78
|
+
@options.source = config_file[@options.site_name]['source'][-1,1] == "/" ? config_file[@options.site_name]['source'] : config_file[@options.site_name]['source'] + "/"
|
79
|
+
@options.user = config_file[@options.site_name]['username']
|
80
|
+
@options.server = config_file[@options.site_name]['server']
|
81
|
+
rescue
|
82
|
+
puts "Can't read configuration file - #{File.expand_path @options.file}"
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
#Basic rsync script that will update the site
|
90
|
+
# rsync -avz --delete --exclude '.git' --exclude '.gitignore' --exclude-from '/Users/bshelton/copyexperts/.gitignore' /Users/bshelton/copyexperts/ /Users/bshelton/cclone/
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: production-sync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Shelton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-30 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Production-Sync
|
17
|
+
email: bryan@sheltonopensolutions.com
|
18
|
+
executables:
|
19
|
+
- production-sync
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- bin/production-sync
|
26
|
+
- lib/production-sync.rb
|
27
|
+
- Readme
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://github.com/bshelton229/production-sync
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.3.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Git Sync
|
56
|
+
test_files: []
|
57
|
+
|