libdolt 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/lib/libdolt/git/repository.rb +23 -11
- data/lib/libdolt/gitorious_repo_resolver.rb +1 -1
- data/lib/libdolt/version.rb +1 -1
- data/libdolt.gemspec +4 -4
- data/test/libdolt/git/repository_test.rb +75 -0
- metadata +18 -15
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
libdolt (0.8.0)
|
5
5
|
em_pessimistic (~> 0.1)
|
6
|
-
em_rugged (~> 0.
|
6
|
+
em_rugged (~> 0.3)
|
7
7
|
eventmachine (~> 1.0)
|
8
8
|
htmlentities (~> 4.3)
|
9
9
|
json (~> 1.7)
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
eventmachine
|
20
20
|
em_pessimistic (0.1.2)
|
21
21
|
eventmachine (~> 1.0)
|
22
|
-
em_rugged (0.
|
22
|
+
em_rugged (0.3.0)
|
23
23
|
eventmachine (~> 1.0)
|
24
24
|
rugged (= 0.17.0.b6)
|
25
25
|
eventmachine (1.0.0)
|
@@ -37,10 +37,10 @@ GEM
|
|
37
37
|
posix-spawn (~> 0.3.6)
|
38
38
|
yajl-ruby (~> 1.1.0)
|
39
39
|
rake (0.9.2.2)
|
40
|
-
redcarpet (2.
|
40
|
+
redcarpet (2.2.0)
|
41
41
|
rugged (0.17.0.b6)
|
42
42
|
tilt (1.3.3)
|
43
|
-
tiltout (1.
|
43
|
+
tiltout (1.2.0)
|
44
44
|
tilt (~> 1.3)
|
45
45
|
tzinfo (0.3.33)
|
46
46
|
when (0.1.0)
|
@@ -54,5 +54,5 @@ DEPENDENCIES
|
|
54
54
|
libdolt!
|
55
55
|
minitest (~> 2.0)
|
56
56
|
rake (~> 0.9)
|
57
|
-
redcarpet
|
58
|
-
tiltout (~> 1)
|
57
|
+
redcarpet (= 2.2.0)
|
58
|
+
tiltout (~> 1.2)
|
@@ -69,20 +69,32 @@ module Dolt
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def tree_history(ref, path, limit = 1)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
When.defer do |d|
|
73
|
+
rp = rev_parse("#{ref}:#{path}")
|
74
|
+
rp.errback { |err| d.reject(err) }
|
75
|
+
rp.callback do |tree|
|
76
|
+
if tree.class != Rugged::Tree
|
77
|
+
message = "#{ref}:#{path} is not a tree (#{tree.class.to_s})"
|
78
|
+
break d.reject(Exception.new(message))
|
79
|
+
end
|
80
|
+
|
81
|
+
building = build_history(path || "./", ref, tree, limit)
|
82
|
+
building.callback { |history| d.resolve(history) }
|
83
|
+
building.errback { |err| d.reject(err) }
|
79
84
|
end
|
85
|
+
end
|
86
|
+
end
|
80
87
|
|
81
|
-
|
82
|
-
|
83
|
-
|
88
|
+
def readme(ref)
|
89
|
+
When.defer do |d|
|
90
|
+
t = self.tree(ref, "")
|
91
|
+
t.callback do |tree|
|
92
|
+
d.resolve(tree.entries.select do |e|
|
93
|
+
e[:type] == :blob && e[:name].match(/readme/i)
|
94
|
+
end)
|
95
|
+
end
|
96
|
+
t.errback { |err| d.resolve([]) }
|
84
97
|
end
|
85
|
-
d
|
86
98
|
end
|
87
99
|
|
88
100
|
private
|
data/lib/libdolt/version.rb
CHANGED
data/libdolt.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency "eventmachine", "~>1.0"
|
17
17
|
s.add_dependency "when", "~>0"
|
18
18
|
s.add_dependency "em_pessimistic", "~>0.1"
|
19
|
-
s.add_dependency "em_rugged", "~> 0.
|
19
|
+
s.add_dependency "em_rugged", "~> 0.3"
|
20
20
|
s.add_dependency "tzinfo", "~> 0.3"
|
21
|
-
s.add_dependency "makeup", "~>0"
|
21
|
+
s.add_dependency "makeup", "~>0.2"
|
22
22
|
s.add_dependency "htmlentities", "~> 4.3"
|
23
23
|
s.add_dependency "json", "~> 1.7"
|
24
24
|
s.add_dependency "mime-types", "~> 1.19"
|
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency "minitest", "~> 2.0"
|
27
27
|
s.add_development_dependency "em-minitest-spec", "~> 1.1"
|
28
28
|
s.add_development_dependency "rake", "~> 0.9"
|
29
|
-
s.add_development_dependency "redcarpet"
|
30
|
-
s.add_development_dependency "tiltout", "~>1"
|
29
|
+
s.add_development_dependency "redcarpet", "2.2.0"
|
30
|
+
s.add_development_dependency "tiltout", "~>1.2"
|
31
31
|
|
32
32
|
s.files = `git ls-files`.split("\n")
|
33
33
|
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
@@ -18,6 +18,7 @@
|
|
18
18
|
require "test_helper"
|
19
19
|
require "libdolt/git/repository"
|
20
20
|
require "time"
|
21
|
+
require "ostruct"
|
21
22
|
|
22
23
|
describe Dolt::Git::Repository do
|
23
24
|
include EM::MiniTest::Spec
|
@@ -216,4 +217,78 @@ describe Dolt::Git::Repository do
|
|
216
217
|
wait!
|
217
218
|
end
|
218
219
|
end
|
220
|
+
|
221
|
+
describe "#readme" do
|
222
|
+
it "returns deferrable" do
|
223
|
+
deferrable = @repository.readme("master")
|
224
|
+
assert deferrable.respond_to?(:callback)
|
225
|
+
assert deferrable.respond_to?(:errback)
|
226
|
+
end
|
227
|
+
|
228
|
+
it "yields single readme" do
|
229
|
+
def @repository.tree(ref, path)
|
230
|
+
entries = [{ :type => :blob, :name => "Readme" },
|
231
|
+
{ :type => :blob, :name => "file.txt" },
|
232
|
+
{ :type => :tree, :name => "dir" }]
|
233
|
+
if ref == "master" && path == ""
|
234
|
+
When.resolve(OpenStruct.new(:entries => entries))
|
235
|
+
else
|
236
|
+
When.reject("Wrong ref/path")
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
@repository.readme("master").callback do |readmes|
|
241
|
+
assert_equal 1, readmes.length
|
242
|
+
assert_equal "Readme", readmes.first[:name]
|
243
|
+
done!
|
244
|
+
end
|
245
|
+
|
246
|
+
wait!
|
247
|
+
end
|
248
|
+
|
249
|
+
it "does not yield trees" do
|
250
|
+
def @repository.tree(ref, path)
|
251
|
+
entries = [{ :type => :tree, :name => "Readme" },
|
252
|
+
{ :type => :blob, :name => "file.txt" },
|
253
|
+
{ :type => :tree, :name => "dir" }]
|
254
|
+
When.resolve(OpenStruct.new(:entries => entries))
|
255
|
+
end
|
256
|
+
|
257
|
+
@repository.readme("master").callback do |readmes|
|
258
|
+
assert_equal 0, readmes.length
|
259
|
+
done!
|
260
|
+
end
|
261
|
+
|
262
|
+
wait!
|
263
|
+
end
|
264
|
+
|
265
|
+
it "yields all readmes" do
|
266
|
+
def @repository.tree(ref, path)
|
267
|
+
entries = [{ :type => :blob, :name => "Readme.rdoc" },
|
268
|
+
{ :type => :blob, :name => "readme" },
|
269
|
+
{ :type => :blob, :name => "Readme.md" }]
|
270
|
+
When.resolve(OpenStruct.new(:entries => entries))
|
271
|
+
end
|
272
|
+
|
273
|
+
@repository.readme("master").callback do |readmes|
|
274
|
+
assert_equal 3, readmes.length
|
275
|
+
done!
|
276
|
+
end
|
277
|
+
|
278
|
+
wait!
|
279
|
+
end
|
280
|
+
|
281
|
+
it "yields empty array of readmes when promise rejects" do
|
282
|
+
def @repository.tree(ref, path)
|
283
|
+
When.reject(OpenStruct.new({ :message => "Unknown reason" }))
|
284
|
+
end
|
285
|
+
|
286
|
+
@repository.readme("master").callback do |readmes|
|
287
|
+
assert_equal 0, readmes.length
|
288
|
+
done!
|
289
|
+
end
|
290
|
+
|
291
|
+
wait!
|
292
|
+
end
|
293
|
+
end
|
219
294
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libdolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christian Johansen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-10-
|
18
|
+
date: 2012-10-15 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -70,12 +70,11 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ~>
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
73
|
+
hash: 13
|
74
74
|
segments:
|
75
75
|
- 0
|
76
|
-
-
|
77
|
-
|
78
|
-
version: 0.1.2
|
76
|
+
- 3
|
77
|
+
version: "0.3"
|
79
78
|
type: :runtime
|
80
79
|
version_requirements: *id004
|
81
80
|
- !ruby/object:Gem::Dependency
|
@@ -101,10 +100,11 @@ dependencies:
|
|
101
100
|
requirements:
|
102
101
|
- - ~>
|
103
102
|
- !ruby/object:Gem::Version
|
104
|
-
hash:
|
103
|
+
hash: 15
|
105
104
|
segments:
|
106
105
|
- 0
|
107
|
-
|
106
|
+
- 2
|
107
|
+
version: "0.2"
|
108
108
|
type: :runtime
|
109
109
|
version_requirements: *id006
|
110
110
|
- !ruby/object:Gem::Dependency
|
@@ -203,12 +203,14 @@ dependencies:
|
|
203
203
|
requirement: &id013 !ruby/object:Gem::Requirement
|
204
204
|
none: false
|
205
205
|
requirements:
|
206
|
-
- - "
|
206
|
+
- - "="
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
hash:
|
208
|
+
hash: 7
|
209
209
|
segments:
|
210
|
+
- 2
|
211
|
+
- 2
|
210
212
|
- 0
|
211
|
-
version:
|
213
|
+
version: 2.2.0
|
212
214
|
type: :development
|
213
215
|
version_requirements: *id013
|
214
216
|
- !ruby/object:Gem::Dependency
|
@@ -219,10 +221,11 @@ dependencies:
|
|
219
221
|
requirements:
|
220
222
|
- - ~>
|
221
223
|
- !ruby/object:Gem::Version
|
222
|
-
hash:
|
224
|
+
hash: 11
|
223
225
|
segments:
|
224
226
|
- 1
|
225
|
-
|
227
|
+
- 2
|
228
|
+
version: "1.2"
|
226
229
|
type: :development
|
227
230
|
version_requirements: *id014
|
228
231
|
description: Dolt API for serving git trees and syntax highlighted blobs
|