repertoire 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +19 -0
- data/README.txt +44 -0
- data/Rakefile +17 -0
- data/bin/repertoire +0 -0
- data/lib/repertoire/compat.rb +47 -0
- data/lib/repertoire/extensions/uri.rb +24 -0
- data/lib/repertoire/extensions.rb +1 -0
- data/lib/repertoire/media/cvs.rb +32 -0
- data/lib/repertoire/media/darcs.rb +32 -0
- data/lib/repertoire/media/exceptions/unknown_media.rb +4 -0
- data/lib/repertoire/media/exceptions.rb +2 -0
- data/lib/repertoire/media/media.rb +134 -0
- data/lib/repertoire/media/rsync.rb +25 -0
- data/lib/repertoire/media/svn.rb +32 -0
- data/lib/repertoire/media.rb +5 -0
- data/lib/repertoire/version.rb +3 -0
- data/lib/repertoire.rb +2 -0
- data/test/test_repertoire.rb +0 -0
- metadata +82 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/repertoire
|
6
|
+
lib/repertoire.rb
|
7
|
+
lib/repertoire/compat.rb
|
8
|
+
lib/repertoire/extensions.rb
|
9
|
+
lib/repertoire/extensions/uri.rb
|
10
|
+
lib/repertoire/media.rb
|
11
|
+
lib/repertoire/media/exceptions.rb
|
12
|
+
lib/repertoire/media/exceptions/unknown_media.rb
|
13
|
+
lib/repertoire/media/media.rb
|
14
|
+
lib/repertoire/media/cvs.rb
|
15
|
+
lib/repertoire/media/darcs.rb
|
16
|
+
lib/repertoire/media/rsync.rb
|
17
|
+
lib/repertoire/media/svn.rb
|
18
|
+
lib/repertoire/version.rb
|
19
|
+
test/test_repertoire.rb
|
data/README.txt
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
R'epertoire
|
2
|
+
by Postmodern Modulus III
|
3
|
+
http://rubyforge.org/projects/repertoire/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
R'epertoire is a Ruby library and utility for quickly checking-out and updating code-bases from various SCMs. R'epertoire currently supports Subversion, CVS, Git and even RSync.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Currently supports checking-out and updating from...
|
12
|
+
* Subversion (SVN)
|
13
|
+
* Darcs
|
14
|
+
* CVS
|
15
|
+
* RSync
|
16
|
+
|
17
|
+
== INSTALL:
|
18
|
+
|
19
|
+
$ sudo gem install repertoire
|
20
|
+
|
21
|
+
== LICENSE:
|
22
|
+
|
23
|
+
The MIT License
|
24
|
+
|
25
|
+
Copyright (c) 2008 Hal Brodigan
|
26
|
+
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
28
|
+
a copy of this software and associated documentation files (the
|
29
|
+
'Software'), to deal in the Software without restriction, including
|
30
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
31
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
32
|
+
permit persons to whom the Software is furnished to do so, subject to
|
33
|
+
the following conditions:
|
34
|
+
|
35
|
+
The above copyright notice and this permission notice shall be
|
36
|
+
included in all copies or substantial portions of the Software.
|
37
|
+
|
38
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
39
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
40
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
41
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
42
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
43
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
44
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/repertoire/version.rb'
|
6
|
+
|
7
|
+
Hoe.new('repertoire', Repertoire::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'repertoire'
|
9
|
+
p.author = 'Postmodern Modulus III'
|
10
|
+
p.email = 'postmodern.mod3@gmail.com'
|
11
|
+
p.summary = "R'epertoire is a Ruby library and utility for quickly checking-out and updating code-bases from various SCMs. R'epertoire currently supports Subversion, Darcs, CVS, and even RSync."
|
12
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
+
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
# vim: syntax=Ruby
|
data/bin/repertoire
ADDED
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Repertoire
|
2
|
+
module Compat
|
3
|
+
#
|
4
|
+
# Returns the native _platform_.
|
5
|
+
#
|
6
|
+
# Compat.arch #=> "linux"
|
7
|
+
#
|
8
|
+
def self.platform
|
9
|
+
RUBY_PLATFORM.split('-').last
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# Returns an array representing the +PATH+ environment variable.
|
14
|
+
# If the +PATH+ environment variable is not setup, an empty array will
|
15
|
+
# be returned.
|
16
|
+
#
|
17
|
+
# Compat.PATH #=> ["/bin", "/usr/bin"]
|
18
|
+
#
|
19
|
+
def self.PATH
|
20
|
+
# return an empty array in case
|
21
|
+
# the PATH variable does not exist
|
22
|
+
return [] unless ENV['PATH']
|
23
|
+
|
24
|
+
if self.platform =~ /mswin32/
|
25
|
+
return ENV['PATH'].split(';')
|
26
|
+
else
|
27
|
+
return ENV['PATH'].split(':')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Finds the program matching _name_ and returns it's full path.
|
33
|
+
# If the program was not found, +nil+ will be returned.
|
34
|
+
#
|
35
|
+
# Compat.find_program('as') #=> "/usr/bin/as"
|
36
|
+
#
|
37
|
+
def self.find_program(name)
|
38
|
+
self.PATH.each do |dir|
|
39
|
+
full_path = File.expand_path(File.join(dir,name))
|
40
|
+
|
41
|
+
return full_path if File.file?(full_path)
|
42
|
+
end
|
43
|
+
|
44
|
+
return nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module URI
|
4
|
+
#
|
5
|
+
# Returns the +basename+ of the specified _uri_, unless the +basename+ is
|
6
|
+
# +'trunk'+ then the +basename+ of the parent directory within the _uri_
|
7
|
+
# is returned.
|
8
|
+
#
|
9
|
+
# URI.repo_name('http://www.today.com/is/now') # => "now"
|
10
|
+
#
|
11
|
+
# URI.repo_name('svn://svn.repo.com/var/svn/awesome/trunk') # =>
|
12
|
+
# "awesome"
|
13
|
+
#
|
14
|
+
def URI.repo_name(uri)
|
15
|
+
path = URI.parse(uri).path
|
16
|
+
name = File.basename(path)
|
17
|
+
|
18
|
+
if name=='trunk' || name.empty?
|
19
|
+
name = File.basename(File.dirname(path))
|
20
|
+
end
|
21
|
+
|
22
|
+
return name
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'repertoire/extensions/uri'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'repertoire/media/media'
|
2
|
+
|
3
|
+
module Repertoire
|
4
|
+
class CVS < Media
|
5
|
+
|
6
|
+
uses_schemes 'cvs'
|
7
|
+
|
8
|
+
#
|
9
|
+
# Returns +true+ if the repository located at the specified _path_
|
10
|
+
# contains the +CVS+ directory, returns +false+ otherwise.
|
11
|
+
#
|
12
|
+
def self.is_repo?(path)
|
13
|
+
File.directory?(File.join(path,'CVS'))
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Checks out the CVS repository located at the specified _uri_ into the
|
18
|
+
# specified _path_.
|
19
|
+
#
|
20
|
+
def self.checkout(uri,path)
|
21
|
+
sh('cvs','-d',path,'co',uri)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Updated the CVS repository located at the specified _path_.
|
26
|
+
#
|
27
|
+
def self.update(path,uri=nil)
|
28
|
+
sh('cvs','up',path)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'repertoire/media/media'
|
2
|
+
|
3
|
+
module Repertoire
|
4
|
+
class Darcs < Media
|
5
|
+
|
6
|
+
uses_schemes 'darcs'
|
7
|
+
|
8
|
+
#
|
9
|
+
# Returns +true+ if the repository located at the specified _path_
|
10
|
+
# contains the +_darcs+ directory, returns +false+ otherwise.
|
11
|
+
#
|
12
|
+
def self.is_repo?(path)
|
13
|
+
File.directory?(File.join(path,'_darcs'))
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Checks out the Darcs repository located at the specified _uri_ into
|
18
|
+
# the specified _path_.
|
19
|
+
#
|
20
|
+
def self.checkout(uri,path=nil)
|
21
|
+
sh('darcs','get','--partial',uri,path)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Updated the Darcs repository located at the specified _path_.
|
26
|
+
#
|
27
|
+
def self.update(uri,path)
|
28
|
+
sh('darcs','pull','-a',path)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'repertoire/media/exceptions/unknown_media'
|
2
|
+
require 'repertoire/media/exceptions/program_not_found'
|
3
|
+
require 'repertoire/extensions/uri'
|
4
|
+
require 'repertoire/compat'
|
5
|
+
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
module Repertoire
|
9
|
+
class Media
|
10
|
+
|
11
|
+
#
|
12
|
+
# Returns the Hash of all registered Media types.
|
13
|
+
#
|
14
|
+
def Media.types
|
15
|
+
@types ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Returns +true+ if a Media type was registered for the specified
|
20
|
+
# _scheme_, returns +false+ otherwise.
|
21
|
+
#
|
22
|
+
def Media.supported?(scheme)
|
23
|
+
Media.types.has_key?(scheme.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Get the Media type that was registered for the specified _scheme_.
|
28
|
+
#
|
29
|
+
def Media.get(scheme)
|
30
|
+
unless Media.supported?(scheme)
|
31
|
+
raise(UnknownMedia,"media type #{scheme.dump} is unsupported",caller)
|
32
|
+
end
|
33
|
+
|
34
|
+
return Media.types[scheme]
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Get the Media type that was registered for the scheme of the
|
39
|
+
# specified _uri_.
|
40
|
+
#
|
41
|
+
def Media.get_for_uri(uri)
|
42
|
+
Media.get(URI.parse(uri).scheme)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Attempts to determine the correct Media type for the specified _path_.
|
47
|
+
#
|
48
|
+
def Media.guess(path)
|
49
|
+
path = File.expand_path(path)
|
50
|
+
|
51
|
+
Media.types.values.uniq.each do |media|
|
52
|
+
if media.respond_to?(:is_repo?)
|
53
|
+
return media if media.is_repo?(path)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
raise(UnknownMedia,"the media type for #{path.dump} is unknown",caller)
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Checkout the repository at the specified _uri_ and the given _path_.
|
62
|
+
#
|
63
|
+
def Media.checkout(uri,path=nil)
|
64
|
+
if path
|
65
|
+
path = File.expand_path(path)
|
66
|
+
else
|
67
|
+
path = URI.repo_name(uri)
|
68
|
+
end
|
69
|
+
|
70
|
+
return Media.get_for_uri(uri).checkout(uri,path)
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Update the repository at the specified _path_ and the given _uri_.
|
75
|
+
# If _uri_ is not given Repertoire will attempt to guess the media
|
76
|
+
# type of the repository, see Media.guess.
|
77
|
+
#
|
78
|
+
def Media.update(path,uri=nil)
|
79
|
+
path = File.expand_path(path)
|
80
|
+
|
81
|
+
if uri.nil?
|
82
|
+
media = Media.guess(path)
|
83
|
+
else
|
84
|
+
media = Media.get_for_uri(uri)
|
85
|
+
end
|
86
|
+
|
87
|
+
return media.update(path,uri)
|
88
|
+
end
|
89
|
+
|
90
|
+
#
|
91
|
+
# Delete the repository at the specified _path_.
|
92
|
+
#
|
93
|
+
def Media.delete(path)
|
94
|
+
FileUtils.rm_r(path.to_s,:force => true, :secure => true)
|
95
|
+
end
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
#
|
100
|
+
# Register a Media type for the specified _schemes_.
|
101
|
+
#
|
102
|
+
# uses_schemes 'cvs'
|
103
|
+
#
|
104
|
+
# uses_schemes 'svn', 'svn+ssh'
|
105
|
+
#
|
106
|
+
def self.uses_schemes(*schemes)
|
107
|
+
schemes.each do |scheme|
|
108
|
+
Media.types[scheme.to_s] = self
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Runs the command specified by _program_ and the given _args_.
|
114
|
+
# If _program_ cannot be found on the system, a ProgramNotFound
|
115
|
+
# exception will be raised.
|
116
|
+
#
|
117
|
+
# sh('ls','-la','/')
|
118
|
+
#
|
119
|
+
def self.sh(program,*args)
|
120
|
+
program = program.to_s
|
121
|
+
|
122
|
+
program_path = Compat.find_program(program)
|
123
|
+
unless program_path
|
124
|
+
raise(ProgramNotFound,"the program #{program.dump} was not found",caller)
|
125
|
+
end
|
126
|
+
|
127
|
+
# stringify the args
|
128
|
+
args = args.map { |arg| arg.to_s }
|
129
|
+
|
130
|
+
return system(program_path,*args)
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'repertoire/media/media'
|
2
|
+
|
3
|
+
module Repertoire
|
4
|
+
class Rsync < Media
|
5
|
+
|
6
|
+
uses_schemes 'rsync'
|
7
|
+
|
8
|
+
#
|
9
|
+
# Checks out the Rsync repository located at the specified _uri_ into
|
10
|
+
# the specified _path_.
|
11
|
+
#
|
12
|
+
def self.checkout(uri,path)
|
13
|
+
sh('rsync','-av',uri,path)
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Updated the Rsync repository located at the specified _path_ with the
|
18
|
+
# remote repository at the specified _uri_.
|
19
|
+
#
|
20
|
+
def self.update(path,uri)
|
21
|
+
sh('rsync','-av','--delete-after',uri,path)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'repertoire/media/media'
|
2
|
+
|
3
|
+
module Repertoire
|
4
|
+
class SVN < Media
|
5
|
+
|
6
|
+
uses_schemes 'svn', 'svn+ssh'
|
7
|
+
|
8
|
+
#
|
9
|
+
# Returns +true+ if the repository located at the specified _path_
|
10
|
+
# contains the +.svn+ directory, returns +false+ otherwise.
|
11
|
+
#
|
12
|
+
def self.is_repo?(path)
|
13
|
+
File.directory?(File.join(path,'.svn'))
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Checks out the SVN repository located at the specified _uri_ into the
|
18
|
+
# specified _path_.
|
19
|
+
#
|
20
|
+
def self.checkout(uri,path)
|
21
|
+
sh('svn','co',uri,path)
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Updated the SVN repository located at the specified _path_.
|
26
|
+
#
|
27
|
+
def self.update(path,uri=nil)
|
28
|
+
sh('svn','up',path)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/repertoire.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: repertoire
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Postmodern Modulus III
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-17 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.4.0
|
23
|
+
version:
|
24
|
+
description: "== FEATURES/PROBLEMS: * Currently supports checking-out and updating from... * Subversion (SVN) * Darcs * CVS * RSync == INSTALL: $ sudo gem install repertoire == LICENSE:"
|
25
|
+
email: postmodern.mod3@gmail.com
|
26
|
+
executables:
|
27
|
+
- repertoire
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- History.txt
|
32
|
+
- Manifest.txt
|
33
|
+
- README.txt
|
34
|
+
files:
|
35
|
+
- History.txt
|
36
|
+
- Manifest.txt
|
37
|
+
- README.txt
|
38
|
+
- Rakefile
|
39
|
+
- bin/repertoire
|
40
|
+
- lib/repertoire.rb
|
41
|
+
- lib/repertoire/compat.rb
|
42
|
+
- lib/repertoire/extensions.rb
|
43
|
+
- lib/repertoire/extensions/uri.rb
|
44
|
+
- lib/repertoire/media.rb
|
45
|
+
- lib/repertoire/media/exceptions.rb
|
46
|
+
- lib/repertoire/media/exceptions/unknown_media.rb
|
47
|
+
- lib/repertoire/media/media.rb
|
48
|
+
- lib/repertoire/media/cvs.rb
|
49
|
+
- lib/repertoire/media/darcs.rb
|
50
|
+
- lib/repertoire/media/rsync.rb
|
51
|
+
- lib/repertoire/media/svn.rb
|
52
|
+
- lib/repertoire/version.rb
|
53
|
+
- test/test_repertoire.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: " by Postmodern Modulus III"
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --main
|
59
|
+
- README.txt
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: repertoire
|
77
|
+
rubygems_version: 1.0.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 2
|
80
|
+
summary: R'epertoire is a Ruby library and utility for quickly checking-out and updating code-bases from various SCMs. R'epertoire currently supports Subversion, Darcs, CVS, and even RSync.
|
81
|
+
test_files:
|
82
|
+
- test/test_repertoire.rb
|