class RBT::Cookbooks::GobolinuxRecipesComparer

Constants

REMOTE_RECIPES_HOMEPAGE
#

REMOTE_RECIPES_HOMEPAGE

#

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::Cookbooks::GobolinuxRecipesComparer[]

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 145
def self.[](i = ARGV)
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 43
def initialize(
    i           = nil,
    run_already = true
  )
  register_sigint
  reset
  set_input(i)
  run if run_already
end

Public Instance Methods

input?() click to toggle source
#

input?

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 73
def input?
  @input
end
iterate_over_the_results() click to toggle source
#

iterate_over_the_results

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 95
def iterate_over_the_results
  @scanned_results.each_with_index {|line, index| index += 1
    if line.include? '&ver='
      splitted = line.split('&ver=')
      program_name = splitted.first.downcase
      program_version = splitted.last
      if program_version.include?('-r') and
         program_version =~ /\d+$/ # End with a regex.
        end_position = (program_version.index('-r')-1)
        program_version = program_version[0 .. end_position]
      end
      e
      e orange(index)
      e
      if does_include?(program_name, :do_not_use_aliases)
        opne 'The program '+sfancy(program_name)+' is included.'
        opne 'The remote program version is '+simp(program_version)+'.'
        local_program_version = RBT.swift_return_version_of_this_program(program_name)
        opne 'The local program version is '+simp(local_program_version)+'.'
        a = gem_version(local_program_version)
        b = gem_version(program_version)
        if a and b
          if a < b
            opne 'The remote version appears to be more up to date than'
            opne 'the local version. This means that you could update.'
          end
        else
          e 'Something went wrong with local version ('+sfancy(local_program_version)+
            ') and program version ('+sfancy(program_version)+').'
        end
      else
        opne 'The program '+sfancy(program_name)+' is NOT included.'
      end
      e
    end
  }
end
read_in_dataset_from_the_remote_webpage() click to toggle source
#

read_in_dataset_from_the_remote_webpage

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 88
def read_in_dataset_from_the_remote_webpage
  @dataset = open(REMOTE_RECIPES_HOMEPAGE).read
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 56
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 136
def run
  read_in_dataset_from_the_remote_webpage
  scan_for_remote_versions
  iterate_over_the_results
end
scan_for_remote_versions() click to toggle source
#

scan_for_remote_versions

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 80
def scan_for_remote_versions
  use_this_regex = /<tr><td>\s*<a class='RecipeTitle' href='\?list=(.+?)'>/ # See: http://rubular.com/r/a3dgeZ3gb1
  @scanned_results = @dataset.scan(use_this_regex).flatten
end
set_input(i = '') click to toggle source
#

set_input

#
# File lib/rbt/linux/gobolinux/gobolinux_recipes_comparer.rb, line 64
def set_input(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup
  @input = i
end