repomap 0.0.10 → 0.0.11
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/bin/repo +3 -3
- data/lib/repomap.rb +5 -5
- data/lib/repomap/add.rb +9 -15
- data/lib/repomap/config.rb +2 -2
- data/lib/repomap/find.rb +8 -8
- data/lib/repomap/helpers.rb +2 -4
- data/lib/repomap/list.rb +1 -1
- data/lib/repomap/remove.rb +2 -2
- data/lib/repomap/version.rb +1 -1
- data/spec/repoman_spec.rb +30 -10
- metadata +8 -2
data/bin/repo
CHANGED
@@ -94,12 +94,12 @@ begin
|
|
94
94
|
RepoMap.handle(opts)
|
95
95
|
end
|
96
96
|
else
|
97
|
-
puts "repo: Not a known subcommand"
|
97
|
+
STDOUT.puts "repo: Not a known subcommand"
|
98
98
|
end
|
99
99
|
|
100
100
|
exit 0
|
101
101
|
rescue OptionParser::MissingArgument => e
|
102
|
-
puts "repo: #{e}"
|
102
|
+
STDERR.puts "repo: #{e}"
|
103
103
|
rescue NoMethodError => e
|
104
|
-
puts banner
|
104
|
+
STDOUT.puts banner
|
105
105
|
end
|
data/lib/repomap.rb
CHANGED
@@ -22,13 +22,13 @@ module RepoMap
|
|
22
22
|
# :pattern => "some regex"}}
|
23
23
|
#
|
24
24
|
# Then, call appropriate functions.
|
25
|
-
def self.handle
|
25
|
+
def self.handle(options)
|
26
26
|
|
27
27
|
case options[:action].to_s
|
28
28
|
when /add/
|
29
29
|
if path_exists? options
|
30
30
|
add_recursive! options[:options][:path] if options[:options][:recursive]
|
31
|
-
add! options[:options][:path] if
|
31
|
+
add! options[:options][:path] if !(options[:options][:recursive])
|
32
32
|
end
|
33
33
|
when /remove/
|
34
34
|
if path_exists? options
|
@@ -44,10 +44,10 @@ module RepoMap
|
|
44
44
|
|
45
45
|
end
|
46
46
|
|
47
|
-
def path_exists?
|
47
|
+
def path_exists?(options)
|
48
48
|
|
49
|
-
if options[:options][:path] != nil
|
50
|
-
options[:options][:path] != ''
|
49
|
+
if (options[:options][:path] != nil) &&
|
50
|
+
(options[:options][:path] != '')
|
51
51
|
return true
|
52
52
|
else
|
53
53
|
return false
|
data/lib/repomap/add.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
1
3
|
module RepoMap
|
2
4
|
|
3
|
-
def add!
|
4
|
-
if File.directory?
|
5
|
+
def add!(path)
|
6
|
+
if File.directory?(path) && has_git?(path)
|
5
7
|
full_path = File.expand_path(path)
|
6
8
|
basename = File.basename(full_path)
|
7
9
|
puts "repo: I'm adding '#{basename}' to '#{repo_map}'"
|
@@ -12,22 +14,14 @@ module RepoMap
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Dir.foreach(path) do |item|
|
20
|
-
next if item == '.' or item == '..'
|
21
|
-
item_path = File.join(File.expand_path(path), item)
|
22
|
-
add_recursive! item_path if File.directory? item_path
|
23
|
-
end
|
24
|
-
else
|
25
|
-
STDERR.puts "repo: Not a directory or repository -- #{path}"
|
26
|
-
exit 1
|
17
|
+
|
18
|
+
def add_recursive!(path)
|
19
|
+
Find.find(path) do |f|
|
20
|
+
add! f if File.directory?(f) && has_git?(f)
|
27
21
|
end
|
28
22
|
end
|
29
23
|
|
30
|
-
def add_repo!
|
24
|
+
def add_repo!(reponame, full_path)
|
31
25
|
repo_map_validate
|
32
26
|
hash = YAML::load(File.read(repo_map))
|
33
27
|
hash = {} if hash==nil
|
data/lib/repomap/config.rb
CHANGED
data/lib/repomap/find.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module RepoMap
|
2
2
|
|
3
|
-
def find
|
3
|
+
def find(path, pattern)
|
4
4
|
if path
|
5
|
-
find_with_path
|
5
|
+
find_with_path(path, pattern)
|
6
6
|
else
|
7
|
-
find_without_path
|
7
|
+
find_without_path(pattern)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def find_with_path
|
11
|
+
def find_with_path(path, pattern)
|
12
12
|
repo_map_validate
|
13
13
|
hash = YAML::load(File.read(repo_map))
|
14
14
|
regex = Regexp.new(pattern)
|
@@ -17,17 +17,17 @@ module RepoMap
|
|
17
17
|
hash.each do |k, v|
|
18
18
|
fk = File.expand_path(k.to_s)
|
19
19
|
m = fk.match(fp_reg)
|
20
|
-
is_subdir = (fk.length>fp.length)&&(m.to_s==fp)
|
21
|
-
if is_subdir
|
20
|
+
is_subdir = (fk.length>fp.length) && (m.to_s==fp)
|
21
|
+
if is_subdir && v[:name].to_s.match(regex)!=nil
|
22
22
|
puts k.to_s
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def find_without_path
|
27
|
+
def find_without_path(pattern)
|
28
28
|
repo_map_validate
|
29
29
|
hash = YAML::load(File.read(repo_map))
|
30
|
-
regex = Regexp.new
|
30
|
+
regex = Regexp.new(pattern)
|
31
31
|
hash.each do |k, v|
|
32
32
|
if v[:name].to_s.match(regex)!=nil
|
33
33
|
puts k.to_s
|
data/lib/repomap/helpers.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module RepoMap
|
2
2
|
|
3
|
-
repo_map = ENV['REPO_MAP']
|
4
|
-
|
5
3
|
def repo_map_validate
|
6
4
|
unless repo_map_exists?
|
7
5
|
File.new(repo_map, "w")
|
@@ -11,14 +9,14 @@ module RepoMap
|
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
|
-
def has_git?
|
12
|
+
def has_git?(path)
|
15
13
|
File.directory? "#{File.expand_path(path)}/.git"
|
16
14
|
end
|
17
15
|
|
18
16
|
def repo_map_exists?
|
19
17
|
a = File.exist? repo_map
|
20
18
|
b = File.read(repo_map)!='' if a
|
21
|
-
a
|
19
|
+
a && b
|
22
20
|
end
|
23
21
|
|
24
22
|
end
|
data/lib/repomap/list.rb
CHANGED
data/lib/repomap/remove.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module RepoMap
|
2
2
|
|
3
|
-
def remove!
|
3
|
+
def remove!(path)
|
4
4
|
repo_map_validate
|
5
5
|
full_path = File.expand_path(path)
|
6
6
|
basename = File.basename(full_path)
|
7
7
|
hash = YAML::load(File.read(repo_map))
|
8
8
|
if hash.has_key?(full_path.to_sym)
|
9
|
-
puts "repo: I'm removing '#{basename}' from '#{repo_map}'"
|
9
|
+
STDOUT.puts "repo: I'm removing '#{basename}' from '#{repo_map}'"
|
10
10
|
else
|
11
11
|
STDERR.puts "repo: I don't have this repository -- '#{full_path}'"
|
12
12
|
exit 1
|
data/lib/repomap/version.rb
CHANGED
data/spec/repoman_spec.rb
CHANGED
@@ -6,7 +6,9 @@ require 'fileutils'
|
|
6
6
|
include FileUtils
|
7
7
|
|
8
8
|
module RepoMap
|
9
|
-
|
9
|
+
TEST_REPO_MAP = "#{File.dirname(__FILE__)}/../tmp/repomap.yml"
|
10
|
+
def repo_map; TEST_REPO_MAP; end
|
11
|
+
MANY_REPOS = "#{File.dirname(__FILE__)}/../tmp/many_repos"
|
10
12
|
REPO1 = "#{File.dirname(__FILE__)}/../tmp/repo1"
|
11
13
|
end
|
12
14
|
|
@@ -16,12 +18,16 @@ describe "RepoMap SubCommands" do
|
|
16
18
|
|
17
19
|
before :each do
|
18
20
|
mkdir_p "#{REPO1}/.git"
|
19
|
-
# so it's not empty...
|
20
21
|
touch "#{REPO1}/README"
|
22
|
+
mkdir_p "#{MANY_REPOS}/repo2a/.git"
|
23
|
+
touch "#{MANY_REPOS}/repo2a/README"
|
24
|
+
mkdir_p "#{MANY_REPOS}/repo2b/.git"
|
25
|
+
touch "#{MANY_REPOS}/repo2b/README"
|
21
26
|
end
|
22
27
|
|
23
28
|
after :each do
|
24
29
|
rm_rf "#{REPO1}/.git"
|
30
|
+
rm_rf "#{MANY_REPOS}"
|
25
31
|
end
|
26
32
|
|
27
33
|
after :all do
|
@@ -30,8 +36,8 @@ describe "RepoMap SubCommands" do
|
|
30
36
|
|
31
37
|
describe "#add!" do
|
32
38
|
|
33
|
-
it "should add a given path to
|
34
|
-
opts = repo_opts
|
39
|
+
it "should add a given path to RepoMap file" do
|
40
|
+
opts = repo_opts(:add, REPO1)
|
35
41
|
RepoMap.handle(opts)
|
36
42
|
hash = YAML::load(File.read(repo_map))
|
37
43
|
hash[File.expand_path(REPO1).to_sym][:name].should == File.basename(REPO1)
|
@@ -39,29 +45,43 @@ describe "RepoMap SubCommands" do
|
|
39
45
|
|
40
46
|
end
|
41
47
|
|
48
|
+
describe "#add_recursive!" do
|
49
|
+
|
50
|
+
it "should recursively add all git repo's in a certain path" do
|
51
|
+
opts = repo_opts(:add, MANY_REPOS, true)
|
52
|
+
RepoMap.handle(opts)
|
53
|
+
hash = YAML::load(File.read(repo_map))
|
54
|
+
repo2a_path = File.expand_path("#{MANY_REPOS}/repo2a")
|
55
|
+
repo2b_path = File.expand_path("#{MANY_REPOS}/repo2b")
|
56
|
+
hash[repo2a_path.to_sym][:name].should == File.basename(repo2a_path)
|
57
|
+
hash[repo2b_path.to_sym][:name].should == File.basename(repo2b_path)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
42
62
|
describe "#remove!" do
|
43
63
|
|
44
|
-
it "should remove a given path from
|
45
|
-
opts = repo_opts
|
64
|
+
it "should remove a given path from RepoMap file" do
|
65
|
+
opts = repo_opts(:add, REPO1)
|
46
66
|
RepoMap.handle opts
|
47
67
|
hash1 = YAML::load(File.read(repo_map))
|
48
68
|
repo1_in_repomap = hash1[File.expand_path(REPO1).to_sym][:name] \
|
49
69
|
== File.basename(REPO1)
|
50
|
-
opts = repo_opts
|
70
|
+
opts = repo_opts(:remove, REPO1)
|
51
71
|
RepoMap.handle opts
|
52
72
|
hash2 = YAML::load(File.read(repo_map))
|
53
73
|
repo1_removed = !(hash2.has_key?(File.expand_path(REPO1).to_sym))
|
54
|
-
(repo1_in_repomap
|
74
|
+
(repo1_in_repomap && repo1_removed).should == true
|
55
75
|
end
|
56
76
|
|
57
77
|
end
|
58
78
|
|
59
79
|
end
|
60
80
|
|
61
|
-
def repo_opts
|
81
|
+
def repo_opts(action, repo_path, recursive=false)
|
62
82
|
opts = {}
|
63
83
|
opts[:action] = action
|
64
84
|
opts[:options] = {:path => repo_path,
|
65
|
-
:recursive =>
|
85
|
+
:recursive => recursive}
|
66
86
|
return opts
|
67
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repomap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -79,12 +79,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- - ! '>='
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
hash: -1475655317722997625
|
82
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
86
|
none: false
|
84
87
|
requirements:
|
85
88
|
- - ! '>='
|
86
89
|
- !ruby/object:Gem::Version
|
87
90
|
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: -1475655317722997625
|
88
94
|
requirements: []
|
89
95
|
rubyforge_project:
|
90
96
|
rubygems_version: 1.8.24
|