Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 12, 2012
@cadwallion cadwallion Replaces Vindicia::Util with ActiveSupport
Uses camelize and underscore methods
e29395d
Commits on Sep 13, 2012
@cadwallion cadwallion Merge pull request #2 from agoragames/active_support
Replaces Vindicia::Util with ActiveSupport
04d1fa9
View
1 lib/vindicia-api.rb
@@ -1,2 +1,3 @@
+require 'active_support/core_ext/string/conversions'
require 'vindicia/config'
require 'vindicia/model'
View
5 lib/vindicia/config.rb
@@ -1,5 +1,4 @@
require 'singleton'
-require 'vindicia/util'
module Vindicia
@@ -193,7 +192,7 @@ def self.initialize!
return false unless API_CLASSES[config.api_version]
API_CLASSES[config.api_version].each_key do |vindicia_klass|
- const_set(Vindicia::Util.camelize(vindicia_klass.to_s),
+ const_set(vindicia_klass.to_s.camelize,
Class.new do
include Vindicia::Model
@@ -214,4 +213,4 @@ def self.initialize!
)
end
end
-end
+end
View
7 lib/vindicia/model.rb
@@ -1,5 +1,4 @@
require "savon"
-require "savon/core_ext/string"
module Vindicia
@@ -46,7 +45,7 @@ def actions(*actions)
def define_class_action(action)
class_action_module.module_eval <<-CODE
- def #{action.to_s.snakecase}(body = {}, &block)
+ def #{action.to_s.underscore}(body = {}, &block)
client.request :tns, #{action.inspect} do
soap.namespaces["xmlns:tns"] = vindicia_target_namespace
http.headers["SOAPAction"] = vindicia_soap_action('#{action}')
@@ -56,7 +55,7 @@ def #{action.to_s.snakecase}(body = {}, &block)
block.call(soap, wsdl, http, wsse) if block
end
rescue Exception => e
- rescue_exception(:#{action.to_s.snakecase}, e)
+ rescue_exception(:#{action.to_s.underscore}, e)
end
CODE
end
@@ -90,7 +89,7 @@ def underscoreize_periods(target)
end
def vindicia_soap_action(action)
- %{"#{vindicia_target_namespace}##{action.to_s.lower_camelcase}"}
+ %{"#{vindicia_target_namespace}##{action.to_s.camelize(:lower)}"}
end
def rescue_exception(action, error)
View
8 lib/vindicia/util.rb
@@ -1,8 +0,0 @@
-module Vindicia
- module Util
- # Taken from Rails 3.0.4 ActiveSupport::Inflector
- def self.camelize(lower_case_and_underscored_word)
- lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
- end
- end
-end
View
5 test/vindicia/config_test.rb
@@ -1,5 +1,4 @@
require 'helper'
-require 'vindicia/util'
class Vindicia::ConfigTest < Test::Unit::TestCase
@@ -8,7 +7,7 @@ def setup
def self.clear_config
if Vindicia.config.is_configured?
Vindicia::API_CLASSES[Vindicia.config.api_version].each_key do |vindicia_klass|
- Vindicia.send(:remove_const, Vindicia::Util.camelize(vindicia_klass.to_s).to_sym)
+ Vindicia.send(:remove_const, vindicia_klass.to_s.camelize.to_sym)
end
end
end
@@ -88,7 +87,7 @@ def test_should_define_vindicia_classes_for_respective_api_version
assert Vindicia.config.is_configured?
Vindicia::API_CLASSES[good_api_version].each_key do |vindicia_klass|
- assert Vindicia.const_get(Vindicia::Util.camelize(vindicia_klass.to_s))
+ assert Vindicia.const_get(vindicia_klass.to_s.camelize)
end
end
View
5 test/vindicia/model_test.rb
@@ -1,5 +1,4 @@
require 'helper'
-require 'vindicia/util'
require 'net/http'
class Vindicia::ModelTest < Test::Unit::TestCase
@@ -9,7 +8,7 @@ def setup
def self.clear_config
if Vindicia.config.is_configured?
Vindicia::API_CLASSES[Vindicia.config.api_version].each_key do |vindicia_klass|
- Vindicia.send(:remove_const, Vindicia::Util.camelize(vindicia_klass.to_s).to_sym)
+ Vindicia.send(:remove_const, vindicia_klass.to_s.camelize.to_sym)
end
end
end
@@ -39,7 +38,7 @@ def teardown
def test_should_define_api_methods_of_respective_vindicia_class_for_respective_api_version
Vindicia::API_CLASSES[@good_api_version].each_key do |vindicia_klass_name|
- vindicia_klass = Vindicia.const_get(Vindicia::Util.camelize(vindicia_klass_name.to_s))
+ vindicia_klass = Vindicia.const_get(vindicia_klass_name.to_s.camelize)
Vindicia::API_CLASSES[@good_api_version][vindicia_klass_name].each do |api_method|
assert vindicia_klass.respond_to?(api_method)
View
8 test/vindicia/util_test.rb
@@ -1,8 +0,0 @@
-require 'helper'
-require 'vindicia/util'
-
-class Vindicia::UtilTest < Test::Unit::TestCase
- def test_camelize_should_produce_camalcase_name_from_lowercase_underscore_name
- assert_equal 'FooBarBaz', Vindicia::Util.camelize('foo_bar_baz')
- end
-end
View
1 vindicia-api.gemspec
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.add_dependency('savon')
+ gem.add_dependency('active_support')
gem.add_development_dependency('rake')
gem.add_development_dependency('mocha')

No commit comments for this range

Something went wrong with that request. Please try again.