BasicObject
Add protocol
# File lib/common_helper.rb, line 42 def add_http_protocol(url) url =~ /^https?:/ ? url : "http://#{url}" end
# File lib/common_helper.rb, line 46 def add_trailing_slash(url) url =~ /\/$/ ? url : "#{url}/" end
# File lib/common_helper.rb, line 131 def colorize(text, color_code) "\e[#{color_code}m#{text}\e[0m" end
Gets the string all elements in stringarray ends with
# File lib/common_helper.rb, line 51 def get_equal_string_end(stringarray = [""]) already_found = "" looping = true counter = -1 if stringarray.kind_of? Array and stringarray.length > 1 base = stringarray[0] while looping character = base[counter, 1] stringarray.each do |s| if s[counter, 1] != character looping = false break end end if looping == false or (counter * -1) > base.length break end already_found = "#{character if character}#{already_found}" counter -= 1 end end already_found end
# File lib/common_helper.rb, line 139 def green(text) colorize(text, 32) end
# File lib/wpstools/wpstools_helper.rb, line 46 def help() puts "Help :" puts puts "--help | -h This help screen." puts "--Verbose | -v Verbose output." puts "--update | -u Update to the latest revision." puts "--generate_plugin_list [number of pages] Generate a new data/plugins.txt file. (supply number of *pages* to parse, default : 150)" puts "--gpl Alias for --generate_plugin_list" puts "--generate_full_plugin_list Generate a new full data/plugins.txt file" puts "--gfpl Alias for --generate_full_plugin_list" puts "--generate_theme_list [number of pages] Generate a new data/themes.txt file. (supply number of *pages* to parse, default : 150)" puts "--gtl Alias for --generate_theme_list" puts "--generate_full_theme_list Generate a new full data/themes.txt file" puts "--gftl Alias for --generate_full_theme_list" puts end
# File lib/common_helper.rb, line 135 def red(text) colorize(text, 31) end
TODO : add an exclude pattern ?
# File lib/common_helper.rb, line 33 def require_files_from_directory(absolute_dir_path, files_pattern = "*.rb") Dir[File.join(absolute_dir_path, files_pattern)].sort.each do |f| f = File.expand_path(f) require f #puts "require #{f}" # Used for debug end end
# File lib/wpstools/wpstools_helper.rb, line 23 def usage() script_name = $0 puts puts "-h for further help." puts puts "Examples:" puts puts "- Generate a new 'most popular' plugin list, up to 150 pages ..." puts "ruby " + script_name + " --generate_plugin_list 150" puts puts "- Generate a new full plugin list" puts "ruby " + script_name + " --generate_full_plugin_list" puts puts "- Generate a new 'most popular' theme list, up to 150 pages ..." puts "ruby " + script_name + " --generate_theme_list 150" puts puts "- Generate a new full theme list" puts "ruby " + script_name + " --generate_full_theme_list" puts puts "See README for further information." puts end
Generated with the Darkfish Rdoc Generator 2.