xot 0.1.21 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/include/xot/pimpl.h +8 -3
- data/lib/xot/bit_flag.rb +5 -5
- data/lib/xot/bit_flag_accessor.rb +7 -7
- data/lib/xot/bit_util.rb +1 -1
- data/lib/xot/block_util.rb +2 -2
- data/lib/xot/const_symbol_accessor.rb +3 -3
- data/lib/xot/extconf.rb +5 -5
- data/lib/xot/hookable.rb +8 -8
- data/lib/xot/invoker.rb +5 -5
- data/lib/xot/module.rb +5 -5
- data/lib/xot/rake/alias_task.rb +4 -3
- data/lib/xot/rake/escalation.rb +3 -3
- data/lib/xot/rake/util.rb +62 -60
- data/lib/xot/rake.rb +17 -16
- data/lib/xot/setter.rb +2 -2
- data/lib/xot/test.rb +2 -2
- data/lib/xot/universal_accessor.rb +4 -4
- data/test/test_bit_flag.rb +4 -4
- data/test/test_bit_flag_accessor.rb +10 -10
- data/test/test_bit_util.rb +1 -1
- data/test/test_block_util.rb +2 -2
- data/test/test_const_symbol_accessor.rb +9 -9
- data/test/test_hookable.rb +11 -11
- data/test/test_invoker.rb +4 -4
- data/test/test_rake.rb +1 -1
- data/test/test_setter.rb +5 -5
- data/test/test_tester.rb +1 -1
- data/test/test_universal_accessor.rb +5 -5
- data/xot.gemspec +3 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d28e71082099d11ea8291b3b0584625a0f4965f4eac7ddc7e773fdf85c63168d
|
4
|
+
data.tar.gz: 36695805ada2c39a9d5fbc843192a88c1673d1cdae16726cd258ba35fdee5853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2fc66704a8acc15b95b9c637ebbc955bb4b8c6c33eb4d873cbd7395c710174a6f02721aa9b7d9a8f80748b6f4f095c01b5eb72b61645f95e2b5e770c71f72f4
|
7
|
+
data.tar.gz: 7e38df2591560cb874bd9a9f4d1ea8f18dd75d4a434faa1617142dbbed41d2e3f5a6903b67dff4938f96a745ee095e5bc55769e403a2afdd9f6101f5aa02288c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.25
|
data/include/xot/pimpl.h
CHANGED
@@ -25,11 +25,16 @@ namespace Xot
|
|
25
25
|
|
26
26
|
PImpl (T* p) : Super(p) {}
|
27
27
|
|
28
|
-
PImpl (const This& obj)
|
28
|
+
PImpl (const This& obj)
|
29
|
+
: Super(obj ? new T(*obj) : NULL)
|
30
|
+
{
|
31
|
+
}
|
29
32
|
|
30
33
|
This& operator = (const This& obj)
|
31
34
|
{
|
32
|
-
if (&obj
|
35
|
+
if (&obj == this) return *this;
|
36
|
+
|
37
|
+
this->reset(obj ? new T(*obj) : NULL);
|
33
38
|
return *this;
|
34
39
|
}
|
35
40
|
|
@@ -42,7 +47,7 @@ namespace Xot
|
|
42
47
|
|
43
48
|
typedef std::shared_ptr<T> Super;
|
44
49
|
|
45
|
-
typedef
|
50
|
+
typedef PSharedImpl<T> This;
|
46
51
|
|
47
52
|
public:
|
48
53
|
|
data/lib/xot/bit_flag.rb
CHANGED
@@ -13,13 +13,13 @@ module Xot
|
|
13
13
|
|
14
14
|
alias make_bit bit
|
15
15
|
|
16
|
-
def initialize
|
16
|
+
def initialize(auto: false, none: 0, **flags, &block)
|
17
17
|
@bit2sym, @sym2bit, @auto, @next = {}, {none: none, no: none}, auto, 1
|
18
18
|
flags.each {|sym, value| flag sym, value}
|
19
19
|
BlockUtil.instance_eval_or_block_call self, &block if block
|
20
20
|
end
|
21
21
|
|
22
|
-
def flag
|
22
|
+
def flag(symbol, value = nil, bit: nil)
|
23
23
|
bit = value || make_bit(bit) || (@auto ? @next : nil)
|
24
24
|
|
25
25
|
raise ArgumentError if !bit
|
@@ -35,7 +35,7 @@ module Xot
|
|
35
35
|
bit
|
36
36
|
end
|
37
37
|
|
38
|
-
def bits2symbols
|
38
|
+
def bits2symbols(bits)
|
39
39
|
array = []
|
40
40
|
bits.to_s(2).reverse.each_char.with_index do |char, index|
|
41
41
|
next unless char == '1'
|
@@ -46,13 +46,13 @@ module Xot
|
|
46
46
|
array
|
47
47
|
end
|
48
48
|
|
49
|
-
def symbols2bits
|
49
|
+
def symbols2bits(*symbols)
|
50
50
|
symbols.flatten.reduce(0) {|value, symbol| value | sym2bit(symbol)}
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|
54
54
|
|
55
|
-
def sym2bit
|
55
|
+
def sym2bit(symbol)
|
56
56
|
bit = @sym2bit[symbol]
|
57
57
|
bit = flag symbol if !bit && @auto
|
58
58
|
raise "unknown symbol #{symbol.inspect} for flag." unless bit
|
@@ -10,24 +10,24 @@ module Xot
|
|
10
10
|
|
11
11
|
module BitFlagAccessor
|
12
12
|
|
13
|
-
def bit_flag_accessor
|
13
|
+
def bit_flag_accessor(name, bit_flag = nil, **flags, &block)
|
14
14
|
bf = define_bit_flag name, bit_flag, flags, block
|
15
15
|
define_bit_flag_writer name, bf
|
16
16
|
define_bit_flag_reader name, bf
|
17
17
|
end
|
18
18
|
|
19
|
-
def bit_flag_writer
|
19
|
+
def bit_flag_writer(name, bit_flag = nil, **flags, &block)
|
20
20
|
define_bit_flag_writer name, define_bit_flag(name, bit_flag, flags, block)
|
21
21
|
end
|
22
22
|
|
23
|
-
def bit_flag_reader
|
23
|
+
def bit_flag_reader(name, bit_flag = nil, **flags, &block)
|
24
24
|
define_bit_flag_reader name, define_bit_flag(name, bit_flag, flags, block)
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def define_bit_flag
|
30
|
-
bit_flag ||= Xot::BitFlag.new
|
29
|
+
def define_bit_flag(name, bit_flag, flags, block)
|
30
|
+
bit_flag ||= Xot::BitFlag.new(**flags)
|
31
31
|
Xot::BlockUtil.instance_eval_or_block_call bit_flag, &block if block
|
32
32
|
|
33
33
|
define_singleton_method "#{name}_flag".intern do
|
@@ -37,7 +37,7 @@ module Xot
|
|
37
37
|
bit_flag
|
38
38
|
end
|
39
39
|
|
40
|
-
def define_bit_flag_writer
|
40
|
+
def define_bit_flag_writer(name, bit_flag)
|
41
41
|
writer = "#{name}=".intern
|
42
42
|
setter = "bf_set_#{name}__".intern
|
43
43
|
|
@@ -51,7 +51,7 @@ module Xot
|
|
51
51
|
name
|
52
52
|
end
|
53
53
|
|
54
|
-
def define_bit_flag_reader
|
54
|
+
def define_bit_flag_reader(name, bit_flag)
|
55
55
|
reader = name.intern
|
56
56
|
getter = "bf_get_#{name}__".intern
|
57
57
|
|
data/lib/xot/bit_util.rb
CHANGED
data/lib/xot/block_util.rb
CHANGED
@@ -6,9 +6,9 @@ module Xot
|
|
6
6
|
|
7
7
|
module BlockUtil
|
8
8
|
|
9
|
-
def instance_eval_or_block_call
|
9
|
+
def instance_eval_or_block_call(recv, *args, &block)
|
10
10
|
if block.arity == 0
|
11
|
-
recv.instance_eval
|
11
|
+
recv.instance_eval(&block)
|
12
12
|
else
|
13
13
|
block.call recv, *args
|
14
14
|
end
|
@@ -6,12 +6,12 @@ module Xot
|
|
6
6
|
|
7
7
|
module ConstSymbolAccessor
|
8
8
|
|
9
|
-
def const_symbol_accessor
|
9
|
+
def const_symbol_accessor(name, **symbol2const)
|
10
10
|
const_symbol_writer name, **symbol2const
|
11
11
|
const_symbol_reader name, **symbol2const
|
12
12
|
end
|
13
13
|
|
14
|
-
def const_symbol_writer
|
14
|
+
def const_symbol_writer(name, **symbol2const)
|
15
15
|
writer = "#{name}=".intern
|
16
16
|
setter = "cs_set_#{name}__".intern
|
17
17
|
|
@@ -27,7 +27,7 @@ module Xot
|
|
27
27
|
name
|
28
28
|
end
|
29
29
|
|
30
|
-
def const_symbol_reader
|
30
|
+
def const_symbol_reader(name, **symbol2const)
|
31
31
|
reader = name.intern
|
32
32
|
getter = "cs_get_#{name}__".intern
|
33
33
|
|
data/lib/xot/extconf.rb
CHANGED
@@ -14,18 +14,18 @@ module Xot
|
|
14
14
|
|
15
15
|
attr_reader :modules, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
|
16
16
|
|
17
|
-
def initialize
|
17
|
+
def initialize(*modules, &block)
|
18
18
|
@modules = modules.map {|m| m.const_get :Module}
|
19
19
|
@defs, @inc_dirs, @lib_dirs, @headers, @libs, @local_libs, @frameworks =
|
20
|
-
([[]] * 7).map
|
20
|
+
([[]] * 7).map(&:dup)
|
21
21
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
22
22
|
end
|
23
23
|
|
24
|
-
def debug
|
24
|
+
def debug()
|
25
25
|
env :DEBUG, false
|
26
26
|
end
|
27
27
|
|
28
|
-
def setup
|
28
|
+
def setup()
|
29
29
|
yield if block_given?
|
30
30
|
|
31
31
|
modules.each do |m|
|
@@ -43,7 +43,7 @@ module Xot
|
|
43
43
|
$LOCAL_LIBS << local_libs.map {|s| " -l#{s}"}.join
|
44
44
|
end
|
45
45
|
|
46
|
-
def create_makefile
|
46
|
+
def create_makefile(*args)
|
47
47
|
modules.each do |m|
|
48
48
|
dir_config m.name.downcase, m.inc_dir, m.lib_dir
|
49
49
|
end
|
data/lib/xot/hookable.rb
CHANGED
@@ -6,28 +6,28 @@ module Xot
|
|
6
6
|
|
7
7
|
module Hookable
|
8
8
|
|
9
|
-
def hook
|
9
|
+
def hook(name, &block)
|
10
10
|
c = class << self; self; end
|
11
11
|
c.__send__ :define_method, name, &block
|
12
12
|
self
|
13
13
|
end
|
14
14
|
|
15
|
-
def on
|
15
|
+
def on(name, &block)
|
16
16
|
hook name do |*a, &b|
|
17
|
-
block.call
|
17
|
+
block.call(*a, &b)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def before
|
21
|
+
def before(name, &block)
|
22
22
|
hook name do |*a, &b|
|
23
|
-
super
|
23
|
+
super(*a, &b) unless block.call(*a, &b) == :skip
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def after
|
27
|
+
def after(name, &block)
|
28
28
|
hook name do |*a, &b|
|
29
|
-
ret = super
|
30
|
-
block.call
|
29
|
+
ret = super(*a, &b)
|
30
|
+
block.call(*a, &b)
|
31
31
|
ret
|
32
32
|
end
|
33
33
|
end
|
data/lib/xot/invoker.rb
CHANGED
@@ -9,10 +9,10 @@ module Xot
|
|
9
9
|
|
10
10
|
module Invoker
|
11
11
|
|
12
|
-
def initialize
|
12
|
+
def initialize()
|
13
13
|
end
|
14
14
|
|
15
|
-
def handlers
|
15
|
+
def handlers(create = false)
|
16
16
|
if create
|
17
17
|
@handlers ||= []
|
18
18
|
else
|
@@ -20,18 +20,18 @@ module Xot
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def add_handler
|
23
|
+
def add_handler(handler)
|
24
24
|
return unless handler
|
25
25
|
a = self.handlers true
|
26
26
|
a.push handler unless a.include? handler
|
27
27
|
end
|
28
28
|
|
29
|
-
def remove_handler
|
29
|
+
def remove_handler(handler)
|
30
30
|
return unless handler
|
31
31
|
self.handlers.delete handler
|
32
32
|
end
|
33
33
|
|
34
|
-
def invoke
|
34
|
+
def invoke(name, attributes = {}, options = {})
|
35
35
|
only = options[:only]
|
36
36
|
only = [only] if only && !only.kind_of?(Array)
|
37
37
|
handlers = only ? only : @handlers
|
data/lib/xot/module.rb
CHANGED
@@ -8,23 +8,23 @@ module Xot
|
|
8
8
|
|
9
9
|
module_function
|
10
10
|
|
11
|
-
def name
|
11
|
+
def name()
|
12
12
|
super.split('::')[-2]
|
13
13
|
end
|
14
14
|
|
15
|
-
def version
|
15
|
+
def version()
|
16
16
|
open(root_dir 'VERSION') {|f| f.readline.chomp}
|
17
17
|
end
|
18
18
|
|
19
|
-
def root_dir
|
19
|
+
def root_dir(path = '')
|
20
20
|
File.expand_path "../../#{path}", __dir__
|
21
21
|
end
|
22
22
|
|
23
|
-
def inc_dir
|
23
|
+
def inc_dir()
|
24
24
|
root_dir 'include'
|
25
25
|
end
|
26
26
|
|
27
|
-
def lib_dir
|
27
|
+
def lib_dir()
|
28
28
|
root_dir 'lib'
|
29
29
|
end
|
30
30
|
|
data/lib/xot/rake/alias_task.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
require 'rake/task'
|
5
|
+
require 'rake/dsl_definition'
|
5
6
|
|
6
7
|
|
7
8
|
module Xot
|
@@ -12,7 +13,7 @@ module Xot
|
|
12
13
|
|
13
14
|
class AliasTask < ::Rake::Task
|
14
15
|
|
15
|
-
def timestamp
|
16
|
+
def timestamp()
|
16
17
|
prerequisite_tasks.map {|pre| pre.timestamp}.max || ::Rake::EARLY
|
17
18
|
end
|
18
19
|
|
@@ -27,8 +28,8 @@ end# Xot
|
|
27
28
|
|
28
29
|
module Rake
|
29
30
|
module DSL
|
30
|
-
def alias_task
|
31
|
-
Xot::Rake::AliasTask.define_task
|
31
|
+
def alias_task(*args, &block)
|
32
|
+
Xot::Rake::AliasTask.define_task(*args, &block)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
data/lib/xot/rake/escalation.rb
CHANGED
@@ -9,8 +9,8 @@ module Rake
|
|
9
9
|
|
10
10
|
alias invoke_task_org invoke_task
|
11
11
|
|
12
|
-
def invoke_task
|
13
|
-
invoke_task_org
|
12
|
+
def invoke_task(*args, &block)
|
13
|
+
invoke_task_org(*args, &block)
|
14
14
|
rescue RuntimeError => e
|
15
15
|
if e.message =~ /don't\s+know\s+.*\s+task\s+/i
|
16
16
|
escalate_tasks
|
@@ -19,7 +19,7 @@ module Rake
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def escalate_tasks
|
22
|
+
def escalate_tasks()
|
23
23
|
Dir.chdir '..' do
|
24
24
|
cmd = "rake #{ARGV.join ' '}"
|
25
25
|
$stderr.puts "(in #{Dir.pwd}) #{cmd}"
|
data/lib/xot/rake/util.rb
CHANGED
@@ -12,71 +12,71 @@ module Xot
|
|
12
12
|
|
13
13
|
VERSION_NAME = 'VERSION'
|
14
14
|
|
15
|
-
def modules
|
15
|
+
def modules()
|
16
16
|
env(:MODULES, []).map {|m| m::Module}
|
17
17
|
end
|
18
18
|
|
19
|
-
def target
|
19
|
+
def target()
|
20
20
|
modules.last
|
21
21
|
end
|
22
22
|
|
23
|
-
def target_name
|
23
|
+
def target_name()
|
24
24
|
env :MODNAME, target.name.downcase
|
25
25
|
end
|
26
26
|
|
27
|
-
def inc_dir
|
27
|
+
def inc_dir()
|
28
28
|
env :INCDIR, 'include'
|
29
29
|
end
|
30
30
|
|
31
|
-
def src_dir
|
31
|
+
def src_dir()
|
32
32
|
env :SRCDIR, 'src'
|
33
33
|
end
|
34
34
|
|
35
|
-
def lib_dir
|
35
|
+
def lib_dir()
|
36
36
|
env :LIBDIR, 'lib'
|
37
37
|
end
|
38
38
|
|
39
|
-
def doc_dir
|
39
|
+
def doc_dir()
|
40
40
|
env :DOCDIR, 'doc'
|
41
41
|
end
|
42
42
|
|
43
|
-
def ext_dir
|
43
|
+
def ext_dir()
|
44
44
|
env :EXTDIR, "ext/#{target_name}"
|
45
45
|
end
|
46
46
|
|
47
|
-
def ext_lib_dir
|
47
|
+
def ext_lib_dir()
|
48
48
|
env :EXTLIBDIR, "lib/#{target_name}"
|
49
49
|
end
|
50
50
|
|
51
|
-
def test_dir
|
51
|
+
def test_dir()
|
52
52
|
env :TESTDIR, 'test'
|
53
53
|
end
|
54
54
|
|
55
|
-
def vendor_dir
|
55
|
+
def vendor_dir()
|
56
56
|
env :VENDORDIR, 'vendor'
|
57
57
|
end
|
58
58
|
|
59
|
-
def inc_dirs
|
59
|
+
def inc_dirs()
|
60
60
|
env_array(:INCDIRS, []) + modules.reverse.map {|m| m.inc_dir}.flatten
|
61
61
|
end
|
62
62
|
|
63
|
-
def src_dirs
|
63
|
+
def src_dirs()
|
64
64
|
env_array :SRCDIRS, []
|
65
65
|
end
|
66
66
|
|
67
|
-
def src_exts
|
67
|
+
def src_exts()
|
68
68
|
env_array(:SRCEXTS, []) + %w[c cc cpp m mm]
|
69
69
|
end
|
70
70
|
|
71
|
-
def excludes
|
71
|
+
def excludes()
|
72
72
|
env_array :EXCLUDES, []
|
73
73
|
end
|
74
74
|
|
75
|
-
def excluded?
|
75
|
+
def excluded?(path)
|
76
76
|
excludes.any? {|s| path =~ %r{#{s}}}
|
77
77
|
end
|
78
78
|
|
79
|
-
def glob
|
79
|
+
def glob(*patterns)
|
80
80
|
paths = []
|
81
81
|
patterns.each do |pattern|
|
82
82
|
paths.concat Dir.glob(pattern)
|
@@ -84,30 +84,30 @@ module Xot
|
|
84
84
|
paths
|
85
85
|
end
|
86
86
|
|
87
|
-
def filter_file
|
87
|
+
def filter_file(path, &block)
|
88
88
|
File.write path, block.call(File.read path)
|
89
89
|
end
|
90
90
|
|
91
|
-
def cd_sh
|
91
|
+
def cd_sh(dir, cmd)
|
92
92
|
Dir.chdir dir do
|
93
93
|
$stderr.puts "(in #{Dir.pwd})"
|
94
94
|
sh cmd
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
def modified_files
|
98
|
+
def modified_files(dir: '.', hash: '@')
|
99
99
|
`git diff --name-only #{hash} -- #{dir}`.lines.map &:chomp
|
100
100
|
end
|
101
101
|
|
102
|
-
def version_path
|
102
|
+
def version_path(dir = nil)
|
103
103
|
dir ? "#{dir}/#{VERSION_NAME}" : VERSION_NAME
|
104
104
|
end
|
105
105
|
|
106
|
-
def get_version
|
106
|
+
def get_version(dir = nil)
|
107
107
|
File.readlines(version_path dir).first.chomp
|
108
108
|
end
|
109
109
|
|
110
|
-
def bump_version
|
110
|
+
def bump_version(index, version = get_version)
|
111
111
|
nums = version.split('.').map &:to_i
|
112
112
|
nums << 0 until nums.size > index
|
113
113
|
nums[index] += 1
|
@@ -116,13 +116,13 @@ module Xot
|
|
116
116
|
nums.join '.'
|
117
117
|
end
|
118
118
|
|
119
|
-
def bump_version_file
|
119
|
+
def bump_version_file(index, dir: nil)
|
120
120
|
newver = bump_version index, get_version(dir)
|
121
121
|
File.write version_path(dir), newver
|
122
122
|
newver
|
123
123
|
end
|
124
124
|
|
125
|
-
def update_and_tag_version
|
125
|
+
def update_and_tag_version(index, dir: nil, &block)
|
126
126
|
raise 'modified files exist' unless modified_files.empty?
|
127
127
|
|
128
128
|
message = ENV['message']
|
@@ -138,7 +138,7 @@ module Xot
|
|
138
138
|
sh %( git tag -a -m "#{message}" v#{newver} )
|
139
139
|
end
|
140
140
|
|
141
|
-
def compile_erb
|
141
|
+
def compile_erb(path, out)
|
142
142
|
open(path) do |input|
|
143
143
|
open(out, 'w') do |output|
|
144
144
|
output.write compile_erb_str(input.read)
|
@@ -147,20 +147,20 @@ module Xot
|
|
147
147
|
#rescue
|
148
148
|
end
|
149
149
|
|
150
|
-
def compile_erb_str
|
150
|
+
def compile_erb_str(str)
|
151
151
|
ERB.new(str, nil, '%').result binding
|
152
152
|
end
|
153
153
|
|
154
|
-
def params
|
154
|
+
def params(max, sep = '', &block)
|
155
155
|
raise 'block not given.' unless block
|
156
156
|
return '' if max == 0
|
157
157
|
(1..max).map(&block).join(sep)
|
158
158
|
end
|
159
159
|
|
160
|
-
def make_path_map
|
160
|
+
def make_path_map(paths, ext_map)
|
161
161
|
paths = paths.map do |path|
|
162
162
|
newpath = ext_map.inject path do |value, (from, to)|
|
163
|
-
value.sub
|
163
|
+
value.sub(/#{from.gsub('.', '\.')}$/, to)
|
164
164
|
end
|
165
165
|
raise "map to same path" if path == newpath
|
166
166
|
[path, newpath]
|
@@ -168,12 +168,12 @@ module Xot
|
|
168
168
|
Hash[*paths.flatten]
|
169
169
|
end
|
170
170
|
|
171
|
-
def get_env
|
171
|
+
def get_env(name, defval = nil)
|
172
172
|
val = ENV[name.to_s] || Object.const_get(name) rescue defval
|
173
173
|
val.dup rescue val
|
174
174
|
end
|
175
175
|
|
176
|
-
def env
|
176
|
+
def env(name, defval = nil)
|
177
177
|
case val = get_env(name, defval)
|
178
178
|
when /^\d+$/ then val.to_i
|
179
179
|
when 'true', true then true
|
@@ -183,24 +183,24 @@ module Xot
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
def env_array
|
186
|
+
def env_array(name, defval = nil)
|
187
187
|
val = get_env name, defval
|
188
188
|
val = val.strip.split(/\s+/) if val.kind_of? String
|
189
189
|
val
|
190
190
|
end
|
191
191
|
|
192
|
-
def append_env
|
192
|
+
def append_env(name, *args)
|
193
193
|
ENV[name] = (ENV[name] || '') + " #{args.join ' '}"
|
194
194
|
end
|
195
195
|
|
196
|
-
def make_cppflags
|
196
|
+
def make_cppflags(flags = '', defs = [], incdirs = [])
|
197
197
|
s = flags.dup
|
198
198
|
s += make_cppflags_defs(defs) .map {|s| " -D#{s}"}.join
|
199
199
|
s += make_cppflags_incdirs(incdirs).map {|s| " -I#{s}"}.join
|
200
200
|
s
|
201
201
|
end
|
202
202
|
|
203
|
-
def make_cppflags_defs
|
203
|
+
def make_cppflags_defs(defs = [])
|
204
204
|
a = defs.dup
|
205
205
|
a << $~[0].upcase if RUBY_PLATFORM =~ /mswin|ming|cygwin|darwin/i
|
206
206
|
a << (debug? ? '_DEBUG' : 'NDEBUG')
|
@@ -210,16 +210,16 @@ module Xot
|
|
210
210
|
a
|
211
211
|
end
|
212
212
|
|
213
|
-
def make_cppflags_incdirs
|
213
|
+
def make_cppflags_incdirs(dirs = [])
|
214
214
|
dirs.dup + ruby_inc_dirs
|
215
215
|
end
|
216
216
|
|
217
|
-
def ruby_inc_dirs
|
217
|
+
def ruby_inc_dirs()
|
218
218
|
root = RbConfig::CONFIG['rubyhdrdir']
|
219
219
|
[root, RbConfig::CONFIG['rubyarchhdrdir'] || "#{root}/#{RUBY_PLATFORM}"]
|
220
220
|
end
|
221
221
|
|
222
|
-
def make_cflags
|
222
|
+
def make_cflags(flags = '')
|
223
223
|
warning_opts = %w[
|
224
224
|
no-unknown-pragmas
|
225
225
|
no-deprecated-register
|
@@ -227,79 +227,81 @@ module Xot
|
|
227
227
|
]
|
228
228
|
s = flags.dup
|
229
229
|
s << warning_opts.map {|s| " -W#{s}"}.join
|
230
|
-
s <<
|
231
|
-
s << ' -std=c++
|
230
|
+
s << " -arch arm64" if RUBY_PLATFORM =~ /arm64-darwin/
|
231
|
+
s << ' -std=c++17' if gcc?
|
232
|
+
s << ' -std=c++17 -stdlib=libc++ -mmacosx-version-min=10.7' if clang?
|
232
233
|
s << ' ' + RbConfig::CONFIG['debugflags'] if debug?
|
233
|
-
s.gsub!
|
234
|
+
s.gsub!(/-O\d?\w*/, '-O0') if debug?
|
234
235
|
s
|
235
236
|
end
|
236
237
|
|
237
|
-
def make_ldflags
|
238
|
+
def make_ldflags(flags = '', libdirs = [], frameworks = [])
|
238
239
|
s = flags.dup
|
239
240
|
s << libdirs.map {|s| " -L#{s}"}.join
|
240
241
|
s << frameworks.map {|s| " -framework #{s}"}.join
|
241
242
|
s
|
242
243
|
end
|
243
244
|
|
244
|
-
def debug
|
245
|
+
def debug(state)
|
245
246
|
ENV['DEBUG'] = state.to_s
|
246
247
|
end
|
247
248
|
|
248
|
-
def debug?
|
249
|
+
def debug?()
|
249
250
|
env :DEBUG, false
|
250
251
|
end
|
251
252
|
|
252
|
-
def win32?
|
253
|
+
def win32?()
|
253
254
|
RUBY_PLATFORM =~ /mswin|ming|cygwin/
|
254
255
|
end
|
255
256
|
|
256
|
-
def mswin?
|
257
|
+
def mswin?()
|
257
258
|
RUBY_PLATFORM =~ /mswin/
|
258
259
|
end
|
259
260
|
|
260
|
-
def ming?
|
261
|
+
def ming?()
|
261
262
|
RUBY_PLATFORM =~ /ming/
|
262
263
|
end
|
263
264
|
|
264
|
-
def cygwin?
|
265
|
+
def cygwin?()
|
265
266
|
RUBY_PLATFORM =~ /cygwin/
|
266
267
|
end
|
267
268
|
|
268
|
-
def osx?
|
269
|
+
def osx?()
|
269
270
|
RUBY_PLATFORM =~ /darwin/
|
270
271
|
end
|
271
272
|
|
272
|
-
def ios?
|
273
|
+
def ios?()
|
273
274
|
false
|
274
275
|
end
|
275
276
|
|
276
|
-
def gcc?
|
277
|
+
def gcc?()
|
277
278
|
RbConfig::CONFIG['CXX'] =~ /(^|\s)g\+\+/i
|
278
279
|
end
|
279
280
|
|
280
|
-
def clang?
|
281
|
+
def clang?()
|
281
282
|
RbConfig::CONFIG['CXX'] =~ /(^|\s)clang/i
|
282
283
|
end
|
283
284
|
|
284
|
-
def cxx
|
285
|
+
def cxx()
|
285
286
|
env :CXX, RbConfig::CONFIG['CXX'] || 'g++'
|
286
287
|
end
|
287
288
|
|
288
|
-
def ar
|
289
|
+
def ar()
|
289
290
|
env :AR, RbConfig::CONFIG['AR'] || 'ar'
|
290
291
|
end
|
291
292
|
|
292
|
-
def cppflags
|
293
|
+
def cppflags()
|
293
294
|
flags = env :CPPFLAGS, RbConfig::CONFIG['CPPFLAGS']
|
294
295
|
make_cppflags flags, defs, inc_dirs
|
295
296
|
end
|
296
297
|
|
297
|
-
def cxxflags
|
298
|
-
|
299
|
-
|
298
|
+
def cxxflags()
|
299
|
+
cflags = env :CFLAGS, RbConfig::CONFIG['CFLAGS']
|
300
|
+
cxxflags = env :CXXFLAGS, RbConfig::CONFIG['CXXFLAGS']
|
301
|
+
make_cflags "#{cflags} #{cxxflags}"
|
300
302
|
end
|
301
303
|
|
302
|
-
def arflags
|
304
|
+
def arflags()
|
303
305
|
env :ARFLAGS, RbConfig::CONFIG['ARFLAGS'] || 'crs'
|
304
306
|
end
|
305
307
|
|
data/lib/xot/rake.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
require 'rbconfig'
|
5
|
+
require 'rake'
|
5
6
|
require 'rake/loaders/makefile'
|
6
7
|
require 'rake/testtask'
|
7
8
|
require 'xot/rake/alias_task'
|
@@ -15,7 +16,7 @@ module Xot
|
|
15
16
|
module Rake
|
16
17
|
|
17
18
|
|
18
|
-
def srcs_map
|
19
|
+
def srcs_map()
|
19
20
|
paths = glob("#{src_dir}/**/*.{#{src_exts.join ','}}") +
|
20
21
|
erbs_map.values.grep(/\.(#{src_exts.join '|'})$/)
|
21
22
|
paths.reject! {|path| excluded? path}
|
@@ -25,36 +26,36 @@ module Xot
|
|
25
26
|
make_path_map paths, src_ext_map
|
26
27
|
end
|
27
28
|
|
28
|
-
def erbs_map
|
29
|
-
paths = glob
|
29
|
+
def erbs_map()
|
30
|
+
paths = glob(*[inc_dir, src_dir].map {|s| "#{s}/**/*.erb"})
|
30
31
|
paths.reject! {|path| excluded? path}
|
31
32
|
make_path_map paths, {".erb" => ""}
|
32
33
|
end
|
33
34
|
|
34
|
-
def vendor_srcs_map
|
35
|
+
def vendor_srcs_map(*dirs)
|
35
36
|
dirs = src_dirs if dirs.empty?
|
36
37
|
paths = dirs.map {|dir| glob "#{dir}/**/*.{#{src_exts.join ','}}"}.flatten
|
37
38
|
paths.reject! {|path| excluded? path}
|
38
39
|
make_path_map paths.flatten, src_ext_map
|
39
40
|
end
|
40
41
|
|
41
|
-
def src_ext_map
|
42
|
+
def src_ext_map(to = '.o')
|
42
43
|
Hash[*src_exts.map {|ext| [".#{ext}", to]}.flatten]
|
43
44
|
end
|
44
45
|
|
45
|
-
def defs
|
46
|
+
def defs()
|
46
47
|
env_array :DEFS, []
|
47
48
|
end
|
48
49
|
|
49
|
-
def test_alones
|
50
|
+
def test_alones()
|
50
51
|
env :TESTS_ALONE, []
|
51
52
|
end
|
52
53
|
|
53
|
-
def test_excludes
|
54
|
+
def test_excludes()
|
54
55
|
env :TESTS_EXCLUDE, []
|
55
56
|
end
|
56
57
|
|
57
|
-
def build_native_library
|
58
|
+
def build_native_library()
|
58
59
|
outname = "lib#{target_name}.a"
|
59
60
|
out = File.join lib_dir, outname
|
60
61
|
erbs = erbs_map
|
@@ -114,7 +115,7 @@ module Xot
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
|
-
def build_ruby_extension
|
118
|
+
def build_ruby_extension(dlname: 'native', dlext: 'so')
|
118
119
|
dlname = env :DLNAME, dlname
|
119
120
|
dlext = env :DLEXT, RbConfig::CONFIG['DLEXT'] || dlext
|
120
121
|
|
@@ -169,7 +170,7 @@ module Xot
|
|
169
170
|
end
|
170
171
|
end
|
171
172
|
|
172
|
-
def test_ruby_extension
|
173
|
+
def test_ruby_extension()
|
173
174
|
alias_task :test => [:ext, 'test:full', 'test:alones']
|
174
175
|
|
175
176
|
namespace :test do
|
@@ -188,7 +189,7 @@ module Xot
|
|
188
189
|
end
|
189
190
|
end
|
190
191
|
|
191
|
-
def build_ruby_gem
|
192
|
+
def build_ruby_gem()
|
192
193
|
gemspec = "#{target_name}.gemspec"
|
193
194
|
gemname = env :GEMNAME, target_name
|
194
195
|
gemver = env :GEMVERSION, target.version
|
@@ -229,7 +230,7 @@ module Xot
|
|
229
230
|
end
|
230
231
|
end
|
231
232
|
|
232
|
-
def build_application
|
233
|
+
def build_application()
|
233
234
|
bindir = env :BINDIR, 'bin'
|
234
235
|
bin = "#{bindir}/#{target_name}"
|
235
236
|
appdir = "#{target.name}.app"
|
@@ -257,7 +258,7 @@ module Xot
|
|
257
258
|
end
|
258
259
|
end
|
259
260
|
|
260
|
-
def use_external_library
|
261
|
+
def use_external_library(
|
261
262
|
repos, branch: nil, tag: nil,
|
262
263
|
incdir: nil, srcdir: nil, excludes: [],
|
263
264
|
submodules: [], post_submodules: nil)
|
@@ -312,7 +313,7 @@ module Xot
|
|
312
313
|
end
|
313
314
|
end
|
314
315
|
|
315
|
-
def use_boost_library
|
316
|
+
def use_boost_library(modules = [], branch: nil, tag: nil)
|
316
317
|
default_modules = %w[tools/build libs/config]
|
317
318
|
use_external_library 'https://github.com/boostorg/boost',
|
318
319
|
branch: branch,
|
@@ -322,7 +323,7 @@ module Xot
|
|
322
323
|
post_submodules: './bootstrap.sh && ./b2 headers'
|
323
324
|
end
|
324
325
|
|
325
|
-
def define_placeholder_tasks
|
326
|
+
def define_placeholder_tasks()
|
326
327
|
desc "delete temporary files"
|
327
328
|
alias_task :clean
|
328
329
|
|
data/lib/xot/setter.rb
CHANGED
@@ -6,7 +6,7 @@ module Xot
|
|
6
6
|
|
7
7
|
module Setter
|
8
8
|
|
9
|
-
def set
|
9
|
+
def set(*args)
|
10
10
|
first = args.shift
|
11
11
|
if first.kind_of? Hash
|
12
12
|
first.each {|name, value| set_value__ name, value}
|
@@ -17,7 +17,7 @@ module Xot
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def set_value__
|
20
|
+
def set_value__(name, *values)
|
21
21
|
raise ArgumentError, "set '#{values}' to '#{name}'" if
|
22
22
|
!name || name.empty? || values.empty?
|
23
23
|
__send__ "#{name}=", *values
|
data/lib/xot/test.rb
CHANGED
@@ -6,11 +6,11 @@ module Xot
|
|
6
6
|
|
7
7
|
module Test
|
8
8
|
|
9
|
-
def assert_not
|
9
|
+
def assert_not(expression, *args)
|
10
10
|
assert !expression, *args
|
11
11
|
end
|
12
12
|
|
13
|
-
def assert_not_includes
|
13
|
+
def assert_not_includes(collection, obj, *args)
|
14
14
|
assert !collection.include?(obj), *args
|
15
15
|
end
|
16
16
|
|
@@ -6,22 +6,22 @@ module Xot
|
|
6
6
|
|
7
7
|
module UniversalAccessor
|
8
8
|
|
9
|
-
def universal_accessor
|
9
|
+
def universal_accessor(*names, **names_with_options)
|
10
10
|
names.each {|name| define_universal_accessor name}
|
11
11
|
names_with_options.each {|name, opts| define_universal_accessor name, opts}
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def define_universal_accessor
|
16
|
+
def define_universal_accessor(name, options = {})
|
17
17
|
set = "ua_set_#{name}__"
|
18
18
|
get = "ua_get_#{name}__"
|
19
19
|
class_eval <<-END
|
20
20
|
alias_method :#{set}, options[:writer] || :#{name}=
|
21
21
|
alias_method :#{get}, options[:reader] || :#{name}
|
22
22
|
private :#{set}, :#{get}
|
23
|
-
def #{name}
|
24
|
-
#{set}
|
23
|
+
def #{name}(*args)
|
24
|
+
#{set}(*args) unless args.empty?
|
25
25
|
#{get}
|
26
26
|
end
|
27
27
|
END
|
data/test/test_bit_flag.rb
CHANGED
@@ -8,8 +8,8 @@ class TestBitFlag < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
include Xot::BitUtil
|
10
10
|
|
11
|
-
def flag
|
12
|
-
bf = Xot::BitFlag.new
|
11
|
+
def flag(*args, &block)
|
12
|
+
bf = Xot::BitFlag.new(*args, &block)
|
13
13
|
bf.flag :bit1, bit(1)
|
14
14
|
bf.flag :bit2, bit(2)
|
15
15
|
bf.flag :bit3, bit(3)
|
@@ -18,7 +18,7 @@ class TestBitFlag < Test::Unit::TestCase
|
|
18
18
|
bf
|
19
19
|
end
|
20
20
|
|
21
|
-
def test_bits2symbols
|
21
|
+
def test_bits2symbols()
|
22
22
|
assert_equal [], flag.bits2symbols(0)
|
23
23
|
assert_equal [:bit1], flag.bits2symbols(bit 1)
|
24
24
|
assert_equal [:bit2], flag.bits2symbols(bit 2)
|
@@ -34,7 +34,7 @@ class TestBitFlag < Test::Unit::TestCase
|
|
34
34
|
assert_raise(RuntimeError) {flag.bits2symbols(bit 0, 1)}
|
35
35
|
end
|
36
36
|
|
37
|
-
def test_symbols2bits
|
37
|
+
def test_symbols2bits()
|
38
38
|
assert_equal bit(1), flag.symbols2bits(:bit1)
|
39
39
|
assert_equal bit(2), flag.symbols2bits(:bit2)
|
40
40
|
assert_equal bit(5), flag.symbols2bits(:bit5)
|
@@ -12,7 +12,7 @@ class TestBitFlagAccessor < Test::Unit::TestCase
|
|
12
12
|
attr_accessor :bits
|
13
13
|
alias set bits=
|
14
14
|
alias get bits
|
15
|
-
def initialize
|
15
|
+
def initialize(&block)
|
16
16
|
@bits = 0
|
17
17
|
block.call self if block
|
18
18
|
end
|
@@ -25,38 +25,38 @@ class TestBitFlagAccessor < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def int
|
29
|
-
IntAccessor.new
|
28
|
+
def int(&block)
|
29
|
+
IntAccessor.new(&block)
|
30
30
|
end
|
31
31
|
|
32
|
-
def symbol
|
33
|
-
SymbolAccessor.new
|
32
|
+
def symbol(&block)
|
33
|
+
SymbolAccessor.new(&block)
|
34
34
|
end
|
35
35
|
|
36
|
-
def flag
|
36
|
+
def flag()
|
37
37
|
SymbolAccessor.bits_flag
|
38
38
|
end
|
39
39
|
|
40
|
-
def test_int_accessor
|
40
|
+
def test_int_accessor()
|
41
41
|
assert_equal 0b0, int.get
|
42
42
|
assert_equal 0b1, int{|o| o.bits = bit 0}.get
|
43
43
|
assert_equal 0b10, int{|o| o.bits = bit 1}.get
|
44
44
|
end
|
45
45
|
|
46
|
-
def test_symbol_writer
|
46
|
+
def test_symbol_writer()
|
47
47
|
assert_equal 0b0, symbol.get
|
48
48
|
assert_equal 0b1, symbol{|o| o.bits = :bit0}.get
|
49
49
|
assert_equal 0b10, symbol{|o| o.bits = :bit1}.get
|
50
50
|
end
|
51
51
|
|
52
|
-
def test_symbol_reader
|
52
|
+
def test_symbol_reader()
|
53
53
|
assert_equal [], symbol.bits
|
54
54
|
assert_equal [:bit0], symbol{|o| o.set bit 0}.bits
|
55
55
|
assert_equal [:bit1], symbol{|o| o.set bit 1}.bits
|
56
56
|
assert_equal [:bit0, :bit1], symbol{|o| o.set bit 0, 1}.bits
|
57
57
|
end
|
58
58
|
|
59
|
-
def test_singleton_flag_reader
|
59
|
+
def test_singleton_flag_reader()
|
60
60
|
assert_equal 0b11, flag.symbols2bits(:bit0, :bit1)
|
61
61
|
assert_equal [:bit0, :bit1], flag.bits2symbols(0b11)
|
62
62
|
end
|
data/test/test_bit_util.rb
CHANGED
data/test/test_block_util.rb
CHANGED
@@ -14,40 +14,40 @@ class TestConstSymbolAccessor < Test::Unit::TestCase
|
|
14
14
|
attr_accessor :const
|
15
15
|
alias set const=
|
16
16
|
alias get const
|
17
|
-
def initialize
|
17
|
+
def initialize(&block)
|
18
18
|
@const = Const0
|
19
19
|
block.call self if block
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
class SymbolAccessor < ConstAccessor
|
24
|
-
const_symbol_accessor :const, {
|
24
|
+
const_symbol_accessor :const, **{
|
25
25
|
const0: Const0,
|
26
26
|
const1: Const1
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
def const
|
31
|
-
ConstAccessor.new
|
30
|
+
def const(&block)
|
31
|
+
ConstAccessor.new(&block)
|
32
32
|
end
|
33
33
|
|
34
|
-
def symbol
|
35
|
-
SymbolAccessor.new
|
34
|
+
def symbol(&block)
|
35
|
+
SymbolAccessor.new(&block)
|
36
36
|
end
|
37
37
|
|
38
|
-
def test_const_accessor
|
38
|
+
def test_const_accessor()
|
39
39
|
assert_equal Const0, const.get
|
40
40
|
assert_equal Const1, const{|o| o.const = Const1}.get
|
41
41
|
assert_nothing_raised {const.const = Unknown}
|
42
42
|
end
|
43
43
|
|
44
|
-
def test_symbol_writer
|
44
|
+
def test_symbol_writer()
|
45
45
|
assert_equal Const0, symbol.get
|
46
46
|
assert_equal Const1, symbol{|o| o.const = :const1}.get
|
47
47
|
assert_raise(ArgumentError) {symbol.const = :unknown}
|
48
48
|
end
|
49
49
|
|
50
|
-
def test_symbol_reader
|
50
|
+
def test_symbol_reader()
|
51
51
|
assert_equal :const0, symbol.const
|
52
52
|
assert_equal :const1, symbol{|o| o.set Const1}.const
|
53
53
|
assert_raise(RuntimeError) {symbol{|o| o.set Unknown}.const}
|
data/test/test_hookable.rb
CHANGED
@@ -12,58 +12,58 @@ class TestHookable < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
attr_reader :log
|
14
14
|
|
15
|
-
def initialize
|
15
|
+
def initialize()
|
16
16
|
@log = []
|
17
17
|
end
|
18
18
|
|
19
|
-
def test
|
19
|
+
def test(val1, val2)
|
20
20
|
@log << val1 << val2
|
21
21
|
end
|
22
22
|
|
23
|
-
def zero
|
23
|
+
def zero()
|
24
24
|
@log << 0
|
25
25
|
end
|
26
26
|
|
27
27
|
end# Temp
|
28
28
|
|
29
|
-
def temp
|
29
|
+
def temp(*args)
|
30
30
|
Temp.new
|
31
31
|
end
|
32
32
|
|
33
|
-
def test_hook
|
33
|
+
def test_hook()
|
34
34
|
o = temp
|
35
35
|
o.hook(:test) do |*args|
|
36
|
-
super
|
36
|
+
super(-1, 0)
|
37
37
|
o.log << args
|
38
|
-
super
|
38
|
+
super(*args)
|
39
39
|
super 8, 9
|
40
40
|
end
|
41
41
|
o.test 1, 2
|
42
42
|
assert_equal [-1, 0, [1, 2], 1, 2, 8, 9], o.log
|
43
43
|
end
|
44
44
|
|
45
|
-
def test_before
|
45
|
+
def test_before()
|
46
46
|
o = temp
|
47
47
|
o.before(:zero) {o.log << 1}
|
48
48
|
o.zero
|
49
49
|
assert_equal [1, 0], o.log
|
50
50
|
end
|
51
51
|
|
52
|
-
def test_after
|
52
|
+
def test_after()
|
53
53
|
o = temp
|
54
54
|
o.after(:zero) {o.log << 1}
|
55
55
|
o.zero
|
56
56
|
assert_equal [0, 1], o.log
|
57
57
|
end
|
58
58
|
|
59
|
-
def test_on
|
59
|
+
def test_on()
|
60
60
|
o = temp
|
61
61
|
o.on(:zero) {o.log << 1}
|
62
62
|
o.zero
|
63
63
|
assert_equal [1], o.log
|
64
64
|
end
|
65
65
|
|
66
|
-
def test_hook_self
|
66
|
+
def test_hook_self()
|
67
67
|
o, id = temp, nil
|
68
68
|
o.hook(:zero) {id = __id__}
|
69
69
|
o.zero
|
data/test/test_invoker.rb
CHANGED
@@ -10,17 +10,17 @@ class TestInvoker < Test::Unit::TestCase
|
|
10
10
|
include Xot::Invoker
|
11
11
|
end
|
12
12
|
|
13
|
-
def invoker
|
14
|
-
Invoker.new
|
13
|
+
def invoker(*args, &block)
|
14
|
+
Invoker.new(*args, &block)
|
15
15
|
end
|
16
16
|
|
17
|
-
def handler
|
17
|
+
def handler(method, &block)
|
18
18
|
o = Object.new
|
19
19
|
o.define_singleton_method method, &block
|
20
20
|
o
|
21
21
|
end
|
22
22
|
|
23
|
-
def test_add_handler
|
23
|
+
def test_add_handler()
|
24
24
|
inv, var = invoker, nil
|
25
25
|
|
26
26
|
assert_equal nil, var
|
data/test/test_rake.rb
CHANGED
data/test/test_setter.rb
CHANGED
@@ -14,29 +14,29 @@ class TestSetter < Test::Unit::TestCase
|
|
14
14
|
|
15
15
|
end# Temp
|
16
16
|
|
17
|
-
def temp
|
17
|
+
def temp(*args)
|
18
18
|
Temp.new
|
19
19
|
end
|
20
20
|
|
21
|
-
def test_set
|
21
|
+
def test_set()
|
22
22
|
o = temp
|
23
23
|
assert_equal nil, o.x
|
24
24
|
o.set :x, 1
|
25
25
|
assert_equal 1, o.x
|
26
26
|
end
|
27
27
|
|
28
|
-
def test_set_by_hash
|
28
|
+
def test_set_by_hash()
|
29
29
|
o = temp
|
30
30
|
o.set :x => 1, :y => 2
|
31
31
|
assert_equal [1, 2], [o.x, o.y]
|
32
32
|
end
|
33
33
|
|
34
|
-
def test_invalid_name
|
34
|
+
def test_invalid_name()
|
35
35
|
assert_raise(NoMethodError) {temp.set :badname, 1}
|
36
36
|
assert_raise(ArgumentError) {temp.set :badname}
|
37
37
|
end
|
38
38
|
|
39
|
-
def test_invalid_value
|
39
|
+
def test_invalid_value()
|
40
40
|
assert_raise(ArgumentError) {temp.set :x}
|
41
41
|
end
|
42
42
|
|
data/test/test_tester.rb
CHANGED
@@ -12,7 +12,7 @@ class TestUniversalAccessor < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
attr_reader :args
|
14
14
|
|
15
|
-
def args=
|
15
|
+
def args=(*args)
|
16
16
|
@args = args
|
17
17
|
end
|
18
18
|
|
@@ -20,11 +20,11 @@ class TestUniversalAccessor < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
end# Accessor
|
22
22
|
|
23
|
-
def accessor
|
24
|
-
Accessor.new
|
23
|
+
def accessor(*args)
|
24
|
+
Accessor.new(*args)
|
25
25
|
end
|
26
26
|
|
27
|
-
def test_accessor
|
27
|
+
def test_accessor()
|
28
28
|
a = accessor
|
29
29
|
assert_equal nil, a.val
|
30
30
|
|
@@ -36,7 +36,7 @@ class TestUniversalAccessor < Test::Unit::TestCase
|
|
36
36
|
assert_equal 3, a.val
|
37
37
|
end
|
38
38
|
|
39
|
-
def test_accessor_splat_args
|
39
|
+
def test_accessor_splat_args()
|
40
40
|
a = accessor
|
41
41
|
|
42
42
|
a.args = 1, 2, 3; assert_equal [[1, 2, 3]], a.args
|
data/xot.gemspec
CHANGED
@@ -26,7 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.homepage = "https://github.com/xord/xot"
|
27
27
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
|
-
s.required_ruby_version = '
|
29
|
+
s.required_ruby_version = '>= 2.6.0'
|
30
|
+
|
31
|
+
s.add_development_dependency 'test-unit'
|
30
32
|
|
31
33
|
s.files = `git ls-files`.split $/
|
32
34
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2021-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-unit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: This library include some useful utility classes and functions for development
|
14
28
|
with C++.
|
15
29
|
email: xordog@gmail.com
|
@@ -78,16 +92,16 @@ require_paths:
|
|
78
92
|
- lib
|
79
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
|
-
- - "
|
95
|
+
- - ">="
|
82
96
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
97
|
+
version: 2.6.0
|
84
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - ">="
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: '0'
|
89
103
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.2.32
|
91
105
|
signing_key:
|
92
106
|
specification_version: 4
|
93
107
|
summary: A Utility library for C++ developemt.
|