Sha256: eefa11c83b57ef372f5aee8c44cf608e7d34a977f0c768100d586696a21e7c44

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'infoboxer'

include Infoboxer

require 'optparse'

wiki_url = nil

OptionParser.new do |opts|
  opts.banner = 'Usage: infoboxer [-w wiki_api_url]'

  opts.on('-w', '--wiki WIKI_API_URL',
              "Make wiki by WIKI_API_URL a default wiki, and use it with just get('Pagename')") do |w|
    wiki_url = w
  end
end.parse!

if wiki_url
  if wiki_url =~ /^[a-z]+$/
    wiki_url = case
               when domain = Infoboxer::WIKIMEDIA_PROJECTS[wiki_url.to_sym]
                 "https://en.#{domain}/w/api.php"
               when domain = Infoboxer::WIKIMEDIA_PROJECTS[('w' + wiki_url).to_sym]
                 "https://en.#{domain}/w/api.php"
               else
                 fail("Unidentified wiki: #{wiki_url}")
               end
  end

  DEFAULT_WIKI = Infoboxer.wiki(wiki_url)
  puts "Default Wiki selected: #{wiki_url}.\nNow you can use `get('Pagename')`, `category('Categoryname')` and so on.\n\n"
  [:raw, :get, :get_h, :category, :search, :prefixsearch].each do |m|
    define_method(m) { |*arg|
      DEFAULT_WIKI.send(m, *arg)
    }
  end
end

require 'irb'
ARGV.shift until ARGV.empty?
IRB.start

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
infoboxer-0.4.0 bin/infoboxer
infoboxer-0.3.3 bin/infoboxer
infoboxer-0.3.2 bin/infoboxer
infoboxer-0.3.1 bin/infoboxer
infoboxer-0.3.1.pre bin/infoboxer
infoboxer-0.3.0.pre bin/infoboxer
infoboxer-0.3.0 bin/infoboxer
infoboxer-0.2.8 bin/infoboxer