aranea 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTgzYzg1NjVhM2MyNzdiMDRkNzJkNzQ4MjMwMmI2ZDUzMWIzM2FkMg==
4
+ ZjFiZjY1OTNlMjBhNmJhM2RkYmFmZDE1ZjI2ZGE1N2QxNWFkMmQ1NQ==
5
5
  data.tar.gz: !binary |-
6
- YmFmYjdjMTBkOWU2ZjljMGE1ZjcxM2FkMTY1M2E4MGQ4ZGU4ODMwOA==
6
+ YWNmYTc1YjVjZTQ1OTI0MTIwODNjMjYzMDM0YzBiMDk2YmE4MmE0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGMyMDg3MjkxYzhhOGI4YzkwNGE0MDI4ZTk1ZDNmYTUzNjM0ZjkwNjhkMjM2
10
- ODI4NTViMTk2ZDQzMWU5NjMxMTZkNjYyY2E3YWE3NDcxNDI3N2E3MGE2NDcw
11
- NDViNWI3ZmYzZjJlMjViMDc5ZGEwN2VhYmRkYTIxNGY5NWNlZDg=
9
+ NDU3ZGNjYmIwNDI4NWI4NmZhODgxYTEwNTUzZjcyZmRmOGEyZTczYzQwNzg3
10
+ MDEyMjA4YzUyMjk4NDM0Mzc3NGRkYmEzNzVlNjc3YzhjM2ZkZGI3ZjM1NmZk
11
+ NTk1MDkxZWMyMjEzOTJlNDUxMTQ4OTQ1MDBhMWJmZTUzYjMxM2M=
12
12
  data.tar.gz: !binary |-
13
- MTA0OTAyMGEyYzg4MzFiMzY1Njc4YTEzYzM4ZjMwYjNhZGI0OGIyMzFhMDJk
14
- YzNhNjRkNDJhOWIyOWU2ZGI4MGQ0NzhkNzIwOTEzOGUxZjNiOWI4OGI3MjE1
15
- MTI4NjUxOGY3NmZkZTU4NGRkZjhiYmZhMDhmYjY4MjQwODUzZjA=
13
+ ZjRkMzYzYmQ3OWJmYjE1OGRmODliNDZkOGRiMzM4N2Y5ZDU2NmRhMTAwOWM0
14
+ Yzc5ZmI0ZTc2Zjc4OWM4MWZkMTBiMmFlYTA0YTM4YWI1ODVhYmUxMDNmNWFk
15
+ MTRlZjM0ZGE1ODIwNGE5MzljNTdlODk1ZTBhZGVlN2ZiNDFkNTU=
@@ -54,28 +54,35 @@ module Aranea
54
54
  #TODO: Actually implement Repository pattern, dependency injection and all.
55
55
  # As is we only support sharing between multiple instances if Rails.cache exists and does
56
56
  class Repository
57
- @cache = if defined?(Rails::RAILS_CACHE) && Rails.cache
58
- Rails.cache
59
- else
60
- require 'active_support/cache'
61
- ActiveSupport::Cache::MemoryStore.new
62
- end
63
-
57
+
64
58
  KEY = 'aranea_current_failure'
65
59
 
66
60
  class << self
67
61
 
68
62
  def store(failure, lifespan)
69
63
  failure.expiration_date = Time.now + lifespan
70
- @cache.write(KEY, failure, expires_in: lifespan)
64
+ cache.write(KEY, failure, expires_in: lifespan)
71
65
  end
72
66
 
73
67
  def get
74
- @cache.read(KEY)
68
+ cache.read(KEY)
75
69
  end
76
70
 
77
71
  def clear
78
- @cache.delete(KEY)
72
+ cache.delete(KEY)
73
+ end
74
+
75
+ def cache
76
+ @cache ||= rails_cache || memory_store
77
+ end
78
+
79
+ def rails_cache
80
+ defined?(Rails.cache) && Rails.cache
81
+ end
82
+
83
+ def memory_store
84
+ require 'active_support/cache'
85
+ ActiveSupport::Cache::MemoryStore.new
79
86
  end
80
87
 
81
88
  end
@@ -1,5 +1,5 @@
1
1
  module Aranea
2
2
 
3
- VERSION = '0.0.0'
3
+ VERSION = '0.0.1'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Weiner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-04 00:00:00.000000000 Z
12
+ date: 2015-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday