Permalink
Browse files

Renaming String.camelize to String.rtmize.

Overriding the camelize method caused rails to blow up.
  • Loading branch information...
1 parent c19957d commit 511121ce58ed6eae40d39d33c4d9f976ea07fbac @mattmueller mattmueller committed Nov 9, 2009
Showing with 21 additions and 16 deletions.
  1. +1 −1 ext/{string_camelize.rb → string_rtmize.rb}
  2. +2 −1 lib/moocow.rb
  3. +4 −3 lib/moocow/auth.rb
  4. +7 −6 lib/moocow/moocow.rb
  5. +5 −4 test/tc_auth.rb
  6. +2 −1 test/testbase.rb
@@ -1,7 +1,7 @@
class String
# Stolen from sequel; gives String a camelize method
- def camelize(first_letter_in_uppercase = :lower)
+ def rtmize(first_letter_in_uppercase = :lower)
s = gsub(/\/(.?)/){|x| "::#{x[-1..-1].upcase unless x == '/'}"}.gsub(/(^|_)(.)/){|x| x[-1..-1].upcase}
s[0...1] = s[0...1].downcase unless first_letter_in_uppercase == :upper
s
View
@@ -2,4 +2,5 @@
require 'moocow/auth'
require 'moocow/endpoint'
require 'hash_array'
-require 'string_camelize'
+require 'string_rtmize'
+
View
@@ -1,9 +1,9 @@
-require 'string_camelize'
+require 'string_rtmize'
module RTM
# Implements authorization related tasks. These are to be used one-time only
# when the user first uses your application.
- #
+ #
# auth = RTMAuth.new(api_key,secret)
# url = auth.get_auth_url
# # send user to url
@@ -17,7 +17,7 @@ def initialize(endpoint)
# Get the URL to allow the user to authorize the application
# [perms] the permissions you wish to get, either :read, :write, or :delete
- # [application_type] if :desktop, a frob is gotten and the URL is suitable for a desktop application. if :web, a url suitable for the web is returned.
+ # [application_type] if :desktop, a frob is gotten and the URL is suitable for a desktop application. if :web, a url suitable for the web is returned.
# [callback_url] the callback URL you want the user sent to after they authorize. This will have the frob and you must call frob= before get_token with the frob that was given to you.
def url(perms = :delete, application_type=:desktop, callback_url=nil)
@frob = get_frob if application_type == :desktop
@@ -56,3 +56,4 @@ def frob=(frob)
end
end
end
+
View
@@ -1,5 +1,5 @@
require 'rubygems'
-require 'string_camelize'
+require 'string_rtmize'
require 'digest/md5'
require 'cgi'
require 'moocow/auth'
@@ -25,13 +25,13 @@ module RTM
# Also note that you can use Ruby-style method calls instead of filthy camel-case, e.g.
#
# response = rtm.tasks.get_list(:filter => 'location:Work and status:completed')
- # # Same as
+ # # Same as
# response = rtm.tasks.getList(:filter => 'location:Work and status:completed')
#
class RTM
# Create access to RTM
- #
+ #
# [endpoint] an Endpoint to RTM
def initialize(endpoint)
@endpoint = endpoint
@@ -77,7 +77,7 @@ def test
# method names are converted to camelcase.
def method_missing(symbol,*args)
if !args || args.empty?
- rtm_object = symbol.to_s.camelize
+ rtm_object = symbol.to_s.rtmize
return RTMMethodSpace.new(rtm_object,@endpoint)
else
return super(symbol,*args)
@@ -87,7 +87,7 @@ def method_missing(symbol,*args)
end
# Generic means of calling an RTM method. This is returned by RTM.method_missing and, in most cases, is
- # the end point that calls an RTM method.
+ # the end point that calls an RTM method.
class RTMMethodSpace
# Create an RTMMethodSpace
@@ -125,7 +125,7 @@ def method_missing(symbol,*args)
if (@name == 'tasks' && symbol.to_s == 'notes')
return RTMMethodSpace.new("tasks.notes",@endpoint)
else
- rtm_method = "rtm.#{@name}.#{symbol.to_s.camelize}"
+ rtm_method = "rtm.#{@name}.#{symbol.to_s.rtmize}"
@endpoint.call_method(rtm_method,*args)
end
end
@@ -143,3 +143,4 @@ class InvalidTokenException < Exception
class NoTokenException < Exception
end
end
+
View
@@ -2,11 +2,11 @@
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'testbase'
-require 'string_camelize'
+require 'string_rtmize'
include RTM
class TC_testAuth < TestBase
-
+
def test_get_set_frob
rtm = get_rtm
auth = rtm.auth
@@ -29,8 +29,8 @@ def test_check_token_good
end
def test_check_token_bad
- rtm = get_rtm(true,{'rsp' =>
- { 'stat' => 'fail', 'err' =>
+ rtm = get_rtm(true,{'rsp' =>
+ { 'stat' => 'fail', 'err' =>
{ 'code' => '98', 'msg' => 'Invalid auth token' }
}
});
@@ -85,3 +85,4 @@ def body
end
end
+
View
@@ -1,5 +1,5 @@
require 'rexml/formatters/pretty'
-require 'string_camelize'
+require 'string_rtmize'
class MockHttp
def initialize(response=nil)
@response = response
@@ -49,3 +49,4 @@ def get_rtm(use_token=true,response=nil)
rtm
end
end
+

0 comments on commit 511121c

Please sign in to comment.