gh-archive 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gh-archive.rb +15 -0
  3. metadata +9 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c493a4b789b2fc8b8b544287614667417f668c080e086a98e142eb70e5ada40
4
- data.tar.gz: ab043dd0e56f9fa884405de70e86d1e8ff7b0091cbd980cd4c7be8694fcc3d77
3
+ metadata.gz: c90ec7c3f14e2f57de8a145ad50c1f7730869c5aad0b1de33286accec99642c7
4
+ data.tar.gz: a16c29db393499905695d411a62ca0dfb6e319d7fd509c104d41b2d0959b3414
5
5
  SHA512:
6
- metadata.gz: 663226f4cd9b6dd51d679848877f1b93f64069a839c35d2149511135a960a07736589e8aa69b01d60c9ebdc295db25fb3cde6fa24f1a11885958aba9ffac0af1
7
- data.tar.gz: f8889d87fb7853ae54871ccf192527d6021535d12c614fc4059a235e1df9c6245516d5ac9478f53c613932ca4a0655dd2e5c4a29955b8cacd843b38f99ddcba2
6
+ metadata.gz: f6a9feafaa7d0d06f75c489b147b2fc9b5485e88a28c15f98b1081c8b1f05fffc8218253ca817b0ecf64c1050f3e63ed4e1ad2d6aec9df5a4d362cf5ed2832bc
7
+ data.tar.gz: 1bfa5ab2dbccc74bd2b162066bab6874fc3a2fc08b6d2ad9ec02c05a73078ee84abe1d069eb2b51b491134b35ea4ee0724b81aa3ffbd845b9997ba3860639c05
@@ -243,15 +243,23 @@ class GHADownloader
243
243
  @logger = Logger.new(STDERR)
244
244
  @decompress = decompress
245
245
  @folder = folder
246
+ @max = nil
247
+
246
248
  Dir.mkdir(@folder) unless FileTest.exist?(@folder)
247
249
  raise "A file exist with the desired folder name #{folder}" unless FileTest.directory?(@folder)
248
250
  end
249
251
 
252
+ def max(max)
253
+ @max = max
254
+ return self
255
+ end
256
+
250
257
  def logger=(logger)
251
258
  @logger = logger
252
259
  end
253
260
 
254
261
  def download(from = Time.gm(2015, 1, 1), to = Time.now)
262
+ archive = []
255
263
  self.each_date(from, to) do |current_date|
256
264
  filename = self.get_gha_filename(current_date)
257
265
  out_filename = filename.clone
@@ -274,6 +282,13 @@ class GHADownloader
274
282
  end
275
283
  end
276
284
  end
285
+ archive << target_file
286
+
287
+ if @max && archive.size > @max
288
+ last = archive.shift
289
+ @logger.info("Removing local file #{last}")
290
+ File.unlink(last)
291
+ end
277
292
 
278
293
  yield filename if block_given?
279
294
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh-archive
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Scalabrino
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-01-26 00:00:00.000000000 Z
@@ -14,20 +14,20 @@ dependencies:
14
14
  name: code-assertions
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.2
20
- - - ">="
20
+ - - "~>"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.1.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.1.2
30
- - - ">="
30
+ - - "~>"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.1.2
33
33
  description: Download and analyze the GitHub events stored at GitHub archive
@@ -41,7 +41,7 @@ homepage: https://github.com/intersimone999/gh-archive
41
41
  licenses:
42
42
  - GPL-3.0-only
43
43
  metadata: {}
44
- post_install_message:
44
+ post_install_message:
45
45
  rdoc_options: []
46
46
  require_paths:
47
47
  - lib
@@ -56,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.1.4
60
- signing_key:
59
+ rubygems_version: 3.0.3
60
+ signing_key:
61
61
  specification_version: 4
62
62
  summary: GitHub Archive mining utility
63
63
  test_files: []