bonobot 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +29 -0
- data/lib/bonobot/railtie.rb +9 -0
- data/lib/bonobot/status.rb +123 -0
- data/lib/bonobot/version.rb +5 -0
- data/lib/bonobot.rb +6 -0
- data/lib/tasks/bonobot_tasks.rake +11 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d98086bc805495c4a5928de01d918312edf9ef6ea1eb1e21c3c473f110209a8
|
4
|
+
data.tar.gz: 8f2a79bfd4c4a1e05ebc440937c685a502c48eda1908d5388203ead94b646080
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5de5eae448fce75e15c3052941e5cc4052faa63eeaed8b7bffc7ea030607d54cebcd071e414a55b3165388ff36faece8ddb1a31a6baf1121ea064c315116933
|
7
|
+
data.tar.gz: 39eda7bcded9749c6782cfde96a07c94ae257b29a4345fe2553ca4e8d1a1c99e7fde57c755eb2ddb9c8a3d5c32b601b54a96b7e3e629cf1b93627053aa957968
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2023 armandfardeau
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Bonobo
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'bonobot'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install bonobot
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "bundler/setup"
|
5
|
+
rescue LoadError
|
6
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
7
|
+
end
|
8
|
+
|
9
|
+
require "rdoc/task"
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = "rdoc"
|
13
|
+
rdoc.title = "Bonobot"
|
14
|
+
rdoc.options << "--line-numbers"
|
15
|
+
rdoc.rdoc_files.include("README.md")
|
16
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
require "bundler/gem_tasks"
|
20
|
+
|
21
|
+
require "rake/testtask"
|
22
|
+
|
23
|
+
Rake::TestTask.new(:test) do |t|
|
24
|
+
t.libs << "test"
|
25
|
+
t.pattern = "test/**/*_test.rb"
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
|
29
|
+
task default: :test
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Bonobot
|
6
|
+
class Status
|
7
|
+
def self.generate
|
8
|
+
puts "#####"
|
9
|
+
puts "🙈 🙉 🙊 Bonobot 🙈 🙉 🙊"
|
10
|
+
puts "-----"
|
11
|
+
puts "🛠Generating status.json"
|
12
|
+
File.write("status.json", JSON.pretty_generate({ rails_files: rails_files, engines_files: engines_files, overloads: overloads }))
|
13
|
+
puts File.expand_path("status.json")
|
14
|
+
puts "-----"
|
15
|
+
|
16
|
+
unless up_to_date.empty?
|
17
|
+
puts "🥳 Up to date fingerprint count: #{up_to_date.count}"
|
18
|
+
puts "-> Up to date fingerprint: #{up_to_date}"
|
19
|
+
puts ""
|
20
|
+
end
|
21
|
+
|
22
|
+
unless out_of_date.empty?
|
23
|
+
puts "😱 Out of date fingerprint count: #{out_of_date.count}"
|
24
|
+
puts "-> Out of date fingerprint: #{out_of_date}"
|
25
|
+
puts ""
|
26
|
+
end
|
27
|
+
|
28
|
+
unless missing.empty?
|
29
|
+
puts "🤬 Files missing fingerprint count: #{missing.count}"
|
30
|
+
puts "-> Missing fingerprint: #{missing}"
|
31
|
+
puts ""
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "-----"
|
35
|
+
puts "#####"
|
36
|
+
|
37
|
+
out_of_date.empty? && missing.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.out_of_date
|
41
|
+
overloads.fetch(:out_of_date, [])
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.up_to_date
|
45
|
+
overloads.fetch(:up_to_date, [])
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.missing
|
49
|
+
overloads.fetch(:missing, [])
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.overloads
|
53
|
+
@overloads ||= rails_files.each_with_object({}) do |(path, fingerprint), hash|
|
54
|
+
engines_files.keys.each do |engine_name|
|
55
|
+
next unless path.include? engine_name
|
56
|
+
|
57
|
+
source_path = engines_files[engine_name].fetch(path, nil)
|
58
|
+
next unless source_path
|
59
|
+
|
60
|
+
result = [engine_name, source_path]
|
61
|
+
|
62
|
+
key = status_key(source_path[:fingerprint], fingerprint)
|
63
|
+
if hash[key].nil?
|
64
|
+
hash[key] = [result]
|
65
|
+
else
|
66
|
+
hash[key] << result
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.rails_files
|
73
|
+
@rails_files ||= Dir.glob(Rails.root.join("app", "**", "*.{erb,rb}")).map { |path| path.sub("#{Rails.root}/", "") }.each_with_object({}) do |path, hash|
|
74
|
+
hash[path] = read_annotation(path)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.engines_files
|
79
|
+
@engine_files ||= ::Rails::Engine.subclasses.each_with_object({}) do |klass, hash|
|
80
|
+
paths = Dir.glob("#{klass.instance.root}/app/**/*.{erb,rb}")
|
81
|
+
next if paths.empty?
|
82
|
+
|
83
|
+
hash[engine_to_gem(klass)] = engine_paths(paths)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.engine_to_gem(engine_class)
|
88
|
+
if engine_class.respond_to?(:railtie_namespace) && engine_class.railtie_namespace
|
89
|
+
engine_class.railtie_namespace.to_s.split("::").map(&:underscore).join("/")
|
90
|
+
else
|
91
|
+
engine_class.engine_name.sub("_engine", "")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.engine_paths(paths)
|
96
|
+
paths.each_with_object({}) do |path, hash|
|
97
|
+
_name, *short_path = path.sub("#{gems_dir}/gems/", "").split("/")
|
98
|
+
hash[short_path.join("/")] = { path: path, fingerprint: fingerprint(path) }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.fingerprint(path)
|
103
|
+
Digest::MD5.hexdigest(File.read(path))
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.gems_dir
|
107
|
+
@gems_dir ||= Bundler.rubygems.gem_dir
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.read_annotation(path)
|
111
|
+
File.readlines(path).map do |line|
|
112
|
+
line.sub(/# bonobo_fingerprint:/, "").sub("<%", "").sub("%>", "").strip if line.match?(/# bonobo_fingerprint:/) || line.match?(/<%# bonobo_fingerprint:/)
|
113
|
+
end.compact.first
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.status_key(source_fingerprint, target_fingerprint)
|
117
|
+
return :up_to_date if source_fingerprint == target_fingerprint
|
118
|
+
return :missing if target_fingerprint.nil?
|
119
|
+
|
120
|
+
:out_of_date
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/bonobot.rb
ADDED
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bonobot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- armandfardeau
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.30'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.30'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-faker
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.11.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.11.1
|
83
|
+
description: Description of Bonobot.
|
84
|
+
email:
|
85
|
+
- fardeauarmand@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.md
|
92
|
+
- Rakefile
|
93
|
+
- lib/bonobot.rb
|
94
|
+
- lib/bonobot/railtie.rb
|
95
|
+
- lib/bonobot/status.rb
|
96
|
+
- lib/bonobot/version.rb
|
97
|
+
- lib/tasks/bonobot_tasks.rake
|
98
|
+
homepage: https://github.com/armandfardeau/bonobo
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.5.0
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubygems_version: 3.3.5
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Summary of Bonobot.
|
121
|
+
test_files: []
|