factbase 0.0.43 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a44a8cee031e25c222a2953ad01a064927c97f57639d494a170223956521a5b3
4
- data.tar.gz: fe5ddd0ad80092930b245ab03766f6dc6ea75c77acc3b501daed17a36ff6a793
3
+ metadata.gz: f50658ed4f005f217ac62d0d7915a02bda424b81b27b8fd28c04d72a87720f42
4
+ data.tar.gz: 96593b68ec2ead36739708e150794a640786f76bb015476a90f80814f0f211fb
5
5
  SHA512:
6
- metadata.gz: fec97a8470185dcfc528154847d84de2130e89bdbff91ed26a37744e536fe4b3b5613c40049c5924ec0f84ad9e11f625a611e346551217c261535dbdbdc02466
7
- data.tar.gz: 9a39a69321538139bbb86975434e4dcb184d12fa970db1edf63607cb4bceaf67d69c3ad4559693a633e41577a0b489bc73e8080708cf07d22e0e33daad6ff36c
6
+ metadata.gz: 5595f2de94f831ed456771bfbf52efb86b2c3e29be426923dadcdee51389983ef2bedd2e41cdccb5246b91682cc7bb47164f7bf8adefbd2cf08f76812e8412a7
7
+ data.tar.gz: ccbf0464b43eb277c497e27f3827c7cd3051fc94e34c727c4c258d3a999d717a600635eda52c62a874165eb3bf7804a0665edbe1bdaf7eca47aa1e568db9bc17
@@ -18,40 +18,13 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
  ---
21
- name: license
21
+ name: copyrights
22
22
  'on':
23
23
  push:
24
- branches:
25
- - master
26
24
  pull_request:
27
- branches:
28
- - master
29
25
  jobs:
30
- license:
26
+ copyrights:
31
27
  runs-on: ubuntu-22.04
32
28
  steps:
33
29
  - uses: actions/checkout@v4
34
- - shell: bash
35
- run: |
36
- header="Copyright (c) $(date +%Y) Yegor Bugayenko"
37
- failed="false"
38
- while IFS= read -r file; do
39
- if ! grep -q "${header}" "${file}"; then
40
- failed="true"
41
- echo "⚠️ Copyright header is not found in: ${file}"
42
- else
43
- echo "File looks good: ${file}"
44
- fi
45
- done < <(find . -type f \( \
46
- -name "Dockerfile" -o \
47
- -name "LICENSE.txt" -o \
48
- -name "Makefile" -o \
49
- -name "Rakefile" -o \
50
- -name "*.sh" -o \
51
- -name "*.rb" -o \
52
- -name "*.fe" -o \
53
- -name "*.yml" \
54
- \) -print)
55
- if [ "${failed}" = "true" ]; then
56
- exit 1
57
- fi
30
+ - uses: yegor256/copyrights-action@0.0.4
data/Gemfile CHANGED
@@ -28,7 +28,7 @@ gem 'rake', '13.2.1', require: false
28
28
  gem 'rspec-rails', '6.1.2', require: false
29
29
  gem 'rubocop', '1.64.1', require: false
30
30
  gem 'rubocop-performance', '1.21.0', require: false
31
- gem 'rubocop-rspec', '2.30.0', require: false
31
+ gem 'rubocop-rspec', '2.31.0', require: false
32
32
  gem 'simplecov', '0.22.0', require: false
33
33
  gem 'simplecov-cobertura', '2.1.0', require: false
34
34
  gem 'yard', '0.9.36', require: false
data/Gemfile.lock CHANGED
@@ -145,7 +145,7 @@ GEM
145
145
  rubocop-performance (1.21.0)
146
146
  rubocop (>= 1.48.1, < 2.0)
147
147
  rubocop-ast (>= 1.31.1, < 2.0)
148
- rubocop-rspec (2.30.0)
148
+ rubocop-rspec (2.31.0)
149
149
  rubocop (~> 1.40)
150
150
  rubocop-capybara (~> 2.17)
151
151
  rubocop-factory_bot (~> 2.22)
@@ -186,7 +186,7 @@ DEPENDENCIES
186
186
  rspec-rails (= 6.1.2)
187
187
  rubocop (= 1.64.1)
188
188
  rubocop-performance (= 1.21.0)
189
- rubocop-rspec (= 2.30.0)
189
+ rubocop-rspec (= 2.31.0)
190
190
  simplecov (= 0.22.0)
191
191
  simplecov-cobertura (= 2.1.0)
192
192
  yard (= 0.9.36)
@@ -52,7 +52,14 @@ class Factbase::Looged
52
52
  end
53
53
 
54
54
  def txn(this = self, &)
55
- @fb.txn(this, &)
55
+ r = false
56
+ @fb.txn(this) do |x|
57
+ tail = Factbase::Looged.elapsed do
58
+ r = yield x
59
+ end
60
+ @loog.debug("Txn #{r ? 'modified' : 'did nothing'} #{tail}")
61
+ end
62
+ r
56
63
  end
57
64
 
58
65
  def export
@@ -53,11 +53,14 @@ class Factbase::Rules
53
53
  def txn(this = self, &)
54
54
  before = @check
55
55
  @check = Blind.new
56
- @fb.txn(this, &)
56
+ modified = @fb.txn(this, &)
57
57
  @check = before
58
- @fb.query('(always)').each do |f|
59
- @check.it(f)
58
+ if modified
59
+ @fb.query('(always)').each do |f|
60
+ @check.it(f)
61
+ end
60
62
  end
63
+ modified
61
64
  end
62
65
 
63
66
  def export
data/lib/factbase.rb CHANGED
@@ -79,7 +79,7 @@ require 'yaml'
79
79
  # License:: MIT
80
80
  class Factbase
81
81
  # Current version of the gem (changed by .rultor.yml on every release)
82
- VERSION = '0.0.43'
82
+ VERSION = '0.0.45'
83
83
 
84
84
  # An exception that may be thrown in a transaction, to roll it back.
85
85
  class Rollback < StandardError; end
@@ -159,22 +159,30 @@ class Factbase
159
159
  # inserted and all changes that happened in the block will be rolled back.
160
160
  #
161
161
  # @param [Factbase] this The factbase to use (don't provide this param)
162
+ # @return [Boolean] TRUE if some changes have been made, FALSE otherwise
162
163
  def txn(this = self)
163
164
  copy = this.dup
164
165
  begin
165
166
  yield copy
166
167
  rescue Factbase::Rollback
167
- return
168
+ return false
168
169
  end
170
+ modified = false
169
171
  @mutex.synchronize do
170
172
  after = Marshal.load(copy.export)
171
173
  after.each_with_index do |m, i|
172
- @maps << {} if i >= @maps.size
174
+ if i >= @maps.size
175
+ @maps << {}
176
+ modified = true
177
+ end
173
178
  m.each do |k, v|
179
+ next if @maps[i][k] == v
174
180
  @maps[i][k] = v
181
+ modified = true
175
182
  end
176
183
  end
177
184
  end
185
+ modified
178
186
  end
179
187
 
180
188
  # Export it into a chain of bytes.
@@ -44,6 +44,16 @@ class TestLooged < Minitest::Test
44
44
  assert_equal(2, fb.size)
45
45
  end
46
46
 
47
+ def test_with_txn
48
+ fb = Factbase::Looged.new(Factbase.new, Loog::NULL)
49
+ assert(
50
+ fb.txn do |fbt|
51
+ fbt.insert.foo = 42
52
+ end
53
+ )
54
+ assert_equal(1, fb.size)
55
+ end
56
+
47
57
  def test_returns_int
48
58
  fb = Factbase.new
49
59
  fb.insert
@@ -143,10 +143,11 @@ class TestFactbase < Minitest::Test
143
143
 
144
144
  def test_txn_with_rollback
145
145
  fb = Factbase.new
146
- fb.txn do |fbt|
146
+ modified = fb.txn do |fbt|
147
147
  fbt.insert.bar = 33
148
148
  raise Factbase::Rollback
149
149
  end
150
+ assert(!modified)
150
151
  assert_equal(0, fb.query('(always)').each.to_a.size)
151
152
  end
152
153
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.43
4
+ version: 0.0.45
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-06-06 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -82,7 +82,7 @@ files:
82
82
  - ".gitattributes"
83
83
  - ".github/workflows/actionlint.yml"
84
84
  - ".github/workflows/codecov.yml"
85
- - ".github/workflows/license.yml"
85
+ - ".github/workflows/copyrights.yml"
86
86
  - ".github/workflows/markdown-lint.yml"
87
87
  - ".github/workflows/pdd.yml"
88
88
  - ".github/workflows/rake.yml"