xot 0.1.29 → 0.1.31

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: 9ea50533d0983d63cf356e4e9b22e86e59e61b22c42aae9b8e08012ea9995197
4
- data.tar.gz: 28c5390e0096c11706816e393f71d92b9fb50285713a70a8e52bb51d735e804b
3
+ metadata.gz: 2cb1f6146789ec235d8ba43238e68a88be8f5298db1f22f3435db1bf14dd7c2a
4
+ data.tar.gz: 2853e920d96950fbb338dcee693f5447dc121d0c9c18f0b1ecc291bd13c79f34
5
5
  SHA512:
6
- metadata.gz: d099cd440d749b82395b1cb3f8ceddcc4a6e96636e765ddd58f3d5f8e6d03825efafde4dc7c8c64fef069e633e95eaf7a2f2925290a9486c469d08da2d99c45d
7
- data.tar.gz: 6e9233c41a2531d90ace4c4c3ce122cd06c2817cf5c0aabede9f194a357cb5e9dc291064f76178a200d5a18838b2af19601201d24c09dbfff89e21cf47ef899e
6
+ metadata.gz: f241ce0b846f954fc5f06b7bad24981a73b4b22cc8c804e92436855e6cf54631730736476361819105e718b3d0ba341a4f006cc9814361799cdbd79e262cc6c7
7
+ data.tar.gz: f2c7a9ee50a3e0dfc473632c1eec5834e95c560dc43c86981691aa0d4a98c4cc21e1c7905bf2be53be7682303dfd2564593886a7c0348ec80c9562718c1ee9b5
@@ -0,0 +1,34 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ['v[0-9]*']
6
+
7
+ jobs:
8
+ release:
9
+ runs-on: macos-latest
10
+
11
+ steps:
12
+ - name: ruby 3.2
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 3.2
16
+
17
+ - name: checkout
18
+ uses: actions/checkout@v2
19
+
20
+ - name: setup dependencies
21
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
22
+
23
+ - name: test
24
+ run: rake test
25
+
26
+ - name: upload to rubygems
27
+ env:
28
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
29
+ run: |
30
+ mkdir -p $HOME/.gem
31
+ touch $HOME/.gem/credentials
32
+ chmod 0600 $HOME/.gem/credentials
33
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
34
+ rake upload
@@ -0,0 +1,35 @@
1
+ name: Tag
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+
7
+ jobs:
8
+ tag:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - name: ruby 3.2
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 3.2
16
+
17
+ - name: checkout
18
+ uses: actions/checkout@v2
19
+ with:
20
+ fetch-depth: 0
21
+ token: ${{ secrets.PAT }}
22
+
23
+ - name: setup dependencies
24
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies only: :xot'"
25
+
26
+ - name: setup user name and email
27
+ run: |
28
+ git config --global user.email "xordog@gmail.com"
29
+ git config --global user.name "xord"
30
+
31
+ - name: tag versions
32
+ run: "ruby -I.github/workflows -rutils -e 'tag_versions'"
33
+
34
+ - name: push tags
35
+ run: git push origin --tags
@@ -0,0 +1,32 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: macos-latest
12
+
13
+ steps:
14
+ - name: ruby 3.2
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 3.2
18
+
19
+ - name: checkout
20
+ uses: actions/checkout@v2
21
+
22
+ - name: setup dependencies
23
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
24
+
25
+ - name: lib
26
+ run: rake lib
27
+
28
+ - name: ext
29
+ run: rake ext
30
+
31
+ - name: test
32
+ run: rake test
@@ -0,0 +1,47 @@
1
+ def sh(cmd)
2
+ puts cmd
3
+ system cmd
4
+ end
5
+
6
+ def setup_dependencies(build: true, only: nil)
7
+ gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
8
+ gemspec = File.read gemspec_path
9
+ name = File.basename gemspec_path, '.gemspec'
10
+
11
+ exts = File.readlines('Rakefile')
12
+ .map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
13
+ .compact
14
+ .reject {|ext| ext == name}
15
+ exts = exts & [only].flatten.map(&:to_s) if only
16
+
17
+ exts.each do |ext|
18
+ ver = gemspec[/add_runtime_dependency.*'#{ext}'.*'\s*~>\s*([\d\.]+)\s*'/, 1]
19
+ url = "https://github.com/xord/#{ext}.git"
20
+ sh %( git clone --depth 1 --branch v#{ver} #{url} ../#{ext} )
21
+ sh %( cd ../#{ext} && rake ext )
22
+ end
23
+ end
24
+
25
+ def tag_versions()
26
+ tags = `git tag`.lines chomp: true
27
+ vers = `git log --oneline ./VERSION`
28
+ .lines(chomp: true)
29
+ .map {|line| line.split.first[/^\w+$/]}
30
+ .map {|hash| [`git cat-file -p #{hash}:./VERSION 2>/dev/null`[/[\d\.]+/], hash]}
31
+ .select {|ver, hash| ver && hash}
32
+ .reverse
33
+ .to_h
34
+
35
+ changes = File.read('ChangeLog.md')
36
+ .split(/^\s*##\s*\[\s*v([\d\.]+)\s*\].*$/)
37
+ .slice(1..-1)
38
+ .each_slice(2)
39
+ .to_h
40
+ .transform_values(&:strip!)
41
+
42
+ vers.to_a.reverse.each do |ver, hash|
43
+ tag = "v#{ver}"
44
+ break if tags.include?(tag)
45
+ sh %( git tag -a -m \"#{changes[ver]&.gsub '"', '\\"'}\" #{tag} #{hash} )
46
+ end
47
+ end
data/ChangeLog.md ADDED
@@ -0,0 +1,13 @@
1
+ # xot ChangeLog
2
+
3
+
4
+ ## [v0.1.31] - 2023-02-26
5
+
6
+ - add ChangeLog.md file
7
+ - add test.yml, tag.yaml, and release.yml
8
+ - requires ruby 2.7.0 or later
9
+
10
+
11
+ ## [v0.1.30] - 2023-02-09
12
+
13
+ - refactoring
data/Rakefile CHANGED
@@ -7,14 +7,14 @@
7
7
 
8
8
  require 'xot/rake'
9
9
 
10
- require 'xot/module'
10
+ require 'xot/extension'
11
11
 
12
12
 
13
- MODULES = [Xot]
14
- DLNAME = 'tester'
13
+ EXTENSIONS = [Xot]
14
+ DLNAME = 'tester'
15
15
 
16
16
  build_native_library
17
- build_ruby_extension dlname: DLNAME
17
+ build_ruby_extension dlname: DLNAME, liboutput: false
18
18
  test_ruby_extension
19
19
  build_ruby_gem
20
20
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.29
1
+ 0.1.31
data/ext/xot/extconf.rb CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  require 'mkmf'
9
9
  require 'xot/extconf'
10
- require 'xot/module'
10
+ require 'xot/extension'
11
11
 
12
12
 
13
13
  Xot::ExtConf.new Xot do
data/lib/xot/extconf.rb CHANGED
@@ -12,10 +12,10 @@ module Xot
12
12
 
13
13
  include Xot::Rake
14
14
 
15
- attr_reader :modules, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
15
+ attr_reader :extensions, :defs, :inc_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks
16
16
 
17
- def initialize(*modules, &block)
18
- @modules = modules.map {|m| m.const_get :Module}
17
+ def initialize(*extensions, &block)
18
+ @extensions = extensions.map {|x| x.const_get :Extension}
19
19
  @defs, @inc_dirs, @lib_dirs, @headers, @libs, @local_libs, @frameworks =
20
20
  ([[]] * 7).map(&:dup)
21
21
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
@@ -28,8 +28,8 @@ module Xot
28
28
  def setup()
29
29
  yield if block_given?
30
30
 
31
- modules.each do |m|
32
- name = m.name.downcase
31
+ extensions.each do |x|
32
+ name = x.name.downcase
33
33
  headers << "#{name}.h"
34
34
  libs << name
35
35
  end
@@ -44,8 +44,8 @@ module Xot
44
44
  end
45
45
 
46
46
  def create_makefile(*args)
47
- modules.each do |m|
48
- dir_config m.name.downcase, m.inc_dir, m.lib_dir
47
+ extensions.each do |x|
48
+ dir_config x.name.downcase, x.inc_dir, x.lib_dir
49
49
  end
50
50
 
51
51
  exit 1 unless headers.all? {|s| have_header s}
@@ -4,7 +4,7 @@
4
4
  module Xot
5
5
 
6
6
 
7
- module Module
7
+ module Extension
8
8
 
9
9
  module_function
10
10
 
@@ -13,7 +13,7 @@ module Xot
13
13
  end
14
14
 
15
15
  def version()
16
- open(root_dir 'VERSION') {|f| f.readline.chomp}
16
+ File.read(root_dir 'VERSION')[/[\d\.]+/]
17
17
  end
18
18
 
19
19
  def root_dir(path = '')
@@ -28,7 +28,7 @@ module Xot
28
28
  root_dir 'lib'
29
29
  end
30
30
 
31
- end# Module
31
+ end# Extension
32
32
 
33
33
 
34
34
  end# Xot
data/lib/xot/rake/util.rb CHANGED
@@ -12,16 +12,16 @@ module Xot
12
12
 
13
13
  VERSION_NAME = 'VERSION'
14
14
 
15
- def modules()
16
- env(:MODULES, []).map {|m| m::Module}
15
+ def extensions()
16
+ env(:EXTENSIONS, []).map {|m| m::Extension}
17
17
  end
18
18
 
19
19
  def target()
20
- modules.last
20
+ extensions.last
21
21
  end
22
22
 
23
23
  def target_name()
24
- env :MODNAME, target.name.downcase
24
+ env :EXTNAME, target.name.downcase
25
25
  end
26
26
 
27
27
  def inc_dir()
@@ -57,7 +57,7 @@ module Xot
57
57
  end
58
58
 
59
59
  def inc_dirs()
60
- env_array(:INCDIRS, []) + modules.reverse.map {|m| m.inc_dir}.flatten
60
+ env_array(:INCDIRS, []) + extensions.reverse.map {|m| m.inc_dir}.flatten
61
61
  end
62
62
 
63
63
  def src_dirs()
@@ -107,12 +107,12 @@ module Xot
107
107
  File.readlines(version_path dir).first.chomp
108
108
  end
109
109
 
110
- def bump_version(index, version = get_version)
110
+ def bump_version(index, version = get_version, min_digits: 3)
111
111
  nums = version.split('.').map &:to_i
112
112
  nums << 0 until nums.size > index
113
113
  nums[index] += 1
114
114
  nums.map!.with_index {|num, i| i > index ? 0 : num}
115
- nums.pop while nums.last == 0 && nums.size >= 3
115
+ nums.pop while nums.last == 0 && nums.size > min_digits
116
116
  nums.join '.'
117
117
  end
118
118
 
data/lib/xot/rake.rb CHANGED
@@ -115,9 +115,9 @@ module Xot
115
115
  end
116
116
  end
117
117
 
118
- def build_ruby_extension(dlname: 'native', dlext: 'so')
118
+ def build_ruby_extension(dlname: 'native', dlext: nil, liboutput: true)
119
119
  dlname = env :DLNAME, dlname
120
- dlext = env :DLEXT, RbConfig::CONFIG['DLEXT'] || dlext
120
+ dlext = env :DLEXT, dlext || RbConfig::CONFIG['DLEXT'] || 'so'
121
121
 
122
122
  extconf = File.join ext_dir, 'extconf.rb'
123
123
  makefile = File.join ext_dir, 'Makefile'
@@ -128,9 +128,9 @@ module Xot
128
128
  libout = File.join ext_lib_dir, outname
129
129
 
130
130
  srcs = FileList["#{ext_dir}/**/*.cpp"]
131
- libs = modules.map {|m| "#{m.lib_dir}/lib#{m.name.downcase}.a"}
131
+ libs = extensions.map {|x| "#{x.lib_dir}/lib#{x.name.downcase}.a"}
132
132
 
133
- alias_task :ext => libout
133
+ alias_task :ext => (liboutput ? libout : extout)
134
134
  alias_task :clean => 'ext:clean'
135
135
  alias_task :clobber => 'ext:clobber'
136
136
 
@@ -220,7 +220,7 @@ module Xot
220
220
  end
221
221
 
222
222
  desc "upload gem"
223
- task :upload => :install do
223
+ task :upload => gemfile do
224
224
  sh %( gem push #{gemfile} )
225
225
  end
226
226
 
data/lib/xot.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
 
4
- require 'xot/module'
4
+ require 'xot/extension'
5
+
5
6
  require 'xot/bit_flag'
6
7
  require 'xot/bit_flag_accessor'
7
8
  require 'xot/bit_util'
data/test/helper.rb CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
 
4
4
  %w[.]
5
- .map {|s| File.expand_path "../../#{s}/lib", __FILE__}
5
+ .map {|s| File.expand_path "../#{s}/lib", __dir__}
6
6
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
7
 
8
8
  require 'test/unit'
9
9
  require 'xot'
10
10
  require 'xot/test'
11
- require 'xot/tester'
11
+ require_relative '../ext/xot/tester'
12
12
 
13
13
  include Xot::Test
data/xot.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
 
4
- File.expand_path('../lib', __FILE__)
4
+ File.expand_path('lib', __dir__)
5
5
  .tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
6
 
7
- require 'xot/module'
7
+ require 'xot/extension'
8
8
 
9
9
 
10
10
  Gem::Specification.new do |s|
@@ -12,22 +12,23 @@ Gem::Specification.new do |s|
12
12
  patterns.map {|pat| Dir.glob(pat).to_a}.flatten
13
13
  end
14
14
 
15
- mod = Xot::Module
16
- name = mod.name.downcase
15
+ ext = Xot::Extension
16
+ name = ext.name.downcase
17
17
  rdocs = glob.call *%w[README]
18
18
 
19
19
  s.name = name
20
20
  s.summary = 'A Utility library for C++ developemt.'
21
21
  s.description = 'This library include some useful utility classes and functions for development with C++.'
22
- s.version = mod.version
22
+ s.version = ext.version
23
23
 
24
24
  s.authors = %w[xordog]
25
25
  s.email = 'xordog@gmail.com'
26
26
  s.homepage = "https://github.com/xord/xot"
27
27
 
28
28
  s.platform = Gem::Platform::RUBY
29
- s.required_ruby_version = '>= 2.6.0'
29
+ s.required_ruby_version = '>= 2.7.0'
30
30
 
31
+ s.add_development_dependency 'rake'
31
32
  s.add_development_dependency 'test-unit'
32
33
 
33
34
  s.files = `git ls-files`.split $/
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.29
4
+ version: 0.1.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-13 00:00:00.000000000 Z
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
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
  - !ruby/object:Gem::Dependency
14
28
  name: test-unit
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -32,6 +46,11 @@ extensions:
32
46
  - Rakefile
33
47
  extra_rdoc_files: []
34
48
  files:
49
+ - ".github/workflows/release.yml"
50
+ - ".github/workflows/tag.yml"
51
+ - ".github/workflows/test.yml"
52
+ - ".github/workflows/utils.rb"
53
+ - ChangeLog.md
35
54
  - LICENSE
36
55
  - README.md
37
56
  - Rakefile
@@ -55,9 +74,9 @@ files:
55
74
  - lib/xot/block_util.rb
56
75
  - lib/xot/const_symbol_accessor.rb
57
76
  - lib/xot/extconf.rb
77
+ - lib/xot/extension.rb
58
78
  - lib/xot/hookable.rb
59
79
  - lib/xot/invoker.rb
60
- - lib/xot/module.rb
61
80
  - lib/xot/rake.rb
62
81
  - lib/xot/rake/alias_task.rb
63
82
  - lib/xot/rake/escalation.rb
@@ -94,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
113
  requirements:
95
114
  - - ">="
96
115
  - !ruby/object:Gem::Version
97
- version: 2.6.0
116
+ version: 2.7.0
98
117
  required_rubygems_version: !ruby/object:Gem::Requirement
99
118
  requirements:
100
119
  - - ">="
101
120
  - !ruby/object:Gem::Version
102
121
  version: '0'
103
122
  requirements: []
104
- rubygems_version: 3.2.33
123
+ rubygems_version: 3.4.6
105
124
  signing_key:
106
125
  specification_version: 4
107
126
  summary: A Utility library for C++ developemt.