Skip to content

Instantly share code, notes, and snippets.

@tiagopog
Last active May 19, 2016 20:03
Show Gist options
  • Select an option

  • Save tiagopog/a55cc2e7519debceb4f76765346977e5 to your computer and use it in GitHub Desktop.

Select an option

Save tiagopog/a55cc2e7519debceb4f76765346977e5 to your computer and use it in GitHub Desktop.
ARGV Example
ARGV << '--help' if ARGV.empty?
aliases = {
"g" => "generate",
"d" => "destroy",
"c" => "console",
"s" => "server",
"db" => "dbconsole",
"r" => "runner"
}
command = ARGV.shift
command = aliases[command] || command
require 'rails/commands/commands_tasks'
Rails::CommandsTasks.new(ARGV).run_command!(command)
#!/usr/bin/env ruby
require 'spdeck-scrape'
query = ARGV[0]
range = ARGV[1].to_i
user = SpeakerdeckScraper.new(query, range)
user.query_results_scrape(range)
user.scrape_all
#!/usr/bin/env ruby
require 'spdeck-scrape'
# usage: $ spdeck-scrape my_query my_range [verbose | concise] -html[optional for html gen]
if ARGV.empty?
puts "\n\n------- spdeck-scrape: ERROR! --------"
puts " Usage:"
puts " Please specify a query, range, and display option (if desired):\n"
puts " spdeck-scrape my_query an_integer [options]"
puts " Options:
-v # verbose display while running"
puts " -c # concise display"
puts " -html # include this tag to print data to an HTML file (must also include a display option)\n"
puts " Example:"
puts " spdeck-scrape ruby 15 -v -html\n\n"
else
query = ARGV[0]
ARGV[1].nil? ? range = 5 : range = ARGV[1].to_i
display = ARGV[2] || '-c'
user = SpeakerdeckScraper.new(query, range, display)
user.query_results_scrape(range)
user.scrape_all
if ARGV[3] == ("-html")
user.html_gen
system("open spd-#{query}.html")
puts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment