gitlab-crystalball 0.7.1 → 1.1.3
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 +4 -4
- data/README.md +5 -6
- data/lib/crystalball/example_group_map.rb +2 -1
- data/lib/crystalball/execution_map.rb +1 -1
- data/lib/crystalball/logging.rb +6 -4
- data/lib/crystalball/map_generator/base_strategy.rb +26 -5
- data/lib/crystalball/map_generator/configuration.rb +10 -4
- data/lib/crystalball/map_generator/coverage_strategy/execution_detector.rb +15 -1
- data/lib/crystalball/map_generator/coverage_strategy.rb +28 -11
- data/lib/crystalball/map_generator/described_class_strategy.rb +12 -4
- data/lib/crystalball/map_generator/helpers/path_filter.rb +33 -6
- data/lib/crystalball/map_generator/object_sources_detector.rb +4 -3
- data/lib/crystalball/map_generator/oneshot_coverage_strategy.rb +39 -0
- data/lib/crystalball/map_generator/strategies_collection.rb +18 -12
- data/lib/crystalball/map_generator.rb +63 -15
- data/lib/crystalball/rails/map_generator/action_view_strategy/patch.rb +1 -1
- data/lib/crystalball/rails/map_generator/action_view_strategy.rb +15 -4
- data/lib/crystalball/rails.rb +0 -1
- data/lib/crystalball/rspec/runner/configuration.rb +1 -1
- data/lib/crystalball/version.rb +1 -1
- data/lib/crystalball.rb +1 -1
- metadata +45 -25
- data/lib/crystalball/factory_bot.rb +0 -3
- data/lib/crystalball/map_generator/allocated_objects_strategy/object_tracker.rb +0 -45
- data/lib/crystalball/map_generator/allocated_objects_strategy.rb +0 -45
- data/lib/crystalball/map_generator/factory_bot_strategy/dsl_patch/factory_path_fetcher.rb +0 -30
- data/lib/crystalball/map_generator/factory_bot_strategy/dsl_patch.rb +0 -40
- data/lib/crystalball/map_generator/factory_bot_strategy/factory_gem_loader.rb +0 -27
- data/lib/crystalball/map_generator/factory_bot_strategy/factory_runner_patch.rb +0 -25
- data/lib/crystalball/map_generator/factory_bot_strategy.rb +0 -59
- data/lib/crystalball/map_generator/parser_strategy/processor.rb +0 -129
- data/lib/crystalball/map_generator/parser_strategy.rb +0 -60
- data/lib/crystalball/rails/map_generator/i18n_strategy/simple_patch.rb +0 -89
- data/lib/crystalball/rails/map_generator/i18n_strategy.rb +0 -47
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "i18n"
|
|
4
|
-
|
|
5
|
-
module Crystalball
|
|
6
|
-
module Rails
|
|
7
|
-
class MapGenerator
|
|
8
|
-
class I18nStrategy
|
|
9
|
-
# Module to add new patched `load_file`, `store_translations` and `lookup`
|
|
10
|
-
# methods to `I18n::Backend::Simple`.
|
|
11
|
-
module SimplePatch
|
|
12
|
-
class << self
|
|
13
|
-
# Patches `I18n::Backend::Simple`.
|
|
14
|
-
def apply!
|
|
15
|
-
::I18n::Backend::Simple.class_eval do
|
|
16
|
-
include SimplePatch
|
|
17
|
-
|
|
18
|
-
%i[load_file store_translations lookup].each do |method|
|
|
19
|
-
alias_method :"cb_original_#{method}", method
|
|
20
|
-
alias_method method, :"cb_patched_#{method}"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# Reverts original behavior of `I18n::Backend::Simple`
|
|
26
|
-
def revert!
|
|
27
|
-
::I18n::Backend::Simple.class_eval do
|
|
28
|
-
%i[load_file store_translations lookup].each do |method|
|
|
29
|
-
alias_method method, :"cb_original_#{method}"
|
|
30
|
-
undef_method :"cb_patched_#{method}"
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
::I18n.reload!
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Will replace original `I18n::Backend::Simple#load_file`.
|
|
38
|
-
# Stores filename in current thread
|
|
39
|
-
def cb_patched_load_file(filename, *args)
|
|
40
|
-
Thread.current[:cb_locale_file_name] = filename
|
|
41
|
-
cb_original_load_file(filename, *args)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Will replace original `I18n::Backend::Simple#store_translations`.
|
|
45
|
-
# Adds filename for each value
|
|
46
|
-
def cb_patched_store_translations(locale, data, *args)
|
|
47
|
-
cb_add_filename_to_values(data, Thread.current[:cb_locale_file_name])
|
|
48
|
-
cb_original_store_translations(locale, data, *args)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Will replace original `I18n::Backend::Simple#lookup`.
|
|
52
|
-
# Records origin filename of each value used.
|
|
53
|
-
def cb_patched_lookup(*args)
|
|
54
|
-
value = cb_original_lookup(*args)
|
|
55
|
-
cb_remove_and_track_filename_from_values(value)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
private
|
|
59
|
-
|
|
60
|
-
def cb_add_filename_to_values(data, filename)
|
|
61
|
-
data.each do |key, value|
|
|
62
|
-
case value
|
|
63
|
-
when Hash
|
|
64
|
-
next if value.frozen?
|
|
65
|
-
|
|
66
|
-
cb_add_filename_to_values(value, filename)
|
|
67
|
-
else
|
|
68
|
-
data[key] = {cb_filename: filename, cb_value: value}.freeze
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def cb_remove_and_track_filename_from_values(data)
|
|
74
|
-
return data unless data.is_a?(Hash)
|
|
75
|
-
|
|
76
|
-
if data.key?(:cb_filename)
|
|
77
|
-
::Crystalball::Rails::MapGenerator::I18nStrategy.locale_files << data[:cb_filename]
|
|
78
|
-
return data[:cb_value]
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
data.each.with_object({}) do |(key, value), collector|
|
|
82
|
-
collector[key] = cb_remove_and_track_filename_from_values(value)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "crystalball/map_generator/base_strategy"
|
|
4
|
-
require "crystalball/map_generator/helpers/path_filter"
|
|
5
|
-
require "crystalball/rails/map_generator/i18n_strategy/simple_patch"
|
|
6
|
-
|
|
7
|
-
module Crystalball
|
|
8
|
-
module Rails
|
|
9
|
-
class MapGenerator
|
|
10
|
-
# Map generator strategy to build map of locale files used by an example.
|
|
11
|
-
class I18nStrategy
|
|
12
|
-
include ::Crystalball::MapGenerator::BaseStrategy
|
|
13
|
-
include ::Crystalball::MapGenerator::Helpers::PathFilter
|
|
14
|
-
|
|
15
|
-
class << self
|
|
16
|
-
# List of locale files affected by current example
|
|
17
|
-
#
|
|
18
|
-
# @return [Array<String>]
|
|
19
|
-
def locale_files
|
|
20
|
-
@locale_files ||= []
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Reset cached list of locale files
|
|
24
|
-
def reset_locale_files
|
|
25
|
-
@locale_files = []
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def after_register
|
|
30
|
-
SimplePatch.apply!
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def before_finalize
|
|
34
|
-
SimplePatch.revert!
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Adds to the example group map the locale files used by the example
|
|
38
|
-
# @param [Crystalball::ExampleGroupMap] example_group_map - object holding example metadata and used files
|
|
39
|
-
def call(example_group_map, _)
|
|
40
|
-
self.class.reset_locale_files
|
|
41
|
-
yield example_group_map
|
|
42
|
-
example_group_map.push(*filter(self.class.locale_files.compact))
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|