fbe 0.0.52 → 0.0.54
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/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +27 -0
- data/lib/fbe/conclude.rb +0 -1
- data/lib/fbe/copy.rb +44 -0
- data/lib/fbe/middleware.rb +2 -0
- data/lib/fbe/octo.rb +200 -0
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_copy.rb +57 -0
- data/test/fbe/test_octo.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0b9b1716b7cc0b7f757fdbc023c90254d27582eba1e865e1d003a9a1b212f5
|
4
|
+
data.tar.gz: ba55f263c9a091c14ea08764bd081bc93e53e842539a9294899a5f6b760f32ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de5a40ffed186489c61661796d469c1b67a323230fb60120e4db02d6389b73e8c3d03071171dfd208e5e35813d82c05927a35f4b8e5e545507ed0e09199977a3
|
7
|
+
data.tar.gz: e2301187e03a966495eb31bd8f8ba89675ca0b78effe4f4542b04a9b03c4ce9e53f9fb31f2f0f126188187c29c9e6e06df6d562ade4e510bcae52060a816b1d5
|
data/Gemfile
CHANGED
@@ -24,7 +24,7 @@ source 'https://rubygems.org'
|
|
24
24
|
gemspec
|
25
25
|
|
26
26
|
gem 'graphql-client'
|
27
|
-
gem 'minitest', '5.25.
|
27
|
+
gem 'minitest', '5.25.1', require: false
|
28
28
|
gem 'minitest-reporters', '1.7.1', require: false
|
29
29
|
gem 'rake', '13.2.1', require: false
|
30
30
|
gem 'rspec-rails', '6.1.4', require: false
|
data/Gemfile.lock
CHANGED
@@ -141,7 +141,7 @@ GEM
|
|
141
141
|
crass (~> 1.0.2)
|
142
142
|
nokogiri (>= 1.12.0)
|
143
143
|
loog (0.6.0)
|
144
|
-
minitest (5.25.
|
144
|
+
minitest (5.25.1)
|
145
145
|
minitest-reporters (1.7.1)
|
146
146
|
ansi
|
147
147
|
builder
|
@@ -287,7 +287,7 @@ PLATFORMS
|
|
287
287
|
DEPENDENCIES
|
288
288
|
fbe!
|
289
289
|
graphql-client
|
290
|
-
minitest (= 5.25.
|
290
|
+
minitest (= 5.25.1)
|
291
291
|
minitest-reporters (= 1.7.1)
|
292
292
|
rake (= 13.2.1)
|
293
293
|
rspec-rails (= 6.1.4)
|
data/README.md
CHANGED
@@ -15,6 +15,33 @@ It's a collection of tools for
|
|
15
15
|
You are not supposed to use it directly, but only in a combination
|
16
16
|
with other tools of Zerocracy.
|
17
17
|
|
18
|
+
The following tools runs a block:
|
19
|
+
|
20
|
+
* `Fbe.regularly` runs a block of code every X days.
|
21
|
+
* `Fbe.conclude` runs a block on every fact from a query.
|
22
|
+
* `Fbe.iterate` runs a block on each repository, until it's time to stop.
|
23
|
+
* `Fbe.repeatedly` runs a block of code every X hours, leaving
|
24
|
+
a fact-marker in the factbase.
|
25
|
+
|
26
|
+
These tools help manage facts:
|
27
|
+
|
28
|
+
* `Fbe.fb` makes an entry point to the factbase.
|
29
|
+
* `Fbe.overwrite` changes a property in a fact to another value by deleting
|
30
|
+
the fact first, and then creating a new similar fact with all previous
|
31
|
+
properties but one changed.
|
32
|
+
* `Fbe.pmp` takes a PMP-related property by the area.
|
33
|
+
|
34
|
+
They help with formatting:
|
35
|
+
|
36
|
+
* `Fbe.who` formats user name.
|
37
|
+
* `Fbe.issue` formats issue number.
|
38
|
+
* `Fbe.award` calculates award by the policy.
|
39
|
+
* `Fbe.sec` formats seconds.
|
40
|
+
|
41
|
+
They help with external connections:
|
42
|
+
|
43
|
+
* `Fbe.octo` connects to GitHub API.
|
44
|
+
|
18
45
|
## How to contribute
|
19
46
|
|
20
47
|
Read
|
data/lib/fbe/conclude.rb
CHANGED
data/lib/fbe/copy.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2024 Zerocracy
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
require_relative '../fbe'
|
26
|
+
require_relative 'fb'
|
27
|
+
|
28
|
+
# Make a copy of a fact, moving all properties to a new fact.
|
29
|
+
#
|
30
|
+
# @param [Factbase::Fact] source The source
|
31
|
+
# @param [Factbase::Fact] target The targer
|
32
|
+
# @param [Array<String>] except List of properties to NOT copy
|
33
|
+
def Fbe.copy(source, target, except: [])
|
34
|
+
raise 'The source is nil' if source.nil?
|
35
|
+
raise 'The target is nil' if target.nil?
|
36
|
+
raise 'The except is nil' if except.nil?
|
37
|
+
source.all_properties.each do |k|
|
38
|
+
next unless target[k].nil?
|
39
|
+
next if except.include?(k)
|
40
|
+
source[k].each do |v|
|
41
|
+
target.send(:"#{k}=", v)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/fbe/middleware.rb
CHANGED
data/lib/fbe/octo.rb
CHANGED
@@ -498,6 +498,206 @@ class Fbe::FakeOctokit
|
|
498
498
|
},
|
499
499
|
created_at: random_time,
|
500
500
|
public: true
|
501
|
+
},
|
502
|
+
{
|
503
|
+
id: 42,
|
504
|
+
created_at: Time.now,
|
505
|
+
actor: { id: 42 },
|
506
|
+
type: 'PullRequestEvent',
|
507
|
+
repo: { id: repo },
|
508
|
+
payload: {
|
509
|
+
action: 'closed',
|
510
|
+
number: 172,
|
511
|
+
ref_type: 'tag',
|
512
|
+
ref: 'foo',
|
513
|
+
pull_request: {
|
514
|
+
url: 'https://api.github.com/repos/yegor256/judges/pulls/93',
|
515
|
+
id: 1_990_323_142,
|
516
|
+
node_id: 'PR_kwDOL6GCO852oevG',
|
517
|
+
number: 172,
|
518
|
+
state: 'closed',
|
519
|
+
locked: false,
|
520
|
+
title: '#999 new feature',
|
521
|
+
user: {
|
522
|
+
login: 'test',
|
523
|
+
id: 88_084_038,
|
524
|
+
node_id: 'MDQ6VXNlcjE2NDYwMjA=',
|
525
|
+
type: 'User',
|
526
|
+
site_admin: false
|
527
|
+
},
|
528
|
+
base: {
|
529
|
+
label: 'zerocracy:master',
|
530
|
+
ref: 'master',
|
531
|
+
user: {
|
532
|
+
login: 'zerocracy',
|
533
|
+
id: 24_234_201
|
534
|
+
},
|
535
|
+
repo: {
|
536
|
+
id: repo,
|
537
|
+
node_id: 'R_kgDOK2_4Aw',
|
538
|
+
name: 'baza',
|
539
|
+
full_name: 'zerocracy/baza',
|
540
|
+
private: false
|
541
|
+
}
|
542
|
+
},
|
543
|
+
head: {
|
544
|
+
ref: 'zerocracy/baza'
|
545
|
+
},
|
546
|
+
merged_at: Time.now,
|
547
|
+
comments: 2,
|
548
|
+
review_comments: 2,
|
549
|
+
commits: 1,
|
550
|
+
additions: 3,
|
551
|
+
deletions: 3,
|
552
|
+
changed_files: 2
|
553
|
+
}
|
554
|
+
}
|
555
|
+
}
|
556
|
+
]
|
557
|
+
end
|
558
|
+
|
559
|
+
def pull_request_comments(_name, _number)
|
560
|
+
[
|
561
|
+
{
|
562
|
+
pull_request_review_id: 2_227_372_510,
|
563
|
+
id: 1_709_082_318,
|
564
|
+
path: 'test/baza/test_locks.rb',
|
565
|
+
commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847',
|
566
|
+
original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c',
|
567
|
+
user: {
|
568
|
+
login: 'Reviewer',
|
569
|
+
id: 2_566_462
|
570
|
+
},
|
571
|
+
body: 'Most likely, parentheses were missed here.',
|
572
|
+
created_at: '2024-08-08T09:41:46Z',
|
573
|
+
updated_at: '2024-08-08T09:42:46Z',
|
574
|
+
reactions: {
|
575
|
+
url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082318/reactions',
|
576
|
+
total_count: 0
|
577
|
+
},
|
578
|
+
start_line: 'null',
|
579
|
+
original_start_line: 'null',
|
580
|
+
start_side: 'null',
|
581
|
+
line: 'null',
|
582
|
+
original_line: 62,
|
583
|
+
side: 'RIGHT',
|
584
|
+
original_position: 25,
|
585
|
+
position: 'null',
|
586
|
+
subject_type: 'line'
|
587
|
+
},
|
588
|
+
{
|
589
|
+
pull_request_review_id: 2_227_372_510,
|
590
|
+
id: 1_709_082_319,
|
591
|
+
path: 'test/baza/test_locks.rb',
|
592
|
+
commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847',
|
593
|
+
original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c',
|
594
|
+
user: {
|
595
|
+
login: 'test',
|
596
|
+
id: 88_084_038
|
597
|
+
},
|
598
|
+
body: 'definitely a typo',
|
599
|
+
created_at: '2024-08-08T09:42:46Z',
|
600
|
+
updated_at: '2024-08-08T09:42:46Z',
|
601
|
+
reactions: {
|
602
|
+
url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082319/reactions',
|
603
|
+
total_count: 0
|
604
|
+
},
|
605
|
+
start_line: 'null',
|
606
|
+
original_start_line: 'null',
|
607
|
+
start_side: 'null',
|
608
|
+
line: 'null',
|
609
|
+
original_line: 62,
|
610
|
+
side: 'RIGHT',
|
611
|
+
original_position: 25,
|
612
|
+
in_reply_to_id: 1_709_082_318,
|
613
|
+
position: 'null',
|
614
|
+
subject_type: 'line'
|
615
|
+
}
|
616
|
+
]
|
617
|
+
end
|
618
|
+
|
619
|
+
def issue_comments(_name, _number)
|
620
|
+
[
|
621
|
+
{
|
622
|
+
pull_request_review_id: 2_227_372_510,
|
623
|
+
id: 1_709_082_320,
|
624
|
+
path: 'test/baza/test_locks.rb',
|
625
|
+
commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847',
|
626
|
+
original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c',
|
627
|
+
user: {
|
628
|
+
login: 'Reviewer',
|
629
|
+
id: 2_566_462
|
630
|
+
},
|
631
|
+
body: 'reviewer comment',
|
632
|
+
created_at: '2024-08-08T09:41:46Z',
|
633
|
+
updated_at: '2024-08-08T09:42:46Z',
|
634
|
+
reactions: {
|
635
|
+
url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082320/reactions',
|
636
|
+
total_count: 1
|
637
|
+
},
|
638
|
+
start_line: 'null',
|
639
|
+
original_start_line: 'null',
|
640
|
+
start_side: 'null',
|
641
|
+
line: 'null',
|
642
|
+
original_line: 62,
|
643
|
+
side: 'RIGHT',
|
644
|
+
original_position: 25,
|
645
|
+
position: 'null',
|
646
|
+
subject_type: 'line'
|
647
|
+
},
|
648
|
+
{
|
649
|
+
pull_request_review_id: 2_227_372_510,
|
650
|
+
id: 1_709_082_321,
|
651
|
+
path: 'test/baza/test_locks.rb',
|
652
|
+
commit_id: 'a9f5f94cf28f29a64d5dd96d0ee23b4174572847',
|
653
|
+
original_commit_id: 'e8c6f94274d14ed3cb26fe71467a9c3f229df59c',
|
654
|
+
user: {
|
655
|
+
login: 'test',
|
656
|
+
id: 88_084_038
|
657
|
+
},
|
658
|
+
body: 'author comment',
|
659
|
+
created_at: '2024-08-08T09:42:46Z',
|
660
|
+
updated_at: '2024-08-08T09:42:46Z',
|
661
|
+
reactions: {
|
662
|
+
url: 'https://api.github.com/repos/zerocracy/baza/pulls/comments/1709082321/reactions',
|
663
|
+
total_count: 1
|
664
|
+
},
|
665
|
+
start_line: 'null',
|
666
|
+
original_start_line: 'null',
|
667
|
+
start_side: 'null',
|
668
|
+
line: 'null',
|
669
|
+
original_line: 62,
|
670
|
+
side: 'RIGHT',
|
671
|
+
original_position: 25,
|
672
|
+
in_reply_to_id: 1_709_082_318,
|
673
|
+
position: 'null',
|
674
|
+
subject_type: 'line'
|
675
|
+
}
|
676
|
+
]
|
677
|
+
end
|
678
|
+
|
679
|
+
def issue_comment_reactions(_name, _comment)
|
680
|
+
[
|
681
|
+
{
|
682
|
+
id: 248_923_574,
|
683
|
+
user: {
|
684
|
+
login: 'user',
|
685
|
+
id: 8_086_956
|
686
|
+
},
|
687
|
+
content: 'heart'
|
688
|
+
}
|
689
|
+
]
|
690
|
+
end
|
691
|
+
|
692
|
+
def pull_request_review_comment_reactions(_name, _comment)
|
693
|
+
[
|
694
|
+
{
|
695
|
+
id: 248_923_574,
|
696
|
+
user: {
|
697
|
+
login: 'user',
|
698
|
+
id: 8_086_956
|
699
|
+
},
|
700
|
+
content: 'heart'
|
501
701
|
}
|
502
702
|
]
|
503
703
|
end
|
data/lib/fbe.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2024 Zerocracy
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
require 'minitest/autorun'
|
26
|
+
require 'factbase'
|
27
|
+
require_relative '../test__helper'
|
28
|
+
require_relative '../../lib/fbe/copy'
|
29
|
+
|
30
|
+
# Test.
|
31
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
32
|
+
# Copyright:: Copyright (c) 2024 Zerocracy
|
33
|
+
# License:: MIT
|
34
|
+
class TestCopy < Minitest::Test
|
35
|
+
def test_simple_copy
|
36
|
+
fb = Factbase.new
|
37
|
+
f1 = fb.insert
|
38
|
+
f1._id = 1
|
39
|
+
f1.foo = 42
|
40
|
+
f2 = fb.insert
|
41
|
+
f2._id = 2
|
42
|
+
Fbe.copy(f1, f2)
|
43
|
+
assert_equal(2, f2._id)
|
44
|
+
assert_equal(42, f2.foo)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_with_except
|
48
|
+
fb = Factbase.new
|
49
|
+
f1 = fb.insert
|
50
|
+
f1._id = 1
|
51
|
+
f1.foo = 42
|
52
|
+
f2 = fb.insert
|
53
|
+
f2._id = 2
|
54
|
+
Fbe.copy(f1, f2, except: ['foo'])
|
55
|
+
assert(f2['foo'].nil?)
|
56
|
+
end
|
57
|
+
end
|
data/test/fbe/test_octo.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.54
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- lib/fbe.rb
|
241
241
|
- lib/fbe/award.rb
|
242
242
|
- lib/fbe/conclude.rb
|
243
|
+
- lib/fbe/copy.rb
|
243
244
|
- lib/fbe/fb.rb
|
244
245
|
- lib/fbe/github_graph.rb
|
245
246
|
- lib/fbe/if_absent.rb
|
@@ -261,6 +262,7 @@ files:
|
|
261
262
|
- test/fbe/middleware/test_quota.rb
|
262
263
|
- test/fbe/test_award.rb
|
263
264
|
- test/fbe/test_conclude.rb
|
265
|
+
- test/fbe/test_copy.rb
|
264
266
|
- test/fbe/test_fb.rb
|
265
267
|
- test/fbe/test_github_graph.rb
|
266
268
|
- test/fbe/test_if_absent.rb
|