Sha256: 1c3aeadf46ac4339e2a2af9281fbfe1b846b1fd85340678ee2de5101853693a8

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

require "human_power/version"
require "human_power/generator"
require "human_power/rule"
require "human_power/rails" if defined?(Rails)

module HumanPower
  class << self
    # Yields a configuration block.
    # 
    #   HumanPower.configure do |config|
    #     config.base_controller = MyOtherController
    #   end
    def configure(&block)
      yield self
    end

    # Registers a user agent.
    def register_user_agent(key, user_agent_string)
      user_agents[key] = user_agent_string
    end

    # Hash of registered user agents.
    def user_agents
      @user_agents ||= load_user_agents
    end

  private

      # Loads the built-in user agents from crawlers.yml.
      def load_user_agents
        path = File.expand_path("../../user_agents.yml", __FILE__)
        Hash[YAML.load(open(path).read).map { |k, v| [k.to_sym, v] }]
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
human_power-0.0.6 lib/human_power.rb
human_power-0.0.4 lib/human_power.rb
human_power-0.0.3 lib/human_power.rb