File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed
lib/ontologies_api_client Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,4 @@ gem 'rake'
66gem 'pry'
77gem 'test-unit'
88gem 'webmock' , require : false
9- # Add these lines to your Gemfile
10- gem 'rails'
119gem 'activesupport'
Original file line number Diff line number Diff line change 11require 'active_support/core_ext/hash'
2+ require 'active_support/cache'
23
34module LinkedData
45 module Client
56 module RequestFederation
67
8+ CACHE = ActiveSupport ::Cache ::MemoryStore . new
9+
710 def self . included ( base )
811 base . extend ( ClassMethods )
912 end
@@ -17,8 +20,8 @@ def federated_get(params = {}, &link)
1720 portal_name = portal_name_from_id ( conn . url_prefix . to_s )
1821 portal_status = true
1922
20- unless Rails . cache . read ( "federation_portal_up_#{ portal_name } " ) . nil?
21- portal_status = Rails . cache . read ( "federation_portal_up_#{ portal_name } " )
23+ unless CACHE . read ( "federation_portal_up_#{ portal_name } " ) . nil?
24+ portal_status = CACHE . read ( "federation_portal_up_#{ portal_name } " )
2225 end
2326
2427 unless portal_status
@@ -29,7 +32,7 @@ def federated_get(params = {}, &link)
2932 begin
3033 HTTP . get ( link . call ( conn . url_prefix . to_s . chomp ( '/' ) ) , params , connection : conn )
3134 rescue Exception => e
32- Rails . cache . write ( "federation_portal_up_#{ portal_name } " , false , expires_in : 10 . minutes )
35+ CACHE . write ( "federation_portal_up_#{ portal_name } " , false , expires_in : 10 . minutes )
3336 [ OpenStruct . new ( errors : "Problem retrieving #{ link . call ( conn . url_prefix . to_s . chomp ( '/' ) ) || conn . url_prefix } " ) ]
3437 end
3538 end
Original file line number Diff line number Diff line change 77
88WebMock . allow_net_connect!
99
10- module Rails
11- def self . cache
12- @cache ||= ActiveSupport ::Cache ::MemoryStore . new
13- end
14- end
10+ # Set up a cache for testing
11+ CACHE = ActiveSupport ::Cache ::MemoryStore . new
1512
1613module LinkedData
1714 module Client
1815 class TestCase < Test ::Unit ::TestCase
16+ # You can use CACHE in your tests if needed
1917 end
2018 end
2119end
You can’t perform that action at this time.
0 commit comments