compact_index 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/compact_index/version.rb +1 -1
- data/lib/compact_index/versions_file.rb +29 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcd3c9891c4ff09594376dc40cef9da11ce81d78
|
4
|
+
data.tar.gz: 4e4811f7c90b9fa18d3d3687d30c289dd2446ac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 252ee4f5411e570acffcfd659db4764d8a797fb024711c3d66d5d02e18702e20d0936c67905f72ca8bceb8c8fa5520559ae54d2816f64a8bcf65a51561c3cb0d
|
7
|
+
data.tar.gz: 72cf0eb34eff9cb433475e22eab6606673e4178da04940f4a4615c289e973aca374513b26ea9b42420f846e0127842f3696bf3085e21069344d90705f7a47bb0
|
@@ -5,22 +5,6 @@ class CompactIndex::VersionsFile
|
|
5
5
|
@path = file || "/versions.list"
|
6
6
|
end
|
7
7
|
|
8
|
-
def create(gems)
|
9
|
-
content = "created_at: #{Time.now.iso8601}"
|
10
|
-
content += "\n---\n"
|
11
|
-
content += parse_gems_for_create(gems)
|
12
|
-
|
13
|
-
File.open(@path, 'w') do |io|
|
14
|
-
io.write content
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def update(gems)
|
19
|
-
File.open(@path, 'a') do |io|
|
20
|
-
io.write parse_gems(gems)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
8
|
def contents(gems=nil)
|
25
9
|
out = File.open(@path).read
|
26
10
|
out += parse_gems(gems) if gems
|
@@ -28,13 +12,41 @@ class CompactIndex::VersionsFile
|
|
28
12
|
end
|
29
13
|
|
30
14
|
def updated_at
|
31
|
-
|
15
|
+
if File.exists? @path
|
16
|
+
DateTime.parse(File.mtime(@path).to_s)
|
17
|
+
else
|
18
|
+
Time.new('1984')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_with(gems)
|
23
|
+
if File.exists?(@path) && !File.zero?(@path)
|
24
|
+
update(gems)
|
25
|
+
else
|
26
|
+
create(gems)
|
27
|
+
end
|
32
28
|
end
|
33
29
|
|
34
30
|
|
35
31
|
private
|
36
32
|
|
37
33
|
|
34
|
+
def create(gems)
|
35
|
+
content = "created_at: #{Time.now.iso8601}"
|
36
|
+
content += "\n---\n"
|
37
|
+
content += parse_gems_for_create(gems)
|
38
|
+
|
39
|
+
File.open(@path, 'w') do |io|
|
40
|
+
io.write content
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def update(gems)
|
45
|
+
File.open(@path, 'a') do |io|
|
46
|
+
io.write parse_gems(gems)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
38
50
|
def parse_gems_for_create(gems)
|
39
51
|
fixed_format_gems = gems.map do |k,v|
|
40
52
|
numbers = v.map { |x| x[:number] }
|