treet 0.10.3 → 0.11.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/README.md +1 -0
- data/lib/treet/farm.rb +17 -11
- data/lib/treet/gitfarm.rb +4 -0
- data/lib/treet/repo.rb +2 -6
- data/lib/treet/version.rb +1 -1
- data/spec/lib/repo_spec.rb +0 -1
- data/spec/lib/test_farm.rb +10 -2
- data/spec/lib/test_gitfarm.rb +5 -0
- data/spec/lib/test_gitrepo.rb +2 -2
- data/treet.gemspec +1 -0
- metadata +20 -4
data/README.md
CHANGED
@@ -85,6 +85,7 @@ are not allowed.
|
|
85
85
|
|
86
86
|
## TODO
|
87
87
|
|
88
|
+
* why is caching built into treet farm? The data on disk could change. Caching doesn't belong here.
|
88
89
|
* Enforce limitation on structure depth (top-level elements can contain flat hashes or arrays, nothing else)
|
89
90
|
* refac: move diff stuff from hash.rb to Treet::Diff class, to encapsulate the structure of a diff (array of arrays); create methods for hunting for special stuff in a diff
|
90
91
|
* Check all exceptions for explicit classes
|
data/lib/treet/farm.rb
CHANGED
@@ -14,17 +14,17 @@ class Treet::Farm
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def repos(opts = {})
|
17
|
-
|
17
|
+
xrefs.each_with_object({}) do |subdir,h|
|
18
18
|
# in a Farm we are looking for repositories under the root
|
19
|
-
|
20
|
-
xref = File.basename(subdir)
|
21
|
-
h[xref] = repotype.new(subdir, opts.merge(:xrefkey => xrefkey, :xref => xref))
|
22
|
-
end
|
19
|
+
h[subdir] = repo(subdir, opts)
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
26
|
-
def
|
27
|
-
|
23
|
+
def repo(id, opts = {})
|
24
|
+
repotype.new("#{root}/#{id}", opts)
|
25
|
+
rescue Errno::ENOENT
|
26
|
+
# no such repository exists
|
27
|
+
nil
|
28
28
|
end
|
29
29
|
|
30
30
|
# export as an array, not as a hash
|
@@ -58,10 +58,6 @@ class Treet::Farm
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def [](xref)
|
62
|
-
repos[xref]
|
63
|
-
end
|
64
|
-
|
65
61
|
# add a new repo, with data from an input hash
|
66
62
|
# if an :id is provided, then the new repo will be stored under that directory name,
|
67
63
|
# otherwise a unique id will be generated
|
@@ -70,4 +66,14 @@ class Treet::Farm
|
|
70
66
|
thash = Treet::Hash.new(hash)
|
71
67
|
repos[uuid] = thash.to_repo("#{root}/#{uuid}", opts.merge(:repotype => repotype))
|
72
68
|
end
|
69
|
+
|
70
|
+
def xrefs
|
71
|
+
Dir.chdir(root) do
|
72
|
+
Dir.glob("*").select {|f| File.directory?(f)}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def count
|
77
|
+
xrefs.count
|
78
|
+
end
|
73
79
|
end
|
data/lib/treet/gitfarm.rb
CHANGED
data/lib/treet/repo.rb
CHANGED
@@ -4,7 +4,7 @@ class Treet::Repo
|
|
4
4
|
attr_reader :root
|
5
5
|
|
6
6
|
def initialize(path, opts = {})
|
7
|
-
raise "Missing or invalid source path #{path}" unless File.directory?(path)
|
7
|
+
raise Errno::ENOENT, "Missing or invalid source path #{path}" unless File.directory?(path)
|
8
8
|
|
9
9
|
@root = path
|
10
10
|
end
|
@@ -13,10 +13,6 @@ class Treet::Repo
|
|
13
13
|
expand(root)
|
14
14
|
end
|
15
15
|
|
16
|
-
def reset
|
17
|
-
# clear any cached data
|
18
|
-
end
|
19
|
-
|
20
16
|
def compare(target)
|
21
17
|
Treet::Hash.diff(to_hash, target.to_hash)
|
22
18
|
end
|
@@ -45,7 +41,7 @@ class Treet::Repo
|
|
45
41
|
|
46
42
|
Dir.chdir(root) do
|
47
43
|
diffs.each do |diff|
|
48
|
-
flag, key, v1,
|
44
|
+
flag, key, v1, _ = diff
|
49
45
|
# if key =~ /\[/
|
50
46
|
# keyname = key.match(/^(.*)\[\]$/).captures
|
51
47
|
# elsif key =~ /\./
|
data/lib/treet/version.rb
CHANGED
data/spec/lib/repo_spec.rb
CHANGED
data/spec/lib/test_farm.rb
CHANGED
@@ -32,7 +32,7 @@ describe "Repository Farm" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "planting should create a directory of UUID-labeled repos" do
|
35
|
-
farm = Treet::Farm.plant(:json =>
|
35
|
+
farm = Treet::Farm.plant(:json => jsonfile('master'), :root => Dir.mktmpdir)
|
36
36
|
|
37
37
|
Dir.glob("#{farm.root}/*").count.must_equal 3
|
38
38
|
Dir.glob("#{farm.root}/*/emails/*").count.must_equal 5
|
@@ -47,9 +47,17 @@ describe "Repository Farm" do
|
|
47
47
|
# farm['two'].to_hash['xref'].must_equal {'test' => 'two'}
|
48
48
|
# end
|
49
49
|
|
50
|
+
it "should allow direct fetch by id" do
|
51
|
+
farm = Treet::Farm.plant(:json => jsonfile('master'), :root => Dir.mktmpdir)
|
52
|
+
repoid = farm.xrefs.sample
|
53
|
+
farm.repo(repoid).wont_be_nil
|
54
|
+
farm.repo("BOGUS").must_be_nil
|
55
|
+
end
|
56
|
+
|
50
57
|
it "should take additions" do
|
51
|
-
farm = Treet::Farm.plant(:json =>
|
58
|
+
farm = Treet::Farm.plant(:json => jsonfile('master'), :root => Dir.mktmpdir)
|
52
59
|
farm.repos.count.must_equal 3
|
60
|
+
farm.count.must_equal 3
|
53
61
|
|
54
62
|
bob_hash = load_json("bob1")
|
55
63
|
repo = farm.add(bob_hash)
|
data/spec/lib/test_gitfarm.rb
CHANGED
data/spec/lib/test_gitrepo.rb
CHANGED
@@ -185,7 +185,7 @@ describe Treet::Gitrepo do
|
|
185
185
|
|
186
186
|
describe "a tagged & patched repo" do
|
187
187
|
def self.makerepo
|
188
|
-
@
|
188
|
+
@repo ||= begin
|
189
189
|
r = make_gitrepo('two',
|
190
190
|
:author => {:name => 'Bob', :email => 'bob@example.com'},
|
191
191
|
:xrefkey => 'app1',
|
@@ -269,7 +269,7 @@ describe Treet::Gitrepo do
|
|
269
269
|
|
270
270
|
describe "a multiply-patched gitrepo" do
|
271
271
|
def self.makerepo
|
272
|
-
@
|
272
|
+
@repo ||= begin
|
273
273
|
r = make_gitrepo('two', :author => {:name => 'Bob', :email => 'bob@example.com'})
|
274
274
|
r.tag('app1')
|
275
275
|
r.tag('app2')
|
data/treet.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
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-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -123,6 +123,22 @@ dependencies:
|
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rb-fsevent
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
126
142
|
description: Transform between trees of files and JSON blobs
|
127
143
|
email:
|
128
144
|
- jmay@pobox.com
|
@@ -190,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
206
|
version: '0'
|
191
207
|
segments:
|
192
208
|
- 0
|
193
|
-
hash:
|
209
|
+
hash: -2853716979805169129
|
194
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
211
|
none: false
|
196
212
|
requirements:
|
@@ -199,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
215
|
version: '0'
|
200
216
|
segments:
|
201
217
|
- 0
|
202
|
-
hash:
|
218
|
+
hash: -2853716979805169129
|
203
219
|
requirements: []
|
204
220
|
rubyforge_project:
|
205
221
|
rubygems_version: 1.8.24
|