Class: U3dCore::Changelog

Inherits:
Object
  • Object
show all
Defined in:
lib/u3d_core/update_checker/changelog.rb

Class Method Summary collapse

Class Method Details

.releases(gem_name) ⇒ Object



61
62
63
64
# File 'lib/u3d_core/update_checker/changelog.rb', line 61

def releases(gem_name)
  url = "https://api.github.com/repos/DragonBox/#{gem_name}/releases"
  JSON.parse(U3d::Utils.page_content(url))
end

.show_changes(gem_name, current_version, update_gem_command: "bundle update") ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/u3d_core/update_checker/changelog.rb', line 31

def show_changes(gem_name, current_version, update_gem_command: "bundle update")
  did_show_changelog = false

  releases(gem_name).each_with_index do |release, index|
    next unless Gem::Version.new(to_version(release['tag_name'])) > Gem::Version.new(current_version)

    puts("")
    puts(release['name'].green)
    puts(release['body'])
    did_show_changelog = true

    next unless index == 2

    puts("")
    puts("To see all new releases, open https://github.com/DragonBox/#{gem_name}/releases".green)
    break
  end

  puts("")
  puts("Please update using `#{update_gem_command}`".green) if did_show_changelog
rescue StandardError => e
  # Something went wrong, we don't care so much about this
  UI.error("Unable to show_changes: #{e}")
end

.to_version(tag_name) ⇒ Object



56
57
58
59
# File 'lib/u3d_core/update_checker/changelog.rb', line 56

def to_version(tag_name)
  tag_name = tag_name[1..-1] if tag_name[0] == 'v'
  tag_name
end