xot 0.4.0 → 0.5.0
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/.github/actions/setup-monorepo/action.yml +44 -0
- data/.github/workflows/release-gem.yml +25 -9
- data/.github/workflows/tag.yml +44 -10
- data/.github/workflows/test.yml +37 -7
- data/ChangeLog.md +20 -0
- data/Gemfile.lock +13 -8
- data/VERSION +1 -1
- data/ext/xot/tester.cpp +12 -0
- data/include/xot/util.h +29 -7
- data/lib/xot/bit_flag.rb +11 -11
- data/lib/xot/bit_flag_accessor.rb +25 -25
- data/lib/xot/rake/changelog.rb +49 -0
- data/lib/xot/rake/github.rb +106 -0
- data/lib/xot/rake/hooks/pre-commit +32 -0
- data/lib/xot/rake/util.rb +98 -42
- data/lib/xot/rake.rb +29 -0
- data/lib/xot/setter.rb +5 -5
- data/lib/xot/universal_accessor.rb +13 -13
- data/src/util.cpp +0 -16
- data/test/helper.rb +51 -0
- data/test/test_bit_flag.rb +28 -22
- data/test/test_rake.rb +30 -0
- data/test/test_rake_changelog.rb +86 -0
- data/test/test_rake_github.rb +79 -0
- data/test/test_rake_util.rb +119 -0
- data/xot.gemspec +4 -1
- metadata +42 -5
- data/.github/workflows/utils.rb +0 -127
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8bdbb4eecd0d88463747c1df1bd34d727f94eec833ae6d02827b991353f8f294
|
|
4
|
+
data.tar.gz: 43945ff6140b64dda239f7cd7ebfbfd9445140e3569582be88c2f17a105653ca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 411340544314d34155b41df758eb53d053fdb58e805bba8ddc34d588e834e3b21caa48bd89827847ca93d946efa114c46fda3ba2e29c12350da5af2c2df129ba
|
|
7
|
+
data.tar.gz: ef728a1a99b8211faa0b73e1d9ee14391a4e9197959b33dff6de15b7499552beb7b06410881d1e14721f231f033db28e54e4ef98c3828c1d892a5bfad62892ab
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: setup monorepo
|
|
2
|
+
description: 'check out xord/all next to the app, and build and link its libraries, with the cache'
|
|
3
|
+
|
|
4
|
+
inputs:
|
|
5
|
+
ref:
|
|
6
|
+
description: 'branch, tag or commit of xord/all'
|
|
7
|
+
required: true
|
|
8
|
+
libraries:
|
|
9
|
+
description: 'the libraries of xord/all, by the order to build'
|
|
10
|
+
required: true
|
|
11
|
+
|
|
12
|
+
runs:
|
|
13
|
+
using: composite
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: prepare monorepo
|
|
17
|
+
id: prepare
|
|
18
|
+
shell: bash
|
|
19
|
+
env:
|
|
20
|
+
REF: ${{ inputs.ref }}
|
|
21
|
+
LIBS: ${{ inputs.libraries }}
|
|
22
|
+
RUBYLIB: ${{ github.action_path }}/../../../lib
|
|
23
|
+
run: |
|
|
24
|
+
commit=$(git ls-remote https://github.com/xord/all.git "$REF" | tail -1 | cut -f1)
|
|
25
|
+
commit=${commit:-$REF}
|
|
26
|
+
dir=$(ruby -rxot/rake -e 'puts File.expand_path MONOREPO_DIR')
|
|
27
|
+
prefix=$(ruby -e 'puts RbConfig::CONFIG["prefix"]')
|
|
28
|
+
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
|
29
|
+
echo "dir=$dir" >> "$GITHUB_OUTPUT"
|
|
30
|
+
echo "cache-key=monorepo-$commit-$LIBS-$prefix" >> "$GITHUB_OUTPUT"
|
|
31
|
+
|
|
32
|
+
- name: cache monorepo
|
|
33
|
+
uses: actions/cache@v4
|
|
34
|
+
with:
|
|
35
|
+
path: ${{ steps.prepare.outputs.dir }}
|
|
36
|
+
key: ${{ steps.prepare.outputs.cache-key }}
|
|
37
|
+
|
|
38
|
+
- name: setup monorepo
|
|
39
|
+
shell: bash
|
|
40
|
+
env:
|
|
41
|
+
COMMIT: ${{ steps.prepare.outputs.commit }}
|
|
42
|
+
LIBS: ${{ inputs.libraries }}
|
|
43
|
+
RUBYLIB: ${{ github.action_path }}/../../../lib
|
|
44
|
+
run: ruby -rxot/rake -e 'setup_monorepo(*ARGV)' "$COMMIT" $LIBS
|
|
@@ -4,6 +4,16 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
tags: ['v[0-9]*']
|
|
6
6
|
|
|
7
|
+
workflow_call:
|
|
8
|
+
inputs:
|
|
9
|
+
ruby-version:
|
|
10
|
+
type: string
|
|
11
|
+
zig:
|
|
12
|
+
type: boolean
|
|
13
|
+
secrets:
|
|
14
|
+
RUBYGEMS_AUTH_TOKEN:
|
|
15
|
+
required: true
|
|
16
|
+
|
|
7
17
|
permissions:
|
|
8
18
|
contents: write
|
|
9
19
|
|
|
@@ -12,28 +22,33 @@ jobs:
|
|
|
12
22
|
runs-on: macos-latest
|
|
13
23
|
|
|
14
24
|
steps:
|
|
15
|
-
- name: ruby 3.2
|
|
16
|
-
uses: ruby/setup-ruby@v1
|
|
17
|
-
with:
|
|
18
|
-
ruby-version: 3.2
|
|
19
|
-
|
|
20
25
|
- name: checkout
|
|
21
26
|
uses: actions/checkout@v4
|
|
22
27
|
|
|
28
|
+
- name: setup ruby
|
|
29
|
+
uses: ruby/setup-ruby@v1
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: ${{ inputs.ruby-version || '3.3' }}
|
|
32
|
+
|
|
23
33
|
- name: setup gems
|
|
24
34
|
run: bundle install
|
|
25
35
|
|
|
36
|
+
- name: setup xot
|
|
37
|
+
run: git clone -q --depth 1 https://github.com/xord/xot.git "${{ runner.temp }}/xot"
|
|
38
|
+
|
|
26
39
|
- name: setup dependencies
|
|
27
|
-
|
|
40
|
+
env:
|
|
41
|
+
RUBYLIB: ${{ runner.temp }}/xot/lib
|
|
42
|
+
run: ruby -rxot/rake -e 'setup_dependencies'
|
|
28
43
|
|
|
29
44
|
- name: packages
|
|
30
45
|
run: bundle exec rake packages
|
|
31
46
|
|
|
32
47
|
- name: setup zig
|
|
33
|
-
if:
|
|
48
|
+
if: inputs.zig
|
|
34
49
|
uses: mlugg/setup-zig@v2
|
|
35
50
|
with:
|
|
36
|
-
version: 0.
|
|
51
|
+
version: 0.17.0
|
|
37
52
|
|
|
38
53
|
- name: test
|
|
39
54
|
run: bundle exec rake test
|
|
@@ -47,7 +62,8 @@ jobs:
|
|
|
47
62
|
- name: create github release
|
|
48
63
|
env:
|
|
49
64
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
50
|
-
|
|
65
|
+
RUBYLIB: lib:../xot/lib
|
|
66
|
+
run: ruby -rxot/rake -e 'release_on_github(*ARGV)' ./${{ steps.gem.outputs.path }}
|
|
51
67
|
|
|
52
68
|
- name: upload to rubygems
|
|
53
69
|
env:
|
data/.github/workflows/tag.yml
CHANGED
|
@@ -1,35 +1,69 @@
|
|
|
1
1
|
name: Tag
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: [Test]
|
|
6
|
+
types: [completed]
|
|
5
7
|
branches: [master]
|
|
6
8
|
|
|
9
|
+
workflow_call:
|
|
10
|
+
inputs:
|
|
11
|
+
ruby-version:
|
|
12
|
+
type: string
|
|
13
|
+
git-user-name:
|
|
14
|
+
type: string
|
|
15
|
+
git-user-email:
|
|
16
|
+
type: string
|
|
17
|
+
secrets:
|
|
18
|
+
PAT:
|
|
19
|
+
required: true
|
|
20
|
+
|
|
7
21
|
jobs:
|
|
8
22
|
tag:
|
|
9
23
|
runs-on: ubuntu-latest
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ruby-version: 3.2
|
|
25
|
+
# after the tests of a push, not of a fork, or as the caller tells
|
|
26
|
+
if: github.event_name != 'workflow_run' || (
|
|
27
|
+
github.event.workflow_run.conclusion == 'success' &&
|
|
28
|
+
github.event.workflow_run.event == 'push')
|
|
16
29
|
|
|
30
|
+
steps:
|
|
17
31
|
- name: checkout
|
|
18
32
|
uses: actions/checkout@v4
|
|
19
33
|
with:
|
|
20
34
|
fetch-depth: 0
|
|
35
|
+
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
|
|
21
36
|
token: ${{ secrets.PAT }}
|
|
22
37
|
|
|
38
|
+
- name: setup ruby
|
|
39
|
+
uses: ruby/setup-ruby@v1
|
|
40
|
+
with:
|
|
41
|
+
ruby-version: ${{ inputs.ruby-version || '3.3' }}
|
|
42
|
+
|
|
43
|
+
- name: setup xot
|
|
44
|
+
run: git clone -q --depth 1 https://github.com/xord/xot.git "${{ runner.temp }}/xot"
|
|
45
|
+
|
|
23
46
|
- name: setup dependencies
|
|
24
|
-
|
|
47
|
+
env:
|
|
48
|
+
RUBYLIB: ${{ runner.temp }}/xot/lib
|
|
49
|
+
run: "ruby -rxot/rake -e 'setup_dependencies only: :xot, ext: false'"
|
|
25
50
|
|
|
26
51
|
- name: setup user name and email
|
|
52
|
+
env:
|
|
53
|
+
NAME: ${{ inputs.git-user-name ||
|
|
54
|
+
(github.repository_owner == 'xord' && 'xord') ||
|
|
55
|
+
'github-actions[bot]' }}
|
|
56
|
+
EMAIL: ${{ inputs.git-user-email ||
|
|
57
|
+
(github.repository_owner == 'xord' && 'xordog@gmail.com') ||
|
|
58
|
+
'41898282+github-actions[bot]@users.noreply.github.com' }}
|
|
27
59
|
run: |
|
|
28
|
-
git config --global user.
|
|
29
|
-
git config --global user.
|
|
60
|
+
git config --global user.name "$NAME"
|
|
61
|
+
git config --global user.email "$EMAIL"
|
|
30
62
|
|
|
31
63
|
- name: tag versions
|
|
32
|
-
|
|
64
|
+
env:
|
|
65
|
+
RUBYLIB: lib:../xot/lib:${{ runner.temp }}/xot/lib
|
|
66
|
+
run: ruby -rxot/rake -e 'tag_versions'
|
|
33
67
|
|
|
34
68
|
- name: push tags
|
|
35
69
|
run: git push origin --tags
|
data/.github/workflows/test.yml
CHANGED
|
@@ -5,33 +5,63 @@ on:
|
|
|
5
5
|
branches: [master]
|
|
6
6
|
pull_request:
|
|
7
7
|
|
|
8
|
+
workflow_call:
|
|
9
|
+
inputs:
|
|
10
|
+
ruby-version:
|
|
11
|
+
type: string
|
|
12
|
+
zig:
|
|
13
|
+
type: boolean
|
|
14
|
+
all-ref:
|
|
15
|
+
description: 'branch, tag or commit of xord/all for an app to take'
|
|
16
|
+
type: string
|
|
17
|
+
libraries:
|
|
18
|
+
description: 'the libraries of xord/all for all-ref, by the order to build'
|
|
19
|
+
type: string
|
|
20
|
+
|
|
8
21
|
jobs:
|
|
9
22
|
test:
|
|
10
23
|
runs-on: macos-latest
|
|
11
24
|
|
|
12
25
|
steps:
|
|
13
|
-
- name:
|
|
26
|
+
- name: checkout
|
|
27
|
+
uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- name: setup ruby
|
|
14
30
|
uses: ruby/setup-ruby@v1
|
|
15
31
|
with:
|
|
16
|
-
ruby-version:
|
|
32
|
+
ruby-version: ${{ inputs.ruby-version ||
|
|
33
|
+
(hashFiles('.ruby-version') != '' && 'default') ||
|
|
34
|
+
'3.3' }}
|
|
17
35
|
|
|
18
|
-
- name:
|
|
19
|
-
|
|
36
|
+
- name: setup xot
|
|
37
|
+
run: git clone -q --depth 1 https://github.com/xord/xot.git "${{ runner.temp }}/xot"
|
|
38
|
+
|
|
39
|
+
- name: setup monorepo
|
|
40
|
+
if: inputs.all-ref
|
|
41
|
+
uses: xord/xot/.github/actions/setup-monorepo@master
|
|
42
|
+
with:
|
|
43
|
+
ref: ${{ inputs.all-ref }}
|
|
44
|
+
libraries: ${{ inputs.libraries }}
|
|
20
45
|
|
|
21
46
|
- name: setup gems
|
|
47
|
+
env:
|
|
48
|
+
# not for all-ref, as the Gemfile takes the gems of the monorepo then
|
|
49
|
+
BUNDLE_FROZEN: ${{ hashFiles('Gemfile.lock') != '' && !inputs.all-ref }}
|
|
22
50
|
run: bundle install
|
|
23
51
|
|
|
24
52
|
- name: setup dependencies
|
|
25
|
-
|
|
53
|
+
env:
|
|
54
|
+
RUBYLIB: ${{ runner.temp }}/xot/lib
|
|
55
|
+
run: ruby -rxot/rake -e 'setup_dependencies'
|
|
26
56
|
|
|
27
57
|
- name: packages
|
|
28
58
|
run: bundle exec rake verbose packages
|
|
29
59
|
|
|
30
60
|
- name: setup zig
|
|
31
|
-
if:
|
|
61
|
+
if: inputs.zig
|
|
32
62
|
uses: mlugg/setup-zig@v2
|
|
33
63
|
with:
|
|
34
|
-
version: 0.
|
|
64
|
+
version: 0.17.0
|
|
35
65
|
|
|
36
66
|
- name: vendor
|
|
37
67
|
run: bundle exec rake vendor
|
data/ChangeLog.md
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
# xot ChangeLog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [v0.5.0] - 2026-11-04
|
|
5
|
+
|
|
6
|
+
- [BREAKING] Remove the hint_memory_usage callback
|
|
7
|
+
- [BREAKING] Raise ArgumentError instead of RuntimeError for an unknown bit flag
|
|
8
|
+
- [BREAKING] Raise the deployment targets to macOS 11.0 and iOS 14.0
|
|
9
|
+
- Return symbols in declaration order from BitFlag#bits2symbols
|
|
10
|
+
- Add Xot::update_flag to set or clear a flag by a bool
|
|
11
|
+
- Add Xot::call_and_log_errors to write an error to stderr instead of throwing it
|
|
12
|
+
- Add Xot::ChangeLog and automate_release for the tasks to release by VERSION and ChangeLog.md
|
|
13
|
+
- Add package_application for the tasks to package and release an app
|
|
14
|
+
- Make the workflows of xot callable from other repositories, to test, tag, release and package an app
|
|
15
|
+
- Take Ruby 3.3 as the oldest for the workflows
|
|
16
|
+
- Install the git hooks before the changelog tasks
|
|
17
|
+
- Declare rake and ostruct, which xot requires, as dependencies
|
|
18
|
+
- Silence the deprecation warnings of OpenGL and OpenAL on macOS
|
|
19
|
+
|
|
20
|
+
- Fix universal_accessor ignoring keyword-only calls
|
|
21
|
+
- Fix remove_flag clearing the upper bits of a 64-bit value
|
|
22
|
+
|
|
23
|
+
|
|
4
24
|
## [v0.4.0] - 2026-08-04
|
|
5
25
|
|
|
6
26
|
- [BREAKING] Rework String conversions to std::wstring and CFString
|
data/Gemfile.lock
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
power_assert (3.0
|
|
5
|
-
rake (13.
|
|
6
|
-
test-unit (3.7.
|
|
4
|
+
power_assert (3.1.0)
|
|
5
|
+
rake (13.4.2)
|
|
6
|
+
test-unit (3.7.8)
|
|
7
7
|
power_assert
|
|
8
|
-
yard (0.9.
|
|
8
|
+
yard (0.9.45)
|
|
9
9
|
|
|
10
10
|
PLATFORMS
|
|
11
|
-
|
|
12
|
-
arm64-darwin-23
|
|
13
|
-
arm64-darwin-24
|
|
11
|
+
ruby
|
|
14
12
|
|
|
15
13
|
DEPENDENCIES
|
|
16
14
|
rake
|
|
17
15
|
test-unit
|
|
18
16
|
yard
|
|
19
17
|
|
|
18
|
+
CHECKSUMS
|
|
19
|
+
bundler (4.0.20) sha256=7978a8ac648767f5e635bc522445b79e80a52b907a39a36c2d8085ed6bc762ae
|
|
20
|
+
power_assert (3.1.0) sha256=fefe98ed5d3140628138f3f9f9194d6ece01f1320e69700d3c928adca7518251
|
|
21
|
+
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
|
22
|
+
test-unit (3.7.8) sha256=689d1ca53f4d46f678b4e5d68d8e4294f87fc5e8b9238cc4de7c5727e8d65943
|
|
23
|
+
yard (0.9.45) sha256=52e211493f7cb8a3ebf7e104a25a1e73937a3103092545d34cb88fafebb3dc51
|
|
24
|
+
|
|
20
25
|
BUNDLED WITH
|
|
21
|
-
|
|
26
|
+
4.0.20
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.5.0
|
data/ext/xot/tester.cpp
CHANGED
|
@@ -111,6 +111,18 @@ test_util ()
|
|
|
111
111
|
if ( Xot::has_flag(flags, F0 | F1)) return false;
|
|
112
112
|
if ( Xot::has_flag(flags, F0 | F1 | F2)) return false;
|
|
113
113
|
|
|
114
|
+
Xot:: update_flag(&flags, F1, true);
|
|
115
|
+
if (!Xot::has_flag(flags, F0)) return false;
|
|
116
|
+
if (!Xot::has_flag(flags, F1)) return false;
|
|
117
|
+
if (!Xot::has_flag(flags, F0 | F1)) return false;
|
|
118
|
+
if ( Xot::has_flag(flags, F0 | F1 | F2)) return false;
|
|
119
|
+
|
|
120
|
+
Xot:: update_flag(&flags, F1, false);
|
|
121
|
+
if (!Xot::has_flag(flags, F0)) return false;
|
|
122
|
+
if ( Xot::has_flag(flags, F1)) return false;
|
|
123
|
+
if ( Xot::has_flag(flags, F0 | F1)) return false;
|
|
124
|
+
if ( Xot::has_flag(flags, F0 | F1 | F2)) return false;
|
|
125
|
+
|
|
114
126
|
int value;
|
|
115
127
|
int* p = &value;
|
|
116
128
|
if (!(Xot::get_pointer_flag(p) == false)) return false;
|
data/include/xot/util.h
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
#include <stdint.h>
|
|
8
|
-
#include <
|
|
8
|
+
#include <stdio.h>
|
|
9
9
|
#include <math.h>
|
|
10
10
|
#include <assert.h>
|
|
11
|
+
#include <exception>
|
|
12
|
+
#include <functional>
|
|
11
13
|
#include <xot/defs.h>
|
|
12
14
|
#include <xot/time.h>
|
|
13
15
|
|
|
@@ -64,7 +66,17 @@ namespace Xot
|
|
|
64
66
|
{
|
|
65
67
|
assert(pvalue);
|
|
66
68
|
|
|
67
|
-
*pvalue &= ~flag;
|
|
69
|
+
*pvalue &= ~(T) flag;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
template <typename T>
|
|
73
|
+
inline void
|
|
74
|
+
update_flag (T* pvalue, uint flag, bool add)
|
|
75
|
+
{
|
|
76
|
+
if (add)
|
|
77
|
+
add_flag(pvalue, flag);
|
|
78
|
+
else
|
|
79
|
+
remove_flag(pvalue, flag);
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
template <typename T>
|
|
@@ -125,11 +137,21 @@ namespace Xot
|
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
template <typename E = std::exception>
|
|
141
|
+
inline bool
|
|
142
|
+
call_and_log_errors (const std::function<void()>& fun)
|
|
143
|
+
{
|
|
144
|
+
try
|
|
145
|
+
{
|
|
146
|
+
fun();
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
catch (const E& e)
|
|
150
|
+
{
|
|
151
|
+
fprintf(stderr, "%s\n", e.what());
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
133
155
|
|
|
134
156
|
|
|
135
157
|
#if defined(OSX) || defined(IOS)
|
data/lib/xot/bit_flag.rb
CHANGED
|
@@ -33,13 +33,13 @@ module Xot
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def bits2symbols(bits)
|
|
36
|
-
array = []
|
|
37
|
-
|
|
38
|
-
next
|
|
39
|
-
symbol = @bit2sym[bit index]
|
|
40
|
-
raise "unknown bit #{index} for flag." unless symbol
|
|
36
|
+
array, rest = [], bits
|
|
37
|
+
@bit2sym.each do |bit, symbol|
|
|
38
|
+
next if (bits & bit) == 0
|
|
41
39
|
array << symbol
|
|
40
|
+
rest &= ~bit
|
|
42
41
|
end
|
|
42
|
+
raise ArgumentError, "unknown bits 0b#{rest.to_s 2} for flag." if rest != 0
|
|
43
43
|
array
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -49,12 +49,12 @@ module Xot
|
|
|
49
49
|
|
|
50
50
|
private
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
def sym2bit(symbol)
|
|
53
|
+
bit = @sym2bit[symbol]
|
|
54
|
+
bit = flag symbol if !bit && @auto
|
|
55
|
+
raise ArgumentError, "unknown symbol #{symbol.inspect} for flag." unless bit
|
|
56
|
+
bit
|
|
57
|
+
end
|
|
58
58
|
|
|
59
59
|
end# BitFlag
|
|
60
60
|
|
|
@@ -23,45 +23,45 @@ module Xot
|
|
|
23
23
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
define_singleton_method "#{name}_flag".intern do
|
|
31
|
-
bit_flag
|
|
32
|
-
end
|
|
26
|
+
def define_bit_flag(name, bit_flag, flags, block)
|
|
27
|
+
bit_flag ||= Xot::BitFlag.new(**flags)
|
|
28
|
+
Xot::BlockUtil.instance_eval_or_block_call bit_flag, &block if block
|
|
33
29
|
|
|
30
|
+
define_singleton_method "#{name}_flag".intern do
|
|
34
31
|
bit_flag
|
|
35
32
|
end
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
setter = "bf_set_#{name}__".intern
|
|
34
|
+
bit_flag
|
|
35
|
+
end
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
def define_bit_flag_writer(name, bit_flag)
|
|
38
|
+
writer = "#{name}=".intern
|
|
39
|
+
setter = "bf_set_#{name}__".intern
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
end
|
|
41
|
+
alias_method setter, writer
|
|
42
|
+
private setter
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
define_method writer do |*symbols|
|
|
45
|
+
__send__ setter, bit_flag.symbols2bits(symbols)
|
|
49
46
|
end
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
getter = "bf_get_#{name}__".intern
|
|
48
|
+
name
|
|
49
|
+
end
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
def define_bit_flag_reader(name, bit_flag)
|
|
52
|
+
reader = name.intern
|
|
53
|
+
getter = "bf_get_#{name}__".intern
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
end
|
|
55
|
+
alias_method getter, reader
|
|
56
|
+
private getter
|
|
61
57
|
|
|
62
|
-
|
|
58
|
+
define_method reader do
|
|
59
|
+
bit_flag.bits2symbols __send__(getter)
|
|
63
60
|
end
|
|
64
61
|
|
|
62
|
+
name
|
|
63
|
+
end
|
|
64
|
+
|
|
65
65
|
end# BitFlagAccessor
|
|
66
66
|
|
|
67
67
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Xot
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ChangeLog
|
|
5
|
+
|
|
6
|
+
HEADING = /^[[:blank:]]*##\s*\[\s*v(\d[\d\.]*)\s*\].*$/
|
|
7
|
+
|
|
8
|
+
def initialize(path = 'ChangeLog.md')
|
|
9
|
+
@path = path
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :path
|
|
13
|
+
|
|
14
|
+
def add(version, changes, date: Time.now)
|
|
15
|
+
version = version.to_s.delete_prefix 'v'
|
|
16
|
+
section = [
|
|
17
|
+
"## [v#{version}] - #{date.strftime '%Y-%m-%d'}",
|
|
18
|
+
changes.map {"- #{_1}"}.join("\n")
|
|
19
|
+
].join("\n\n")
|
|
20
|
+
|
|
21
|
+
text = File.read @path
|
|
22
|
+
if index = text.index(HEADING)
|
|
23
|
+
text.insert(index, "#{section}\n\n\n")
|
|
24
|
+
else
|
|
25
|
+
text = "#{text.rstrip}\n\n\n#{section}\n"
|
|
26
|
+
end
|
|
27
|
+
File.write @path, text
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def sections()
|
|
31
|
+
File.read(@path)
|
|
32
|
+
.split(HEADING)
|
|
33
|
+
.drop(1)
|
|
34
|
+
.each_slice(2)
|
|
35
|
+
.to_h {|version, changes| [version, changes.to_s.strip]}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def versions()
|
|
39
|
+
sections.keys
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def changes(version)
|
|
43
|
+
sections[version.to_s.delete_prefix 'v']
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end# ChangeLog
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
end# Xot
|