class Cookbooks::CheckForNewReleaseOnRubygems

Constants

NAMESPACE
#

NAMESPACE

#
RUBYGEMS_ORG_DOWNLOADS_URL
#

RUBYGEMS_ORG_DOWNLOADS_URL

#
USE_THIS_REGEX
#

USE_THIS_REGEX

This is the main regex that will be used.

See: rubular.com/r/QcooOoIXVU

#

Public Class Methods

new( remote_url, run_already = true ) click to toggle source
#

initialize

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 43
def initialize(
    remote_url,
    run_already = true
  )
  reset
  set_remote_url(remote_url)
  case remote_url
  when :dont_run_yet
    run_already = false
  end
  run if run_already
end

Public Instance Methods

apply_the_main_regex_onto_the_dataset() click to toggle source
#

#apply_the_main_regex_onto_the_dataset

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 151
def apply_the_main_regex_onto_the_dataset
  @dataset =~ USE_THIS_REGEX
  @remote_program_version = $1.to_s.dup
end
check_this_remote_url(remote_url) click to toggle source
#

#check_this_remote_url

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 81
def check_this_remote_url(remote_url)
  set_remote_url(remote_url)
  run
end
compare_the_remote_program_version_with_the_local_program_version() click to toggle source
#

#compare_the_remote_program_version_with_the_local_program_version

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 118
def compare_the_remote_program_version_with_the_local_program_version
  array_we_did_update_these_programs = []
  require 'cookbooks/class/class.rb' unless Cookbooks.const_defined? :Cookbook
  program_name = File.basename(@homepage)
  local_version = ::Cookbooks::Cookbook.new(program_name) { :bypass_menu_check }.program_version?
  remote_program_version = ProgramInformation.new(@remote_program_version).version?
  if remote_program_version == local_version
    opnn; e "The local program #{sfancy(program_name)} is "\
            "#{turquoise('up to date')}"\
            "! (At version: #{simp(local_version)})"
  else
    # ===================================================================== #
    # We must build up the remote download-URL next.
    # ===================================================================== #
    remote_download_url = RUBYGEMS_ORG_DOWNLOADS_URL+@remote_program_version+'.gem'
    opnn; e 'Now updating to a new program version '\
            'at `'+sfancy(remote_download_url)+'`.'
    UpdateEntry.new(remote_download_url) # <- Delegate towards UpdateEntry.
    array_we_did_update_these_programs << remote_download_url
  end
  unless array_we_did_update_these_programs.empty?
    opnn; e "The following "\
            "#{simp(array_we_did_update_these_programs.size.to_s)}"\
            " programs were updated:"
    array_we_did_update_these_programs.each {|remote_url|
      e sfancy('  '+remote_url)
    }
  end
end
identify_homepage() click to toggle source
#

#identify_homepage

This method will determine the homepage of the given .gem file at hand. Keep in mind that a homepage on rubygems.org may have '-' characters.

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 100
def identify_homepage
  _ = remote_url?
  if _.end_with? '.gem'
    basename = File.basename(_)
    basename = ProgramInformation.new(basename).program_name?
    basename << '/' unless basename.end_with? '/'
    @homepage = 'https://rubygems.org/gems/'+basename
    opnn; e 'Next checking for any updates '\
            'on the remote URL '+sfancy(@homepage)
    obtain_dataset
    apply_the_main_regex_onto_the_dataset
    compare_the_remote_program_version_with_the_local_program_version
  end
end
obtain_dataset( use_this_url = @homepage ) click to toggle source
#

#obtain_dataset

The first URL to this method should be the remote homepage of the given .gem at hand.

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 162
def obtain_dataset(
    use_this_url = @homepage
  )
  begin
    @dataset = open(use_this_url).read
  rescue OpenURI::HTTPError
    opnn; e 'OpenURI::HTTPError error for `'+sfancy(use_this_url)+'`.'
  end
end
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 89
def opnn
  super(NAMESPACE)
end
remote_url?() click to toggle source
#

remote_url?

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 74
def remote_url?
  @remote_url
end
reset() click to toggle source
#

reset

#
Calls superclass method Cookbooks::CheckForRemoteWebpages#reset
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 59
def reset
  super()
end
run() click to toggle source
#

run

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 175
def run
  identify_homepage
end
set_remote_url(i) click to toggle source
#

#set_remote_url

#
# File lib/cookbooks/check_for_updates/check_for_new_release_on_rubygems.rb, line 66
def set_remote_url(i)
  i = i.first if i.is_a? Array
  @remote_url = i
end