diff --git a/Gemfile b/Gemfile index 7d4529f..04f4ef6 100644 --- a/Gemfile +++ b/Gemfile @@ -4,5 +4,5 @@ gemspec group :debug do gem 'debugger', :platforms => [:mri_19] - gem 'byebug', :platforms => [:mri_20, :mri_21] + gem 'byebug', :platforms => [:mri_20, :mri_21, :mri_22, :mri_23, :mri_24] end diff --git a/Gemfile.lock b/Gemfile.lock index b895157..d888b91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,71 +1,80 @@ PATH remote: . specs: - mbsy (1.0.4) - httparty (>= 0.8.3) - json (>= 1.7.3) + mbsy (1.1.4) + httparty (= 0.14.0) + json (= 2.0.3) GEM remote: https://rubygems.org/ specs: - activesupport (4.1.1) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) + activesupport (5.0.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) minitest (~> 5.1) - thread_safe (~> 0.1) tzinfo (~> 1.1) - addressable (2.3.6) - byebug (3.1.2) - columnize (~> 0.8) - debugger-linecache (~> 1.2) - columnize (0.8.9) - crack (0.4.2) + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) + byebug (9.0.6) + columnize (0.9.0) + concurrent-ruby (1.0.5) + crack (0.4.3) safe_yaml (~> 1.0.0) - debugger (1.6.6) + debugger (1.6.8) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.2) + debugger-ruby_core_source (~> 1.3.5) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.4) - diff-lcs (1.2.5) - faker (1.3.0) + debugger-ruby_core_source (1.3.8) + diff-lcs (1.3) + faker (1.7.3) i18n (~> 0.5) - httparty (0.13.1) - json (~> 1.8) + hashdiff (0.3.2) + httparty (0.14.0) multi_xml (>= 0.5.2) - i18n (0.6.9) - json (1.8.1) - minitest (5.3.3) - multi_xml (0.5.5) - rake (10.3.1) - rspec (2.14.1) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rspec-core (2.14.8) - rspec-expectations (2.14.5) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.6) - safe_yaml (1.0.3) - shoulda-matchers (2.6.1) - activesupport (>= 3.0.0) - thread_safe (0.3.3) - tzinfo (1.1.0) + i18n (0.8.1) + json (2.0.3) + minitest (5.10.1) + multi_xml (0.6.0) + public_suffix (2.0.5) + rake (12.0.0) + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.4) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + safe_yaml (1.0.4) + shoulda-matchers (3.1.1) + activesupport (>= 4.0.0) + thread_safe (0.3.6) + tzinfo (1.2.2) thread_safe (~> 0.1) - webmock (1.17.4) - addressable (>= 2.2.7) + webmock (2.3.2) + addressable (>= 2.3.6) crack (>= 0.3.2) + hashdiff PLATFORMS ruby DEPENDENCIES - activesupport (>= 3.2.18) + activesupport (= 5.0.2) byebug debugger - faker (~> 1.3.0) + faker (= 1.7.3) mbsy! - rake (>= 0.9.2) - rspec (~> 2.14.1) - shoulda-matchers (= 2.6.1) - webmock (~> 1.17.4) + rake (= 12.0.0) + rspec (= 3.5.0) + shoulda-matchers (= 3.1.1) + webmock (= 2.3.2) + +BUNDLED WITH + 1.13.7 diff --git a/lib/mbsy/resources/base.rb b/lib/mbsy/resources/base.rb index 80b07f1..4de28f7 100644 --- a/lib/mbsy/resources/base.rb +++ b/lib/mbsy/resources/base.rb @@ -12,31 +12,33 @@ class Base default_timeout 30 default_params :output => 'json' - def self.element_name - name.split(/::/).last.underscore - end + class << self + def element_name + name.split(/::/).last.underscore + end - def self.api_url(method) - Mbsy.site_uri + self.element_name + '/' + method - end - - def self.call(method, params = {}) - response = JSON.parse(self.get(api_url(method), :query => params).body)['response'] - case response['code'] - when '200' # Nothing to do here... - when '400' - raise BadRequestError.new(response['errors']['error']) - when '401' - raise UnauthorizedError.new(response['errors']['error']) - when '404' - raise RecordNotFound.new(response['errors']['error']) - when '500' - raise ServerError.new(response['errors']['error']) - else - raise BadResponse.new(response: response) + def api_url(method) + Mbsy.site_uri + element_name + '/' + method end - response['data'] + def call(method, params = {}) + response = JSON.parse(self.get(api_url(method), :query => params).body)['response'] + case response['code'] + when '200' # Nothing to do here... + when '400' + raise BadRequestError.new(response['errors']['error']) + when '401' + raise UnauthorizedError.new(response['errors']['error']) + when '404' + raise RecordNotFound.new(response['errors']['error']) + when '500' + raise ServerError.new(response['errors']['error']) + else + raise BadResponse.new(response: response) + end + + response['data'] + end end end end diff --git a/lib/mbsy/version.rb b/lib/mbsy/version.rb index 51f701c..1e8328c 100644 --- a/lib/mbsy/version.rb +++ b/lib/mbsy/version.rb @@ -1,3 +1,3 @@ module Mbsy - VERSION = '1.1.3' + VERSION = '2.0.0' end diff --git a/mbsy.gemspec b/mbsy.gemspec index 9a8eb60..7f38f26 100644 --- a/mbsy.gemspec +++ b/mbsy.gemspec @@ -19,13 +19,13 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9.2" - s.add_runtime_dependency('httparty', '>= 0.8.3') - s.add_runtime_dependency('json', '>= 1.7.3') + s.add_runtime_dependency('httparty', '0.14.0') + s.add_runtime_dependency('json', '2.0.3') - s.add_development_dependency('rake', '>= 0.9.2') - s.add_development_dependency('rspec', '~> 2.14.1') - s.add_development_dependency('webmock', '~> 1.17.4') - s.add_development_dependency('faker', '~> 1.3.0') - s.add_development_dependency('shoulda-matchers', '2.6.1') - s.add_development_dependency('activesupport', '>= 3.2.18') + s.add_development_dependency('rake', '12.0.0') + s.add_development_dependency('rspec', '3.5.0') + s.add_development_dependency('webmock', '2.3.2') + s.add_development_dependency('faker', '1.7.3') + s.add_development_dependency('shoulda-matchers', '3.1.1') + s.add_development_dependency('activesupport', '5.0.2') end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index adaa840..765520f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,7 +19,6 @@ def configure_mbsy! # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus