bonobot 0.0.8 ā†’ 0.0.10

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: cc132231e160106724b3171093853b83eea9b0822e0d4b54dfc8e86a8b07ccd6
4
- data.tar.gz: b6f885310d0d98cd3ba7ee46959dd4a76763b7840da8fb13c71e4f16f13c86c8
3
+ metadata.gz: 5cb9e5c0eaac02524d810bf6f59774cd16437e09a5c0e588996aa80826d4b371
4
+ data.tar.gz: dc0b5858278ba66cb75db9839853bfc4a0c25a29667d768761b1ebe46b0b3d01
5
5
  SHA512:
6
- metadata.gz: 9a7562360338162a0fddb51bd0e00b17fe066f957eedc2209f8010d3a22762452ee8cb349887ff73d181deca5abb20349964878e6c5d1d4dc4ebb0ec9306dd4c
7
- data.tar.gz: a1c88acb9a0b4b271b611663295bd116e49efc7e9d90f5d8f3301836d97e625d36a9dd8ac613f8f9b06b68bc78d63364622a76a983691fe8642af2b402a507a5
6
+ metadata.gz: 9805b50c084da6db7e6b593e3e86cfe6af985f5d799355163d0239f70c9c67027a42cf4330c7736d11ebf24e38866075b5426531476f145e5178cd23fe93f4bc
7
+ data.tar.gz: aaf8b17b178404a4d78aa7cec759b6136245ac29b3512e01ef5bcf5663a1cd4c21895746ce3b9b8b4b558bf01ce3ef84248b85683a23dfb6ea8cccc5540c8cac
data/README.md CHANGED
@@ -15,6 +15,7 @@ bundle exec rake bonobot: status
15
15
  bundle exec rake bonobot:status:out_of_date
16
16
  bundle exec rake bonobot:status:up_to_date
17
17
  bundle exec rake bonobot:update_out_of_date
18
+ bundle exec rake bonobot:unused
18
19
  ```
19
20
 
20
21
  ### Add missing
@@ -14,6 +14,7 @@ module Bonobot
14
14
  end
15
15
 
16
16
  def status
17
+ return :unused if @engine_file.nil?
17
18
  return :missing if @local_file.annotation.nil?
18
19
  return :up_to_date if @local_file.annotation == @engine_file.fingerprint
19
20
 
@@ -4,10 +4,17 @@ module Bonobot
4
4
  module OverloadsRegistry
5
5
  def self.all
6
6
  @all ||= LocalFilesRegistry.all.flat_map do |local_file|
7
- EnginesFilesRegistry.find_by(short_path: local_file.path).map do |engine_file|
8
- Overload.new(local_file, engine_file)
7
+ next if local_file.nil? || local_file.annotation.nil?
8
+
9
+ engines_files = EnginesFilesRegistry.find_by(short_path: local_file.path)
10
+ if engines_files.empty?
11
+ Overload.new(local_file, nil)
12
+ else
13
+ engines_files.map do |engine_file|
14
+ Overload.new(local_file, engine_file)
15
+ end
9
16
  end
10
- end
17
+ end.compact
11
18
  end
12
19
 
13
20
  # TODO: Extract to module
@@ -22,5 +29,9 @@ module Bonobot
22
29
  def self.output
23
30
  all.map(&:as_json)
24
31
  end
32
+
33
+ def self.reload
34
+ @all = nil
35
+ end
25
36
  end
26
37
  end
@@ -4,52 +4,80 @@ require "json"
4
4
 
5
5
  module Bonobot
6
6
  class Status
7
- STATUS = { up_to_date: "šŸ„³", out_of_date: "šŸ˜±", missing: "šŸ¤¬" }.freeze
7
+ STATUS = { up_to_date: "šŸ„³", out_of_date: "šŸ˜±", unused: "šŸ˜…", missing: "šŸ¤¬" }.freeze
8
+ STATUS_FILE_PATH = "status.json"
8
9
 
9
10
  def self.generate(status = nil)
10
- puts "-----"
11
- puts "šŸ™ˆ šŸ™‰ šŸ™Š Bonobot šŸ™ˆ šŸ™‰ šŸ™Š"
12
- puts "-----"
13
- puts "šŸ›  Generating status"
14
- File.write("status.json", status_json)
15
- puts File.expand_path("status.json")
16
- puts "-----"
17
-
18
- if status
19
- generate_status(status.to_sym, STATUS[status.to_sym])
20
- else
21
- STATUS.each do |status_type, emoji|
22
- generate_status(status_type, emoji)
23
- end
24
- end
11
+ new(status).generate
12
+ end
25
13
 
26
- puts "-----"
27
- OverloadsRegistry.find_by(status: :out_of_date).empty? && OverloadsRegistry.find_by(status: :missing).empty?
14
+ def initialize(status)
15
+ @status = status
16
+ end
17
+
18
+ def generate
19
+ generate_status_file
20
+ puts display_banner
21
+ return_status_code
28
22
  end
29
23
 
30
- def self.present(entries)
24
+ def present(entries)
31
25
  entries.map do |entry|
32
- " - #{entry.engine_file.engine_name}: #{entry.engine_file.short_path} (#{entry.engine_file.fingerprint})"
26
+ if entry.engine_file.nil?
27
+ " - #{entry.path} (unused)"
28
+ else
29
+ " - #{entry.engine_file.engine_name}: #{entry.engine_file.short_path} (#{entry.engine_file.fingerprint})"
30
+ end
33
31
  end.join("\n")
34
32
  end
35
33
 
36
- def self.generate_status(status, emoji)
37
- return if OverloadsRegistry.find_by(status: status).empty?
38
-
34
+ def generate_status(status, emoji)
39
35
  overload_status = OverloadsRegistry.find_by(status: status)
40
36
  status_to_text = status.to_s.capitalize.gsub("_", " ")
41
37
 
42
- puts "-> #{emoji} #{status_to_text} fingerprint (#{overload_status.count}):"
43
- puts present(OverloadsRegistry.find_by(status: status))
44
- puts ""
38
+ if overload_status.empty?
39
+ ["-> #{emoji} #{status_to_text} : All good! \n"]
40
+ else
41
+ ["-> #{emoji} #{status_to_text} fingerprint (#{overload_status.count}):", present(OverloadsRegistry.find_by(status: status)), ""]
42
+ end
45
43
  end
46
44
 
47
- def self.status_json
45
+ def status_json
48
46
  JSON.pretty_generate({
49
47
  rails_files: LocalFilesRegistry.output,
50
48
  engines_files: EnginesFilesRegistry.output,
51
49
  overloads: OverloadsRegistry.output
52
50
  })
53
51
  end
52
+
53
+ def generate_status_file
54
+ File.write(STATUS_FILE_PATH, status_json)
55
+ end
56
+
57
+ def display_banner
58
+ [display_intro + display_status.join("\n") + display_outro].join("\n")
59
+ end
60
+
61
+ def display_intro
62
+ "-----\nšŸ™ˆ šŸ™‰ šŸ™Š Bonobot šŸ™ˆ šŸ™‰ šŸ™Š\n-----\n\nšŸ›  Generating status\n#{File.expand_path("status.json")}\n-----\n\n"
63
+ end
64
+
65
+ def display_status
66
+ if @status
67
+ generate_status(@status.to_sym, STATUS[@status.to_sym])
68
+ else
69
+ STATUS.map do |status_type, emoji|
70
+ generate_status(status_type, emoji)
71
+ end
72
+ end
73
+ end
74
+
75
+ def display_outro
76
+ "\n-----"
77
+ end
78
+
79
+ def return_status_code
80
+ OverloadsRegistry.find_by(status: :out_of_date).empty? && OverloadsRegistry.find_by(status: :missing).empty?
81
+ end
54
82
  end
55
83
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bonobot
4
- VERSION = "0.0.8"
4
+ VERSION = "0.0.10"
5
5
  end
@@ -26,6 +26,11 @@ namespace :bonobot do
26
26
  end
27
27
 
28
28
  task uptodate: :up_to_date
29
+
30
+ desc "Generate status for unused"
31
+ task unused: :environment do
32
+ Bonobot::Status.generate(:unused)
33
+ end
29
34
  end
30
35
 
31
36
  desc "Add missing fingerprint to local files"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bonobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - armandfardeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel