Sha256: f852b26bef66729196192db3e5f7b6831757b5f7d1e6a3ca44c3bc13130695de

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

Dir[File.dirname(__FILE__) + '/wikipedia/**/*.rb'].each { |f| require f }

module Wikipedia
  # Examples :
  # page = Wikipedia.find('Rails')
  # => #<Wikipedia:0x123102>
  # page.content
  # => wiki content appears here

  # basically just a wrapper for doing
  # client = Wikipedia::Client.new
  # client.find('Rails')
  #
  def self.find( page, options = {} )
    client.find( page, options )
  end

  def self.find_image( title, options = {} )
    client.find_image( title, options )
  end

  def self.find_random( options = {} )
    client.find_random( options )
  end

  def self.configure(&block)
    Configuration.instance.instance_eval(&block)
  end

  # rubocop:disable Style/MethodName
  def self.Configure(&block)
    configure(&block)
  end

  configure do
    protocol  'https'
    domain    'en.wikipedia.org'
    path      'w/api.php'
    user_agent(
      'wikipedia-client/1.7 (https://github.com/kenpratt/wikipedia-client)'
    )
  end

  class << self
    private

    def client
      @client ||= Wikipedia::Client.new
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wikipedia-client-1.14.0 lib/wikipedia.rb
wikipedia-client-1.13.0 lib/wikipedia.rb