factory_bot_profile 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: d2edd21eb175a104b5ba7ab51adff07b1925d6d42a6c64ca5208f11d8dc3e4d6
4
- data.tar.gz: 178a9cdace27bb6af0c568fa574a02e680af692fd105a55faacf79401f5e9a47
3
+ metadata.gz: 29043f7c22b70be6456a1de2560643e054b64af118d40a258107215542944e8b
4
+ data.tar.gz: 334aac68ce12a573f8fa8ede825ff9a0f1c3f53da1f8d6e22b5c6332d6434204
5
5
  SHA512:
6
- metadata.gz: 178512dae69fcfc88995f67caa1b025484ecfa2e4ea9be844619107c069285e25714fd806b516cfd58517e536b9ef7a546f5f6cd1ad663f6ecf17703dd8d210f
7
- data.tar.gz: fcf87824d84100ce20355a21a391bd17ddebbb80b81830940a635ccfa9ecd2f1098bfbb51a63bcc36a1ddae36fb71c00c8618d15ad13118416c96328a3ecbcc0
6
+ metadata.gz: a7553d19dbf8a004f00d8a4c938ad78a7824f7c0abc05b31936d0f1c917f973bc252ed1edcb3e635d97e716e911e6363f297f13bbfea51abd16cfaca31c2ef09
7
+ data.tar.gz: 96adfb65631249f4fa345eefea5d04844e0b9a04bc1bf54541b8e754ea4dbb733ea0c7ba9a6da37e5b739066bb1e07ba06cd4f4b39378ed2868b9335ef15af5c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-07-19
3
+ ## [0.2.0] - 2023-01-24
4
+
5
+ - Added: configuration for how many factories SimpleReport should list (#6)
6
+ - Added: arbitrary configuration forwarded to the report class (#6)
7
+ - Fixed: Homepage link
8
+
9
+ ## [0.1.0] - 2022-10-24
4
10
 
5
11
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- factory_bot_profile (0.1.0)
4
+ factory_bot_profile (0.2.0)
5
5
  factory_bot (>= 6.2.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4)
10
+ activesupport (7.0.4.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  ast (2.4.2)
16
- concurrent-ruby (1.1.10)
16
+ concurrent-ruby (1.2.0)
17
17
  diff-lcs (1.5.0)
18
18
  factory_bot (6.2.1)
19
19
  activesupport (>= 5.0.0)
20
20
  i18n (1.12.0)
21
21
  concurrent-ruby (~> 1.0)
22
22
  json (2.6.2)
23
- minitest (5.16.3)
23
+ minitest (5.17.0)
24
24
  parallel (1.22.1)
25
25
  parser (3.1.2.1)
26
26
  ast (~> 2.4.1)
@@ -1,9 +1,10 @@
1
1
  module FactoryBotProfile
2
2
  module Report
3
3
  class SimpleReport
4
- def initialize(stats, io: $stdout)
4
+ def initialize(stats, io: $stdout, count: 3)
5
5
  @stats = stats
6
6
  @io = io
7
+ @count = count
7
8
  end
8
9
 
9
10
  def deliver
@@ -13,7 +14,7 @@ module FactoryBotProfile
13
14
  io.puts " Spent #{stats.total_time.round(2)} seconds in factory_bot"
14
15
  io.puts
15
16
  io.puts " Factories taking the most time overall:"
16
- stats.highest_total_time(3).each do |stat|
17
+ stats.highest_total_time(count).each do |stat|
17
18
  io.puts " - :#{stat.name} factory took #{stat.total_time.round(2)} seconds overall (ran #{stat.count} times)"
18
19
  stat.child_stats_by_total_time.reverse_each do |child_stat|
19
20
  io.puts " - #{child_stat.total_time.round(2)} seconds spent in :#{child_stat.name} (ran #{child_stat.count}/#{stat.count} times)"
@@ -22,7 +23,7 @@ module FactoryBotProfile
22
23
  end
23
24
  io.puts
24
25
  io.puts " Slowest factories on average:"
25
- stats.highest_average_time(3).each do |stat|
26
+ stats.highest_average_time(count).each do |stat|
26
27
  io.puts " - :#{stat.name} factory took #{stat.average_time.round(2)} seconds on average (ran #{stat.count} times)"
27
28
  stat.child_stats_by_average_time.reverse_each do |child_stat|
28
29
  io.puts " - #{child_stat.average_time.round(2)} seconds spent in :#{child_stat.name} on average (ran #{child_stat.count}/#{stat.count} times)"
@@ -31,14 +32,14 @@ module FactoryBotProfile
31
32
  end
32
33
  io.puts
33
34
  io.puts " Most used factories:"
34
- stats.highest_count(5).each do |stat|
35
+ stats.highest_count(count).each do |stat|
35
36
  io.puts " - :#{stat.name} factory ran #{stat.count} times"
36
37
  end
37
38
  end
38
39
 
39
40
  private
40
41
 
41
- attr_reader :stats, :io
42
+ attr_reader :stats, :io, :count
42
43
  end
43
44
  end
44
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FactoryBotProfile
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -22,12 +22,12 @@ module FactoryBotProfile
22
22
  Subscription.new(stats).subscribe
23
23
  end
24
24
 
25
- def self.report(stats, reporter: Report::SimpleReport, io: $stdout)
26
- reporter.new(stats, io: io).deliver if stats
25
+ def self.report(stats, reporter: Report::SimpleReport, **options)
26
+ reporter.new(stats, **options).deliver if stats
27
27
  end
28
28
 
29
- def self.merge_and_report(all_stats, reporter: Report::SimpleReport, io: $stdout)
29
+ def self.merge_and_report(all_stats, reporter: Report::SimpleReport, **options)
30
30
  merged_stats = all_stats.reduce(AggregateStats.new, &:merge!)
31
- report(merged_stats, reporter: reporter, io: io)
31
+ report(merged_stats, reporter: reporter, **options)
32
32
  end
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot_profile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Colson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-24 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot
@@ -40,7 +40,6 @@ files:
40
40
  - LICENSE.txt
41
41
  - README.md
42
42
  - Rakefile
43
- - factory_bot_profile.gemspec
44
43
  - lib/factory_bot_profile.rb
45
44
  - lib/factory_bot_profile/aggregate_stats.rb
46
45
  - lib/factory_bot_profile/frame.rb
@@ -50,7 +49,7 @@ files:
50
49
  - lib/factory_bot_profile/subscriber.rb
51
50
  - lib/factory_bot_profile/subscription.rb
52
51
  - lib/factory_bot_profile/version.rb
53
- homepage: https://github.com/composerinterali/factory_bot_profile
52
+ homepage: https://github.com/composerinteralia/factory_bot_profile
54
53
  licenses:
55
54
  - MIT
56
55
  metadata: {}
@@ -69,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
68
  - !ruby/object:Gem::Version
70
69
  version: '0'
71
70
  requirements: []
72
- rubygems_version: 3.3.7
71
+ rubygems_version: 3.4.1
73
72
  signing_key:
74
73
  specification_version: 4
75
74
  summary: Profiling for factory_bot
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/factory_bot_profile/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "factory_bot_profile"
7
- spec.version = FactoryBotProfile::VERSION
8
- spec.authors = ["Daniel Colson"]
9
- spec.email = ["danieljamescolson@gmail.com"]
10
-
11
- spec.summary = "Profiling for factory_bot"
12
- spec.homepage = "https://github.com/composerinterali/factory_bot_profile"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.0.0"
15
-
16
- # Specify which files should be added to the gem when it is released.
17
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(__dir__) do
19
- `git ls-files -z`.split("\x0").reject do |f|
20
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
21
- end
22
- end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
26
-
27
- spec.add_dependency "factory_bot", ">= 6.2.1"
28
- end