compact_index 0.8.1 → 0.9.0

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: 45af59196a7c0e110d5a888103c573b88da564d4
4
- data.tar.gz: c7aa0e482d9f5bd5f08708633676151ba46fbe95
3
+ metadata.gz: d64d44d1fea23ce0a76b7845acc0014b8ca8aec7
4
+ data.tar.gz: 51b9ae7960a546363e9d78327467f7a8b482ab68
5
5
  SHA512:
6
- metadata.gz: a3ddc30cb5ea6dfd4a82f08772f0ca75e36a62e46c441f03f5687837be5d46292b4b9658b37e780cd3b07d8ecb9e54553cb6e276d5dbe20d32d70bf74a502f51
7
- data.tar.gz: 3989c7b72b3582b6df70e86a1db72b4c65c2dd5795ad0f637db4c2579da95b169842d65889846ade6412634b70514a6743e3cd77d004c1c75cdfd74491ddbc5c
6
+ metadata.gz: 7aee9ae1d0b33076d8e6109cef53eee7c2e4e805007114f446b50736c9cfd4f3877fd2dbd27dcb1096294b771a90386ea2a6d20a3a39f35a18d0d267d2cd01ae
7
+ data.tar.gz: 434971c492a216938303c67a16cdb399a49aed8232065c6f93640830bf2e86e842debca4a3dffc51cf4f5431fb9b5ace7104c49db004ca67d0bff597e5ccf4c9
@@ -1,3 +1,11 @@
1
+ ## 0.9.0 (August 17, 2015)
2
+
3
+ Features:
4
+
5
+ - Remove sort responsability from compact_index
6
+ - Change interface for versions_file in order to receive sorted gems
7
+
8
+
1
9
  ## 0.8.1 (August 13, 2015)
2
10
 
3
11
  Bugfixes:
@@ -12,16 +12,7 @@ module CompactIndex
12
12
 
13
13
  def self.info(params)
14
14
  output = "---\n"
15
- sorted = params.sort do |a,b|
16
- if a[:created_at] and b[:created_at]
17
- a[:created_at] <=> b[:created_at]
18
- elsif a[:created_at]
19
- -1
20
- else
21
- 1
22
- end
23
- end
24
- sorted.each do |version|
15
+ params.each do |version|
25
16
  output << version_line(version) << "\n"
26
17
  end
27
18
  output
@@ -30,7 +21,7 @@ module CompactIndex
30
21
  private
31
22
  def self.version_line(version)
32
23
  if version[:dependencies]
33
- version[:dependencies].sort! { |a,b| a[:gem] <=> b[:gem] }
24
+ version[:dependencies]
34
25
  deps = version[:dependencies].map do |d|
35
26
  [
36
27
  d[:gem],
@@ -1,3 +1,3 @@
1
1
  module CompactIndex
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -48,50 +48,46 @@ class CompactIndex::VersionsFile
48
48
  end
49
49
 
50
50
  def parse_gems_for_create(gems)
51
- fixed_format_gems = gems.map do |k,v|
52
- numbers = v.map { |x| [x[:number], x[:platform] ] }
53
- { name: k, versions: numbers, checksum: v.first[:checksum] }
51
+ # Join all versions for each gem in one hash
52
+ gems_hash = {}
53
+ gems.each do |entry|
54
+ gems_hash[entry[:name]] ||= []
55
+ gems_hash[entry[:name]] += entry[:versions]
54
56
  end
55
- fixed_format_gems.sort! { |a,b| a[:name] <=> b[:name] }
56
- gem_lines(fixed_format_gems)
57
- end
58
57
 
59
- def parse_gems(gems)
60
- sorted_gems = format_by_created_time(gems)
61
- gem_lines(sorted_gems)
58
+ # Transform hash in a list of line informations to be printed
59
+ gems = gems_hash.map do |gem, versions|
60
+ { name: gem, versions: versions, checksum: versions.first[:checksum] }
61
+ end
62
+
63
+ # Sort gems by name and versions by number
64
+ gems.sort! { |a,b| a[:name] <=> b[:name] }
65
+ gems.each do |entry|
66
+ entry[:versions].sort_by! { |v| Gem::Version.create(v[:number]) }
67
+ end
68
+
69
+ gem_lines(gems)
62
70
  end
63
71
 
64
- def format_by_created_time(gems)
65
- by_created_at = {}
66
- checksums = {}
67
- gems.each do |name, versions|
68
- versions.each do |v|
69
- by_created_at[v[:created_at]] ||= {}
70
- by_created_at[v[:created_at]][name] ||= []
71
- by_created_at[v[:created_at]][name] << [v[:number], v[:platform]]
72
- checksums[v[:created_at]] ||= {}
73
- checksums[v[:created_at]] = v[:checksum]
74
- end
72
+ def parse_gems(gems)
73
+ gem_lines = gems.map do |entry|
74
+ {
75
+ name: entry[:name],
76
+ versions: entry[:versions],
77
+ checksum: entry[:versions].first[:checksum]
78
+ }
75
79
  end
76
- by_created_at.sort.map do |created_at,gems|
77
- gems.map do |name, versions|
78
- { name: name, versions: versions, checksum: checksums[created_at] }
79
- end
80
- end.flatten
80
+ gem_lines(gem_lines)
81
81
  end
82
82
 
83
83
  def gem_lines(gems)
84
84
  gems.reduce("") do |concat, entry|
85
- versions = sort_versions(entry[:versions])
86
- versions.map! { |version, platform| number_and_platform(version, platform) }
87
- concat << "#{entry[:name]} #{versions.join(',')} #{entry[:checksum]}\n"
85
+ versions = entry[:versions]
86
+ number_and_plat = versions.map { |version| number_and_platform(version[:number], version[:platform]) }
87
+ concat << "#{entry[:name]} #{number_and_plat.join(',')} #{entry[:checksum]}\n"
88
88
  end
89
89
  end
90
90
 
91
- def sort_versions(versions)
92
- versions.sort_by { |v| Gem::Version.create(v.first) }
93
- end
94
-
95
91
  def number_and_platform(number, platform)
96
92
  if platform.nil? || platform == 'ruby'
97
93
  number
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compact_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fotanus@gmail.com
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake