bonobot 0.0.9 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e09dd5420ba03ab108dd23316f5171ad5f402d0075af929391b40b6ca4cf066c
4
- data.tar.gz: 6ec4202d42ee696375c4377da3c957ff1b67fe4a92dbe8c2a3361a523e21cf64
3
+ metadata.gz: 5cb9e5c0eaac02524d810bf6f59774cd16437e09a5c0e588996aa80826d4b371
4
+ data.tar.gz: dc0b5858278ba66cb75db9839853bfc4a0c25a29667d768761b1ebe46b0b3d01
5
5
  SHA512:
6
- metadata.gz: b37d57570d73e78dfecb0a5e65ed4171552593b81f1588418cc3653d24133aff4468831cda0a293c3b249d2faebd5cdcd2ae7632af6ca7ad3e6f79805979c0cb
7
- data.tar.gz: a368a1f128a152fd0928057a6b4e564b1a79d3913a80db48bb8a05b2a14a25c9c0bb5c630722668cd22f87cfaf80c34309bd37dae98da3d335f493e3bba4f0a4
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.9"
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.9
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
@@ -176,8 +176,7 @@ files:
176
176
  homepage: https://github.com/armandfardeau/bonobo
177
177
  licenses:
178
178
  - MIT
179
- metadata:
180
- documentation_uri: https://github.com/armandfardeau/bonobo
179
+ metadata: {}
181
180
  post_install_message:
182
181
  rdoc_options: []
183
182
  require_paths: