repertoire 0.1.1 → 0.1.2

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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.2 / 2008-05-01
2
+
3
+ * Added Media support for Git.
4
+
1
5
  == 0.1.1 / 2008-02-09
2
6
 
3
7
  * Added the Type module to add meta-programming methods to Media types.
data/Manifest.txt CHANGED
@@ -22,8 +22,10 @@ lib/repertoire/media/type.rb
22
22
  lib/repertoire/media/types.rb
23
23
  lib/repertoire/media/types/cvs.rb
24
24
  lib/repertoire/media/types/darcs.rb
25
+ lib/repertoire/media/types/git.rb
25
26
  lib/repertoire/media/types/rsync.rb
26
27
  lib/repertoire/media/types/svn.rb
28
+ lib/repertoire/repository.rb
27
29
  lib/repertoire/repertoire.rb
28
30
  lib/repertoire/version.rb
29
31
  test/test_repertoire.rb
data/README.txt CHANGED
@@ -1,18 +1,22 @@
1
- R'epertoire
2
- by Postmodern Modulus III
3
- http://rubyforge.org/projects/repertoire/
1
+ = R'epertoire
2
+
3
+ * http://repertoire.rubyforge.org/
4
+ * Postmodern Modulus III (postmodern.mod3@gmail.com)
4
5
 
5
6
  == DESCRIPTION:
6
7
 
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
+ R'epertoire is a Ruby library for quickly checking-out and updating
9
+ code-bases from various SCMs. R'epertoire currently supports Subversion,
10
+ CVS, Git and even RSync.
8
11
 
9
12
  == FEATURES/PROBLEMS:
10
13
 
11
14
  * Currently supports checking-out and updating from:
12
- * Subversion (SVN)
13
- * Darcs
14
- * CVS
15
- * RSync
15
+ * Subversion (SVN)
16
+ * Git
17
+ * Darcs
18
+ * CVS
19
+ * RSync
16
20
 
17
21
  == INSTALL:
18
22
 
data/Rakefile CHANGED
@@ -6,12 +6,8 @@ require './lib/repertoire/version.rb'
6
6
 
7
7
  Hoe.new('repertoire', Repertoire::VERSION) do |p|
8
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")
9
+ p.developer('Postmodern Modulus III','postmodern.mod3@gmail.com')
10
+ p.remote_rdoc_dir = ''
15
11
  end
16
12
 
17
13
  # vim: syntax=Ruby
data/lib/repertoire.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'repertoire/media'
2
+ require 'repertoire/repository'
2
3
  require 'repertoire/repertoire'
3
4
  require 'repertoire/version'
@@ -1,4 +1,5 @@
1
1
  require 'repertoire/media/types/cvs'
2
2
  require 'repertoire/media/types/darcs'
3
+ require 'repertoire/media/types/git'
3
4
  require 'repertoire/media/types/svn'
4
5
  require 'repertoire/media/types/rsync'
@@ -0,0 +1,31 @@
1
+ require 'repertoire/media/type'
2
+
3
+ module Repertoire
4
+ module Media
5
+ class Git
6
+
7
+ include Type
8
+
9
+ known_as :git
10
+
11
+ uses_schemes 'git'
12
+ uses_directory '.git'
13
+
14
+ #
15
+ # Checks out the Git repository located at the specified _uri_ into the
16
+ # specified _path_.
17
+ #
18
+ def self.checkout(uri,path)
19
+ sh('git','clone',uri,path)
20
+ end
21
+
22
+ #
23
+ # Updated the Git repository located at the specified _path_.
24
+ #
25
+ def self.update(path,uri=nil)
26
+ sh('git','pull',path)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,122 @@
1
+ require 'repertoire/media'
2
+
3
+ module Repertoire
4
+ class Repository
5
+
6
+ # Path to the directory
7
+ attr_reader :path
8
+
9
+ # Media type of the directory
10
+ attr_reader :media
11
+
12
+ #
13
+ # Creates a new Repository object with the specified _path_ and _media_
14
+ # type. If a _block_ is given, it will be passed the newly created
15
+ # Repository object.
16
+ #
17
+ # Repository.new('path/to/repo',Media::SVN)
18
+ #
19
+ # Repository.new('path/to/svn_repo',Media::SVN) do |dir|
20
+ # puts dir['**/']
21
+ # end
22
+ #
23
+ def initialize(path,media=nil,&block)
24
+ @path = File.expand_path(path)
25
+ @media = nil
26
+
27
+ if media
28
+ if File.directory?(File.join(path,media.directory))
29
+ @media = media
30
+ end
31
+ end
32
+
33
+ block.call(self) if block
34
+ end
35
+
36
+ #
37
+ # Similar to <tt>Dir.glob</tt>, except the media's directory is omitted
38
+ # from the returned results. If a _block_ is given, it will be passed
39
+ # each resulting path.
40
+ #
41
+ # dir = Directory.new('path/to/my_svn')
42
+ # dir.glob('sub_path/.svn/*') # => []
43
+ # dir.glob('sub_path/**/') # => [...]
44
+ #
45
+ def glob(pattern,flags=0,&block)
46
+ pattern = File.expand_path(File.join(@path,pattern))
47
+ paths = filter(Dir.glob(pattern,flags))
48
+
49
+ paths.each(&block) if block
50
+ return paths
51
+ end
52
+
53
+ #
54
+ # Returns +true+ if the directory contains the specified _sub_path_,
55
+ # returns +false+ otherwise.
56
+ #
57
+ def has_path?(sub_path)
58
+ !(glob(sub_path).empty?)
59
+ end
60
+
61
+ #
62
+ # Returns an +Array+ of the files matching the _sub_path_ within the
63
+ # directory.
64
+ #
65
+ def files(sub_path='*')
66
+ glob(sub_path).select { |path| File.file?(path) }
67
+ end
68
+
69
+ #
70
+ # Returns +true+ if there is a file with the _sub_path_ within the
71
+ # directory, returns +false+ otherwise.
72
+ #
73
+ def has_file?(sub_path)
74
+ !(files(sub_path).empty?)
75
+ end
76
+
77
+ #
78
+ # Returns an +Array+ of the directories matching the _sub_path_ within
79
+ # the directory.
80
+ #
81
+ def directories(sub_path='*')
82
+ glob(sub_path).select { |path| File.directory?(path) }
83
+ end
84
+
85
+ #
86
+ # Returns +true+ if there is a directory with the _sub_path_ within the
87
+ # directory, returns +false+ otherwise.
88
+ #
89
+ def has_directory?(sub_path)
90
+ !(directories(sub_path).empty?)
91
+ end
92
+
93
+ #
94
+ # See glob.
95
+ #
96
+ def [](pattern='')
97
+ glob(pattern)
98
+ end
99
+
100
+ #
101
+ # Returns the path of the directory in +String+ form.
102
+ #
103
+ def to_s
104
+ @path.to_s
105
+ end
106
+
107
+ protected
108
+
109
+ #
110
+ # Filter the specified _paths_, removing any path that contains
111
+ # the media's directory.
112
+ #
113
+ def filter(paths)
114
+ return paths unless @media
115
+
116
+ return paths.select do |path|
117
+ !(path.split(File::SEPARATOR).include?(@media.directory))
118
+ end
119
+ end
120
+
121
+ end
122
+ end
@@ -1,3 +1,3 @@
1
1
  module Repertoire
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,33 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: repertoire
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2008-02-09 00:00:00 -08:00
8
- 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.
9
- require_paths:
10
- - lib
11
- email: postmodern.mod3@gmail.com
12
- homepage: " by Postmodern Modulus III"
13
- rubyforge_project: repertoire
14
- description: "== FEATURES/PROBLEMS: * Currently supports checking-out and updating from: * Subversion (SVN) * Darcs * CVS * RSync == INSTALL: $ sudo gem install repertoire == LICENSE:"
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.1.2
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Postmodern Modulus III
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-25 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.7.0
24
+ version:
25
+ description: R'epertoire is a Ruby library for quickly checking-out and updating code-bases from various SCMs. R'epertoire currently supports Subversion, CVS, Git and even RSync.
26
+ email:
27
+ - postmodern.mod3@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - History.txt
34
+ - Manifest.txt
35
+ - README.txt
31
36
  files:
32
37
  - History.txt
33
38
  - Manifest.txt
@@ -53,33 +58,39 @@ files:
53
58
  - lib/repertoire/media/types.rb
54
59
  - lib/repertoire/media/types/cvs.rb
55
60
  - lib/repertoire/media/types/darcs.rb
61
+ - lib/repertoire/media/types/git.rb
56
62
  - lib/repertoire/media/types/rsync.rb
57
63
  - lib/repertoire/media/types/svn.rb
64
+ - lib/repertoire/repository.rb
58
65
  - lib/repertoire/repertoire.rb
59
66
  - lib/repertoire/version.rb
60
67
  - test/test_repertoire.rb
61
- test_files:
62
- - test/test_repertoire.rb
68
+ has_rdoc: true
69
+ homepage: http://repertoire.rubyforge.org/
70
+ post_install_message:
63
71
  rdoc_options:
64
72
  - --main
65
73
  - README.txt
66
- extra_rdoc_files:
67
- - History.txt
68
- - Manifest.txt
69
- - README.txt
70
- executables: []
71
-
72
- extensions: []
73
-
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
74
88
  requirements: []
75
89
 
76
- dependencies:
77
- - !ruby/object:Gem::Dependency
78
- name: hoe
79
- version_requirement:
80
- version_requirements: !ruby/object:Gem::Version::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 1.5.0
85
- version:
90
+ rubyforge_project: repertoire
91
+ rubygems_version: 1.2.0
92
+ signing_key:
93
+ specification_version: 2
94
+ summary: R'epertoire is a Ruby library for quickly checking-out and updating code-bases from various SCMs
95
+ test_files:
96
+ - test/test_repertoire.rb