compact_index 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +3 -3
- data/lib/compact_index.rb +3 -32
- data/lib/compact_index/gem.rb +5 -1
- data/lib/compact_index/gem_version.rb +26 -0
- data/lib/compact_index/version.rb +1 -1
- data/lib/compact_index/versions_file.rb +14 -60
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a6b9d47c580c53737df7aef9c0e9619a622dfb
|
4
|
+
data.tar.gz: f846a31bc5833ff97687da9c6bb2aec1d865f347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ea035146ce0bcb7eb8c1d227a216dddd6279228c97c180e1f6ef211e969a46bbec6a89e920cd771e3b2fad6ea89de368fa048fdcaeea48e0fb3180986171a8
|
7
|
+
data.tar.gz: 86c03f712b8d4f37e84502245abd7d065299eb9f6ff5081ec4dfcdbbe434df859c491b625c2d94fd6ecd9898f00a33c02dd57bf6d9fa29c3cf21a1618e4c19f9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ And then execute:
|
|
20
20
|
|
21
21
|
### `/names`
|
22
22
|
|
23
|
-
To render the body for this call, all you have to do is generate a list of gems available in
|
23
|
+
To render the body for this call, all you have to do is generate a list of gems available in alphabetical order and use call `CompactIndex.names`.
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
gem 'compact_index'
|
@@ -37,7 +37,7 @@ gem 'compact_index'
|
|
37
37
|
versions_file = CompactIndex::VersionsFile.new("/path/to/versions/file")
|
38
38
|
|
39
39
|
# Get last updated date. This is used to discover what gems aren't in the file yet
|
40
|
-
from_date =
|
40
|
+
from_date = versions_file.updated_at
|
41
41
|
|
42
42
|
# Query the extra gems using the from date. Format should be as follows
|
43
43
|
extra_gems = [
|
@@ -52,7 +52,7 @@ extra_gems = [
|
|
52
52
|
]
|
53
53
|
|
54
54
|
# Render the body for the versions response
|
55
|
-
CompactIndex.versions(
|
55
|
+
CompactIndex.versions(versions_file, extra_gems)
|
56
56
|
```
|
57
57
|
|
58
58
|
### `/info/gem_name`
|
data/lib/compact_index.rb
CHANGED
@@ -69,38 +69,9 @@ module CompactIndex
|
|
69
69
|
# 1.0.1 requirement:<2.0&>1.0|checksum:abc1
|
70
70
|
# 1.0.2 requirement:<2.0&>1.0,requirement2:=1.1|checksum:abc2,ruby:>1.0,rubygems:>2.0
|
71
71
|
# ```
|
72
|
-
def self.info(
|
73
|
-
|
74
|
-
|
75
|
-
output << version_line(version) << "\n"
|
72
|
+
def self.info(versions)
|
73
|
+
versions.inject("---\n".dup) do |output, version|
|
74
|
+
output << version.to_line << "\n"
|
76
75
|
end
|
77
|
-
output
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def self.version_line(version)
|
83
|
-
if version[:dependencies]
|
84
|
-
version[:dependencies]
|
85
|
-
deps = version[:dependencies].map do |d|
|
86
|
-
[
|
87
|
-
d[:gem],
|
88
|
-
d.version_and_platform.split(", ").sort.join("&")
|
89
|
-
].join(":")
|
90
|
-
end
|
91
|
-
else
|
92
|
-
deps = []
|
93
|
-
end
|
94
|
-
|
95
|
-
line = version.number_and_platform.dup
|
96
|
-
line << " "
|
97
|
-
line << deps.join(",")
|
98
|
-
line << "|"
|
99
|
-
|
100
|
-
line << "checksum:#{version[:checksum]}"
|
101
|
-
line << ",ruby:#{version[:ruby_version]}" if version[:ruby_version]
|
102
|
-
line << ",rubygems:#{version[:rubygems_version]}" if version[:rubygems_version]
|
103
|
-
|
104
|
-
line
|
105
76
|
end
|
106
77
|
end
|
data/lib/compact_index/gem.rb
CHANGED
@@ -9,5 +9,31 @@ module CompactIndex
|
|
9
9
|
"#{number}-#{platform}"
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def <=>(other)
|
14
|
+
number_comp = number <=> other.number
|
15
|
+
|
16
|
+
if number_comp.zero?
|
17
|
+
[number, platform].compact <=> [other.number, other.platform].compact
|
18
|
+
else
|
19
|
+
number_comp
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_line
|
24
|
+
line = number_and_platform.dup << " " << deps_line << "|checksum:#{checksum}"
|
25
|
+
line << ",ruby:#{ruby_version}" if ruby_version && ruby_version != ">= 0"
|
26
|
+
line << ",rubygems:#{rubygems_version}" if rubygems_version && rubygems_version != ">= 0"
|
27
|
+
line
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def deps_line
|
33
|
+
return "" if dependencies.nil?
|
34
|
+
dependencies.map do |d|
|
35
|
+
[d[:gem], d.version_and_platform.split(", ").sort.join("&")].join(":")
|
36
|
+
end.join(",")
|
37
|
+
end
|
12
38
|
end
|
13
39
|
end
|
@@ -15,80 +15,34 @@ module CompactIndex
|
|
15
15
|
|
16
16
|
raise ArgumentError, "Unknown options: #{args.keys.join(", ")}" unless args.empty?
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
File.read(@path).tap do |out|
|
19
|
+
out << gem_lines(gems) if gems
|
20
|
+
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def updated_at
|
24
24
|
created_at_header(@path) || Time.at(0).to_datetime
|
25
25
|
end
|
26
26
|
|
27
|
-
def update_with(gems)
|
28
|
-
if File.exist?(@path) && !File.zero?(@path)
|
29
|
-
update(gems)
|
30
|
-
else
|
31
|
-
create(gems)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
27
|
def create(gems)
|
38
|
-
|
39
|
-
content << "\n---\n"
|
40
|
-
content << parse_gems_for_create(gems)
|
28
|
+
gems.sort!
|
41
29
|
|
42
30
|
File.open(@path, "w") do |io|
|
43
|
-
io.write
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
def update(gems)
|
48
|
-
File.open(@path, "a") do |io|
|
49
|
-
io.write parse_gems(gems)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def parse_gems_for_create(gems)
|
54
|
-
# Join all versions for each gem in one hash
|
55
|
-
gems_hash = {}
|
56
|
-
gems.each do |entry|
|
57
|
-
gems_hash[entry[:name]] ||= []
|
58
|
-
gems_hash[entry[:name]] += entry[:versions]
|
59
|
-
end
|
60
|
-
|
61
|
-
# Transform hash in a list of line informations to be printed
|
62
|
-
gems = gems_hash.map do |gem, versions|
|
63
|
-
{ :name => gem, :versions => versions, :info_checksum => versions.last[:info_checksum] }
|
64
|
-
end
|
65
|
-
|
66
|
-
# Sort gems by name and versions by number
|
67
|
-
gems.sort! {|a, b| a[:name] <=> b[:name] }
|
68
|
-
gems.each do |entry|
|
69
|
-
entry[:versions].sort! do |a, b|
|
70
|
-
::Gem::Version.create(a[:number]) <=> ::Gem::Version.create(b[:number])
|
71
|
-
end
|
31
|
+
io.write "created_at: #{Time.now.iso8601}\n---\n"
|
32
|
+
io.write gem_lines(gems)
|
72
33
|
end
|
73
|
-
|
74
|
-
gem_lines(gems)
|
75
34
|
end
|
76
35
|
|
77
|
-
|
78
|
-
gem_lines = gems.map do |entry|
|
79
|
-
{
|
80
|
-
:name => entry[:name],
|
81
|
-
:versions => entry[:versions],
|
82
|
-
:info_checksum => entry[:versions].last[:info_checksum]
|
83
|
-
}
|
84
|
-
end
|
85
|
-
gem_lines(gem_lines)
|
86
|
-
end
|
36
|
+
private
|
87
37
|
|
88
38
|
def gem_lines(gems)
|
89
|
-
gems.
|
90
|
-
|
91
|
-
|
39
|
+
gems.each {|g| g.versions.sort! }
|
40
|
+
|
41
|
+
gems.reduce("".dup) do |lines, gem|
|
42
|
+
version_numbers = gem.versions.map(&:number_and_platform).join(",")
|
43
|
+
lines << gem.name <<
|
44
|
+
" ".freeze << version_numbers <<
|
45
|
+
" #{gem.versions.last.info_checksum}\n"
|
92
46
|
end
|
93
47
|
end
|
94
48
|
|
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.
|
4
|
+
version: 0.11.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: 2016-
|
11
|
+
date: 2016-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -95,9 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.4.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Backend for compact index
|
102
102
|
test_files: []
|
103
|
-
has_rdoc:
|