Module: GHAUtils

Included in:
GHADownloader, GHAProvider
Defined in:
lib/gh-archive.rb

Instance Method Summary collapse

Instance Method Details

#each_date(from, to) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/gh-archive.rb', line 31

def each_date(from, to)
    current_date = from
    while current_date < to
        yield current_date
        current_date += 3600
    end
end

#get_gha_filename(date) ⇒ Object



8
9
10
# File 'lib/gh-archive.rb', line 8

def get_gha_filename(date)
    return ("%04d-%02d-%02d-%d.json.gz" % [date.year, date.month, date.day, date.hour])
end

#read_gha_file(gz) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/gh-archive.rb', line 20

def read_gha_file(gz)
    content = read_gha_file_content(gz)
        
    result = []
    content.lines.each do |line|
        result << JSON.parse(line)
    end
    
    return result
end

#read_gha_file_content(gz) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/gh-archive.rb', line 12

def read_gha_file_content(gz)
    gzip = Zlib::GzipReader.new(gz)
    content = gzip.read
    gzip.close
    
    return content
end