glib-web 0.4.11 → 0.4.12

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dc0677c6f29166100884d7d415d3f85a5caaef4
4
- data.tar.gz: 1d9ab884a48db31bc4957d86b43370938bc5fefc
3
+ metadata.gz: 65d643ab1cf84d5f4dabe58840e51d4b1d13a5cf
4
+ data.tar.gz: 2f01ef5b09d5727aa64994b1d5ba96623ec86ecf
5
5
  SHA512:
6
- metadata.gz: 5f890e2878ee7d3ac12030008b81c703e3a2398b4ed22b829294ca33d28391a01e656fd7d5ae5362e81e50aeeaae80ab4ff2ea36bb4c101a85c83c77062c50d3
7
- data.tar.gz: 3bb000732b8dcc373ee166cdd91bc0d6ef601ab9d74adc427d345e7daad9ca2a840026367059754178a4c2e1c22bda7ae9aa2bcdd09042ab96eced346f53334c
6
+ metadata.gz: 0413434aeaafd7a0cafd4f550370f9247455cb35eef898afe0fa826b3aae538fbcc0a6496093ad26984bac90f8a4de523f7c5a6355d086b2295ca8ccd8af7d05
7
+ data.tar.gz: 874e956236407a17bfb7d5731387f0c91c67d7234f1a6d64604938b51f7969e650490d0eed6c95d5b1e6e2db36766c52a4e7a5d92ec25eca908b8c446dcd280e
@@ -1,9 +1,9 @@
1
1
  module Glib
2
2
  module ActiveStorage
3
3
  class Attachment < ::ActiveStorage::Attachment
4
- if respond_to? :connects_to
4
+ if Glib::DynamicText::Config.database_url.present?
5
5
  connects_to database: { writing: :dynamic_text, reading: :dynamic_text }
6
6
  end
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -1,9 +1,9 @@
1
1
  module Glib
2
2
  module ActiveStorage
3
3
  class Blob < ::ActiveStorage::Blob
4
- if respond_to? :connects_to
4
+ if Glib::DynamicText::Config.database_url.present?
5
5
  connects_to database: { writing: :dynamic_text, reading: :dynamic_text }
6
6
  end
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -2,10 +2,8 @@ module Glib
2
2
  class DynamicTextRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
4
 
5
- # DT is only supported in Rails 6 but make sure things still work in Rails 5.
6
- # TODO: Remove this check once we don't support Rails 5 anymore
7
- if respond_to? :connects_to
5
+ if Glib::DynamicText::Config.database_url.present?
8
6
  connects_to database: { writing: :dynamic_text, reading: :dynamic_text }
9
7
  end
10
8
  end
11
- end
9
+ end
@@ -0,0 +1,20 @@
1
+ module Glib
2
+ module DynamicText
3
+ class Config
4
+ @@redis = nil
5
+ @@database_url = ENV['DT_DATABASE_URL']
6
+
7
+ def self.redis
8
+ if @@redis.nil?
9
+ redis_url = ENV.fetch('DT_REDIS_URL', 'redis://localhost:6379')
10
+ @@redis = Redis.new(url: redis_url)
11
+ end
12
+ @@redis
13
+ end
14
+
15
+ def self.database_url
16
+ @@database_url
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ require_relative './dynamic_text/config'
data/lib/glib-web.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "glib/version"
2
2
  require "glib/engine" if defined?(::Rails)
3
3
  require "glib/value"
4
- require "glib/json_crawler"
4
+ require "glib/json_crawler"
5
+
6
+ require 'glib/dynamic_text'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -171,6 +171,8 @@ files:
171
171
  - lib/generators/templates/database.yml
172
172
  - lib/generators/templates/dynamic_text.rb
173
173
  - lib/glib-web.rb
174
+ - lib/glib/dynamic_text.rb
175
+ - lib/glib/dynamic_text/config.rb
174
176
  - lib/glib/engine.rb
175
177
  - lib/glib/json_crawler.rb
176
178
  - lib/glib/json_crawler/action_crawler.rb