Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

% Yajl -> Oj

  • Loading branch information...
commit 7043f2510fef4949ded426a2d6bb49fa6d9945b0 1 parent d19b53f
Andrew Zinenko authored
View
2  Gemfile
@@ -1,4 +1,2 @@
source "http://rubygems.org"
-
-# Specify your gem's dependencies in vk-ruby.gemspec
gemspec
View
8 Gemfile.lock
@@ -1,8 +1,8 @@
PATH
remote: .
specs:
- vk-ruby (0.7.7)
- json (~> 1.6)
+ vk-ruby (0.7.8)
+ oj (~> 1.0.6)
transformer (~> 0.2.2)
GEM
@@ -10,14 +10,13 @@ GEM
specs:
addressable (2.2.6)
crack (0.3.1)
- json (1.6.5)
minitest (2.10.0)
+ oj (1.0.6)
rake (0.9.2.2)
transformer (0.2.2)
webmock (1.7.8)
addressable (~> 2.2, > 2.2.5)
crack (>= 0.1.7)
- yajl-ruby (1.1.0)
PLATFORMS
ruby
@@ -27,4 +26,3 @@ DEPENDENCIES
rake (~> 0.9)
vk-ruby!
webmock (~> 1.0)
- yajl-ruby (~> 1.0)
View
1  README.md
@@ -36,7 +36,6 @@ end
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
-
## Copyright
Copyright (c) 2011 Andrew Zinenko. See LICENSE.txt for
View
8 lib/vk-ruby.rb
@@ -4,15 +4,9 @@
require 'cgi'
require 'transformer'
require 'yaml'
+require 'oj'
module VK
end
-begin
- require 'yajl'
- require 'yajl/json_gem'
-rescue LoadError
- require 'json'
-end
-
%w(connection core secure serverside standalone vk_exception).each{|lib| require "vk-ruby/#{lib}"}
View
19 lib/vk-ruby/core.rb
@@ -58,6 +58,7 @@ def request verbs, path, options = {}
response = connection(params).request(http_verbs, path, {}, body, attempts)
raise VK::BadResponseException.new(response, verbs, path, options) if response.code.to_i >= 500
+
parse response.body
end
@@ -76,23 +77,7 @@ def connection_params options
end
def parse string
- attempt = 1
-
- # begin
- ::JSON.parse(string)
- # rescue ::JSON::ParserError => exxxc
- # logger.error "Invalid encoding" if logger
-
- # if attempt == 1
- # string = ::Iconv.iconv("UTF-8//IGNORE", "UTF-8", (string + " ")).first[0..-2]
- # string.gsub!(/[^а-яa-z0-9\\\'\"\,\[\]\{\}\.\:\_\s\/]/i, '?')
- # string.gsub!(/(\s\s)*/, '')
- # else
- # raise ::VK::ParseException, string
- # end
-
- # attempt += 1; retry
- end
+ Oj.load string
end
end
View
2  lib/vk-ruby/version.rb
@@ -1,5 +1,5 @@
# encoding: UTF-8
module VK
- VERSION = '0.7.7'
+ VERSION = '0.7.8'
end
View
2  tests/exceptions_test.rb
@@ -13,7 +13,7 @@ def test_bad_requests
end
def test_api_errors
- response = lambda { |request| {:body => {:error => {:error_code => 1, :error_description => 'discription'}}.to_json }}
+ response = lambda { |request| {:body => {'error' => {'error_code' => 1, 'error_description' => 'discription'}}.to_json }}
stub_request(:post, /https:\/\/api.vk.com\/method/).to_return response
assert_raises(::VK::ApiException){ @app.getProfiles :uids => '123' }
View
12 tests/helpers.rb
@@ -12,10 +12,14 @@ def to_params
class Hash
def stringify
- inject({}) do |options, (key, value)|
- options[key.to_s] = value.to_s
- options
- end
+ inject({}) do |options, (key, value)|
+ options[key.to_s] = value.to_s
+ options
+ end
+ end
+
+ def to_json
+ Oj.dump self
end
def stringify!
View
5 vk-ruby.gemspec
@@ -16,12 +16,11 @@ Gem::Specification.new do |gem|
gem.extra_rdoc_files = ["LICENSE.txt", "README.md" ]
- gem.add_runtime_dependency 'transformer', '~> 0.2.2'
- gem.add_runtime_dependency 'json', '~> 1.6'
+ gem.add_runtime_dependency 'transformer', '~> 0.2.2'
+ gem.add_runtime_dependency 'oj', '~> 1.0.6'
gem.add_development_dependency 'rake', '~> 0.9'
gem.add_development_dependency 'minitest', '~> 2.8'
- gem.add_development_dependency 'yajl-ruby', '~> 1.0'
gem.add_development_dependency 'webmock', '~> 1.0'
gem.require_paths = ['lib']
Please sign in to comment.
Something went wrong with that request. Please try again.