locale_kit 0.0.3 → 1.0.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: 975e532773f6d9fa9efcf91104d2a9a2e1dd83a0
4
- data.tar.gz: 3e1dba08cadc46e1623ea7711a7eefd3db23b538
3
+ metadata.gz: fafe0ff1d4b53488d966dc6ea25f7ba96945eac7
4
+ data.tar.gz: dba3501d8a7a49aefd76a8b975f64cd93a362e98
5
5
  SHA512:
6
- metadata.gz: bd91b7007524f366b0a26c1000f7804c6e7229fcec8e181650330b48090c6ae56b75a7de8033c450b9de736fde41797270c56078deea886887f286cc761402b2
7
- data.tar.gz: d2203eb8ab6d4a09291d692439b968364e39de60effb944ed9824deabf3db541b824f3dad38cca8573928430a8bb6acd88dedb7065a30a6f0b288f91daf5473b
6
+ metadata.gz: 9b228afa982ac0d93bd9bd69326f44ec55d4df3e798d5ba7d1956ab038f815b13c4c9615a2ec97a3b3f2a6a4d1ad2167e35f6a38b7eb06d48b291d971a83a845
7
+ data.tar.gz: b947476fac25f3d86e90060b0fd5d8d9623ba91d3f91ed102e483a50254493178779d46e4b09b24ae2c5e5c7bbd2238eff3d145eaecc529d96bf4ef2d8897509
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'singleton'
2
4
 
3
5
  class LocaleKit::Config
@@ -12,4 +14,18 @@ class LocaleKit::Config
12
14
  @logger ||= Rails.logger
13
15
  end
14
16
  attr_writer :logger
17
+
18
+ def reload
19
+ return @reload if instance_variable_defined?(:@reload)
20
+
21
+ @reload = Rails.env.development?
22
+ end
23
+ attr_writer :reload
24
+
25
+ def verbose
26
+ return @verbose if instance_variable_defined?(:@verbose)
27
+
28
+ @verbose = Rails.env.development?
29
+ end
30
+ attr_writer :verbose
15
31
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'locale_kit/reloader'
4
+
3
5
  class LocaleKit::Engine < ::Rails::Engine
4
6
  isolate_namespace LocaleKit
5
7
 
6
- config.locale_kit = LocaleKit.config
7
-
8
8
  generators do |app|
9
9
  Rails::Generators.configure!(app.config.generators)
10
10
  require 'generators/locale_kit/override/action_controller' if defined?(ActionController)
@@ -12,7 +12,17 @@ class LocaleKit::Engine < ::Rails::Engine
12
12
  require 'generators/locale_kit/override/action_mailer' if defined?(ActionMailer)
13
13
  end
14
14
 
15
- config.to_prepare do
15
+ config.locale_kit = LocaleKit.config
16
+
17
+ initializer 'draper.setup_action_controller' do
18
+ ActiveSupport.on_load :action_controller do
19
+ instance_eval do
20
+ use(LocaleKit::Reloader) if LocaleKit.config.reload
21
+ end
22
+ end
23
+ end
24
+
25
+ config.after_initialize do |_app|
16
26
  LocaleKit.reload!
17
27
  end
18
28
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class LocaleKit::Reloader
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def call(env)
9
+ LocaleKit.reload!
10
+
11
+ @app.call(env)
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LocaleKit
4
- VERSION = '0.0.3'.freeze
4
+ VERSION = '1.0.0'.freeze
5
5
  end
data/lib/locale_kit.rb CHANGED
@@ -23,7 +23,7 @@ module LocaleKit
23
23
  I18n.load_path = (I18n.load_path + locales).uniq
24
24
  I18n.backend.reload!
25
25
 
26
- config.logger.try(:info, 'Reloaded locales by LocaleKit')
26
+ config.logger.try(:info, 'Reloaded locales by LocaleKit') if config.verbose
27
27
  end
28
28
  module_function :reload!
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locale_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -136,6 +136,7 @@ files:
136
136
  - lib/locale_kit.rb
137
137
  - lib/locale_kit/config.rb
138
138
  - lib/locale_kit/engine.rb
139
+ - lib/locale_kit/reloader.rb
139
140
  - lib/locale_kit/version.rb
140
141
  - lib/tasks/locale_kit_tasks.rake
141
142
  homepage: https://github.com/space-pirates-llc/locale_kit