Permalink
Browse files

Fixing lots of warnings, making test file run on their own, adding a

.autotest file.
  • Loading branch information...
1 parent 40334bd commit 6254e8c5eb848aa9b40b4bd171fc3e87f747b3de @tenderlove tenderlove committed Apr 28, 2009
View
@@ -0,0 +1,15 @@
+Autotest.add_hook(:initialize) do |at|
+ at.clear_mappings
+ at.find_directories = %w(lib test)
+
+ at.add_exception("test/test_helper.rb")
+ at.add_exception("test/rails_test_helper.rb")
+
+ at.add_mapping(/^lib\/.*\.rb$/) do |file, _|
+ at.files_matching(/^test\/.*_test\.rb$/)
+ end
+
+ at.add_mapping(/^test\/.*_test\.rb$/) do |file, _|
+ file
+ end
+end
View
@@ -1,7 +1,6 @@
# -*- ruby -*-
#
require 'rubygems'
-ENV['RUBY_FLAGS']="-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}"
require 'hoe'
begin
require 'load_multi_rails_rake_tasks'
View
@@ -1,6 +1,6 @@
begin
unless Object.const_defined?("ActiveSupport") and ActiveSupport.const_defined?("JSON")
- require 'json'
+ require 'json'
module Facebooker
def self.json_decode(str)
JSON.parse(str)
@@ -12,19 +12,25 @@ def self.json_decode(str)
ActiveSupport::JSON.decode(str)
end
end
- end
+ end
rescue
- require 'json'
+ require 'json'
end
require 'zlib'
require 'digest/md5'
module Facebooker
-
+
+ @facebooker_configuration = {}
+ @current_adapter = nil
+ @set_asset_host_to_callback_url = nil
+ @path_prefix = nil
+ @use_curl = false
+
class << self
-
+
def load_configuration(facebooker_yaml_file)
if File.exist?(facebooker_yaml_file)
if defined? RAILS_ENV
@@ -35,7 +41,7 @@ def load_configuration(facebooker_yaml_file)
apply_configuration(config)
end
end
-
+
# Sets the Facebook environment based on a hash of options.
# By default the hash passed in is loaded from facebooker.yml, but it can also be passed in
# manually every request to run multiple Facebook apps off one Rails app.
@@ -53,70 +59,66 @@ def apply_configuration(config)
Facebooker.timeout = config['timeout']
@facebooker_configuration = config
end
-
+
def facebooker_config
- @facebooker_configuration || {} # to prevent pretty_errors error if the config hasn't been set yet
- end
-
- def current_adapter=(adapter_class)
- @current_adapter = adapter_class
+ @facebooker_configuration
end
-
+
+ # TODO: This should be converted to attr_accessor, but we need to
+ # get all the require statements at the top of the file to work.
+
+ # Set the current adapter
+ attr_writer :current_adapter
+
+ # Get the current adapter
def current_adapter
@current_adapter || Facebooker::AdapterBase.default_adapter
end
-
+
def load_adapter(params)
self.current_adapter = Facebooker::AdapterBase.load_adapter(params)
end
-
+
def facebook_path_prefix=(path)
current_adapter.facebook_path_prefix = path
end
-
+
# Default is canvas_page_name in yml file
def facebook_path_prefix
current_adapter.facebook_path_prefix
end
-
+
def is_for?(application_container)
current_adapter.is_for?(application_container)
end
-
+
def set_asset_host_to_callback_url=(val)
@set_asset_host_to_callback_url=val
end
-
+
def set_asset_host_to_callback_url
- @set_asset_host_to_callback_url.nil? ? true : @set_asset_host_to_callback_url
- end
-
- def use_curl=(val)
- @use_curl=val
- end
-
- def use_curl?
- @use_curl
+ @set_asset_host_to_callback_url || true
end
-
+
+ attr_accessor :use_curl
+ alias :use_curl? :use_curl
+
def timeout=(val)
@timeout = val.to_i
end
-
+
def timeout
@timeout
end
-
+
[:api_key,:secret_key, :www_server_base_url,:login_url_base,:install_url_base,:api_rest_path,:api_server_base,:api_server_base_url,:canvas_server_base, :video_server_base].each do |delegated_method|
define_method(delegated_method){ return current_adapter.send(delegated_method)}
end
-
-
- def path_prefix
- @path_prefix
- end
-
-
+
+
+ attr_reader :path_prefix
+
+
# Set the asset path to the canvas path for just this one request
# by definition, we will make this a canvas request
def with_asset_path_for_canvas
@@ -130,7 +132,7 @@ def with_asset_path_for_canvas
ActionController::Base.asset_host = original_asset_host
end
end
-
+
# If this request is_canvas_request
# then use the application name as the url root
def request_for_canvas(is_canvas_request)
@@ -37,7 +37,7 @@ def self.facebooker_config
def self.load_adapter(params)
config_key_base = params[:config_key_base] # This allows for loading of a aspecific adapter
- config_key_base += "_" unless config_key_base.blank?
+ config_key_base += "_" if config_key_base && config_key_base.length > 0
unless api_key = (params[:fb_sig_api_key] || facebooker_config["#{config_key_base}api_key"])
raise Facebooker::AdapterBase::UnableToLoadAdapter
@@ -52,7 +52,7 @@ def self.load_adapter(params)
key_base = key.match(/(.*)[_]?api_key/)[1]
- adapter_class_name = if key_base.blank?
+ adapter_class_name = if !key_base || key_base.length == 0
"FacebookAdapter"
else
facebooker_config[key_base + "adapter"]
@@ -12,16 +12,16 @@ def api_server_base
def api_rest_path
"/restserver.php"
end
-
+
def is_for?(application_context)
application_context == :bebo
end
-
+
def www_server_base_url
"www.bebo.com"
end
-
+
def login_url_base
"http://#{www_server_base_url}/SignIn.jsp?ApiKey=#{api_key}&v=1.0"
end
@@ -33,7 +33,6 @@ def install_url_base
end
# Things that don't actually work as expected in BEBO
-Facebooker::PublishTemplatizedAction
module Facebooker
class User
def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action_fbml, profile_main = nil)
@@ -49,6 +48,9 @@ def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action
private
BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]
+
+ remove_method :collect
+
def collect(fields)
if(Facebooker.is_for?(:bebo) )
BEBO_FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
@@ -5,32 +5,33 @@ class BatchRequest
attr_reader :method
class UnexecutedRequest < StandardError; end
def initialize(params,proc)
- @method=params[:method]
- @uri=params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
- @proc=proc
+ @exception = nil
+ @result = nil
+ @method = params[:method]
+ @uri = params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join("&")
+ @proc = proc
end
-
+
def result=(result_object)
@result = @proc.nil? ? result_object : @proc.call(result_object)
end
-
+
def exception_raised=(ex)
@exception=ex
end
-
+
def exception_raised?
@exception.nil? ? false : raise(@exception)
end
def respond_to?(name)
super || @result.respond_to?(name)
end
-
+
def ===(other)
other === @result
end
-
-
+
def method_missing(name,*args,&proc)
if @exception
raise @exception
@@ -41,4 +42,4 @@ def method_missing(name,*args,&proc)
end
end
end
-end
+end
View
@@ -9,16 +9,9 @@ def self.logger
end
module Logging
-
- def self.skip_api_logging=(val)
- @skip_api_logging=val
- end
-
- def self.skip_api_logging
- @skip_api_logging
- end
-
-
+ @skip_api_logging = nil
+ class << self; attr_accessor :skip_api_logging; end
+
def self.log_fb_api(method, params)
message = method # might customize later
dump = format_fb_params(params)
@@ -36,16 +29,16 @@ def self.log_fb_api(method, params)
log_info(message, exception)
raise
end
-
+
def self.format_fb_params(params)
params.map { |key,value| "#{key} = #{value}" }.join(', ')
end
-
+
def self.log_info(message, dump, seconds = 0)
return unless Facebooker.logger
log_message = "#{message} (#{seconds}) #{dump}"
Facebooker.logger.info(log_message)
end
end
-end
+end
View
@@ -3,12 +3,12 @@ class Mobile
def initialize(session)
@session = session
end
-
+
# Used to determine whether the user identified by "uid" has enabled SMS for this application.
def can_send(user)
@session.post('facebook.sms.canSend', :uid => User.cast_to_facebook_id(user))
end
-
+
# Send the given message to the user.
# See http://wiki.developers.facebook.com/index.php/Mobile
def send(user, message)
Oops, something went wrong.

0 comments on commit 6254e8c

Please sign in to comment.