compact_index 0.9.1 → 0.9.3

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: 1910b8bcbe07ae4b1503386a945c527e9dae0c82
4
- data.tar.gz: eaccc11cf9d9d8e329b66278c1b6a4913225f882
3
+ metadata.gz: 9b3856147725f1163a8a30cbdaf87a50ec11569d
4
+ data.tar.gz: 29d0a42db611e97e05e27e1f6539285769465039
5
5
  SHA512:
6
- metadata.gz: f4c4d5386521b6e29028a09165f16af8cb5da09cd19fed220d003fdfc30e0b86ffeafd602e612830184d3a474090c0ac65d4b03a8f5f403a9d1a74a870e56af2
7
- data.tar.gz: 222bf16b5c83f0927cd5770d7e63497ef410b3db62c280c10d5badf546e8e475f6437f5f87547ec161e6811dca8f3312cc434a56bd287650a01e13753855a1a3
6
+ metadata.gz: bd16103ee70d0a4ee203fc94748c723494fa3da2c2c5d61ec8d610d8c7174ec8e9a943b0ff1e3618002137f75e5c4eeda159e45eb59b452499c49677443f4999
7
+ data.tar.gz: 80d01b2cb95206fb8c781f3c8ad118d050a9ce030e2bf42f2a6533121a477d2d639c18903ec285136081b29aed6e7f1640a45843d018dbdd2668b3153fefb721
@@ -1,4 +1,8 @@
1
1
  language: ruby
2
- rvm: 2.1.5
2
+ rvm:
3
+ - "2.2.3"
4
+ - "2.1.5"
5
+ - "1.9.3"
6
+ - "1.8.7"
3
7
  script: bundle exec rspec
4
8
 
@@ -1,3 +1,15 @@
1
+ ## 0.9.3 (August 25, 2015)
2
+
3
+ Features:
4
+
5
+ - Support for ruby 1.8
6
+
7
+ ## 0.9.2 (August 22, 2015)
8
+
9
+ Features:
10
+
11
+ - Parameters from versions are now optional
12
+
1
13
  ## 0.9.1 (August 19, 2015)
2
14
 
3
15
  Features:
data/README.md CHANGED
@@ -41,39 +41,16 @@ 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 = [
44
- {
45
- name: "gem1",
46
- versions: [
47
- {
48
- number: "0.9.8"
49
- platform: "ruby"
50
- checksum: "abc123" #sha256 checksum available on rubygems.org
51
- },
52
- {
53
- number: "0.9.9"
54
- platform: "java"
55
- checksum: "abc123"
56
- }
57
- ]
58
- },
59
- {
60
- name: "gem2",
61
- versions: [
62
- {
63
- number: "0.9.8"
64
- platform: "ruby"
65
- checksum: "abc123" #sha256 checksum available on rubygems.org
66
- },
67
- {
68
- number: "0.9.9"
69
- platform: "java"
70
- checksum: "abc123"
71
- }
72
- ]
73
- }
44
+ CompactIndex::Gem.new("gem1", [
45
+ CompactIndex::GemVersion.new("0.9.8", "ruby", "abc123"),
46
+ CompactIndex::GemVersion.new("0.9.9", "jruby", "abc123"),
47
+ ]),
48
+ CompactIndex::Gem.new("gem2", [
49
+ CompactIndex::GemVersion.new("0.9.8", "ruby", "abc123"),
50
+ CompactIndex::GemVersion.new("0.9.9", "jruby", "abc123"),
51
+ ])
74
52
  ]
75
53
 
76
-
77
54
  # Render the body for the versions response
78
55
  CompactIndex.versions(@versions_file, extra_gems)
79
56
  ```
@@ -87,17 +64,10 @@ gem 'compact_index'
87
64
 
88
65
  # Expected versions format
89
66
  versions = [
90
- {
91
- number: '1.0.1',
92
- checksum: "abc123",
93
- dependencies: [
94
- {
95
- gem: 'foo',
96
- version: '=1.0.1',
97
- checksum: 'abc123'
98
- }
99
- ]
100
- }
67
+ CompactIndex::GemVersion.new("1.0.1", "ruby", "abc123", "info123", [
68
+ CompactIndex::Dependency.new("foo", "=1.0.1", "abc123"),
69
+ CompactIndex::Dependency.new("bar", ">1.0, <2.0", "abc123"),
70
+ ])
101
71
  ]
102
72
  CompactIndex.info(versions)
103
73
  ```
@@ -1,3 +1,7 @@
1
+ require "compact_index/gem"
2
+ require "compact_index/gem_version"
3
+ require "compact_index/dependency"
4
+
1
5
  require "compact_index/version"
2
6
  require "compact_index/versions_file"
3
7
 
@@ -6,7 +10,7 @@ module CompactIndex
6
10
  "---\n" << gem_names.join("\n") << "\n"
7
11
  end
8
12
 
9
- def self.versions(versions_file, gems, args)
13
+ def self.versions(versions_file, gems = nil, args = {})
10
14
  versions_file.contents(gems, args)
11
15
  end
12
16
 
@@ -25,14 +29,14 @@ module CompactIndex
25
29
  deps = version[:dependencies].map do |d|
26
30
  [
27
31
  d[:gem],
28
- number_and_platform(d[:version],d[:platform]).gsub(/, /, "&")
32
+ d.version_and_platform.gsub(/, /, "&")
29
33
  ].join(':')
30
34
  end
31
35
  else
32
36
  deps = []
33
37
  end
34
38
 
35
- line = number_and_platform(version[:number], version[:platform])
39
+ line = version.number_and_platform
36
40
  line << " "
37
41
  line << deps.join(",")
38
42
  line << "|"
@@ -43,12 +47,4 @@ module CompactIndex
43
47
 
44
48
  line
45
49
  end
46
-
47
- def self.number_and_platform(number, platform)
48
- if platform.nil? || platform == 'ruby'
49
- number.dup
50
- else
51
- "#{number}-#{platform}"
52
- end
53
- end
54
50
  end
@@ -0,0 +1,11 @@
1
+ module CompactIndex
2
+ Dependency = Struct.new(:gem, :version, :platform, :checksum) do
3
+ def version_and_platform
4
+ if platform.nil? || platform == 'ruby'
5
+ version.dup
6
+ else
7
+ "#{version}-#{platform}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module CompactIndex
2
+ Gem = Struct.new(:name, :versions)
3
+ end
@@ -0,0 +1,11 @@
1
+ module CompactIndex
2
+ GemVersion = Struct.new(:number, :platform, :checksum, :info_checksum, :dependencies, :ruby_version, :rubygems_version) do
3
+ def number_and_platform
4
+ if platform.nil? || platform == 'ruby'
5
+ number.dup
6
+ else
7
+ "#{number}-#{platform}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module CompactIndex
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+ require 'date'
1
3
  require 'compact_index'
2
4
 
3
5
  class CompactIndex::VersionsFile
@@ -5,7 +7,7 @@ class CompactIndex::VersionsFile
5
7
  @path = file || "/versions.list"
6
8
  end
7
9
 
8
- def contents(gems=nil, args = {})
10
+ def contents(gems = nil, args = {})
9
11
  if args[:calculate_checksums]
10
12
  gems = calculate_checksums(gems)
11
13
  end
@@ -61,13 +63,15 @@ class CompactIndex::VersionsFile
61
63
 
62
64
  # Transform hash in a list of line informations to be printed
63
65
  gems = gems_hash.map do |gem, versions|
64
- { name: gem, versions: versions, checksum: versions.first[:checksum] }
66
+ { :name => gem, :versions => versions, :checksum => versions.first[:checksum] }
65
67
  end
66
68
 
67
69
  # Sort gems by name and versions by number
68
70
  gems.sort! { |a,b| a[:name] <=> b[:name] }
69
71
  gems.each do |entry|
70
- entry[:versions].sort_by! { |v| Gem::Version.create(v[:number]) }
72
+ entry[:versions].sort! do |a,b|
73
+ Gem::Version.create(a[:number]) <=> Gem::Version.create(b[:number])
74
+ end
71
75
  end
72
76
 
73
77
  gem_lines(gems)
@@ -76,9 +80,9 @@ class CompactIndex::VersionsFile
76
80
  def parse_gems(gems)
77
81
  gem_lines = gems.map do |entry|
78
82
  {
79
- name: entry[:name],
80
- versions: entry[:versions],
81
- checksum: entry[:versions].first[:checksum]
83
+ :name => entry[:name],
84
+ :versions => entry[:versions],
85
+ :checksum => entry[:versions].first[:checksum]
82
86
  }
83
87
  end
84
88
  gem_lines(gem_lines)
@@ -87,16 +91,7 @@ class CompactIndex::VersionsFile
87
91
  def gem_lines(gems)
88
92
  gems.reduce("") do |concat, entry|
89
93
  versions = entry[:versions]
90
- number_and_plat = versions.map { |version| number_and_platform(version[:number], version[:platform]) }
91
- concat << "#{entry[:name]} #{number_and_plat.join(',')} #{entry[:checksum]}\n"
92
- end
93
- end
94
-
95
- def number_and_platform(number, platform)
96
- if platform.nil? || platform == 'ruby'
97
- number.dup
98
- else
99
- "#{number}-#{platform}"
94
+ concat << "#{entry[:name]} #{versions.map(&:number_and_platform).join(',')} #{entry[:checksum]}\n"
100
95
  end
101
96
  end
102
97
 
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.9.1
4
+ version: 0.9.3
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-19 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -65,6 +65,9 @@ files:
65
65
  - db/migrations/06_add_created_at_to_versions.rb
66
66
  - db/migrations/07_add_checksum_to_versions.rb
67
67
  - lib/compact_index.rb
68
+ - lib/compact_index/dependency.rb
69
+ - lib/compact_index/gem.rb
70
+ - lib/compact_index/gem_version.rb
68
71
  - lib/compact_index/version.rb
69
72
  - lib/compact_index/versions_file.rb
70
73
  homepage: https://github.com/bundler/compact_index