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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbd6a30b0d60a7d08b00d9d46e06c277995840cf
4
- data.tar.gz: 7afb08dbfa5fcc801aac009bb2153fab50a8ff6b
3
+ metadata.gz: dcd3c9891c4ff09594376dc40cef9da11ce81d78
4
+ data.tar.gz: 4e4811f7c90b9fa18d3d3687d30c289dd2446ac0
5
5
  SHA512:
6
- metadata.gz: aeb75821bbec6205ddaf38aed73d4552e7e1f7d11889cf7f9f6cf4e9981f12ebe7e51a9c5e822d62d165922f6c9ab8dc2fa44ef66a26ffa272fdd251e43577f1
7
- data.tar.gz: 900911a7cbef27e3602158d148257ecc60fa5e016983ecd668f1a92ac43299e2f39662f01ccf6ffc6b6a71103a9f0c82bf1a0904c9d475d6e7ebdc4fc633b9fa
6
+ metadata.gz: 252ee4f5411e570acffcfd659db4764d8a797fb024711c3d66d5d02e18702e20d0936c67905f72ca8bceb8c8fa5520559ae54d2816f64a8bcf65a51561c3cb0d
7
+ data.tar.gz: 72cf0eb34eff9cb433475e22eab6606673e4178da04940f4a4615c289e973aca374513b26ea9b42420f846e0127842f3696bf3085e21069344d90705f7a47bb0
@@ -1,3 +1,3 @@
1
1
  module CompactIndex
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -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
- DateTime.parse(File.mtime(@path).to_s)
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] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compact_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fotanus@gmail.com