lib/vk.rb in vk-0.0.4 vs lib/vk.rb in vk-0.6.5.53

- old
+ new

@@ -1,37 +1,61 @@ require 'active_support/core_ext/object/try' +require 'vk/exceptions' +require 'vk/version' module Vk - extend self + autoload :Client, 'vk/client' + autoload :DSL, 'vk/dsl' + autoload :Error, 'vk/error' + autoload :Result, 'vk/result' - autoload :DSL, 'vk/dsl' - autoload :Request, 'vk/request' + autoload :Base, 'vk/base' + autoload :User, 'vk/user' + autoload :City, 'vk/city' + autoload :Country, 'vk/country' + autoload :Post, 'vk/post' + autoload :Stats, 'vk/stats' + autoload :Group, 'vk/group' + autoload :Album, 'vk/album' - autoload :Base, 'vk/base' - autoload :User, 'vk/user' - autoload :City, 'vk/city' - autoload :Country, 'vk/country' - autoload :Post, 'vk/post' - class << self - attr_accessor :app_id, :app_secret, :logger + # @return [String] + attr_accessor :app_id + # @return [String] + attr_accessor :app_secret end - # Request to vk.com API - # @return [Vk::Request] Request object - def request - @request ||= Request.new + # @return [Logger] + def self.logger + @logger ||= + begin + require 'logger' + Logger.new(STDOUT) + end end - def log(text, severity = :debug) - Vk.logger.try(severity, text) + # @param [Logger] logger + # @return [Logger] + def self.logger=(logger) + @logger = logger end + module_function + + # Request to vk.com API + # @return [Vk::Client] Request object + def client(access_token = ENV['VK_ACCESS_TOKEN']) + @client ||= Client.new(access_token) + end + + # @return [Vk::Client] def dsl! - Request.dsl! + Client.dsl! end def log! require 'logger' self.logger = Logger.new STDOUT end + + dsl! end