factory_trace 0.4.1 → 1.0.1

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
  SHA256:
3
- metadata.gz: 8a89ea162c1549be94964cbcdb8e0815c01d7e1b510844d928fde97e9b6f1008
4
- data.tar.gz: 631b6277e162570d9d9fb12e23d60cf87fb1a3f615b8afed208b14f6bfaf5159
3
+ metadata.gz: 47392b8b4b5bd8c329e7068531793ea4773d086fcc44cc1a700e58f9b67c658d
4
+ data.tar.gz: 17043ec1bbd6684fc8f0d9259439b3c767ec9748535168c37733c983094dd9da
5
5
  SHA512:
6
- metadata.gz: ee92060fadd43f146477fc7faeaed89157637b37460f5d84db4565112e3f52d1cbf08fbcac4431243e5e59375530cabe361a977b02fe101bf8d56e88005f5108
7
- data.tar.gz: e60fb845b869986c1400ab1c9803c860e0bdcaa2360d626fb15ec268dfeb24763438a275c50417e3635e729a6a7e527bac36e1f4e165636dcf5b14ab7c934304
6
+ metadata.gz: 90c73bd445d000bb676337b831829b5cfa83e46690676e4af6635e85d1536475d4b742b75ed09216a564b452318a2c86a3548849bded0f328002577ebba32c3f
7
+ data.tar.gz: 174df9d321cde04ddb59892e389b9aa80b76f4a601c0ecefac48f350384bfa42cdd59815812096e7bb73fb13ad567513cf03de834de230780a0af0155ea4e698
data/exe/factory_trace CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH.unshift("#{__dir__}/../lib")
4
- require 'factory_trace'
5
+ require "factory_trace"
5
6
 
6
7
  fail "You should pass at least one file with traced information.\nYou can generate it using only_trace mode." if ARGV.empty?
7
8
 
8
9
  config = FactoryTrace.configuration
9
10
  hash = FactoryTrace::Readers::TraceReader.read_from_files(*ARGV)
10
11
  reports = FactoryTrace::Processors::FindUnused.call(hash[:defined], hash[:used])
11
- code = reports.any? { |report| report[:code] == :unused && !report.key?(:value) } ? 1 : 0
12
+ code = (reports.any? { |report| report[:code] == :unused && !report.key?(:value) }) ? 1 : 0
12
13
 
13
14
  FactoryTrace::Writers::ReportWriter.new(config.out, config).write(reports)
14
15
  exit(code)
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  class Configuration
3
5
  attr_accessor :path, :enabled, :color, :mode, :trace_definition
4
6
 
5
7
  def initialize
6
- @enabled = ENV.key?('FB_TRACE') || ENV.key?('FB_TRACE_FILE')
7
- @path = ENV['FB_TRACE_FILE']
8
+ @enabled = ENV.key?("FB_TRACE") || ENV.key?("FB_TRACE_FILE")
9
+ @path = ENV["FB_TRACE_FILE"]
8
10
  @color = path.nil?
9
- @mode = extract_mode(ENV['FB_TRACE']) || :full
11
+ @mode = extract_mode(ENV["FB_TRACE"]) || :full
10
12
  @trace_definition = true
11
13
  end
12
14
 
@@ -15,9 +17,9 @@ module FactoryTrace
15
17
  end
16
18
 
17
19
  def out
18
- return STDOUT unless path
20
+ return $stdout unless path
19
21
 
20
- File.open(path, 'w')
22
+ File.open(path, "w")
21
23
  end
22
24
 
23
25
  def mode?(*args)
@@ -27,7 +29,7 @@ module FactoryTrace
27
29
  private
28
30
 
29
31
  def extract_mode(value)
30
- matcher = value && value.match(/full|trace_only/)
32
+ matcher = value&.match(/full|trace_only/)
31
33
  matcher && matcher[0].to_sym
32
34
  end
33
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Helpers
3
5
  module Caller
@@ -5,7 +7,7 @@ module FactoryTrace
5
7
 
6
8
  # @return [String] file and line where the original method was called
7
9
  def location
8
- location = caller_locations[1]
10
+ location = caller_locations(2..2).first
9
11
 
10
12
  base = Pathname.new(Dir.pwd)
11
13
  method = Pathname.new(location.path)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Helpers
3
5
  module Converter
@@ -32,7 +34,7 @@ module FactoryTrace
32
34
  # @return [Array<String>]
33
35
  def extract_declarations(structure)
34
36
  (structure.definition.declarations.grep(FactoryBot::Declaration::Implicit).map(&:name).map(&:to_s) +
35
- structure.definition.instance_variable_get(:'@base_traits').map(&:to_s)).uniq
37
+ structure.definition.instance_variable_get(:@base_traits).map(&:to_s)).uniq
36
38
  end
37
39
  end
38
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Helpers
3
5
  module Statusable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module MonkeyPatches
3
5
  module DefinitionProxy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module MonkeyPatches
3
5
  module Default
@@ -6,7 +8,7 @@ module FactoryTrace
6
8
  caller_location = options.delete(:caller_location) || Helpers::Caller.location
7
9
  factory = FactoryBot::Factory.new(name, caller_location, options)
8
10
  proxy = FactoryBot::DefinitionProxy.new(factory.definition)
9
- proxy.instance_eval(&block) if block_given?
11
+ proxy.instance_eval(&block) if block
10
12
 
11
13
  REGISTER.register_factory(factory)
12
14
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module MonkeyPatches
3
5
  module Factory
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module MonkeyPatches
3
- REGISTER = FactoryBot::VERSION >= '5.1.0' ? FactoryBot::Internal : FactoryBot
5
+ REGISTER = (FactoryBot::VERSION >= "5.1.0") ? FactoryBot::Internal : FactoryBot
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module MonkeyPatches
3
5
  module Trait
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Preprocessors
3
5
  class ExtractDefined
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Preprocessors
3
5
  class ExtractUsed
@@ -1,117 +1,120 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Processors
3
5
  class FindUnused
4
- # Finds unused factories and traits
5
- #
6
- # @param [FactoryTrace::Structures::Collection] defined
7
- # @param [FactoryTrace::Structures::Collection] used
8
- #
9
- # @return [Array<Hash>]
10
- def self.call(defined, used)
11
- mark_as_used(defined, used)
12
-
13
- output = []
14
-
15
- defined.factories.each do |factory|
16
- output << append_definition_path({code: :unused, factory_names: factory.names}, factory) unless factory.status
17
-
18
- factory.traits.each do |trait|
19
- output << append_definition_path({code: :unused, factory_names: factory.names, trait_name: trait.name}, trait) unless trait.status
6
+ class << self
7
+ # Finds unused factories and traits
8
+ #
9
+ # @param [FactoryTrace::Structures::Collection] defined
10
+ # @param [FactoryTrace::Structures::Collection] used
11
+ #
12
+ # @return [Array<Hash>]
13
+ def call(defined, used)
14
+ mark_as_used(defined, used)
15
+
16
+ output = []
17
+
18
+ defined.factories.each do |factory|
19
+ output << append_definition_path({code: :unused, factory_names: factory.names}, factory) unless factory.status
20
+
21
+ factory.traits.each do |trait|
22
+ output << append_definition_path({code: :unused, factory_names: factory.names, trait_name: trait.name}, trait) unless trait.status
23
+ end
20
24
  end
21
- end
22
25
 
23
- defined.traits.each do |trait|
24
- output << append_definition_path({code: :unused, trait_name: trait.name}, trait) unless trait.status
25
- end
26
+ defined.traits.each do |trait|
27
+ output << append_definition_path({code: :unused, trait_name: trait.name}, trait) unless trait.status
28
+ end
26
29
 
27
- output.unshift(code: :unused, value: output.size)
28
- output.unshift(code: :used, value: defined.total - (output.size - 1))
30
+ output.unshift(code: :unused, value: output.size)
31
+ output.unshift(code: :used, value: defined.total - (output.size - 1))
29
32
 
30
- output
31
- end
33
+ output
34
+ end
32
35
 
33
- private
36
+ private
34
37
 
35
- # @param [FactoryTrace::Structures::Collection] defined
36
- # @param [FactoryTrace::Structures::Collection] used
37
- def self.mark_as_used(defined, used)
38
- used.factories.each do |used_factory|
39
- defined_factory = defined.find_factory_by_names(used_factory.names)
40
- mark_factory(defined_factory, defined, status: :used)
38
+ # @param [FactoryTrace::Structures::Collection] defined
39
+ # @param [FactoryTrace::Structures::Collection] used
40
+ def mark_as_used(defined, used)
41
+ used.factories.each do |used_factory|
42
+ defined_factory = defined.find_factory_by_names(used_factory.names)
43
+ mark_factory(defined_factory, defined, status: :used)
41
44
 
42
- used_factory.traits.each do |used_trait|
43
- trait_owner, defined_trait = defined_trait_by_name(defined, used_factory, used_trait.name)
44
- mark_trait(defined_trait, trait_owner, defined, status: :used)
45
+ used_factory.traits.each do |used_trait|
46
+ trait_owner, defined_trait = defined_trait_by_name(defined, used_factory, used_trait.name)
47
+ mark_trait(defined_trait, trait_owner, defined, status: :used)
48
+ end
45
49
  end
46
50
  end
47
- end
48
51
 
49
- # @param [FactoryTrace::Structures::Collection] defined
50
- # @param [FactoryTrace::Structures::Factory|nil] factory
51
- # @param [String] trait_name
52
- #
53
- # @return [Array<Object>]
54
- def self.defined_trait_by_name(defined, factory, trait_name)
55
- if factory
56
- possible_owner = defined.find_factory_by_names(factory.names)
57
-
58
- while possible_owner
59
- if (trait = possible_owner.traits.find { |t| t.name == trait_name })
60
- return [possible_owner, trait]
52
+ # @param [FactoryTrace::Structures::Collection] defined
53
+ # @param [FactoryTrace::Structures::Factory|nil] factory
54
+ # @param [String] trait_name
55
+ #
56
+ # @return [Array<Object>]
57
+ def defined_trait_by_name(defined, factory, trait_name)
58
+ if factory
59
+ possible_owner = defined.find_factory_by_names(factory.names)
60
+
61
+ while possible_owner
62
+ if (trait = possible_owner.traits.find { |t| t.name == trait_name })
63
+ return [possible_owner, trait]
64
+ end
65
+ possible_owner = defined.find_factory_by_names([possible_owner.parent_name])
61
66
  end
62
- possible_owner = defined.find_factory_by_names([possible_owner.parent_name])
63
67
  end
64
- end
65
68
 
69
+ [nil, defined.find_trait_by_name(trait_name)]
70
+ end
66
71
 
67
- [nil, defined.find_trait_by_name(trait_name)]
68
- end
69
-
70
- # @param [FactoryTrace::Structures::Factory] factory
71
- # @param [FactoryTrace::Structures::Collection] collection
72
- # @param [Symbol] status
73
- def self.mark_factory(factory, collection, status:)
74
- return if factory.has_prioritized_status?(status)
72
+ # @param [FactoryTrace::Structures::Factory] factory
73
+ # @param [FactoryTrace::Structures::Collection] collection
74
+ # @param [Symbol] status
75
+ def mark_factory(factory, collection, status:)
76
+ return if factory.has_prioritized_status?(status)
75
77
 
76
- factory.status = status
77
- if (parent = collection.find_factory_by_names([factory.parent_name]))
78
- mark_factory(parent, collection, status: :indirectly_used)
78
+ factory.status = status
79
+ if (parent = collection.find_factory_by_names([factory.parent_name]))
80
+ mark_factory(parent, collection, status: :indirectly_used)
81
+ end
82
+ mark_declarations(factory.declaration_names, factory, collection, status: :indirectly_used)
79
83
  end
80
- mark_declarations(factory.declaration_names, factory, collection, status: :indirectly_used)
81
- end
82
84
 
83
- # @param [FactoryTrace::Structures::Trait] trait
84
- # @param [FactoryTrace::Structures::Factory|nil] factory which trait belongs to
85
- # @param [FactoryTrace::Structures::Collection] collection
86
- # @param [Symbol] status
87
- def self.mark_trait(trait, factory, collection, status:)
88
- return if trait.has_prioritized_status?(status)
85
+ # @param [FactoryTrace::Structures::Trait] trait
86
+ # @param [FactoryTrace::Structures::Factory|nil] factory which trait belongs to
87
+ # @param [FactoryTrace::Structures::Collection] collection
88
+ # @param [Symbol] status
89
+ def mark_trait(trait, factory, collection, status:)
90
+ return if trait.has_prioritized_status?(status)
89
91
 
90
- trait.status = status
91
- mark_declarations(trait.declaration_names, factory, collection, status: :indirectly_used)
92
- end
92
+ trait.status = status
93
+ mark_declarations(trait.declaration_names, factory, collection, status: :indirectly_used)
94
+ end
93
95
 
94
- # @param [Array<String>] declaration_names
95
- # @param [FactoryTrace::Structures::Factory|nil] factory
96
- # @param [FactoryTrace::Structures::Collection] collection
97
- # @param [Symbol] status
98
- def self.mark_declarations(declaration_names, factory, collection, status:)
99
- declaration_names.each do |declaration_name|
100
- declaration_factory = collection.find_factory_by_names([declaration_name])
101
- next mark_factory(declaration_factory, collection, status: status) if declaration_factory
102
-
103
- declaration_factory, declaration_trait = defined_trait_by_name(collection, factory, declaration_name)
104
- mark_trait(declaration_trait, declaration_factory, collection, status: status) if declaration_trait
96
+ # @param [Array<String>] declaration_names
97
+ # @param [FactoryTrace::Structures::Factory|nil] factory
98
+ # @param [FactoryTrace::Structures::Collection] collection
99
+ # @param [Symbol] status
100
+ def mark_declarations(declaration_names, factory, collection, status:)
101
+ declaration_names.each do |declaration_name|
102
+ declaration_factory = collection.find_factory_by_names([declaration_name])
103
+ next mark_factory(declaration_factory, collection, status: status) if declaration_factory
104
+
105
+ declaration_factory, declaration_trait = defined_trait_by_name(collection, factory, declaration_name)
106
+ mark_trait(declaration_trait, declaration_factory, collection, status: status) if declaration_trait
107
+ end
105
108
  end
106
- end
107
109
 
108
- # @param [Hash]
109
- # @param [FactoryTrace::Structures::Factory|FactoryTrace::Structures::Trait]
110
- #
111
- # @return [Hash]
112
- def self.append_definition_path(hash, object)
113
- hash[:definition_path] = object.definition_path if object.definition_path
114
- hash
110
+ # @param [Hash]
111
+ # @param [FactoryTrace::Structures::Factory|FactoryTrace::Structures::Trait]
112
+ #
113
+ # @return [Hash]
114
+ def append_definition_path(hash, object)
115
+ hash[:definition_path] = object.definition_path if object.definition_path
116
+ hash
117
+ end
115
118
  end
116
119
  end
117
120
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Readers
3
5
  class TraceReader
@@ -10,7 +12,7 @@ module FactoryTrace
10
12
  result = {defined: FactoryTrace::Structures::Collection.new, used: FactoryTrace::Structures::Collection.new}
11
13
 
12
14
  file_names.each do |file_name|
13
- File.open(file_name, 'r') do |file|
15
+ File.open(file_name, "r") do |file|
14
16
  data = new(file, configuration: configuration).read
15
17
 
16
18
  [:defined, :used].each do |key|
@@ -34,35 +36,35 @@ module FactoryTrace
34
36
  hash = JSON.parse(io.read)
35
37
 
36
38
  {
37
- defined: parse_collection(hash['defined']),
38
- used: parse_collection(hash['used'])
39
+ defined: parse_collection(hash["defined"]),
40
+ used: parse_collection(hash["used"])
39
41
  }
40
42
  end
41
43
 
42
44
  private
43
45
 
44
46
  def parse_trait(hash)
45
- FactoryTrace::Structures::Trait.new(hash['name'], declaration_names: hash['declaration_names'], definition_path: hash['definition_path'])
47
+ FactoryTrace::Structures::Trait.new(hash["name"], declaration_names: hash["declaration_names"], definition_path: hash["definition_path"])
46
48
  end
47
49
 
48
50
  def parse_factory(hash)
49
51
  FactoryTrace::Structures::Factory.new(
50
- hash['names'],
51
- hash['traits'].map(&method(:parse_trait)),
52
- parent_name: hash['parent_name'],
53
- declaration_names: hash['declaration_names'],
54
- definition_path: hash['definition_path']
52
+ hash["names"],
53
+ hash["traits"].map(&method(:parse_trait)),
54
+ parent_name: hash["parent_name"],
55
+ declaration_names: hash["declaration_names"],
56
+ definition_path: hash["definition_path"]
55
57
  )
56
58
  end
57
59
 
58
60
  def parse_collection(hash)
59
61
  collection = FactoryTrace::Structures::Collection.new
60
62
 
61
- hash['factories'].each do |h|
63
+ hash["factories"].each do |h|
62
64
  collection.add(parse_factory(h))
63
65
  end
64
66
 
65
- hash['traits'].each do |h|
67
+ hash["traits"].each do |h|
66
68
  collection.add(parse_trait(h))
67
69
  end
68
70
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Structures
3
5
  class Collection
@@ -69,10 +71,10 @@ module FactoryTrace
69
71
  end
70
72
 
71
73
  # @return [Boolean]
72
- def ==(collection)
73
- return false unless collection.is_a?(FactoryTrace::Structures::Collection)
74
+ def ==(other)
75
+ return false unless other.is_a?(FactoryTrace::Structures::Collection)
74
76
 
75
- factories == collection.factories && traits == collection.traits
77
+ factories == other.factories && traits == other.traits
76
78
  end
77
79
  end
78
80
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Structures
3
5
  class Factory
@@ -39,14 +41,14 @@ module FactoryTrace
39
41
  end
40
42
 
41
43
  # @return [Boolean]
42
- def ==(factory)
43
- return false unless factory.is_a?(FactoryTrace::Structures::Factory)
44
+ def ==(other)
45
+ return false unless other.is_a?(FactoryTrace::Structures::Factory)
44
46
 
45
- names == factory.names &&
46
- traits == factory.traits &&
47
- parent_name == factory.parent_name &&
48
- declaration_names == factory.declaration_names &&
49
- definition_path == factory.definition_path
47
+ names == other.names &&
48
+ traits == other.traits &&
49
+ parent_name == other.parent_name &&
50
+ declaration_names == other.declaration_names &&
51
+ definition_path == other.definition_path
50
52
  end
51
53
  end
52
54
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Structures
3
5
  class Trait
@@ -24,10 +26,10 @@ module FactoryTrace
24
26
  end
25
27
 
26
28
  # @return [Boolean]
27
- def ==(trait)
28
- return false unless trait.is_a?(FactoryTrace::Structures::Trait)
29
+ def ==(other)
30
+ return false unless other.is_a?(FactoryTrace::Structures::Trait)
29
31
 
30
- name == trait.name && declaration_names == trait.declaration_names && definition_path == trait.definition_path
32
+ name == other.name && declaration_names == other.declaration_names && definition_path == other.definition_path
31
33
  end
32
34
  end
33
35
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+
1
5
  module FactoryTrace
2
6
  class Tracker
3
7
  attr_reader :storage
@@ -7,7 +11,7 @@ module FactoryTrace
7
11
  end
8
12
 
9
13
  def track!
10
- ActiveSupport::Notifications.subscribe('factory_bot.run_factory') do |_name, _start, _finish, _id, payload|
14
+ ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |_name, _start, _finish, _id, payload|
11
15
  name = payload[:name].to_s
12
16
  traits = payload[:traits].map(&:to_s)
13
17
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
- VERSION = '0.4.1'
4
+ VERSION = "1.0.1"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Writers
3
5
  class ReportWriter < Writer
@@ -9,13 +11,13 @@ module FactoryTrace
9
11
  }.freeze
10
12
 
11
13
  CODES = {
12
- used: 'used',
13
- unused: 'unused',
14
+ used: "used",
15
+ unused: "unused"
14
16
  }.freeze
15
17
 
16
18
  # @param [Array<Hash>] results
17
19
  def write(results)
18
- total_color = results.any? { |result| result[:code] == :unused && !result.key?(:value) } ? :red : :green
20
+ total_color = (results.any? { |result| result[:code] == :unused && !result.key?(:value) }) ? :red : :green
19
21
 
20
22
  results.each do |result|
21
23
  io.puts(convert(result, total_color: total_color))
@@ -27,12 +29,11 @@ module FactoryTrace
27
29
  # @param [Hash<Symbol, Object>] result
28
30
  # @param [Symbol] total_color
29
31
  def convert(result, total_color:)
30
- case
31
- when result[:value]
32
+ if result[:value]
32
33
  colorize(total_color, "total number of unique #{humanize_code(result[:code])} factories & traits: #{result[:value]}")
33
- when result[:factory_names] && result[:trait_name]
34
+ elsif result[:factory_names] && result[:trait_name]
34
35
  append_definition_path(result) { "#{humanize_code(result[:code])} trait #{colorize(:blue, result[:trait_name])} of factory #{list(result[:factory_names])}" }
35
- when result[:factory_names]
36
+ elsif result[:factory_names]
36
37
  append_definition_path(result) { "#{humanize_code(result[:code])} factory #{list(result[:factory_names])}" }
37
38
  else
38
39
  append_definition_path(result) { "#{humanize_code(result[:code])} global trait #{colorize(:blue, result[:trait_name])}" }
@@ -57,7 +58,7 @@ module FactoryTrace
57
58
  end
58
59
 
59
60
  def list(elements, color: :blue)
60
- elements.map { |element| colorize(color, element) }.join(', ')
61
+ elements.map { |element| colorize(color, element) }.join(", ")
61
62
  end
62
63
  end
63
64
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Writers
3
5
  class TraceWriter < Writer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FactoryTrace
2
4
  module Writers
3
5
  class Writer
data/lib/factory_trace.rb CHANGED
@@ -1,38 +1,40 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # External dependencies
2
- require 'factory_bot'
3
- require 'json'
4
- require 'set'
5
- require 'pathname'
4
+ require "factory_bot"
5
+ require "json"
6
+ require "set"
7
+ require "pathname"
6
8
  # Library
7
- require 'factory_trace/configuration'
8
- require 'factory_trace/version'
9
- require 'factory_trace/helpers/converter'
10
- require 'factory_trace/helpers/statusable'
11
- require 'factory_trace/helpers/caller'
12
- require 'factory_trace/tracker'
9
+ require "factory_trace/configuration"
10
+ require "factory_trace/version"
11
+ require "factory_trace/helpers/converter"
12
+ require "factory_trace/helpers/statusable"
13
+ require "factory_trace/helpers/caller"
14
+ require "factory_trace/tracker"
13
15
 
14
- require 'factory_trace/structures/factory'
15
- require 'factory_trace/structures/trait'
16
- require 'factory_trace/structures/collection'
16
+ require "factory_trace/structures/factory"
17
+ require "factory_trace/structures/trait"
18
+ require "factory_trace/structures/collection"
17
19
 
18
- require 'factory_trace/preprocessors/extract_defined'
19
- require 'factory_trace/preprocessors/extract_used'
20
+ require "factory_trace/preprocessors/extract_defined"
21
+ require "factory_trace/preprocessors/extract_used"
20
22
 
21
- require 'factory_trace/processors/find_unused'
23
+ require "factory_trace/processors/find_unused"
22
24
 
23
- require 'factory_trace/readers/trace_reader'
24
- require 'factory_trace/writers/writer'
25
- require 'factory_trace/writers/report_writer'
26
- require 'factory_trace/writers/trace_writer'
25
+ require "factory_trace/readers/trace_reader"
26
+ require "factory_trace/writers/writer"
27
+ require "factory_trace/writers/report_writer"
28
+ require "factory_trace/writers/trace_writer"
27
29
 
28
- require 'factory_trace/monkey_patches/monkey_patches'
29
- require 'factory_trace/monkey_patches/factory'
30
- require 'factory_trace/monkey_patches/trait'
31
- require 'factory_trace/monkey_patches/definition_proxy'
32
- require 'factory_trace/monkey_patches/dsl'
30
+ require "factory_trace/monkey_patches/monkey_patches"
31
+ require "factory_trace/monkey_patches/factory"
32
+ require "factory_trace/monkey_patches/trait"
33
+ require "factory_trace/monkey_patches/definition_proxy"
34
+ require "factory_trace/monkey_patches/dsl"
33
35
 
34
36
  # Integrations
35
- require 'integrations/rspec' if defined?(RSpec::Core)
37
+ require "integrations/rspec" if defined?(RSpec::Core)
36
38
 
37
39
  module FactoryTrace
38
40
  class << self
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.configure do |config|
2
4
  config.before(:suite) { FactoryTrace.start }
3
5
  config.after(:suite) { FactoryTrace.stop }
4
6
  end
5
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_trace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - djezzzl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-06 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_junit_formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.4'
69
83
  description:
70
84
  email:
71
85
  - lawliet.djez@gmail.com
@@ -101,7 +115,8 @@ files:
101
115
  homepage: https://github.com/djezzzl/factory_trace
102
116
  licenses:
103
117
  - MIT
104
- metadata: {}
118
+ metadata:
119
+ funding_uri: https://opencollective.com/factory_trace#support
105
120
  post_install_message:
106
121
  rdoc_options: []
107
122
  require_paths:
@@ -117,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
132
  - !ruby/object:Gem::Version
118
133
  version: '0'
119
134
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.7.9
135
+ rubygems_version: 3.2.33
122
136
  signing_key:
123
137
  specification_version: 4
124
138
  summary: Provide an easy way to maintain factories and traits from FactoryBot