albacore-deployment 0.1.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/VERSION +2 -0
- data/install_dependencies.rb +28 -0
- data/lib/albacore/deployment.rb +14 -0
- data/lib/albacore/deployment/env.rb +17 -0
- data/lib/albacore/deployment/log.rb +5 -0
- data/lib/albacore/deployment/robocopy.rb +55 -0
- data/lib/albacore/rake/robocopy_task.rb +3 -0
- data/lib/albacore/tools/robocopy.exe +0 -0
- data/rakefile.rb +48 -0
- data/readme.textile +4 -0
- data/specs/mocks/mock_env.rb +16 -0
- data/specs/mocks/mock_executor.rb +10 -0
- data/specs/mocks/mock_robocopy.rb +13 -0
- data/specs/robocopy_spec.rb +86 -0
- metadata +127 -0
data/VERSION
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/gem_runner'
|
3
|
+
require 'rubygems/exceptions'
|
4
|
+
|
5
|
+
required_version = Gem::Requirement.new "> 1.8.5"
|
6
|
+
|
7
|
+
unless required_version.satisfied_by? Gem.ruby_version then
|
8
|
+
abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def install(lib)
|
12
|
+
begin
|
13
|
+
matches = Gem.source_index.find_name(lib)
|
14
|
+
if matches.empty?
|
15
|
+
puts "Installing #{lib}"
|
16
|
+
Gem::GemRunner.new.run ['install', lib]
|
17
|
+
else
|
18
|
+
puts "Found #{lib} gem - skipping"
|
19
|
+
end
|
20
|
+
rescue Gem::SystemExitException => e
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "Installing required dependencies"
|
25
|
+
install 'rake'
|
26
|
+
install 'albacore'
|
27
|
+
install 'jeweler'
|
28
|
+
install 'rspec'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
2
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "deployment"))
|
3
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "rake"))
|
4
|
+
|
5
|
+
|
6
|
+
require 'albacore'
|
7
|
+
|
8
|
+
include_files = lambda { |p|
|
9
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), p)).each {|f| require f }
|
10
|
+
}
|
11
|
+
|
12
|
+
include_files.call('deployment/*.rb')
|
13
|
+
include_files.call('rake/*.rb')
|
14
|
+
@@env = Env.new
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Env
|
2
|
+
attr_reader :tools
|
3
|
+
|
4
|
+
def initialize(tools = Tools.new)
|
5
|
+
@tools = tools
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
class Tools
|
10
|
+
attr_accessor :robocopy
|
11
|
+
def initialize()
|
12
|
+
tools_dir = File.dirname(__FILE__) + '/../tools/'
|
13
|
+
@robocopy = tools_dir + 'robocopy.exe'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class Robocopy
|
4
|
+
include RunCommand
|
5
|
+
include YAMLConfig
|
6
|
+
include Logging
|
7
|
+
|
8
|
+
attr_accessor :files, :directories, :destination, :mirror
|
9
|
+
|
10
|
+
def initialize(env = @@env, executor = Executor.new)
|
11
|
+
@env = env
|
12
|
+
@files = []
|
13
|
+
@directories = []
|
14
|
+
@executor = executor
|
15
|
+
@mirror = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute()
|
19
|
+
raise "No files or directories were specified" if @files.length == 0 and @directories.length == 0
|
20
|
+
raise "Destination folder was not specified" if @destination.nil?
|
21
|
+
|
22
|
+
copy = lambda { |type, collection|
|
23
|
+
collection.each do |f|
|
24
|
+
command = "#{@env.tools.robocopy} " + case type
|
25
|
+
when 'file' then file_command(f, @destination)
|
26
|
+
when 'directory' then directory_command(f, @destination)
|
27
|
+
else raise "Unknown copy type"
|
28
|
+
end
|
29
|
+
command += " /MIR" if @mirror
|
30
|
+
|
31
|
+
Log.message("Copying #{f} #{destination}; #{command}", :info)
|
32
|
+
@executor.run(command)
|
33
|
+
end
|
34
|
+
}
|
35
|
+
|
36
|
+
copy.call('file', @files)
|
37
|
+
copy.call('directory', @directories)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def file_command(path, destination)
|
43
|
+
"#{File.dirname(path)} #{destination} #{File.basename(path)}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def directory_command(path, destination)
|
47
|
+
"#{path} #{destination} /E"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Executor
|
52
|
+
def run(command)
|
53
|
+
%x[#{command}]
|
54
|
+
end
|
55
|
+
end
|
Binary file
|
data/rakefile.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'lib/albacore/deployment'
|
2
|
+
|
3
|
+
namespace :specs do
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
@spec_opts = '--colour --format specdoc'
|
7
|
+
|
8
|
+
desc "Run functional specs for Albacore"
|
9
|
+
Spec::Rake::SpecTask.new :all do |t|
|
10
|
+
t.spec_files = FileList['specs/*_spec.rb']
|
11
|
+
t.spec_opts << @spec_opts
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :example do
|
16
|
+
require 'rubygems'
|
17
|
+
require File.dirname(__FILE__) + '/lib/albacore/deployment'
|
18
|
+
|
19
|
+
robocopy do |r|
|
20
|
+
r.files << "foo.txt"
|
21
|
+
r.files << "bar.txt"
|
22
|
+
r.directories << "baz"
|
23
|
+
r.destination = "foo"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
namespace :jeweler do
|
28
|
+
begin
|
29
|
+
require 'jeweler'
|
30
|
+
Jeweler::Tasks.new do |gs|
|
31
|
+
gs.name = "albacore-deployment"
|
32
|
+
gs.summary = "Dolphin-Safe Rake Tasks For The Deployment Of .NET Systems"
|
33
|
+
gs.description = "Easily deploy your .NET solutions with Ruby and Rake, using this suite of Rake tasks."
|
34
|
+
gs.email = "jamiehollingworth@gmail.com"
|
35
|
+
gs.homepage = "http://github.com/jhollingworth/Albacore.Deployment"
|
36
|
+
gs.authors = ["James Hollingworth"]
|
37
|
+
gs.has_rdoc = false
|
38
|
+
gs.files.exclude("albacore-deployment.gemspec", ".gitignore")
|
39
|
+
gs.add_dependency('rake', '>= 0.1.5')
|
40
|
+
gs.add_development_dependency('rspec', '>= 1.2.8')
|
41
|
+
gs.add_development_dependency('jeweler', '>= 1.2.1')
|
42
|
+
end
|
43
|
+
Jeweler::GemcutterTasks.new
|
44
|
+
|
45
|
+
rescue LoadError
|
46
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
47
|
+
end
|
48
|
+
end
|
data/readme.textile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/mock_env'
|
2
|
+
require File.dirname(__FILE__) + '/mock_executor'
|
3
|
+
|
4
|
+
class MockRobocopy < Robocopy
|
5
|
+
|
6
|
+
attr_accessor :executor
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@executor = MockExecutor.new
|
10
|
+
super(MockEnv.new, @executor)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "spec"
|
2
|
+
require File.dirname(__FILE__) + '/../lib/albacore/deployment'
|
3
|
+
require File.dirname(__FILE__) + '/mocks/mock_robocopy'
|
4
|
+
|
5
|
+
describe "When I do not specify a destination" do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@command = MockRobocopy.new
|
9
|
+
@command.destination = ""
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise an exception" do
|
13
|
+
lambda { @command.execute }.should raise_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "When I do not specify either files or directories" do
|
18
|
+
|
19
|
+
before(:all) do
|
20
|
+
@command = MockRobocopy.new
|
21
|
+
@command.destination = "c:\foo"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an exception" do
|
25
|
+
lambda { @command.execute }.should raise_error
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "When I copy a single file" do
|
30
|
+
|
31
|
+
before(:all) do
|
32
|
+
@command = MockRobocopy.new
|
33
|
+
@command.files << "c:/foo.zip"
|
34
|
+
@command.destination = "c:/foo"
|
35
|
+
@command.execute
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should copy the file" do
|
39
|
+
@command.executor.commands.length.should == 1
|
40
|
+
@command.executor.commands[0].should include('robocopy c:/ c:/foo foo.zip')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "When I copy multiple files" do
|
45
|
+
before(:all) do
|
46
|
+
@command = MockRobocopy.new
|
47
|
+
@command.files << "c:/foo.zip"
|
48
|
+
@command.files << "c:/bar.zip"
|
49
|
+
@command.destination = "c:/foo"
|
50
|
+
@command.execute
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should copy all the files" do
|
54
|
+
@command.executor.commands.length.should == 2
|
55
|
+
@command.executor.commands[0].should include 'robocopy c:/ c:/foo foo.zip'
|
56
|
+
@command.executor.commands[1].should include 'robocopy c:/ c:/foo bar.zip'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "When I copy a directory" do
|
61
|
+
before(:all) do
|
62
|
+
@command = MockRobocopy.new
|
63
|
+
@command.directories << "c:/bar"
|
64
|
+
@command.destination = "c:/foo"
|
65
|
+
@command.execute
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should copy the directory" do
|
69
|
+
@command.executor.commands.length.should == 1
|
70
|
+
@command.executor.commands[0].should include 'robocopy c:/bar c:/foo /E'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "when I want to mirror two folders" do
|
75
|
+
before(:all) do
|
76
|
+
@command = MockRobocopy.new
|
77
|
+
@command.directories << "c:/bar"
|
78
|
+
@command.destination = "c:/foo"
|
79
|
+
@command.mirror = true
|
80
|
+
@command.execute
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should include the mirror switch" do
|
84
|
+
@command.executor.commands[0].should include '/MIR'
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: albacore-deployment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- James Hollingworth
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-27 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 17
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 1
|
33
|
+
- 5
|
34
|
+
version: 0.1.5
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 2
|
49
|
+
- 8
|
50
|
+
version: 1.2.8
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: jeweler
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 29
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 2
|
65
|
+
- 1
|
66
|
+
version: 1.2.1
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
description: Easily deploy your .NET solutions with Ruby and Rake, using this suite of Rake tasks.
|
70
|
+
email: jamiehollingworth@gmail.com
|
71
|
+
executables: []
|
72
|
+
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files:
|
76
|
+
- readme.textile
|
77
|
+
files:
|
78
|
+
- VERSION
|
79
|
+
- install_dependencies.rb
|
80
|
+
- lib/albacore/deployment.rb
|
81
|
+
- lib/albacore/deployment/env.rb
|
82
|
+
- lib/albacore/deployment/log.rb
|
83
|
+
- lib/albacore/deployment/robocopy.rb
|
84
|
+
- lib/albacore/rake/robocopy_task.rb
|
85
|
+
- lib/albacore/tools/robocopy.exe
|
86
|
+
- rakefile.rb
|
87
|
+
- readme.textile
|
88
|
+
- specs/mocks/mock_env.rb
|
89
|
+
- specs/mocks/mock_executor.rb
|
90
|
+
- specs/mocks/mock_robocopy.rb
|
91
|
+
- specs/robocopy_spec.rb
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: http://github.com/jhollingworth/Albacore.Deployment
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --charset=UTF-8
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.3.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Dolphin-Safe Rake Tasks For The Deployment Of .NET Systems
|
126
|
+
test_files: []
|
127
|
+
|