necktie 1.0.3 → 1.0.4
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/CHANGELOG +9 -0
- data/README.rdoc +1 -0
- data/example/Necktie +2 -0
- data/lib/necktie/application.rb +30 -3
- data/lib/necktie/capistrano.rb +33 -10
- data/lib/necktie.rb +5 -2
- data/necktie.gemspec +5 -5
- metadata +5 -5
- /data/example/tasks/{current.rb → deploy.rb} +0 -0
data/CHANGELOG
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
1.0.4 (2009-11-4)
|
2
|
+
* When used with -U option and no other argument, necktie command updates the
|
3
|
+
local repo but does not run any task.
|
4
|
+
* Introduced -R option which you can use to checkout specific reference (tag,
|
5
|
+
commit, tree).
|
6
|
+
* cap necktie task broken up into separate stages, now runs deploy:web:disable
|
7
|
+
before running necktie:upgrade.
|
8
|
+
* Added syslog messages.
|
9
|
+
|
1
10
|
1.0.3 (2009-11-2)
|
2
11
|
* Added Necktie::Version.
|
3
12
|
* Added gem clean to rubygems task (examples).
|
data/README.rdoc
CHANGED
data/example/Necktie
CHANGED
data/lib/necktie/application.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "rake"
|
2
|
+
require "syslog"
|
2
3
|
|
3
4
|
module Necktie
|
4
5
|
class Application < Rake::Application #:nodoc:
|
@@ -9,17 +10,17 @@ module Necktie
|
|
9
10
|
@rakefiles = ["Necktie", "necktie", "Necktie.rb", "necktie.rb"]
|
10
11
|
options.nosearch = true
|
11
12
|
options.env = "production"
|
13
|
+
@syslog = Syslog.open("necktie")
|
12
14
|
end
|
13
15
|
|
14
16
|
def run
|
15
17
|
standard_exception_handling do
|
16
18
|
init "necktie"
|
17
|
-
puts "(#{options.env})"
|
18
19
|
repo = File.expand_path("~/.necktie")
|
19
20
|
if File.exist?(repo)
|
20
21
|
Dir.chdir repo do
|
21
22
|
puts "Pulling latest updates to #{repo} ..."
|
22
|
-
sh "git pull origin
|
23
|
+
sh "git pull origin master", :verbose=>false
|
23
24
|
end if options.pull
|
24
25
|
else
|
25
26
|
options.git_url or fail "Need to set Git URL: use --source command line option"
|
@@ -27,8 +28,14 @@ module Necktie
|
|
27
28
|
sh "git clone #{options.git_url} #{repo.inspect}", :verbose=>false
|
28
29
|
end
|
29
30
|
Dir.chdir repo do
|
31
|
+
sh "git checkout #{options.ref}" if options.ref
|
32
|
+
@sha = `git rev-parse --verify HEAD --short`.strip
|
33
|
+
puts "(in #{Dir.pwd}, head is #{@sha}, environment is #{options.env})"
|
34
|
+
syslog :info, "environment is #{options.env}"
|
35
|
+
|
30
36
|
load_rakefile
|
31
|
-
top_level
|
37
|
+
top_level unless options.pull && ARGV.empty?
|
38
|
+
syslog :info, "done"
|
32
39
|
end
|
33
40
|
end
|
34
41
|
end
|
@@ -43,6 +50,9 @@ module Necktie
|
|
43
50
|
['--source', '-S GIT_URL', "Git URL to your Necktie repository",
|
44
51
|
lambda { |value| options.git_url = value }
|
45
52
|
],
|
53
|
+
['--ref', '-R REF', "Checkout specific reference (commit, tag, tree)",
|
54
|
+
lambda { |value| options.ref = value }
|
55
|
+
],
|
46
56
|
['--update', '-U', "Update .necktie directory (git pull)",
|
47
57
|
lambda { |value| options.pull = true }
|
48
58
|
],
|
@@ -131,10 +141,27 @@ module Necktie
|
|
131
141
|
load_imports
|
132
142
|
end
|
133
143
|
|
144
|
+
def syslog(level, message)
|
145
|
+
@syslog.send level, "[#{@sha}] #{message.strip.gsub(/%/, '%%')}" # syslog(3) freaks on % (printf)
|
146
|
+
end
|
147
|
+
|
134
148
|
end
|
135
149
|
|
136
150
|
# Returns the environment name (set using -e command line option).
|
137
151
|
def self.env
|
138
152
|
Rake.application.options.env
|
139
153
|
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
class Rake::Task #:nodoc:
|
159
|
+
alias :execute_without_syslog :execute
|
160
|
+
def execute(args=nil)
|
161
|
+
application.syslog :info, "execute: #{name}"
|
162
|
+
execute_without_syslog args
|
163
|
+
rescue
|
164
|
+
application.syslog :err, "#{$!.backtrace.first}: #{$!.class}: #{$!}"
|
165
|
+
raise
|
166
|
+
end
|
140
167
|
end
|
data/lib/necktie/capistrano.rb
CHANGED
@@ -1,13 +1,36 @@
|
|
1
|
+
# cap necktie task
|
1
2
|
Capistrano::Configuration.instance.load do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
namespace :necktie do
|
4
|
+
desc "[internal] Install necktie on remote server"
|
5
|
+
task :install do
|
6
|
+
spec = Gem::Specification.load(File.expand_path("../../necktie.gemspec", File.dirname(__FILE__)))
|
7
|
+
gem_spec = Gem::SourceIndex.from_installed_gems.find_name(spec.name, spec.version).last
|
8
|
+
gem_file = File.join(Gem.dir, "cache", gem_spec.file_name)
|
9
|
+
upload gem_file, File.basename(gem_file), :via=>:scp
|
10
|
+
sudo "gem install #{File.basename(gem_file)}"
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "[internal] Pull updates from Git"
|
14
|
+
task :pull do
|
15
|
+
fail "You need to set :necktie_url, <git_url>" unless necktie_url
|
16
|
+
sudo "necktie --source #{necktie_url} --update"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "[internal] Run necktie upgrade"
|
20
|
+
task :upgrade do # run necktime
|
21
|
+
tasks = ENV["ROLES"].to_s.split(",") # ROLES => task names
|
22
|
+
sudo "necktie --environment #{fetch(:rails_env, "production")} #{tasks.join(" ")}"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Run necktie on all servers (you can use HOSTS or RAILS env vars)"
|
26
|
+
task :default do
|
27
|
+
fail "You need to set :necktie_url, <git_url>" unless necktie_url
|
28
|
+
install
|
29
|
+
pull
|
30
|
+
upgrade
|
31
|
+
end
|
32
|
+
|
33
|
+
before "necktie:upgrade", "deploy:web:disable"
|
34
|
+
after "necktie:upgrade", "deploy:web:enable"
|
12
35
|
end
|
13
36
|
end
|
data/lib/necktie.rb
CHANGED
@@ -17,7 +17,10 @@ end
|
|
17
17
|
module Necktie
|
18
18
|
# Version number.
|
19
19
|
module Version
|
20
|
-
|
21
|
-
MAJOR
|
20
|
+
version = Gem::Specification.load(File.expand_path("../necktie.gemspec", File.dirname(__FILE__))).version.to_s.split(".").map { |i| i.to_i }
|
21
|
+
MAJOR = version[0]
|
22
|
+
MINOR = version[1]
|
23
|
+
PATCH = version[2]
|
24
|
+
STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
22
25
|
end
|
23
26
|
end
|
data/necktie.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "necktie"
|
3
|
-
spec.version = "1.0.
|
3
|
+
spec.version = "1.0.4"
|
4
4
|
spec.author = "Assaf Arkin"
|
5
5
|
spec.email = "assaf@labnotes.org"
|
6
6
|
spec.homepage = "http://github.com/assaf/necktie"
|
7
7
|
spec.summary = "Dress to impress"
|
8
|
-
spec.description = "Configure your servers
|
8
|
+
spec.description = "Configure your servers using Ruby and Git"
|
9
9
|
|
10
10
|
spec.files = Dir["{bin,lib,vendor,example}/**/*", "CHANGELOG", "README.rdoc", "necktie.gemspec"]
|
11
11
|
spec.executable = "necktie"
|
12
12
|
|
13
13
|
spec.has_rdoc = true
|
14
|
-
spec.extra_rdoc_files =
|
15
|
-
spec.rdoc_options =
|
16
|
-
|
14
|
+
spec.extra_rdoc_files = "README.rdoc", "CHANGELOG"
|
15
|
+
spec.rdoc_options = "--title", "Necktie #{spec.version}", "--main", "README.rdoc",
|
16
|
+
"--webcvs", "http://github.com/assaf/#{spec.name}"
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: necktie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Assaf Arkin
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-04 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: Configure your servers
|
16
|
+
description: Configure your servers using Ruby and Git
|
17
17
|
email: assaf@labnotes.org
|
18
18
|
executables:
|
19
19
|
- necktie
|
@@ -243,8 +243,8 @@ files:
|
|
243
243
|
- example/gems/unicorn-0.93.3.gem
|
244
244
|
- example/Necktie
|
245
245
|
- example/tasks/app.rb
|
246
|
-
- example/tasks/current.rb
|
247
246
|
- example/tasks/db.rb
|
247
|
+
- example/tasks/deploy.rb
|
248
248
|
- CHANGELOG
|
249
249
|
- README.rdoc
|
250
250
|
- necktie.gemspec
|
@@ -255,7 +255,7 @@ licenses: []
|
|
255
255
|
post_install_message:
|
256
256
|
rdoc_options:
|
257
257
|
- --title
|
258
|
-
- Necktie
|
258
|
+
- Necktie 1.0.4
|
259
259
|
- --main
|
260
260
|
- README.rdoc
|
261
261
|
- --webcvs
|
File without changes
|