bonobot 0.0.6 → 0.0.8
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 +4 -4
- data/README.md +18 -9
- data/lib/bonobot/annotator.rb +52 -0
- data/lib/bonobot/files_op.rb +32 -0
- data/lib/bonobot/status.rb +7 -3
- data/lib/bonobot/version.rb +1 -1
- data/lib/bonobot.rb +2 -0
- data/lib/tasks/bonobot_tasks.rake +34 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc132231e160106724b3171093853b83eea9b0822e0d4b54dfc8e86a8b07ccd6
|
4
|
+
data.tar.gz: b6f885310d0d98cd3ba7ee46959dd4a76763b7840da8fb13c71e4f16f13c86c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a7562360338162a0fddb51bd0e00b17fe066f957eedc2209f8010d3a22762452ee8cb349887ff73d181deca5abb20349964878e6c5d1d4dc4ebb0ec9306dd4c
|
7
|
+
data.tar.gz: a1c88acb9a0b4b271b611663295bd116e49efc7e9d90f5d8f3301836d97e625d36a9dd8ac613f8f9b06b68bc78d63364622a76a983691fe8642af2b402a507a5
|
data/README.md
CHANGED
@@ -5,30 +5,39 @@
|
|
5
5
|
BonoBot is a Ruby gem that helps with Rails monkey patching.
|
6
6
|
|
7
7
|
## Usage
|
8
|
-
|
8
|
+
### Status
|
9
|
+
#### Generate all status:
|
9
10
|
```bash
|
10
11
|
bundle exec rake bonobot: status
|
11
12
|
```
|
13
|
+
#### Generate a specific status:
|
14
|
+
```bash
|
15
|
+
bundle exec rake bonobot:status:out_of_date
|
16
|
+
bundle exec rake bonobot:status:up_to_date
|
17
|
+
bundle exec rake bonobot:update_out_of_date
|
18
|
+
```
|
12
19
|
|
13
|
-
|
20
|
+
### Add missing
|
21
|
+
```bash
|
22
|
+
bundle exec rake bonobot:add_missing
|
23
|
+
```
|
14
24
|
|
25
|
+
### Update out of date
|
26
|
+
```bash
|
27
|
+
bundle exec rake bonobot:update_out_of_date
|
28
|
+
```
|
29
|
+
|
30
|
+
## Installation
|
15
31
|
Add this line to your application's Gemfile:
|
16
32
|
|
17
33
|
```ruby
|
18
34
|
gem 'bonobot'
|
19
35
|
```
|
20
36
|
|
21
|
-
And then execute:
|
22
|
-
|
23
|
-
```bash
|
24
|
-
bundle exec rake bonobot:status
|
25
|
-
```
|
26
|
-
|
27
37
|
Or install it yourself as:
|
28
38
|
|
29
39
|
```bash
|
30
40
|
gem install bonobot
|
31
|
-
bundle exec rake bonobot:status
|
32
41
|
```
|
33
42
|
|
34
43
|
## Contributing
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bonobot
|
4
|
+
class Annotator
|
5
|
+
def self.add_annotation(path, fingerprint)
|
6
|
+
new(path, fingerprint).add_annotation
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.update_annotation(path, fingerprint)
|
10
|
+
new(path, fingerprint).update_annotation
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(path, fingerprint)
|
14
|
+
@path = path
|
15
|
+
@fingerprint = fingerprint
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_annotation
|
19
|
+
f = File.read(@path).split("\n")
|
20
|
+
|
21
|
+
if f.first == "# frozen_string_literal: true"
|
22
|
+
f.insert(1, "\n#{annotation}")
|
23
|
+
else
|
24
|
+
f.insert(0, "\n#{annotation}")
|
25
|
+
end
|
26
|
+
|
27
|
+
File.write(@path, "#{f.join("\n")}\n")
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_annotation
|
31
|
+
f = File.read(@path).split("\n")
|
32
|
+
|
33
|
+
f.each_with_index do |line, index|
|
34
|
+
f[index] = annotation if match_line(line)
|
35
|
+
end
|
36
|
+
|
37
|
+
File.write(@path, "#{f.join("\n")}\n")
|
38
|
+
end
|
39
|
+
|
40
|
+
def annotation
|
41
|
+
if @path.to_s.end_with?(".erb")
|
42
|
+
"<%# bonobot_fingerprint: #{@fingerprint} %>"
|
43
|
+
else
|
44
|
+
"# bonobot_fingerprint: #{@fingerprint}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def match_line(line)
|
49
|
+
line.include?("# bonobot_fingerprint") || line.include?("<%# bonobot_fingerprint")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bonobot/overloads_registry"
|
4
|
+
require "bonobot/annotator"
|
5
|
+
|
6
|
+
module Bonobot
|
7
|
+
class FilesOp
|
8
|
+
def self.missing
|
9
|
+
OverloadsRegistry.find_by(status: :missing)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.out_of_date
|
13
|
+
OverloadsRegistry.find_by(status: :out_of_date)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.add_missing
|
17
|
+
missing.each do |overload|
|
18
|
+
Annotator.add_annotation(root.join(overload.path), overload.engine_file.fingerprint)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.update_out_of_date
|
23
|
+
out_of_date.each do |overload|
|
24
|
+
Annotator.update_annotation(root.join(overload.path), overload.engine_file.fingerprint)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.root
|
29
|
+
::Rails.root
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/bonobot/status.rb
CHANGED
@@ -6,7 +6,7 @@ module Bonobot
|
|
6
6
|
class Status
|
7
7
|
STATUS = { up_to_date: "🥳", out_of_date: "😱", missing: "🤬" }.freeze
|
8
8
|
|
9
|
-
def self.generate
|
9
|
+
def self.generate(status = nil)
|
10
10
|
puts "-----"
|
11
11
|
puts "🙈 🙉 🙊 Bonobot 🙈 🙉 🙊"
|
12
12
|
puts "-----"
|
@@ -15,8 +15,12 @@ module Bonobot
|
|
15
15
|
puts File.expand_path("status.json")
|
16
16
|
puts "-----"
|
17
17
|
|
18
|
-
|
19
|
-
generate_status(status,
|
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
|
20
24
|
end
|
21
25
|
|
22
26
|
puts "-----"
|
data/lib/bonobot/version.rb
CHANGED
data/lib/bonobot.rb
CHANGED
@@ -6,4 +6,38 @@ namespace :bonobot do
|
|
6
6
|
status = Bonobot::Status.generate
|
7
7
|
exit 1 unless status
|
8
8
|
end
|
9
|
+
|
10
|
+
namespace :status do
|
11
|
+
desc "Generate status for out of date"
|
12
|
+
task out_of_date: :environment do
|
13
|
+
Bonobot::Status.generate(:out_of_date)
|
14
|
+
end
|
15
|
+
|
16
|
+
task outdated: :out_of_date
|
17
|
+
|
18
|
+
desc "Generate status for missing"
|
19
|
+
task missing: :environment do
|
20
|
+
Bonobot::Status.generate(:missing)
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Generate status for up to date"
|
24
|
+
task up_to_date: :environment do
|
25
|
+
Bonobot::Status.generate(:up_to_date)
|
26
|
+
end
|
27
|
+
|
28
|
+
task uptodate: :up_to_date
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Add missing fingerprint to local files"
|
32
|
+
task add_missing: :environment do
|
33
|
+
Bonobot::FilesOp.add_missing
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Update out of date fingerprint to local files"
|
37
|
+
task update_out_of_date: :environment do
|
38
|
+
Bonobot::FilesOp.update_out_of_date
|
39
|
+
end
|
40
|
+
|
41
|
+
task update_outdated: :update_out_of_date
|
42
|
+
task update: :update_out_of_date
|
9
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- armandfardeau
|
@@ -161,8 +161,10 @@ files:
|
|
161
161
|
- README.md
|
162
162
|
- Rakefile
|
163
163
|
- lib/bonobot.rb
|
164
|
+
- lib/bonobot/annotator.rb
|
164
165
|
- lib/bonobot/engine_file.rb
|
165
166
|
- lib/bonobot/engines_files_registry.rb
|
167
|
+
- lib/bonobot/files_op.rb
|
166
168
|
- lib/bonobot/local_file.rb
|
167
169
|
- lib/bonobot/local_files_registry.rb
|
168
170
|
- lib/bonobot/overload.rb
|