Skip to content

Commit

Permalink
Use autoload instead of require. General cleanup. Fix a typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cook committed Jul 27, 2011
1 parent e29e5e6 commit ad4549b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 21 deletions.
6 changes: 6 additions & 0 deletions lib/linked_in/api.rb
@@ -0,0 +1,6 @@
module LinkedIn
module Api
autoload :QueryMethods, "linked_in/api/query_methods"
autoload :UpdateMethods, "linked_in/api/update_methods"
end
end
6 changes: 0 additions & 6 deletions lib/linked_in/client.rb
@@ -1,9 +1,3 @@
require 'linked_in/helpers/request'
require 'linked_in/helpers/authorization'
require 'linked_in/api/query_methods'
require 'linked_in/api/update_methods'
require 'linked_in/search'

require 'cgi' require 'cgi'


module LinkedIn module LinkedIn
Expand Down
8 changes: 4 additions & 4 deletions lib/linked_in/errors.rb
Expand Up @@ -13,8 +13,8 @@ class RateLimitExceededError < LinkedInError; end
class UnauthorizedError < LinkedInError; end class UnauthorizedError < LinkedInError; end
class GeneralError < LinkedInError; end class GeneralError < LinkedInError; end


class UnavailableError < StandardError; end class UnavailableError < StandardError; end
class InformLinkedInError < StandardError; end class InformLinkedInError < StandardError; end
class NotFoundError < StandardError; end class NotFoundError < StandardError; end


end end
6 changes: 6 additions & 0 deletions lib/linked_in/helpers.rb
@@ -0,0 +1,6 @@
module LinkedIn
module Helpers
autoload :Authorization, "linked_in/helpers/authorization"
autoload :Request, "linked_in/helpers/request"
end
end
6 changes: 3 additions & 3 deletions lib/linked_in/helpers/authorization.rb
Expand Up @@ -7,8 +7,8 @@ module Authorization
:request_token_path => "/uas/oauth/requestToken", :request_token_path => "/uas/oauth/requestToken",
:access_token_path => "/uas/oauth/accessToken", :access_token_path => "/uas/oauth/accessToken",
:authorize_path => "/uas/oauth/authorize", :authorize_path => "/uas/oauth/authorize",
:api_host => 'https://api.linkedin.com', :api_host => "https://api.linkedin.com",
:auth_host => 'https://www.linkedin.com' :auth_host => "https://www.linkedin.com"
} }


def consumer def consumer
Expand Down Expand Up @@ -64,4 +64,4 @@ def full_oauth_url_for(url_type, host_type)
end end


end end
end end
6 changes: 3 additions & 3 deletions lib/linked_in/search.rb
Expand Up @@ -18,17 +18,17 @@ def search(options={})
def format_options_for_query(opts) def format_options_for_query(opts)
opts.inject({}) do |list, kv| opts.inject({}) do |list, kv|
key, value = kv.first.to_s.gsub("_","-"), kv.last key, value = kv.first.to_s.gsub("_","-"), kv.last
list[key] = sanatize_value(value) list[key] = sanitize_value(value)
list list
end end
end end


def sanatize_value(value) def sanitize_value(value)
value = value.join("+") if value.is_a?(Array) value = value.join("+") if value.is_a?(Array)
value = value.gsub(" ", "+") if value.is_a?(String) value = value.gsub(" ", "+") if value.is_a?(String)
value value
end end


end end


end end
12 changes: 7 additions & 5 deletions lib/linkedin.rb
Expand Up @@ -22,9 +22,11 @@ def configure
end end
end end


autoload :Api, "linked_in/api"
autoload :Client, "linked_in/client"
autoload :Mash, "linked_in/mash"
autoload :Errors, "linked_in/errors"
autoload :Helpers, "linked_in/helpers"
autoload :Search, "linked_in/search"
autoload :Version, "linked_in/version"
end end

require 'linked_in/mash'
require 'linked_in/errors'
require 'linked_in/client'
require 'linked_in/version'

0 comments on commit ad4549b

Please sign in to comment.