yalphabetize 0.10.0 → 0.11.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: b2b58ea00743bea3a0a4ca4ef92caa428ced099cdf28bf4caa37bf7214333ade
4
- data.tar.gz: b8c5d394eaf0aef402e4cab38dd1018560950e36488fb60537f9fa48c201985b
3
+ metadata.gz: 620d06de0e383ed3e49a6878958f5fceef74ce7ed12d50e179110ebddb5c9fb3
4
+ data.tar.gz: 85e47f431754b89bfe3ac0b67d46f77f4f1467b351607e8289e9a1b142772ad5
5
5
  SHA512:
6
- metadata.gz: 54d23c05ae16c9eaa72b1f14a817618dbee8e116a0b24d46f08bbfc7ea009ad449e784f8ad07d24f159446deed6382bb7f403393ca45287d16ce740f3ec157b4
7
- data.tar.gz: 731ca71c870831cd1d5b848f46a7d9e93c924d4e76304624762f7ff28c03e1d4eb4144e647ce059d3ce3315c3a48b29553d6e349f150be9777e6f2e4d41471af
6
+ metadata.gz: c388188a52fec11ef2a15c547845ddc213d3a8a2d7b8db0cd972d5e9aa22b8ac78216e812ade4006b77c1e49de7300c84f767f6f4ed5fb951acd602c73859cca
7
+ data.tar.gz: a8ed2b327a0542514b9bc419b07daa0a7c982fb0ad0f62da9a2292d45243661eb66149b379eb925984ed54bc97b11a2296d1a86f4527781f42ba0707d77984d4
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Key length | File length | No of files | Iterations | Benchmark (s)
4
+ bundle exec bin/performance_test 1 1 1 250 0.06 &&
5
+ bundle exec bin/performance_test 1 1 10000 50 0.41 &&
6
+ bundle exec bin/performance_test 1 100000 1 60 0.41 &&
7
+ bundle exec bin/performance_test 1 1000 1000 12 2.6 &&
8
+ bundle exec bin/performance_test 1024 1 1 250 0.06 &&
9
+ bundle exec bin/performance_test 1024 1 40000 12 1.9 &&
10
+ bundle exec bin/performance_test 1024 100000 1 30 1.1 &&
11
+ bundle exec bin/performance_test 1024 800 340 12 2.3
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'benchmark'
5
+ require 'fileutils'
6
+ require 'securerandom'
7
+ require 'yalphabetize'
8
+
9
+ key_length = ARGV[0].to_i
10
+ file_length = ARGV[1].to_i
11
+ number_of_files = ARGV[2].to_i
12
+ iterations = ARGV[3].to_i
13
+ expected = ARGV[4].to_f
14
+
15
+ def suppress_output
16
+ original_stdout = $stdout.clone
17
+ $stdout.reopen(File.new(File::NULL, 'w'))
18
+ yield
19
+ ensure
20
+ $stdout.reopen(original_stdout)
21
+ end
22
+
23
+ puts "Running performance test:\n\n"
24
+ puts "key_length: #{key_length}"
25
+ puts "file_length: #{file_length}"
26
+ puts "number_of_files: #{number_of_files}"
27
+ puts "iterations: #{iterations}"
28
+ puts "expected: #{expected}\n\n"
29
+
30
+ fixtures_dir = "performance/fixtures/#{key_length}_#{file_length}_#{number_of_files}"
31
+
32
+ if !Dir.exist?(fixtures_dir) && !ENV['CI']
33
+ FileUtils.makedirs(fixtures_dir)
34
+
35
+ number_of_files.times do |i|
36
+ yaml = ''
37
+ file_length.times do
38
+ yaml += "#{SecureRandom.alphanumeric(key_length)}: VALUE\n"
39
+ end
40
+
41
+ puts "#{i.fdiv(number_of_files) * 100}% of files written"
42
+
43
+ File.write("#{fixtures_dir}/#{i + 1}.yml", yaml)
44
+ end
45
+ end
46
+
47
+ if !Dir.exist?(fixtures_dir) && ENV['CI']
48
+ puts "Could not find fixtures directory #{fixtures_dir}"
49
+ exit 1
50
+ end
51
+
52
+ times = []
53
+
54
+ suppress_output do
55
+ iterations.times do
56
+ times << Benchmark.measure do
57
+ Yalphabetize::CLI.call([fixtures_dir])
58
+ end.real
59
+ end
60
+ end
61
+
62
+ sorted_times = times.sort
63
+ duration = times.sum
64
+ p50 = sorted_times[iterations / 2]
65
+
66
+ if p50 > expected
67
+ puts 'FAILED'
68
+ puts "Duration: #{duration}"
69
+ puts "P50: #{p50}"
70
+ exit 1
71
+ else
72
+ puts "Duration: #{duration}"
73
+ puts "p50: #{p50}\n\n\n"
74
+ end
@@ -2,37 +2,36 @@
2
2
 
3
3
  module Yalphabetize
4
4
  class Logger
5
- DEFAULT_OUTPUT = $stdout
5
+ DEFAULT_OUTPUT = Kernel
6
6
 
7
- def initialize(output = DEFAULT_OUTPUT)
8
- @output = output
7
+ def initialize
9
8
  @inspected_count = 0
10
9
  @offences = {}
11
10
  end
12
11
 
13
12
  def initial_summary(file_paths)
14
- output.puts "Inspecting #{file_paths.size} YAML files"
13
+ DEFAULT_OUTPUT.puts "Inspecting #{file_paths.size} YAML files"
15
14
  end
16
15
 
17
16
  def log_offence(file_path)
18
17
  self.inspected_count += 1
19
18
  offences[file_path] = :detected
20
- output.print red 'O'
19
+ DEFAULT_OUTPUT.print red 'O'
21
20
  end
22
21
 
23
22
  def log_no_offence
24
23
  self.inspected_count += 1
25
- output.print green '.'
24
+ DEFAULT_OUTPUT.print green '.'
26
25
  end
27
26
 
28
27
  def final_summary
29
- output.puts "\nInspected: #{inspected_count}"
30
- output.puts send(list_offences_color, "Offences: #{offences.size}")
28
+ DEFAULT_OUTPUT.puts "\nInspected: #{inspected_count}"
29
+ DEFAULT_OUTPUT.puts send(list_offences_color, "Offences: #{offences.size}")
31
30
 
32
31
  offences.each { |file_path, status| puts_offence(file_path, status) }
33
32
  return unless uncorrected_offences?
34
33
 
35
- output.puts 'Offences can be automatically fixed with `-a` or `--autocorrect`'
34
+ DEFAULT_OUTPUT.puts 'Offences can be automatically fixed with `-a` or `--autocorrect`'
36
35
  end
37
36
 
38
37
  def uncorrected_offences?
@@ -45,15 +44,15 @@ module Yalphabetize
45
44
 
46
45
  private
47
46
 
48
- attr_reader :offences, :output
47
+ attr_reader :offences
49
48
  attr_accessor :inspected_count
50
49
 
51
50
  def puts_offence(file_path, status)
52
51
  case status
53
52
  when :detected
54
- output.puts yellow file_path
53
+ DEFAULT_OUTPUT.puts yellow file_path
55
54
  when :corrected
56
- output.puts("#{yellow(file_path)} #{green('CORRECTED')}")
55
+ DEFAULT_OUTPUT.puts("#{yellow(file_path)} #{green('CORRECTED')}")
57
56
  end
58
57
  end
59
58
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yalphabetize
4
4
  class Version
5
- STRING = '0.10.0'
5
+ STRING = '0.11.0'
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ module Yalphabetize
25
25
  process_paths(paths)
26
26
  end
27
27
 
28
- files.flatten.select { |file| valid?(file) }.map { |f| File.expand_path(f) }.uniq
28
+ files.flatten.select { |file| valid?(file) }.uniq
29
29
  end
30
30
 
31
31
  private
@@ -56,7 +56,7 @@ module Yalphabetize
56
56
  '--exclude-standard', '--others', '--cached', '--modified'
57
57
  )
58
58
 
59
- output.split("\0").uniq.map { |git_file| "#{Dir.pwd}/#{git_file}" } if status.success?
59
+ output.split("\0").uniq if status.success?
60
60
  end
61
61
 
62
62
  def valid?(path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yalphabetize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Jenkins
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-23 00:00:00.000000000 Z
11
+ date: 2024-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych-comments
@@ -24,13 +24,15 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description:
28
- email:
27
+ description:
28
+ email:
29
29
  executables:
30
30
  - yalphabetize
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - bin/performance_local
35
+ - bin/performance_test
34
36
  - bin/yalphabetize
35
37
  - lib/yalphabetize.rb
36
38
  - lib/yalphabetize/aliaser.rb
@@ -54,13 +56,11 @@ files:
54
56
  - lib/yalphabetize/writer.rb
55
57
  - lib/yalphabetize/yalphabetizer.rb
56
58
  - lib/yalphabetize/yaml_finder.rb
57
- homepage:
59
+ homepage:
58
60
  licenses: []
59
61
  metadata:
60
62
  rubygems_mfa_required: 'true'
61
- post_install_message: |
62
- yalphabetize 0.10.0 now supports YAML comments!
63
- For more info: https://github.com/samrjenkins/yalphabetize?tab=readme-ov-file#preserve_comments
63
+ post_install_message:
64
64
  rdoc_options: []
65
65
  require_paths:
66
66
  - lib
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubygems_version: 3.3.27
79
- signing_key:
79
+ signing_key:
80
80
  specification_version: 4
81
81
  summary: Alphabetize your YAML files
82
82
  test_files: []