weeler 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +16 -0
- data/Gemfile +0 -7
- data/app/assets/javascripts/weeler/init.js +0 -2
- data/app/assets/stylesheets/weeler/style.css.scss +7 -1
- data/app/controllers/weeler/seo_items_controller.rb +3 -2
- data/app/controllers/weeler/settings_controller.rb +27 -9
- data/app/controllers/weeler/static_sections_controller.rb +2 -2
- data/app/controllers/weeler/translations_controller.rb +4 -18
- data/app/models/setting.rb +7 -0
- data/app/views/weeler/base/_footer.html.haml +1 -1
- data/app/views/weeler/settings/_form.html.haml +16 -0
- data/app/views/weeler/settings/index.html.haml +5 -8
- data/app/views/weeler/static_sections/show.html.haml +5 -1
- data/app/views/weeler/translations/_form.html.haml +5 -2
- data/app/views/weeler/translations/index.html.haml +0 -10
- data/lib/generators/weeler/templates/assets/javascripts/weeler/app/index.js +3 -1
- data/lib/generators/weeler/templates/assets/stylesheets/weeler/app/index.css +1 -1
- data/lib/i18n/backend/weeler/exporter.rb +32 -14
- data/lib/i18n/backend/weeler/importer.rb +59 -57
- data/lib/i18n/backend/weeler.rb +14 -25
- data/lib/weeler/action_dispatch/routing/mapper.rb +1 -2
- data/lib/weeler/action_view/helpers/translation_helper.rb +2 -2
- data/lib/weeler/version.rb +1 -1
- data/lib/weeler.rb +6 -1
- data/spec/.DS_Store +0 -0
- data/spec/controllers/translations_controller_spec.rb +1 -1
- data/spec/dummy/.ruby-version +1 -1
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/db/schema.rb +3 -3
- data/spec/fixtures/test_2020_format.xlsx +0 -0
- data/spec/weeler/i18n/backend/weeler/exporter_spec.rb +6 -0
- data/spec/weeler/i18n/backend/weeler/importer_spec.rb +17 -6
- data/spec/weeler/i18n/backend/weeler_spec.rb +51 -66
- data/weeler.gemspec +4 -5
- metadata +22 -37
- data/app/models/settings.rb +0 -2
- data/app/views/weeler/translations/usage_stats.html.haml +0 -34
- data/lib/generators/weeler/templates/migrations/create_weeler_translation_stats.rb +0 -11
- data/lib/i18n/backend/weeler/usage_logger.rb +0 -35
- data/spec/weeler/i18n/backend/weeler/usage_logger_spec.rb +0 -34
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
module I18n
|
4
|
-
module Backend
|
5
|
-
class Weeler
|
6
|
-
|
7
|
-
module UsageLogger
|
8
|
-
|
9
|
-
def log_key_usage(locale, key)
|
10
|
-
existing = i18n_cache.read([:usage_stats, [locale, key]])
|
11
|
-
value = existing.present? ? (existing.to_i + 1) : 1
|
12
|
-
i18n_cache.write [:usage_stats, [locale, key]], value
|
13
|
-
end
|
14
|
-
|
15
|
-
def dump_key_usage
|
16
|
-
already_dumped = i18n_cache.read([:dump_usage_stats, Process.pid]).present?
|
17
|
-
unless already_dumped
|
18
|
-
Weeler::Lock.acquire('usage_stats_dump') do
|
19
|
-
i18n_cache.instance_variable_get(:@data).keys.each do |key|
|
20
|
-
if key.start_with?('usage_stats')
|
21
|
-
translation_stat = TranslationStat.find_or_create_by(key: key.gsub('usage_stats/en/', ''))
|
22
|
-
translation_stat.usage_count += i18n_cache.read(key).to_i
|
23
|
-
translation_stat.save!
|
24
|
-
end
|
25
|
-
end
|
26
|
-
i18n_cache.write [:dump_usage_stats, Process.pid], Process.pid
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Weeler.send(:include, UsageLogger)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe I18n::Backend::Weeler::UsageLogger do
|
4
|
-
before(:each) do
|
5
|
-
Settings.log_key_usage = 'true'
|
6
|
-
@backend_cache = I18n.backend.backends[0].i18n_cache
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "1. #log_key_usage" do
|
10
|
-
|
11
|
-
it "logs key to cache store" do
|
12
|
-
I18n.t('random.key.count')
|
13
|
-
expect(@backend_cache.read([:usage_stats, [I18n.locale, 'random.key.count']])).to eq(1)
|
14
|
-
I18n.t('random.key.count')
|
15
|
-
expect(@backend_cache.read([:usage_stats, [I18n.locale, 'random.key.count']])).to eq(2)
|
16
|
-
I18n.t('random.key.count')
|
17
|
-
expect(@backend_cache.read([:usage_stats, [I18n.locale, 'random.key.count']])).to eq(3)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "2. #dump_key_usage" do
|
23
|
-
|
24
|
-
it "dumps stats to database" do
|
25
|
-
I18n.t('random.key_dump')
|
26
|
-
I18n.t('random.key_dump')
|
27
|
-
I18n.t('random.key_dump')
|
28
|
-
Settings.log_key_usage = 'dump'
|
29
|
-
I18n.t('random.key_dump')
|
30
|
-
expect(I18n::Backend::Weeler::TranslationStat.find_by(key: 'random.key_dump').try(:usage_count)).to eq(3)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|