Skip to content

Commit

Permalink
Merge cbbbf5f into 619dde7
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed May 16, 2015
2 parents 619dde7 + cbbbf5f commit 4ad27d2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kosapi_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'oauth2'
spec.add_runtime_dependency 'faraday', '~> 0.8.9' # VCR does not work with newer versions yet
spec.add_runtime_dependency 'activesupport'
spec.add_runtime_dependency 'corefines', '~> 1.6'
spec.add_runtime_dependency 'escape_utils' unless RUBY_PLATFORM == 'java' # used for uri_template
spec.add_runtime_dependency 'uri_template'
spec.add_runtime_dependency 'ox' # required for correct XML namespace handling (MultiXML, oauth2)
Expand Down
4 changes: 1 addition & 3 deletions lib/kosapi_client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/inflector'
require 'corefines'
require 'uri_template'
require 'escape_utils'

Expand Down
6 changes: 4 additions & 2 deletions lib/kosapi_client/api_client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Corefines::String::camelcase

module KOSapiClient

class ApiClient
Expand All @@ -20,9 +22,9 @@ def initialize(config = Configuration.new)
end

def create_builder(resource_name)
builder_name = "#{resource_name}_builder".camelize.to_sym
builder_name = "#{resource_name}_builder".camelcase(:upper).to_sym
builder_class = find_builder_class(builder_name)
builder_class.new(resource_name.to_s.camelize(:lower), @http_client)
builder_class.new(resource_name.to_s.camelcase(:lower), @http_client)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/kosapi_client/entity/data_mappings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def attr_mappings
if self.superclass.respond_to? :attr_mappings
parent_mappings = self.superclass.attr_mappings
end
@data_mappings.reverse_merge(parent_mappings || {})
(parent_mappings || {}).merge(@data_mappings)
end

# Parses composed domain type from hash response structure.
Expand Down
4 changes: 3 additions & 1 deletion lib/kosapi_client/response_converter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Corefines::String::camelcase

module KOSapiClient

# This class converts parsed response in hash format
Expand Down Expand Up @@ -46,7 +48,7 @@ def detect_type(hash)
end

def extract_type(type_str)
type_name = type_str.camelize
type_name = type_str.camelcase(:upper)
begin
entity_type = Entity.const_get(type_name)
rescue
Expand Down
4 changes: 3 additions & 1 deletion lib/kosapi_client/response_preprocessor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Corefines::String::snake_case

module KOSapiClient
class ResponsePreprocessor

Expand All @@ -18,7 +20,7 @@ def extract_parsed(result)
end

def stringify_keys(response)
HashUtils.deep_transform_hash_keys(response) { |key| key.underscore.sub(':', '_').to_sym rescue key }
HashUtils.deep_transform_hash_keys(response) { |key| key.snake_case.sub(':', '_').to_sym rescue key }
end

def entries_to_array(hash)
Expand Down

0 comments on commit 4ad27d2

Please sign in to comment.