fbe 0.0.52 → 0.0.53

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: 309cd51847c028c9e80e7e40f34ed193c9583c6694ec35bd06a4527bc4953cb4
4
- data.tar.gz: 04d8f6dd7d0e2f37197b2907ae12aa13490c450e9992b03b6a751054fabf0043
3
+ metadata.gz: 14aa27f165a2c6a7ca7cdf10127ba4f6f7aa4a84272316c3098a69381f0017c5
4
+ data.tar.gz: f6a075f722a9ab583c64ddef3322eac30b3df54804fabb54c63ee6281c0455df
5
5
  SHA512:
6
- metadata.gz: 78e677d074d3578301954956d0ff7215cfe0fa214ac6872fb548e53187d4f2fc60b735c8ef3ae35826f8bae86a4d4e0dacef16e342b82073847ee65dc02960a6
7
- data.tar.gz: 50dbfc1f7c4ee42ebf47550c1c5fd6911ae0420adb715676098d756297ca0563c7c64f6d1cda03f0987df82c6b9e5c3b1b23d05acacecaf913d709f9bb4b82df
6
+ metadata.gz: 9b712ed154e715c17a54b36b8fd40d163ec176d9f6c7ba7640f4748c92c8de3cb37deb988d513cf4d9a9abb11144513b2cf67aee4a92a15013c8c89ed5fdb8e5
7
+ data.tar.gz: af7f077c96b1b1f528254b9ef084c3f71c0d0400cd4c2162e5c2ffa4f30d31abb1f2a78faa23b71e1d2633679cb52e24d4d006d21358fc13c01f5549b08a5514
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/copy.rb ADDED
@@ -0,0 +1,41 @@
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
+ def Fbe.copy(source, target)
33
+ raise 'The source is nil' if source.nil?
34
+ raise 'The target is nil' if target.nil?
35
+ source.all_properties.each do |k|
36
+ next unless target[k].nil?
37
+ source[k].each do |v|
38
+ target.send(:"#{k}=", v)
39
+ end
40
+ end
41
+ end
@@ -22,6 +22,8 @@
22
22
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  # SOFTWARE.
24
24
 
25
+ require_relative '../fbe'
26
+
25
27
  # The module.
26
28
  module Fbe::Middleware
27
29
  # empty
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.52'
30
+ VERSION = '0.0.53'
31
31
  end
@@ -0,0 +1,46 @@
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
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52
4
+ version: 0.0.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -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