5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/myprecious.rb', line 5
def self.update
file = File.new("Gemfile", "r")
File.open('myprecious.md', 'w') { |write_file|
write_file.puts "gem | Our Version | Latest Version | Date available | Age (in days) | Home Page | Change Log"
write_file.puts "--- | --- | --- | --- | --- | --- | ---"
while (line = file.gets)
gem_line = line.strip
if (gem_line.include? 'gem') && !gem_line.start_with?('#') && !gem_line.start_with?('source')
name = gem_line.split(' ')[1].split(',')[0].split('\'')[1]
begin
a = require name
if a
current_version = Gem::Specification.find_all_by_name(name).max.version
gems_info = Gems.versions name
gems_latest_info = Gems.info name
latest_build = ''
gems_info.each do |gem_info|
if gem_info["number"].to_s == gems_latest_info["version"].to_s
latest_build = Date.parse gem_info["built_at"]
end
if gem_info["number"].to_s == current_version.to_s
current_build = Date.parse gem_info["built_at"]
days_complete = latest_build - current_build
write_file.puts name + "|" + current_version.to_s + "|" + gems_latest_info["version"].to_s + "|" +
(latest_build).to_s + "|" + days_complete.to_i.to_s + "|" +
gems_latest_info["homepage_uri"].to_s + "|" + gems_latest_info["changelog_uri"].to_s
end
end
end
rescue Exception => e
end
end
end
file.close
}
end
|