ritchiey-deploy-utils 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ritchie Young
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
@@ -0,0 +1,7 @@
1
+ = deploy-utils
2
+
3
+ Supplies a bunch of functionality. Install on the server to which you are deployings.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Ritchie Young. See LICENSE for details.
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 = "deploy-utils"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "ritchie@gmail.com"
10
+ gem.homepage = "http://github.com/ritchiey/deploy-utils"
11
+ gem.authors = ["Ritchie Young"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
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 = "deploy-utils #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.rb')
54
+ end
55
+
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'dir_tree'
data/lib/dir_tree.rb ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'fileutils'
4
+
5
+ class DirTree
6
+
7
+ attr_accessor :base
8
+
9
+ def initialize(base)
10
+ self.base = base
11
+ end
12
+
13
+ def each_node(&blk)
14
+ @base = Dir.new(@base) unless @base.kind_of?(Dir)
15
+ recurse('', &blk)
16
+ end
17
+
18
+ def self.link src, dst, options={}
19
+ copy = options[:copy] || []
20
+ FileUtils.mkdir_p dst
21
+ DirTree.new(src).each_node do |base, path|
22
+ src_path = File.join(base, path)
23
+ dst_path = File.join(dst, path)
24
+ if File.directory?(src_path)
25
+ FileUtils.mkdir dst_path
26
+ elsif copy.include?(path)
27
+ FileUtils.cp src_path, dst_path
28
+ else
29
+ FileUtils.link src_path, dst_path
30
+ end
31
+ end
32
+ end
33
+
34
+
35
+ private
36
+
37
+ def recurse(subdir, &blk)
38
+ dir = Dir.new(File.join(@base.path, subdir))
39
+ dir.each do |filename|
40
+ next if filename == '.' or filename == '..'
41
+ path = File.join(subdir, filename)
42
+ full_path = File.join(@base.path, path)
43
+ blk.call @base.path, path
44
+ recurse(path, &blk) if File.directory?(full_path)
45
+ end
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,6 @@
1
+ require 'test_helper'
2
+
3
+
4
+ require 'tc_dir_tree'
5
+
6
+
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'test/unit'
4
+ require 'fileutils'
5
+ require 'dir_tree'
6
+
7
+ class TcDirTree < Test::Unit::TestCase
8
+
9
+ include FileUtils
10
+
11
+ def basedir() 'test_dir' end
12
+ def subdir() File.join(basedir, 'subdir'); end
13
+ def some_file() "#{subdir}/some_file.txt"; end
14
+
15
+
16
+ def setup
17
+ mkdir_p subdir
18
+ cp __FILE__, some_file
19
+ @dir_tree = DirTree.new(basedir)
20
+ end
21
+
22
+ def teardown
23
+ #rm_r basedir
24
+ end
25
+
26
+ def test_each_node
27
+ nodes = []
28
+ @dir_tree.each_node {|base, path| nodes << File.join(base, path)}
29
+ assert_equal [subdir, some_file], nodes
30
+ end
31
+
32
+ def test_link
33
+ other_dir = 'other_dir'
34
+ rm_r other_dir if File.exists? other_dir
35
+ DirTree.link basedir, other_dir
36
+ assert File.directory?("#{other_dir}/subdir")
37
+ assert File.exists?("#{other_dir}/subdir/some_file.txt")
38
+ end
39
+
40
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ require 'deploy_utils'
7
+
8
+ class Test::Unit::TestCase
9
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ritchiey-deploy-utils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ritchie Young
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-07 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ritchie@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - lib/deploy_utils.rb
30
+ - lib/dir_tree.rb
31
+ - test/deploy_utils_test.rb
32
+ - test/tc_dir_tree.rb
33
+ - test/test_helper.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/ritchiey/deploy-utils
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --charset=UTF-8
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 1.2.0
57
+ signing_key:
58
+ specification_version: 2
59
+ summary: TODO
60
+ test_files:
61
+ - test/deploy_utils_test.rb
62
+ - test/tc_dir_tree.rb
63
+ - test/test_helper.rb