compact_index 0.9.3 → 0.9.4

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: 9b3856147725f1163a8a30cbdaf87a50ec11569d
4
- data.tar.gz: 29d0a42db611e97e05e27e1f6539285769465039
3
+ metadata.gz: ad1dc1768a2c3699451729892496cc84c87b47fa
4
+ data.tar.gz: bc2a2568b268897a9292262754183cd959bbb1e2
5
5
  SHA512:
6
- metadata.gz: bd16103ee70d0a4ee203fc94748c723494fa3da2c2c5d61ec8d610d8c7174ec8e9a943b0ff1e3618002137f75e5c4eeda159e45eb59b452499c49677443f4999
7
- data.tar.gz: 80d01b2cb95206fb8c781f3c8ad118d050a9ce030e2bf42f2a6533121a477d2d639c18903ec285136081b29aed6e7f1640a45843d018dbdd2668b3153fefb721
6
+ metadata.gz: 37ac28ed2d9c66a90e905dabb7fb7f21b6c74272bca4a03d894cdfad2c5f96618ac032c7eae406a52912eda9c34f936a1f87cdd4abc953646a9565acc83fb9be
7
+ data.tar.gz: 56316d3972c1cac287f3bf02d16d5f39f01a4891bb9a6ca089781abdd852a2f4a83a06ff482985b0f5e439a877192cabce411af08ea7de722f7091064d067ff3
@@ -0,0 +1,96 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - tmp/**/*
7
+ - lib/bundler/vendor/**/*
8
+ DisplayCopNames: true
9
+
10
+ # Lint
11
+
12
+ # They are idiomatic
13
+ Lint/AssignmentInCondition:
14
+ Enabled: false
15
+
16
+ Lint/EndAlignment:
17
+ AlignWith: variable
18
+
19
+ Lint/UnusedMethodArgument:
20
+ Enabled: false
21
+
22
+ # Style
23
+
24
+ Style/AccessModifierIndentation:
25
+ EnforcedStyle: outdent
26
+
27
+ Style/AlignParameters:
28
+ EnforcedStyle: with_fixed_indentation
29
+
30
+ Style/MultilineOperationIndentation:
31
+ EnforcedStyle: indented
32
+
33
+ Style/SpaceInsideBlockBraces:
34
+ SpaceBeforeBlockParameters: false
35
+
36
+ Style/TrivialAccessors:
37
+ Enabled: false
38
+
39
+ # We adopted raise instead of fail.
40
+ Style/SignalException:
41
+ EnforcedStyle: only_raise
42
+
43
+ Style/StringLiterals:
44
+ EnforcedStyle: double_quotes
45
+
46
+ Style/StringLiteralsInInterpolation:
47
+ EnforcedStyle: double_quotes
48
+
49
+ # Having these make it easier to *not* forget to add one when adding a new
50
+ # value and you can simply copy the previous line.
51
+ Style/TrailingComma:
52
+ EnforcedStyleForMultiline: comma
53
+
54
+ # 1.8.7 support
55
+
56
+ Style/HashSyntax:
57
+ EnforcedStyle: hash_rockets
58
+
59
+ Style/Lambda:
60
+ Enabled: false
61
+
62
+ Style/DotPosition:
63
+ EnforcedStyle: trailing
64
+
65
+ Style/EachWithObject:
66
+ Enabled: false
67
+
68
+ Style/SpecialGlobalVars:
69
+ Enabled: false
70
+
71
+ Style/TrailingComma:
72
+ Enabled: false
73
+
74
+ # Metrics
75
+
76
+ # We've chosen to use Rubocop only for style, and not for complexity or quality checks.
77
+ Metrics/ClassLength:
78
+ Enabled: false
79
+
80
+ Metrics/ModuleLength:
81
+ Enabled: false
82
+
83
+ Metrics/MethodLength:
84
+ Enabled: false
85
+
86
+ Metrics/BlockNesting:
87
+ Enabled: false
88
+
89
+ Metrics/AbcSize:
90
+ Enabled: false
91
+
92
+ Metrics/CyclomaticComplexity:
93
+ Enabled: false
94
+
95
+ Metrics/PerceivedComplexity:
96
+ Enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from: .rubocop-bundler.yml
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,389 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-07-20 19:11:40 -0300 using RuboCop version 0.32.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 1
9
+ Lint/AmbiguousOperator:
10
+ Enabled: false
11
+
12
+ # Offense count: 1
13
+ # Configuration parameters: AllowSafeAssignment.
14
+ Lint/AssignmentInCondition:
15
+ Enabled: false
16
+
17
+ # Offense count: 1
18
+ # Cop supports --auto-correct.
19
+ Lint/DeprecatedClassMethods:
20
+ Enabled: false
21
+
22
+ # Offense count: 2
23
+ Lint/Eval:
24
+ Enabled: false
25
+
26
+ # Offense count: 1
27
+ Lint/HandleExceptions:
28
+ Enabled: false
29
+
30
+ # Offense count: 1
31
+ Lint/LiteralInCondition:
32
+ Enabled: false
33
+
34
+ # Offense count: 2
35
+ Lint/NestedMethodDefinition:
36
+ Enabled: false
37
+
38
+ # Offense count: 1
39
+ Lint/ShadowingOuterLocalVariable:
40
+ Enabled: false
41
+
42
+ # Offense count: 5
43
+ # Cop supports --auto-correct.
44
+ Lint/UnusedBlockArgument:
45
+ Enabled: false
46
+
47
+ # Offense count: 3
48
+ # Cop supports --auto-correct.
49
+ Lint/UnusedMethodArgument:
50
+ Enabled: false
51
+
52
+ # Offense count: 10
53
+ Lint/UselessAssignment:
54
+ Enabled: false
55
+
56
+ # Offense count: 11
57
+ Metrics/AbcSize:
58
+ Max: 43
59
+
60
+ # Offense count: 2
61
+ # Configuration parameters: CountComments.
62
+ Metrics/ClassLength:
63
+ Max: 143
64
+
65
+ # Offense count: 1
66
+ Metrics/CyclomaticComplexity:
67
+ Max: 7
68
+
69
+ # Offense count: 65
70
+ # Configuration parameters: AllowURI, URISchemes.
71
+ Metrics/LineLength:
72
+ Max: 122
73
+
74
+ # Offense count: 21
75
+ # Configuration parameters: CountComments.
76
+ Metrics/MethodLength:
77
+ Max: 34
78
+
79
+ # Offense count: 2
80
+ # Cop supports --auto-correct.
81
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
82
+ Style/AccessModifierIndentation:
83
+ Enabled: false
84
+
85
+ # Offense count: 3
86
+ Style/AccessorMethodName:
87
+ Enabled: false
88
+
89
+ # Offense count: 5
90
+ # Cop supports --auto-correct.
91
+ Style/AlignArray:
92
+ Enabled: false
93
+
94
+ # Offense count: 3
95
+ # Cop supports --auto-correct.
96
+ # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
97
+ Style/AlignHash:
98
+ Enabled: false
99
+
100
+ # Offense count: 3
101
+ # Cop supports --auto-correct.
102
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
103
+ Style/AlignParameters:
104
+ Enabled: false
105
+
106
+ # Offense count: 1
107
+ # Cop supports --auto-correct.
108
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
109
+ Style/AndOr:
110
+ Enabled: false
111
+
112
+ # Offense count: 9
113
+ # Cop supports --auto-correct.
114
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
115
+ Style/BlockDelimiters:
116
+ Enabled: false
117
+
118
+ # Offense count: 2
119
+ # Cop supports --auto-correct.
120
+ Style/BlockEndNewline:
121
+ Enabled: false
122
+
123
+ # Offense count: 3
124
+ # Cop supports --auto-correct.
125
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
126
+ Style/BracesAroundHashParameters:
127
+ Enabled: false
128
+
129
+ # Offense count: 12
130
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
131
+ Style/ClassAndModuleChildren:
132
+ Enabled: false
133
+
134
+ # Offense count: 9
135
+ Style/ClassVars:
136
+ Enabled: false
137
+
138
+ # Offense count: 31
139
+ Style/Documentation:
140
+ Enabled: false
141
+
142
+ # Offense count: 9
143
+ # Cop supports --auto-correct.
144
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
145
+ Style/DotPosition:
146
+ Enabled: false
147
+
148
+ # Offense count: 2
149
+ # Cop supports --auto-correct.
150
+ # Configuration parameters: AllowAdjacentOneLineDefs.
151
+ Style/EmptyLineBetweenDefs:
152
+ Enabled: false
153
+
154
+ # Offense count: 1
155
+ # Cop supports --auto-correct.
156
+ Style/EmptyLines:
157
+ Enabled: false
158
+
159
+ # Offense count: 6
160
+ # Cop supports --auto-correct.
161
+ Style/EmptyLinesAroundAccessModifier:
162
+ Enabled: false
163
+
164
+ # Offense count: 1
165
+ # Cop supports --auto-correct.
166
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
167
+ Style/EmptyLinesAroundBlockBody:
168
+ Enabled: false
169
+
170
+ # Offense count: 2
171
+ # Cop supports --auto-correct.
172
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
173
+ Style/EmptyLinesAroundClassBody:
174
+ Enabled: false
175
+
176
+ # Offense count: 12
177
+ # Configuration parameters: AllowedVariables.
178
+ Style/GlobalVars:
179
+ Enabled: false
180
+
181
+ # Offense count: 2
182
+ # Configuration parameters: MinBodyLength.
183
+ Style/GuardClause:
184
+ Enabled: false
185
+
186
+ # Offense count: 85
187
+ # Cop supports --auto-correct.
188
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
189
+ Style/HashSyntax:
190
+ Enabled: false
191
+
192
+ # Offense count: 1
193
+ # Cop supports --auto-correct.
194
+ # Configuration parameters: MaxLineLength.
195
+ Style/IfUnlessModifier:
196
+ Enabled: false
197
+
198
+ # Offense count: 1
199
+ # Cop supports --auto-correct.
200
+ Style/IndentArray:
201
+ Enabled: false
202
+
203
+ # Offense count: 1
204
+ # Cop supports --auto-correct.
205
+ # Configuration parameters: Width.
206
+ Style/IndentationWidth:
207
+ Enabled: false
208
+
209
+ # Offense count: 1
210
+ # Cop supports --auto-correct.
211
+ Style/InfiniteLoop:
212
+ Enabled: false
213
+
214
+ # Offense count: 1
215
+ # Cop supports --auto-correct.
216
+ Style/Lambda:
217
+ Enabled: false
218
+
219
+ # Offense count: 1
220
+ # Cop supports --auto-correct.
221
+ Style/LeadingCommentSpace:
222
+ Enabled: false
223
+
224
+ # Offense count: 1
225
+ # Cop supports --auto-correct.
226
+ Style/LineEndConcatenation:
227
+ Enabled: false
228
+
229
+ # Offense count: 3
230
+ # Cop supports --auto-correct.
231
+ Style/MethodCallParentheses:
232
+ Enabled: false
233
+
234
+ # Offense count: 1
235
+ Style/MultilineBlockChain:
236
+ Enabled: false
237
+
238
+ # Offense count: 2
239
+ # Cop supports --auto-correct.
240
+ Style/MultilineBlockLayout:
241
+ Enabled: false
242
+
243
+ # Offense count: 1
244
+ # Cop supports --auto-correct.
245
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
246
+ Style/MultilineOperationIndentation:
247
+ Enabled: false
248
+
249
+ # Offense count: 1
250
+ # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
251
+ Style/Next:
252
+ Enabled: false
253
+
254
+ # Offense count: 1
255
+ # Cop supports --auto-correct.
256
+ Style/NumericLiterals:
257
+ MinDigits: 9
258
+
259
+ # Offense count: 4
260
+ # Cop supports --auto-correct.
261
+ # Configuration parameters: PreferredDelimiters.
262
+ Style/PercentLiteralDelimiters:
263
+ Enabled: false
264
+
265
+ # Offense count: 1
266
+ # Cop supports --auto-correct.
267
+ # Configuration parameters: AllowAsExpressionSeparator.
268
+ Style/Semicolon:
269
+ Enabled: false
270
+
271
+ # Offense count: 4
272
+ # Cop supports --auto-correct.
273
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
274
+ Style/SignalException:
275
+ Enabled: false
276
+
277
+ # Offense count: 1
278
+ # Configuration parameters: Methods.
279
+ Style/SingleLineBlockParams:
280
+ Enabled: false
281
+
282
+ # Offense count: 2
283
+ # Cop supports --auto-correct.
284
+ # Configuration parameters: AllowIfMethodIsEmpty.
285
+ Style/SingleLineMethods:
286
+ Enabled: false
287
+
288
+ # Offense count: 1
289
+ # Cop supports --auto-correct.
290
+ Style/SingleSpaceBeforeFirstArg:
291
+ Enabled: false
292
+
293
+ # Offense count: 1
294
+ # Cop supports --auto-correct.
295
+ Style/SpaceAfterComma:
296
+ Enabled: false
297
+
298
+ # Offense count: 61
299
+ # Cop supports --auto-correct.
300
+ # Configuration parameters: MultiSpaceAllowedForOperators.
301
+ Style/SpaceAroundOperators:
302
+ Enabled: false
303
+
304
+ # Offense count: 2
305
+ # Cop supports --auto-correct.
306
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
307
+ Style/SpaceBeforeBlockBraces:
308
+ Enabled: false
309
+
310
+ # Offense count: 7
311
+ # Cop supports --auto-correct.
312
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
313
+ Style/SpaceInsideBlockBraces:
314
+ Enabled: false
315
+
316
+ # Offense count: 5
317
+ # Cop supports --auto-correct.
318
+ Style/SpaceInsideBrackets:
319
+ Enabled: false
320
+
321
+ # Offense count: 11
322
+ # Cop supports --auto-correct.
323
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
324
+ Style/SpaceInsideHashLiteralBraces:
325
+ Enabled: false
326
+
327
+ # Offense count: 40
328
+ # Cop supports --auto-correct.
329
+ Style/SpaceInsideParens:
330
+ Enabled: false
331
+
332
+ # Offense count: 13
333
+ # Cop supports --auto-correct.
334
+ Style/SpaceInsideStringInterpolation:
335
+ Enabled: false
336
+
337
+ # Offense count: 1
338
+ # Cop supports --auto-correct.
339
+ Style/SpecialGlobalVars:
340
+ Enabled: false
341
+
342
+ # Offense count: 308
343
+ # Cop supports --auto-correct.
344
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
345
+ Style/StringLiterals:
346
+ Enabled: false
347
+
348
+ # Offense count: 1
349
+ # Cop supports --auto-correct.
350
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
351
+ Style/StringLiteralsInInterpolation:
352
+ Enabled: false
353
+
354
+ # Offense count: 1
355
+ Style/StructInheritance:
356
+ Enabled: false
357
+
358
+ # Offense count: 1
359
+ # Cop supports --auto-correct.
360
+ # Configuration parameters: IgnoredMethods.
361
+ Style/SymbolProc:
362
+ Enabled: false
363
+
364
+ # Offense count: 2
365
+ # Cop supports --auto-correct.
366
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
367
+ Style/TrailingBlankLines:
368
+ Enabled: false
369
+
370
+ # Offense count: 2
371
+ # Cop supports --auto-correct.
372
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
373
+ Style/TrailingComma:
374
+ Enabled: false
375
+
376
+ # Offense count: 3
377
+ # Cop supports --auto-correct.
378
+ Style/TrailingUnderscoreVariable:
379
+ Enabled: false
380
+
381
+ # Offense count: 8
382
+ # Cop supports --auto-correct.
383
+ Style/TrailingWhitespace:
384
+ Enabled: false
385
+
386
+ # Offense count: 1
387
+ # Cop supports --auto-correct.
388
+ Style/UnneededCapitalW:
389
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.2.3"
3
+ - "2.3.0"
4
+ - "2.2.4"
4
5
  - "2.1.5"
5
6
  - "1.9.3"
6
7
  - "1.8.7"
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup-provider=redcarpet
2
+ --markup=markdown
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 0.9.4 (January 5, 2016)
2
+
3
+ Features:
4
+
5
+ - YARD documentation
6
+
7
+ Bugfixes:
8
+
9
+ - Use versions.list header time instead of mtime
10
+
11
+
12
+
13
+ ## 0.9.3 (August 25, 2015)
14
+
15
+ Features:
16
+
17
+ - Support for ruby 1.8
18
+
1
19
  ## 0.9.3 (August 25, 2015)
2
20
 
3
21
  Features:
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in compact_index.gemspec
4
4
  gemspec
5
+
6
+ gem "yard", "~>0.8"
7
+ gem "redcarpet", "~>2.3"
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["fotanus@gmail.com"]
10
10
  spec.email = ["Felipe Tanus"]
11
11
 
12
- spec.summary = %q{Backend for compact index}
12
+ spec.summary = "Backend for compact index"
13
13
  spec.homepage = "https://github.com/bundler/compact_index"
14
14
  spec.license = "MIT"
15
15
 
@@ -0,0 +1,8 @@
1
+ require "date"
2
+
3
+ # Ruby 1.8.7 makes Time#to_datetime private, but we need it
4
+ unless Time.public_instance_methods.include? :to_datetime
5
+ class Time
6
+ public :to_datetime
7
+ end
8
+ end
@@ -1,5 +1,6 @@
1
1
  module CompactIndex
2
- GemVersion = Struct.new(:number, :platform, :checksum, :info_checksum, :dependencies, :ruby_version, :rubygems_version) do
2
+ GemVersion = Struct.new(:number, :platform, :checksum, :info_checksum,
3
+ :dependencies, :ruby_version, :rubygems_version) do
3
4
  def number_and_platform
4
5
  if platform.nil? || platform == 'ruby'
5
6
  number.dup
@@ -1,3 +1,3 @@
1
1
  module CompactIndex
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'time'
2
2
  require 'date'
3
+ require 'digest'
3
4
  require 'compact_index'
4
5
 
5
6
  class CompactIndex::VersionsFile
@@ -18,11 +19,7 @@ class CompactIndex::VersionsFile
18
19
  end
19
20
 
20
21
  def updated_at
21
- if File.exists? @path
22
- DateTime.parse(File.mtime(@path).to_s)
23
- else
24
- Time.at(0)
25
- end
22
+ created_at_header(@path) || Time.at(0).to_datetime
26
23
  end
27
24
 
28
25
  def update_with(gems)
@@ -37,68 +34,83 @@ class CompactIndex::VersionsFile
37
34
  private
38
35
 
39
36
 
40
- def create(gems)
41
- content = "created_at: #{Time.now.iso8601}"
42
- content << "\n---\n"
43
- content << parse_gems_for_create(gems)
37
+ def create(gems)
38
+ content = "created_at: #{Time.now.iso8601}"
39
+ content << "\n---\n"
40
+ content << parse_gems_for_create(gems)
44
41
 
45
- File.open(@path, 'w') do |io|
46
- io.write content
47
- end
42
+ File.open(@path, 'w') do |io|
43
+ io.write content
48
44
  end
45
+ end
49
46
 
50
- def update(gems)
51
- File.open(@path, 'a') do |io|
52
- io.write parse_gems(gems)
53
- end
47
+ def update(gems)
48
+ File.open(@path, 'a') do |io|
49
+ io.write parse_gems(gems)
54
50
  end
51
+ end
55
52
 
56
- def parse_gems_for_create(gems)
57
- # Join all versions for each gem in one hash
58
- gems_hash = {}
59
- gems.each do |entry|
60
- gems_hash[entry[:name]] ||= []
61
- gems_hash[entry[:name]] += entry[:versions]
62
- end
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
63
60
 
64
- # Transform hash in a list of line informations to be printed
65
- gems = gems_hash.map do |gem, versions|
66
- { :name => gem, :versions => versions, :checksum => versions.first[:checksum] }
67
- end
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, :checksum => versions.first[:checksum] }
64
+ end
68
65
 
69
- # Sort gems by name and versions by number
70
- gems.sort! { |a,b| a[:name] <=> b[:name] }
71
- gems.each do |entry|
72
- entry[:versions].sort! do |a,b|
73
- Gem::Version.create(a[:number]) <=> Gem::Version.create(b[:number])
74
- end
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])
75
71
  end
72
+ end
76
73
 
77
- gem_lines(gems)
74
+ gem_lines(gems)
75
+ end
76
+
77
+ def parse_gems(gems)
78
+ gem_lines = gems.map do |entry|
79
+ {
80
+ :name => entry[:name],
81
+ :versions => entry[:versions],
82
+ :checksum => entry[:versions].first[:checksum]
83
+ }
78
84
  end
85
+ gem_lines(gem_lines)
86
+ end
79
87
 
80
- def parse_gems(gems)
81
- gem_lines = gems.map do |entry|
82
- {
83
- :name => entry[:name],
84
- :versions => entry[:versions],
85
- :checksum => entry[:versions].first[:checksum]
86
- }
87
- end
88
- gem_lines(gem_lines)
88
+ def gem_lines(gems)
89
+ gems.reduce("") do |concat, entry|
90
+ versions = entry[:versions]
91
+ concat << "#{entry[:name]} #{versions.map(&:number_and_platform).join(',')} #{entry[:checksum]}\n"
89
92
  end
93
+ end
90
94
 
91
- def gem_lines(gems)
92
- gems.reduce("") do |concat, entry|
93
- versions = entry[:versions]
94
- concat << "#{entry[:name]} #{versions.map(&:number_and_platform).join(',')} #{entry[:checksum]}\n"
95
- end
95
+ def calculate_checksums(gems)
96
+ gems.each do |gem|
97
+ info_checksum = Digest::MD5.hexdigest(CompactIndex.info(gem[:versions]))
98
+ gem[:versions].first[:checksum] = info_checksum
96
99
  end
100
+ end
101
+
102
+ def created_at_header(path)
103
+ return unless File.exists? path
97
104
 
98
- def calculate_checksums(gems)
99
- gems.each do |gem|
100
- info_checksum = Digest::MD5.hexdigest(CompactIndex.info(gem[:versions]))
101
- gem[:versions].first[:checksum] = info_checksum
105
+ File.open(path) do |file|
106
+ file.each_line do |line|
107
+ line.match(/created_at: (.*)\n|---\n/) do |match|
108
+ return match[1] && DateTime.parse(match[1])
109
+ end
102
110
  end
103
111
  end
112
+
113
+ nil
114
+ end
115
+
104
116
  end
data/lib/compact_index.rb CHANGED
@@ -4,16 +4,71 @@ require "compact_index/dependency"
4
4
 
5
5
  require "compact_index/version"
6
6
  require "compact_index/versions_file"
7
+ require "compact_index/ext/date"
7
8
 
8
9
  module CompactIndex
10
+ # Formats a list of gem names, to be used on the /names endpoint.
11
+ # @param gem_names [Array] array with gem names to be formated, in alphabetical order
12
+ # @return [String] names on the specified format for new index /names endpoint. Example:
13
+ # ```ruby
14
+ # ---
15
+ # rack
16
+ # rails
17
+ # other-gem
18
+ # ```
9
19
  def self.names(gem_names)
10
20
  "---\n" << gem_names.join("\n") << "\n"
11
21
  end
12
22
 
23
+ # Returns the versions file content argumented with some extra gems
24
+ # @param versions_file [CompactIndex::VersionsFile] which will be used as a base response
25
+ # @param gems [Array] an optional list of [CompactIndex::Gem] to be appended on the end
26
+ # of the base file. Example:
27
+ # ```ruby
28
+ # [
29
+ # CompactIndex::Gem.new("gem1", [
30
+ # CompactIndex::GemVersion.new("0.9.8", "ruby", "abc123"),
31
+ # CompactIndex::GemVersion.new("0.9.9", "jruby", "abc123"),
32
+ # ]),
33
+ # CompactIndex::Gem.new("gem2", [
34
+ # CompactIndex::GemVersion.new("0.9.8", "ruby", "abc123"),
35
+ # CompactIndex::GemVersion.new("0.9.9", "jruby", "abc123"),
36
+ # ])
37
+ # ]
38
+ # ```
39
+ # @return [String] The formated output. Example:
40
+ # ```ruby
41
+ # created_at: 2001-01-01T01:01:01-01:01
42
+ # ---
43
+ # rack 0.1.0,0.1.1,0.1.2,0.2.0,0.2.1,0.3.0,0.4.0,0.4.1,0.5.0,0.5.1,0.5.2,0.5.3 c54e4b7e14861a5d8c225283b75075f4
44
+ # rails 0.0.1,0.1.0 00fd5c36764f4ec1e8adf1c9adaada55
45
+ # sinatra 0.1.1,0.1.2,0.1.3 46f0a24d291725736216b4b6e7412be6
46
+ # ```
13
47
  def self.versions(versions_file, gems = nil, args = {})
14
48
  versions_file.contents(gems, args)
15
49
  end
16
50
 
51
+
52
+ # Formats the versions information of a gem, to be display in the `/info/gemname` endpoint.
53
+ #
54
+ # @param versions_file [CompactIndex::VersionsFile] which will be used as a base response
55
+ # @param gems [Array] an optional list of [CompactIndex::Gem] to be appended on the end
56
+ # of the base file. Example:
57
+ # ```ruby
58
+ # [
59
+ # CompactIndex::GemVersion.new("1.0.1", "ruby", "abc123", "info123", [
60
+ # CompactIndex::Dependency.new("foo", "=1.0.1", "abc123"),
61
+ # CompactIndex::Dependency.new("bar", ">1.0, <2.0", "abc123"),
62
+ # ])
63
+ # ]
64
+ # ```
65
+ #
66
+ # @return [String] The formated output. Example:
67
+ # ```ruby
68
+ # --
69
+ # 1.0.1 requirement:<2.0&>1.0|checksum:abc1
70
+ # 1.0.2 requirement:<2.0&>1.0,requirement2:=1.1|checksum:abc2,ruby:>1.0,rubygems:>2.0
71
+ # ```
17
72
  def self.info(params)
18
73
  output = "---\n"
19
74
  params.each do |version|
@@ -22,29 +77,32 @@ module CompactIndex
22
77
  output
23
78
  end
24
79
 
80
+
25
81
  private
26
- def self.version_line(version)
27
- if version[:dependencies]
28
- version[:dependencies]
29
- deps = version[:dependencies].map do |d|
30
- [
31
- d[:gem],
32
- d.version_and_platform.gsub(/, /, "&")
33
- ].join(':')
34
- end
35
- else
36
- deps = []
82
+
83
+
84
+ def self.version_line(version)
85
+ if version[:dependencies]
86
+ version[:dependencies]
87
+ deps = version[:dependencies].map do |d|
88
+ [
89
+ d[:gem],
90
+ d.version_and_platform.split(', ').sort.join("&")
91
+ ].join(':')
37
92
  end
93
+ else
94
+ deps = []
95
+ end
38
96
 
39
- line = version.number_and_platform
40
- line << " "
41
- line << deps.join(",")
42
- line << "|"
97
+ line = version.number_and_platform
98
+ line << " "
99
+ line << deps.join(",")
100
+ line << "|"
43
101
 
44
- line << "checksum:#{version[:checksum]}"
45
- line << ",ruby:#{version[:ruby_version]}" if version[:ruby_version]
46
- line << ",rubygems:#{version[:rubygems_version]}" if version[:rubygems_version]
102
+ line << "checksum:#{version[:checksum]}"
103
+ line << ",ruby:#{version[:ruby_version]}" if version[:ruby_version]
104
+ line << ",rubygems:#{version[:rubygems_version]}" if version[:rubygems_version]
47
105
 
48
- line
49
- end
106
+ line
107
+ end
50
108
  end
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.3
4
+ version: 0.9.4
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-25 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -47,7 +47,11 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
49
  - ".rspec"
50
+ - ".rubocop-bundler.yml"
51
+ - ".rubocop.yml"
52
+ - ".rubocop_todo.yml"
50
53
  - ".travis.yml"
54
+ - ".yardopts"
51
55
  - CHANGELOG.md
52
56
  - CODE_OF_CONDUCT.md
53
57
  - Gemfile
@@ -66,6 +70,7 @@ files:
66
70
  - db/migrations/07_add_checksum_to_versions.rb
67
71
  - lib/compact_index.rb
68
72
  - lib/compact_index/dependency.rb
73
+ - lib/compact_index/ext/date.rb
69
74
  - lib/compact_index/gem.rb
70
75
  - lib/compact_index/gem_version.rb
71
76
  - lib/compact_index/version.rb