jbe-tuffel 1.0.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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/bin/tuffel +140 -0
- data/lib/tuffel.rb +0 -0
- data/test/test_helper.rb +10 -0
- data/test/tuffel_test.rb +7 -0
- metadata +63 -0
data/.document
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Jostein Berre Eliassen
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "tuffel"
|
|
8
|
+
gem.summary = %Q{Friendly, git-based deployment}
|
|
9
|
+
gem.email = "post@jostein.be"
|
|
10
|
+
gem.homepage = "http://github.com/jbe/tuffel"
|
|
11
|
+
gem.authors = ["Jostein Berre Eliassen"]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
rescue LoadError
|
|
15
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
require 'rake/testtask'
|
|
19
|
+
Rake::TestTask.new(:test) do |test|
|
|
20
|
+
test.libs << 'lib' << 'test'
|
|
21
|
+
test.pattern = 'test/**/*_test.rb'
|
|
22
|
+
test.verbose = true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
begin
|
|
26
|
+
require 'rcov/rcovtask'
|
|
27
|
+
Rcov::RcovTask.new do |test|
|
|
28
|
+
test.libs << 'test'
|
|
29
|
+
test.pattern = 'test/**/*_test.rb'
|
|
30
|
+
test.verbose = true
|
|
31
|
+
end
|
|
32
|
+
rescue LoadError
|
|
33
|
+
task :rcov do
|
|
34
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
task :default => :test
|
|
40
|
+
|
|
41
|
+
require 'rake/rdoctask'
|
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
|
43
|
+
if File.exist?('VERSION.yml')
|
|
44
|
+
config = YAML.load(File.read('VERSION.yml'))
|
|
45
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
|
46
|
+
else
|
|
47
|
+
version = ""
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
51
|
+
rdoc.title = "tuffel #{version}"
|
|
52
|
+
rdoc.rdoc_files.include('README*')
|
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
54
|
+
end
|
|
55
|
+
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0
|
data/bin/tuffel
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'net/ssh/multi'
|
|
5
|
+
|
|
6
|
+
GLOBAL_CONFIG_FILE = File.expand_path '~/.tuffel.yml'
|
|
7
|
+
LOCAL_CONFIG_FILE = File.expand_path './config/tuffel.yml'
|
|
8
|
+
|
|
9
|
+
DEFAULT_CONFIG_ID = 'default'
|
|
10
|
+
|
|
11
|
+
DEFAULT_CONFIG = {
|
|
12
|
+
'editor' => 'vim',
|
|
13
|
+
'default' => {
|
|
14
|
+
'gitosis' => 'user@server [replace]',
|
|
15
|
+
'deploy' => ['user@server [replace]']
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CLIHelper
|
|
21
|
+
|
|
22
|
+
def handle( argv )
|
|
23
|
+
if argv[0].nil?
|
|
24
|
+
handle ['usage']
|
|
25
|
+
else
|
|
26
|
+
if self.public_methods(false).include? argv[0]
|
|
27
|
+
self.send argv.delete_at(0).to_sym, *argv
|
|
28
|
+
else
|
|
29
|
+
invalid_command argv[0]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def invalid_command( name )
|
|
35
|
+
puts "Error: Invalid command: #{name}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def confirm?( question )
|
|
39
|
+
print question + ' (y/N) '
|
|
40
|
+
gets =~ /^(y|Y)/
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CLI < CLIHelper
|
|
46
|
+
|
|
47
|
+
def usage *args
|
|
48
|
+
puts 'Tuffel: friendly gitosis-based deployment'
|
|
49
|
+
puts 'Available commands: ' + self.public_methods(false).join(', ')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def deploy( revision='HEAD' ) # TODO: Better transaction
|
|
53
|
+
repo = config['gitosis']
|
|
54
|
+
deploy = config['deploy']
|
|
55
|
+
session = Net::SSH::Multi.start
|
|
56
|
+
deploy.each {|server| session.use server }
|
|
57
|
+
|
|
58
|
+
puts "Deploy #{project_name} #{revision} :: #{repo} » [#{deploy.join(', ')}]"
|
|
59
|
+
session.exec "rm -rf #{project_name}; git clone #{repo}:#{project_name}.git"
|
|
60
|
+
@session.loop
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def gitosis
|
|
64
|
+
tmp_path = "/tmp/tuffel#{Process.pid}"
|
|
65
|
+
system "mkdir -p #{tmp_path}"
|
|
66
|
+
system [
|
|
67
|
+
"cd #{tmp_path}",
|
|
68
|
+
"git clone #{config['gitosis']}:gitosis-admin.git",
|
|
69
|
+
"cd gitosis-admin",
|
|
70
|
+
"#{editor} gitosis.conf",
|
|
71
|
+
"git add .",
|
|
72
|
+
"git commit -a",
|
|
73
|
+
"git push"
|
|
74
|
+
].join('&&')
|
|
75
|
+
system "rm -rf #{tmp_path}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def plug
|
|
79
|
+
system "git remote add origin #{config['gitosis']}:#{project_name}.git"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def configure( env='local', id=DEFAULT_CONFIG_ID )
|
|
83
|
+
if env == 'global'
|
|
84
|
+
puts 'Scope: Global'
|
|
85
|
+
else
|
|
86
|
+
puts 'Scope: Local - use \'tuffel configure global\' to set global configuration'
|
|
87
|
+
end
|
|
88
|
+
puts "Identifier: #{id}"
|
|
89
|
+
|
|
90
|
+
path = (env == 'global' ? GLOBAL_CONFIG_FILE : LOCAL_CONFIG_FILE)
|
|
91
|
+
puts "Writing configuration to #{path}"
|
|
92
|
+
|
|
93
|
+
unless File.file? path
|
|
94
|
+
File.open(path, 'w') {|f| YAML.dump( DEFAULT_CONFIG, f ) }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
system "#{editor} #{path}"
|
|
98
|
+
path
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
def config_path
|
|
105
|
+
@config_path ||=
|
|
106
|
+
if File.file?(LOCAL_CONFIG_FILE)
|
|
107
|
+
LOCAL_CONFIG_FILE
|
|
108
|
+
elsif File.file?(GLOBAL_CONFIG_FILE)
|
|
109
|
+
GLOBAL_CONFIG_FILE
|
|
110
|
+
else
|
|
111
|
+
if confirm?("No #{GLOBAL_CONFIG_FILE} or #{LOCAL_CONFIG_FILE} found. Create?")
|
|
112
|
+
configure
|
|
113
|
+
else
|
|
114
|
+
exit
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def config_yaml
|
|
120
|
+
@config ||= YAML.load_file( config_path )
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def config
|
|
124
|
+
config_yaml[DEFAULT_CONFIG_ID]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def editor
|
|
128
|
+
config['editor'] || DEFAULT_CONFIG['editor']
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def project_name
|
|
132
|
+
File.basename(Dir.pwd)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
CLI.new.handle $*
|
|
139
|
+
|
|
140
|
+
|
data/lib/tuffel.rb
ADDED
|
File without changes
|
data/test/test_helper.rb
ADDED
data/test/tuffel_test.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jbe-tuffel
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jostein Berre Eliassen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-05-20 00:00:00 -07:00
|
|
13
|
+
default_executable: tuffel
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description:
|
|
17
|
+
email: post@jostein.be
|
|
18
|
+
executables:
|
|
19
|
+
- tuffel
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- LICENSE
|
|
24
|
+
- README.rdoc
|
|
25
|
+
files:
|
|
26
|
+
- .document
|
|
27
|
+
- .gitignore
|
|
28
|
+
- LICENSE
|
|
29
|
+
- README.rdoc
|
|
30
|
+
- Rakefile
|
|
31
|
+
- VERSION
|
|
32
|
+
- lib/tuffel.rb
|
|
33
|
+
- test/test_helper.rb
|
|
34
|
+
- test/tuffel_test.rb
|
|
35
|
+
has_rdoc: true
|
|
36
|
+
homepage: http://github.com/jbe/tuffel
|
|
37
|
+
post_install_message:
|
|
38
|
+
rdoc_options:
|
|
39
|
+
- --charset=UTF-8
|
|
40
|
+
require_paths:
|
|
41
|
+
- lib
|
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: "0"
|
|
47
|
+
version:
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: "0"
|
|
53
|
+
version:
|
|
54
|
+
requirements: []
|
|
55
|
+
|
|
56
|
+
rubyforge_project:
|
|
57
|
+
rubygems_version: 1.2.0
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 2
|
|
60
|
+
summary: Friendly, git-based deployment
|
|
61
|
+
test_files:
|
|
62
|
+
- test/tuffel_test.rb
|
|
63
|
+
- test/test_helper.rb
|