quicktravel_client 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 421aff4ace14fcc897f2e4e2fb6ce1322c59cee5
4
- data.tar.gz: 866639c423532c55b063a28c01158c3c3878a9cb
3
+ metadata.gz: 12215f7e586d4dcc5d210f34eed5823f029be331
4
+ data.tar.gz: b3be0ebba0bf6ae60b0f5039958e25e9f86fa1b5
5
5
  SHA512:
6
- metadata.gz: 8958463c230448871416721396a4942f67028d263a107f7bd873ea34b325f956d3cb509e53bea8500f28c421dbf13a441ab410b79b9c4d196577c441792a4400
7
- data.tar.gz: 1701d78f156203ad7dfda195608f97561a74d6a3783a32882aee910b180709b4a244f64cf6efa61be92265ec7dd158041e5afb87263b0085c16a22817eca650f
6
+ metadata.gz: 04283f96ff13e9e588b641d03e71d2b365c4651272a0361547fb5727d8c110e6bfe954fba1a99eec171ba7731b94f4e3469b4f7a9ae4b243bec938c2b929ef89
7
+ data.tar.gz: 37ea14639851b762575c87fde07b8fe45af6711389ccd81f4b17fb912124ac2dfee4a1bf171e63035d14fb63a22838d7f6ff192e18ee24228d0f457e4cd9acda
data/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
5
5
 
6
+ ## [2.3.0]
7
+ ### Changed
8
+ - Change cache expiries
9
+ - Adds support for passing dates to Resource#all_with_price
10
+
11
+ ### Fixed
12
+ - Fixes issue with HTTParty ~> 0.14
13
+ - Updates HTTParty dependency to ~> 0.14
14
+
6
15
  ## [2.2.2]
7
16
  ### Changed
8
17
  - Deprecates Booking#calculate_price_quote
@@ -2,7 +2,10 @@ source 'https://rubygems.org'
2
2
  gemspec :path => '../'
3
3
 
4
4
  group :development, :test do
5
+ gem 'json', '~> 1.8'
6
+ gem 'tins', '~> 1.6.0'
5
7
  gem 'activesupport', '~> 2.3'
6
8
  gem 'activerecord', '~> 2.3'
7
9
  gem 'actionpack', '~> 2.3'
10
+ gem 'rubocop', '~> 0.41.2'
8
11
  end
@@ -272,7 +272,7 @@ module QuickTravel
272
272
  raise ConnectionError.new('Timeout error')
273
273
  end
274
274
 
275
- if expect && expect == :json && !response.is_a?(Hash)
275
+ if expect && expect == :json && !response.parsed_response.is_a?(Hash)
276
276
  fail AdapterError, <<-FAIL
277
277
  Request expected to be json but failed. Debug information below:
278
278
  http_method: #{http_method.inspect}
@@ -10,6 +10,8 @@ module QuickTravel
10
10
  cached_value = cache_store.read(key)
11
11
  return cached_value unless cached_value.nil?
12
12
  return nil unless block_given?
13
+ cache_options ||= {}
14
+ cache_options[:expires_in] = 1.day unless cache_options.key?(:expires_in)
13
15
  yield.tap { |value| cache_store.write(key, value, cache_options) }
14
16
  end
15
17
 
@@ -12,8 +12,8 @@ module QuickTravel
12
12
  end
13
13
 
14
14
  def self.all_with_price(opts)
15
- find_all!("/api/resources/index_with_price.json",
16
- opts.merge(cache: "#{name}.all_with_price-attrs"))
15
+ cache_key = GenerateCacheKey.new(name, opts).call
16
+ find_all!("/api/resources/index_with_price.json", opts.merge(cache: cache_key))
17
17
  end
18
18
 
19
19
  def product_type
@@ -25,5 +25,24 @@ module QuickTravel
25
25
  BedRequirement.new(bed_requirement)
26
26
  end
27
27
  end
28
+
29
+ private
30
+
31
+ class GenerateCacheKey
32
+ def initialize(resource_name, opts)
33
+ @resource_name = resource_name
34
+ @opts = opts
35
+ end
36
+
37
+ def call
38
+ "#{@resource_name}.all_with_price-attrs?#{cache_params.to_param}"
39
+ end
40
+
41
+ private
42
+
43
+ def cache_params
44
+ { date: Date.current }.merge(@opts.symbolize_keys)
45
+ end
46
+ end
28
47
  end
29
48
  end
@@ -17,9 +17,7 @@ module QuickTravel
17
17
  # All routes for a given product type
18
18
  def self.all(product_type_id)
19
19
  find_all!("/product_types/#{product_type_id}/routes.json",
20
- cache: "QuickTravel::Route.all-#{product_type_id}-attrs",
21
- # expires_in will only work with something like Rails.cache
22
- cache_options: { expires_in: 1440.minutes })
20
+ cache: "QuickTravel::Route.all-#{product_type_id}-attrs")
23
21
  end
24
22
 
25
23
  def self.find(routes_list, route_id)
@@ -1,3 +1,3 @@
1
1
  module QuickTravel
2
- VERSION = '2.2.2'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -16,7 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ['lib']
18
18
 
19
- spec.add_dependency 'httparty'
19
+ spec.add_dependency 'httparty', '~> 0.14'
20
+ spec.add_dependency 'json'
20
21
  # Geokit dependency should be removed (see address.rb for details)
21
22
  spec.add_dependency 'geokit', '~> 1.8.3' # used in address model
22
23
  spec.add_dependency 'activesupport', '>= 2.0.0'
data/spec/spec_helper.rb CHANGED
@@ -11,22 +11,14 @@ require 'bundler/setup'
11
11
  require 'rspec/its'
12
12
  require 'date' # Needed for stamp
13
13
  require 'stamp' # Some reasons stamp doesn't load automatically?
14
- require 'vcr'
15
14
 
16
15
  ENV['QT_KEYS'] ||= 'test_key_1,test_key_2'
17
- qt_keys = ENV['QT_KEYS'].split(',')
18
- VCR.configure do |c|
19
- c.cassette_library_dir = 'spec/support/cassettes'
20
- c.default_cassette_options = { match_requests_on: [:method, :uri, :body] }
21
- c.filter_sensitive_data('<QT_KEY>') { qt_keys[0] }
22
- c.filter_sensitive_data('<QT_KEY_2>') { qt_keys[1] }
23
- c.hook_into :webmock
24
- end
25
-
16
+ require 'support/vcr_loader'
26
17
  require 'support/coverage_loader'
27
18
  require 'quick_travel' # eager load to ensure coverage correct
28
19
 
29
20
  require 'quick_travel/config'
21
+ qt_keys = ENV['QT_KEYS'].split(',')
30
22
  QuickTravel.configure do |c|
31
23
  c.url = 'http://test.qt.sealink.com.au:8080'
32
24
  c.access_key = qt_keys[0]
@@ -0,0 +1,12 @@
1
+ require 'vcr'
2
+ require 'webmock/rspec'
3
+
4
+ qt_keys = ENV['QT_KEYS'].split(',')
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'spec/support/cassettes'
8
+ c.default_cassette_options = { match_requests_on: [:method, :uri, :body] }
9
+ c.filter_sensitive_data('<QT_KEY>') { qt_keys[0] }
10
+ c.filter_sensitive_data('<QT_KEY_2>') { qt_keys[1] }
11
+ c.hook_into :webmock
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quicktravel_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -10,10 +10,24 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-04-26 00:00:00.000000000 Z
13
+ date: 2016-08-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '0.14'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '0.14'
29
+ - !ruby/object:Gem::Dependency
30
+ name: json
17
31
  requirement: !ruby/object:Gem::Requirement
18
32
  requirements:
19
33
  - - ">="
@@ -396,6 +410,7 @@ files:
396
410
  - spec/support/cassettes/route_all.yml
397
411
  - spec/support/cassettes/tenant_switcher.yml
398
412
  - spec/support/coverage_loader.rb
413
+ - spec/support/vcr_loader.rb
399
414
  - spec/tenant_spec.rb
400
415
  homepage: https://bitbucket.org/team-sealink/quicktravel_client
401
416
  licenses: []
@@ -416,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
431
  version: '0'
417
432
  requirements: []
418
433
  rubyforge_project:
419
- rubygems_version: 2.4.8
434
+ rubygems_version: 2.4.5.1
420
435
  signing_key:
421
436
  specification_version: 4
422
437
  summary: Booking process using QuickTravel API
@@ -476,4 +491,5 @@ test_files:
476
491
  - spec/support/cassettes/route_all.yml
477
492
  - spec/support/cassettes/tenant_switcher.yml
478
493
  - spec/support/coverage_loader.rb
494
+ - spec/support/vcr_loader.rb
479
495
  - spec/tenant_spec.rb