cppjieba_rb 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +21 -0
  3. data/.github/workflows/linting.yml +30 -0
  4. data/.github/workflows/release.yml +42 -0
  5. data/.github/workflows/tests.yml +47 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +45 -0
  8. data/.ruby-version +1 -0
  9. data/.yamllint +35 -0
  10. data/CHANGELOG.md +17 -0
  11. data/Gemfile +11 -0
  12. data/README.md +5 -5
  13. data/Rakefile +16 -7
  14. data/cppjieba_rb.gemspec +46 -33
  15. data/ext/cppjieba/.github/workflows/cmake.yml +52 -0
  16. data/ext/cppjieba/.github/workflows/stale-issues.yml +24 -0
  17. data/ext/cppjieba/.gitmodules +3 -0
  18. data/ext/cppjieba/{ChangeLog.md → CHANGELOG.md} +50 -1
  19. data/ext/cppjieba/CMakeLists.txt +11 -14
  20. data/ext/cppjieba/LICENSE +20 -0
  21. data/ext/cppjieba/README.md +9 -18
  22. data/ext/cppjieba/deps/limonp/.github/workflows/cmake.yml +43 -0
  23. data/ext/cppjieba/deps/limonp/.gitignore +9 -0
  24. data/ext/cppjieba/deps/limonp/CHANGELOG.md +160 -0
  25. data/ext/cppjieba/deps/limonp/CMakeLists.txt +61 -0
  26. data/ext/cppjieba/deps/limonp/LICENSE +20 -0
  27. data/ext/cppjieba/deps/limonp/README.md +38 -0
  28. data/ext/cppjieba/deps/limonp/{LocalVector.hpp → include/limonp/LocalVector.hpp} +3 -3
  29. data/ext/cppjieba/deps/limonp/{Logging.hpp → include/limonp/Logging.hpp} +17 -3
  30. data/ext/cppjieba/deps/limonp/{StringUtil.hpp → include/limonp/StringUtil.hpp} +31 -10
  31. data/ext/cppjieba/deps/limonp/test/CMakeLists.txt +8 -0
  32. data/ext/cppjieba/deps/limonp/test/demo.cpp +40 -0
  33. data/ext/cppjieba/deps/limonp/test/testdata/1.conf +5 -0
  34. data/ext/cppjieba/deps/limonp/test/testdata/StdExtension.data +3 -0
  35. data/ext/cppjieba/deps/limonp/test/testdata/dict.gbk +50 -0
  36. data/ext/cppjieba/deps/limonp/test/testdata/dict.utf8 +50 -0
  37. data/ext/cppjieba/deps/limonp/test/testdata/io_testfile +2 -0
  38. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.1.utf8 +93 -0
  39. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.utf8 +93 -0
  40. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.1.utf8 +67 -0
  41. data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.2.utf8 +64 -0
  42. data/ext/cppjieba/deps/limonp/test/unittest/CMakeLists.txt +30 -0
  43. data/ext/cppjieba/deps/limonp/test/unittest/TArgvContext.cpp +16 -0
  44. data/ext/cppjieba/deps/limonp/test/unittest/TCastFloat.cpp +19 -0
  45. data/ext/cppjieba/deps/limonp/test/unittest/TClosure.cpp +85 -0
  46. data/ext/cppjieba/deps/limonp/test/unittest/TColorPrint.cpp +20 -0
  47. data/ext/cppjieba/deps/limonp/test/unittest/TConfig.cpp +17 -0
  48. data/ext/cppjieba/deps/limonp/test/unittest/TLocalVector.cpp +41 -0
  49. data/ext/cppjieba/deps/limonp/test/unittest/TLogging.cpp +12 -0
  50. data/ext/cppjieba/deps/limonp/test/unittest/TStdExtension.cpp +95 -0
  51. data/ext/cppjieba/deps/limonp/test/unittest/TStringUtil.cpp +183 -0
  52. data/ext/cppjieba/include/cppjieba/DictTrie.hpp +9 -0
  53. data/ext/cppjieba/include/cppjieba/Jieba.hpp +4 -0
  54. data/ext/cppjieba/include/cppjieba/Trie.hpp +27 -1
  55. data/ext/cppjieba/test/CMakeLists.txt +4 -3
  56. data/ext/cppjieba/test/unittest/CMakeLists.txt +16 -7
  57. data/ext/cppjieba_rb/extconf.rb +11 -6
  58. data/lib/cppjieba_rb/segment.rb +4 -1
  59. data/lib/cppjieba_rb/version.rb +3 -1
  60. data/lib/cppjieba_rb.rb +12 -5
  61. data/test/test_keyword.rb +8 -8
  62. data/test/test_segment.rb +14 -10
  63. data/test/test_stop_word_filter.rb +5 -3
  64. data/test/test_tagging.rb +5 -2
  65. metadata +63 -140
  66. data/.travis.yml +0 -30
  67. data/ext/cppjieba/.travis.yml +0 -21
  68. data/ext/cppjieba/README_EN.md +0 -115
  69. data/ext/cppjieba/appveyor.yml +0 -32
  70. data/ext/cppjieba/deps/CMakeLists.txt +0 -1
  71. data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
  72. data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
  73. data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
  74. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
  75. data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
  76. data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
  77. data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
  78. data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
  79. data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
  80. data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
  81. data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
  82. data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
  83. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
  84. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
  85. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
  86. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
  87. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
  88. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
  89. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
  90. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
  91. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
  92. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
  93. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
  94. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
  95. data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
  96. data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
  97. data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
  98. data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
  99. data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
  100. data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
  101. data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
  102. data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
  103. data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
  104. data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
  105. data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
  106. data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
  107. data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
  108. data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
  109. data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
  110. data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
  111. data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
  112. data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
  113. data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
  114. data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
  115. data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
  116. data/ext/cppjieba/test/demo.cpp +0 -80
  117. /data/ext/cppjieba/deps/{gtest/src/.deps/.dirstamp → limonp/.gitmodules} +0 -0
  118. /data/ext/cppjieba/deps/limonp/{ArgvContext.hpp → include/limonp/ArgvContext.hpp} +0 -0
  119. /data/ext/cppjieba/deps/limonp/{Closure.hpp → include/limonp/Closure.hpp} +0 -0
  120. /data/ext/cppjieba/deps/limonp/{Colors.hpp → include/limonp/Colors.hpp} +0 -0
  121. /data/ext/cppjieba/deps/limonp/{Condition.hpp → include/limonp/Condition.hpp} +0 -0
  122. /data/ext/cppjieba/deps/limonp/{Config.hpp → include/limonp/Config.hpp} +0 -0
  123. /data/ext/cppjieba/deps/limonp/{ForcePublic.hpp → include/limonp/ForcePublic.hpp} +0 -0
  124. /data/ext/cppjieba/deps/limonp/{NonCopyable.hpp → include/limonp/NonCopyable.hpp} +0 -0
  125. /data/ext/cppjieba/deps/limonp/{StdExtension.hpp → include/limonp/StdExtension.hpp} +0 -0
  126. /data/ext/cppjieba/deps/{gtest/src/gtest_main.cc → limonp/test/unittest/gtest_main.cpp} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0307422c11b4c5b703e3017990e706e242e56f062eca887a0445e3b5b3c20bcc
4
- data.tar.gz: 2b0fb44719d6a0614ceadb99bfd7a49b7a814dc81acd2900897230f6167e7ec1
3
+ metadata.gz: c764f86e12cb63776f9dd2b2ce8b0704de2a766dbb43a361808aec12425c20a9
4
+ data.tar.gz: f0d87212f847cba89b41dfbaa44f82acc61b34cae18b65ef2e44b8baa2c4462b
5
5
  SHA512:
6
- metadata.gz: b642ca8a5afc99e45fb18bcafd06bf4d24a6ea6c5b7e5b5dffa2a76e61418e0f170cf7a8a61c911c8ab035ca71f810100eafbdf7390347d0466f9f7b39f62d99
7
- data.tar.gz: dcbf422afc0d0c85e5db5ed25c90dedff46767d9a6f3c52250f256584ef082437718da0c921c1291e2c1623944529ebd11c80b8e6247c84ee27b2febffaea8ef
6
+ metadata.gz: f2ce849f65fd618b3cb62833de4c43f0771985f2282df99dc10ae61261c92ba13391b7725ce452a1e5a5519cc4477e349e38e5f443d52bd17bc17a278acbcf21
7
+ data.tar.gz: 56660f21c9981bdd7180337674435b9c56d0238187c445ffd2b8146c750da6d319b94d8834ab47c5230d9b8726aac907409ceaeaf870302921cd5ada78331b50
data/.editorconfig ADDED
@@ -0,0 +1,21 @@
1
+ # Top-level setting to indicate this is the root .editorconfig file
2
+ root = true
3
+
4
+ # Default settings for all files
5
+ [*]
6
+ # Enforce LF (\n) as the line ending across all files for consistency
7
+ end_of_line = lf
8
+ # Ensure every file ends with a newline
9
+ insert_final_newline = true
10
+ charset = utf-8
11
+ # Use spaces for indentation (as opposed to tabs)
12
+ indent_style = space
13
+ # Set the width of a single indentation level to 2 spaces
14
+ indent_size = 2
15
+ trim_trailing_whitespace = true
16
+
17
+ # Specific settings for Markdown files
18
+ [*.md]
19
+ # Disable trimming of trailing whitespace in Markdown files,
20
+ # important for Markdown syntax where trailing spaces can be meaningful
21
+ trim_trailing_whitespace = false
@@ -0,0 +1,30 @@
1
+ name: Linting
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ linting:
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Lint YAML
21
+ run: yamllint .
22
+
23
+ - name: Set up Ruby and install dependencies
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ # uses .ruby-version implicitly
27
+ bundler-cache: true
28
+
29
+ - name: Lint Ruby code
30
+ run: bundle exec rubocop
@@ -0,0 +1,42 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch: # allow repo collaborators to publish gem
5
+
6
+ permissions:
7
+ contents: write # required for `rake release` to push the release tag
8
+ id-token: write # required for workflow to publish gem
9
+
10
+ jobs:
11
+ release:
12
+ if: github.ref == 'refs/heads/master'
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v4
18
+ with:
19
+ submodules: recursive # cppjieba requires a vendor library in a submodule
20
+
21
+ # required to run `rake release`.
22
+ - name: Setup Ruby and install dependencies
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ # setup-ruby implicitly uses .ruby-version
26
+ bundler-cache: true
27
+
28
+ # Run `rake release` to create git tag and push to repository based on `lib/cppjieba_rb/version.rb`.
29
+ # Then publish the new gem via trusted publishing
30
+ # Read more on https://guides.rubygems.org/trusted-publishing/releasing-gems/
31
+ - name: Publish gem
32
+ uses: rubygems/release-gem@v1
33
+
34
+ - name: Create GitHub Release
35
+ run: |
36
+ VERSION="v$(bundle exec rake version)"
37
+
38
+ gh release create \
39
+ $VERSION \
40
+ --verify-tag \
41
+ --generate-notes \
42
+ --latest
@@ -0,0 +1,47 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ tests:
14
+ strategy:
15
+ matrix:
16
+ # Tests a range of Ruby to ensure the gem works.
17
+ # Keeps 2.7 for a while but support EOL Ruby for a year in general
18
+ # Read more about Ruby EOL date on https://endoflife.date/ruby
19
+ ruby-version:
20
+ - '2.7'
21
+ - '3.0'
22
+ - '3.1'
23
+ - '3.2'
24
+ - '3.3'
25
+ - head
26
+ # test distributions up to 4 years
27
+ runner:
28
+ - ubuntu-latest
29
+ - ubuntu-20.04
30
+ fail-fast: false # allow contributors understand failure builds
31
+
32
+ runs-on: ${{ matrix.runner }}
33
+
34
+ steps:
35
+ - name: Checkout repository
36
+ uses: actions/checkout@v4
37
+ with:
38
+ submodules: recursive # cppjieba requires a vendor library in a submodule
39
+
40
+ - name: Set up Ruby and install dependencies
41
+ uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby-version }}
44
+ bundler-cache: true
45
+
46
+ - name: Run tests
47
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -9,6 +9,7 @@ _yardoc
9
9
  coverage
10
10
  doc/
11
11
  lib/bundler/man
12
+ *.so
12
13
  *.bundle
13
14
  pkg
14
15
  rdoc
data/.rubocop.yml ADDED
@@ -0,0 +1,45 @@
1
+ # merge the default 'Exclude' key with ours
2
+ inherit_mode:
3
+ merge:
4
+ - Exclude
5
+
6
+ require:
7
+ - rubocop-minitest
8
+ - rubocop-performance
9
+ - rubocop-rake
10
+
11
+ AllCops:
12
+ NewCops: enable
13
+ StyleGuideBaseURL: https://rubystyle.guide
14
+ TargetRubyVersion: 2.7
15
+ SuggestExtensions: false
16
+
17
+ Exclude:
18
+ - bin/**/*
19
+ - tmp/**/*
20
+
21
+ Bundler/OrderedGems:
22
+ Include:
23
+ - '*.gemspec'
24
+
25
+
26
+ # Enforce single quotes in the gem
27
+ Style/StringLiterals:
28
+ Enabled: true
29
+ EnforcedStyle: single_quotes
30
+
31
+ Style/HashSyntax:
32
+ EnforcedStyle: no_mixed_keys # consistent hash syntax
33
+ EnforcedShorthandSyntax: consistent # enforce explicit hash syntax
34
+
35
+ # Project maximum code line length
36
+ Layout/LineLength:
37
+ Max: 120
38
+
39
+ # Exclude test files from BlockComments check
40
+ Style/BlockComments:
41
+ Exclude:
42
+ - 'test/**/*'
43
+
44
+ Metrics/MethodLength:
45
+ Max: 100
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3
data/.yamllint ADDED
@@ -0,0 +1,35 @@
1
+ extends: default
2
+
3
+ locale: en_US.UTF-8
4
+
5
+ # ignored directories
6
+ ignore: |
7
+ .git/
8
+
9
+ rules:
10
+ octal-values: enable
11
+
12
+ document-start: disable
13
+ document-end: disable
14
+
15
+ # allow 120 characters in a line
16
+ line-length:
17
+ max: 120
18
+ level: error
19
+
20
+ indentation:
21
+ spaces: 2
22
+ indent-sequences: true
23
+
24
+ # allow one space indent
25
+ comments:
26
+ level: error
27
+ min-spaces-from-content: 1
28
+
29
+ # disallow boolean values to avoid surprise
30
+ truthy:
31
+ level: error
32
+
33
+ # github workflows uses `on` as trigger
34
+ ignore: |
35
+ .github/workflows/*.yml
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ ## [0.4.3](https://github.com/erickguan/cppjieba_rb/compare/v0.4.2...v0.4.4) ##
2
+
3
+ ### Added
4
+
5
+ - Linting with rubocop.
6
+
7
+ ### Changed
8
+
9
+ - Requires Ruby 2.7.
10
+ - Update `cppjieba` to `v5.3.2`. `cppejieba` supports more compliers. But no functions changes.
11
+ - Testing with GitHub Action.
12
+ - Releases and publishes the gem with Trust Publishing on GitHub Action.
13
+
14
+ ### Fixed
15
+
16
+
17
+ ### Removed
data/Gemfile CHANGED
@@ -1,3 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
6
+
7
+ gem 'rubocop', '~> 1.66.1', require: false
8
+ gem 'rubocop-minitest', '~> 0.36.0', require: false
9
+ gem 'rubocop-performance', '~> 1.22.1', require: false
10
+ gem 'rubocop-rake', '~> 0.6.0', require: false
11
+
12
+ gem 'minitest', '~> 5.14'
13
+ gem 'rake', '~> 13'
14
+ gem 'rake-compiler', '~> 1.1'
data/README.md CHANGED
@@ -2,10 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/cppjieba_rb.svg)](http://badge.fury.io/rb/cppjieba_rb)
4
4
 
5
- [![Build Status](https://travis-ci.com/erickguan/cppjieba_rb.svg?branch=master)](https://travis-ci.com/erickguan/cppjieba_rb)
6
-
7
- [![Patreon](https://img.shields.io/badge/back_on-patreon-red.svg)](https://www.patreon.com/fantasticfears)
8
-
9
5
  Ruby bindings for [Cppjieba](https://github.com/yanyiwu/cppjieba). C++11 required. (gcc 4.8+)
10
6
 
11
7
  The TRIE tree has high memory usage. For default dict, it uses ~120 MB memory.
@@ -14,7 +10,11 @@ The TRIE tree has high memory usage. For default dict, it uses ~120 MB memory.
14
10
 
15
11
  Add this line to your application's Gemfile:
16
12
 
17
- gem 'cppjieba_rb'
13
+ gem 'cppjieba_rb', require: false
14
+
15
+ Or pin a version:
16
+
17
+ gem 'cppjieba_rb', '~> 0.4.2', require: false
18
18
 
19
19
  Or install it as:
20
20
 
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
3
5
  require 'rake/extensiontask'
4
6
 
5
- gem = Gem::Specification.load(File.dirname(__FILE__) + '/cppjieba_rb.gemspec')
6
- Rake::ExtensionTask.new("cppjieba_rb", gem) do |ext|
7
+ gem = Gem::Specification.load("#{File.dirname(__FILE__)}/cppjieba_rb.gemspec")
8
+ Rake::ExtensionTask.new('cppjieba_rb', gem) do |ext|
7
9
  ext.lib_dir = File.join('lib', 'cppjieba_rb')
8
10
  end
9
11
 
@@ -12,9 +14,16 @@ Rake::Task[:test].prerequisites << :compile
12
14
  Rake::TestTask.new do |t|
13
15
  t.libs << 'test'
14
16
  end
15
- desc "clean compile files"
17
+
18
+ desc 'clean compile files'
16
19
  task :clean_compile do
17
- system "rm -r tmp"
18
- system "rm lib/*.bundle"
20
+ system 'rm -r tmp'
21
+ system 'rm lib/*.bundle'
22
+ end
23
+
24
+ task default: :test
25
+
26
+ desc 'report gem version'
27
+ task :version do
28
+ print CppjiebaRb::VERSION
19
29
  end
20
- task :default => :test
data/cppjieba_rb.gemspec CHANGED
@@ -1,50 +1,63 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'cppjieba_rb/version'
5
6
 
7
+ # Recursive function to handle submodules and their submodules
8
+ def collect_submodule_files(spec, relative_path, submodule_dir)
9
+ Dir.chdir(submodule_dir) do
10
+ submodule_relative_path = submodule_dir.gsub(relative_path, '')
11
+
12
+ # Get all files in the current submodule
13
+ submodule_files = `git ls-files -z`.split("\x0")
14
+ submodule_files.each do |file|
15
+ # Add the relative submodule path to each file
16
+ spec.files << File.join(submodule_relative_path, file)
17
+ end
18
+
19
+ # Recurse into any submodules of the current submodule
20
+ nested_submodules = `git submodule foreach --quiet pwd`.split("\n")
21
+ nested_submodules.each do |nested_submodule_path|
22
+ if (ENV['OS'] == 'Windows_NT') && nested_submodule_path.start_with?('/')
23
+ # Handle cygwin-style paths on Windows
24
+ nested_submodule_path = nested_submodule_path[1..] # Remove leading slash
25
+ nested_submodule_path.insert(1, ':') # Add drive letter (e.g., C:)
26
+ end
27
+ collect_submodule_files(spec, relative_path, nested_submodule_path)
28
+ end
29
+ end
30
+ end
31
+
6
32
  Gem::Specification.new do |spec|
7
33
  spec.name = 'cppjieba_rb'
8
34
  spec.version = CppjiebaRb::VERSION
9
35
  spec.authors = ['Erick Guan']
10
- spec.email = ['fantasticfears@gmail.com']
36
+ spec.email = ['erickguanst@gmail.com']
11
37
  spec.summary = 'cppjieba binding for ruby'
12
38
  spec.description = 'cppjieba binding for ruby. Mainly used by Discourse.'
13
- spec.homepage = 'https://github.com/fantasticfears/cppjieba_rb'
14
- spec.required_ruby_version = '>=2.3.0'
15
- spec.license = 'MIT'
39
+ spec.homepage = 'https://github.com/erickguan/cppjieba_rb'
40
+ spec.required_ruby_version = '>=2.7.0'
41
+ spec.license = 'MIT'
16
42
  spec.extensions = ['ext/cppjieba_rb/extconf.rb']
17
43
 
18
- spec.files = `git ls-files -z`.split("\x0")
19
- relative_path = File.expand_path('../', __FILE__) + '/'
20
- `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
21
- if (ENV['OS'] == 'Windows_NT') && submodule_path[0] == '/'
22
- # Detect if cygwin path is being used by git
23
- submodule_path = submodule_path[1..-1]
24
- submodule_path.insert(1, ':')
25
- end
26
- # for each submodule, change working directory to that submodule
27
- Dir.chdir(submodule_path) do
28
- # Make the submodule path relative
29
- submodule_path = submodule_path.gsub(/#{relative_path}/i, '')
30
- # issue git ls-files in submodule's directory
31
- submodule_files = `git ls-files -z`.split("\x0")
32
-
33
- # prepend the submodule path to create relative file paths
34
- submodule_files_paths = submodule_files.map do |filename|
35
- File.join(submodule_path, filename)
36
- end
37
- # add relative paths to gem.files
38
- spec.files += submodule_files_paths
44
+ spec.files = `git ls-files -z`.split("\x0")
45
+ relative_path = "#{File.expand_path(__dir__)}/"
46
+
47
+ # Collect files from all submodules recursively
48
+ submodules = `git submodule foreach --quiet pwd`.split("\n")
49
+ submodules.each do |submodule_path|
50
+ if (ENV['OS'] == 'Windows_NT') && submodule_path.start_with?('/')
51
+ # Handle cygwin-style paths on Windows
52
+ submodule_path = submodule_path[1..] # Remove leading slash
53
+ submodule_path.insert(1, ':') # Add drive letter (e.g., C:)
39
54
  end
55
+
56
+ collect_submodule_files(spec, relative_path, submodule_path)
40
57
  end
41
58
 
42
59
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
43
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
44
- spec.require_paths = ['lib']
60
+ spec.require_paths = ['lib'] # to pick up the compiled shared library.
45
61
 
46
- spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.10'
47
- spec.add_development_dependency 'rake', '~> 13'
48
- spec.add_development_dependency 'rake-compiler', '~> 1.1'
49
- spec.add_development_dependency 'minitest', '~> 5.14'
62
+ spec.metadata['rubygems_mfa_required'] = 'true'
50
63
  end
@@ -0,0 +1,52 @@
1
+ name: CMake
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ env:
8
+ # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
9
+ BUILD_TYPE: Release
10
+
11
+ jobs:
12
+ build:
13
+ # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
14
+ # You can convert this to a matrix build if you need cross-platform coverage.
15
+ # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ matrix:
19
+ os: [
20
+ ubuntu-20.04,
21
+ ubuntu-22.04,
22
+ macos-12,
23
+ macos-13,
24
+ macos-14,
25
+ windows-2019,
26
+ windows-2022,
27
+ ]
28
+ cpp_version: [11, 14, 17, 20]
29
+
30
+ steps:
31
+ - name: Check out repository code
32
+ uses: actions/checkout@v2
33
+ with:
34
+ submodules: recursive
35
+
36
+ - name: Configure CMake
37
+ # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
38
+ # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
39
+ # run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
40
+ run: cmake -B ${{github.workspace}}/build -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=${{matrix.cpp_version}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
41
+
42
+ - name: Build
43
+ # Build your program with the given configuration
44
+ # run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
45
+ run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
46
+
47
+ - name: Test
48
+ working-directory: ${{github.workspace}}/build
49
+ # Execute tests defined by the CMake configuration.
50
+ # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
51
+ run: ctest -C ${{env.BUILD_TYPE}}
52
+
@@ -0,0 +1,24 @@
1
+ name: Close Stale Issues
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 0 * * 0' # Run weekly on Sunday at midnight
6
+
7
+ jobs:
8
+ stale:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ issues: write
12
+ pull-requests: write
13
+
14
+ steps:
15
+ - uses: actions/stale@v5
16
+ with:
17
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
18
+ stale-issue-message: 'This issue has not been updated for over 1 year and will be marked as stale. If the issue still exists, please comment or update the issue, otherwise it will be closed after 7 days.'
19
+ close-issue-message: 'This issue has been automatically closed due to inactivity. If the issue still exists, please reopen it.'
20
+ days-before-issue-stale: 365
21
+ days-before-issue-close: 7
22
+ stale-issue-label: 'Stale'
23
+ exempt-issue-labels: 'pinned,security'
24
+ operations-per-run: 100
@@ -0,0 +1,3 @@
1
+ [submodule "deps/limonp"]
2
+ path = deps/limonp
3
+ url = https://github.com/yanyiwu/limonp.git
@@ -1,4 +1,53 @@
1
- # CppJieba ChangeLog
1
+ # CHANGELOG
2
+
3
+ ## v5.3.2
4
+
5
+ + removed test/demo.cpp and linked https://github.com/yanyiwu/cppjieba-demo
6
+ + Update Demo Link in README.md
7
+ + [github/actions] stale 1 year ago issues
8
+ + limonp v0.9.0 -> v1.0.0
9
+
10
+ ## v5.3.1
11
+
12
+ + [cmake] fetch googletest
13
+ + [submodules] rm test/googletest
14
+
15
+ ## v5.3.0
16
+
17
+ + [c++17,c++20] compatibility
18
+ + limonp version 0.6.7 -> 0.9.0
19
+
20
+ ## v5.2.0
21
+
22
+ + [CI] windows-[2019,2022]
23
+ + [googletest] v1.6.0->v1.10.0
24
+ + [CI] ubuntu version from 20 to 22, macos version from 12 to 14
25
+ + [CMake] mini_required 2.6->3.5 and fix CXX_VERSION variable passed from cmd
26
+ + [CI] matrix and multi cpp version [11, 14]
27
+
28
+ ## v5.1.3
29
+
30
+ + [googletest] git submodule add googletest-1.6.0
31
+
32
+ ## v5.1.2
33
+
34
+ + [submodule:deps/limonp] upgrade to v0.6.7
35
+
36
+ ## v5.1.1
37
+
38
+ + Merged [pr-186](https://github.com/yanyiwu/cppjieba/pull/186)
39
+
40
+ ## v5.1.0
41
+
42
+ + Merged [feature: add RemoveWord api from gojieba/pull/99 #172](https://github.com/yanyiwu/cppjieba/pull/172)
43
+
44
+ ## v5.0.5
45
+
46
+ + Merged [pr-171 submodule update limonp to v0.6.6 #171](https://github.com/yanyiwu/cppjieba/pull/171)
47
+
48
+ ## v5.0.4
49
+
50
+ + Merged [pr-168 limonp as submodule #168](https://github.com/yanyiwu/cppjieba/pull/168)
2
51
 
3
52
  ## v5.0.3
4
53
 
@@ -1,28 +1,25 @@
1
+ CMAKE_MINIMUM_REQUIRED (VERSION 3.5)
1
2
  PROJECT(CPPJIEBA)
2
3
 
3
- CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
4
-
5
- INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/deps
4
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/deps/limonp/include
6
5
  ${PROJECT_SOURCE_DIR}/include)
7
6
 
8
7
  if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
9
8
  set (CMAKE_INSTALL_PREFIX "/usr/local/cppjieba" CACHE PATH "default install path" FORCE )
10
9
  endif()
11
10
 
12
- ADD_DEFINITIONS(-O3 -Wall -g)
13
- IF(APPLE) # mac os
14
- ADD_DEFINITIONS(-std=c++0x)
11
+ if(NOT DEFINED CMAKE_CXX_STANDARD)
12
+ set(CMAKE_CXX_STANDARD 11)
15
13
  endif()
14
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
15
+ set(CMAKE_CXX_EXTENSIONS OFF)
16
16
 
17
- # cmake .. -DENC=GBK
18
- # IF (DEFINED ENC)
19
- # ADD_DEFINITIONS(-DCPPJIEBA_${ENC})
20
- # ENDIF()
17
+ ADD_DEFINITIONS(-O3 -Wall -g)
21
18
 
22
- ADD_SUBDIRECTORY(deps)
23
19
  ADD_SUBDIRECTORY(test)
24
20
 
25
21
  ENABLE_TESTING()
26
- ADD_TEST(NAME ./test/test.run COMMAND ./test/test.run)
27
- ADD_TEST(NAME ./load_test COMMAND ./load_test)
28
- ADD_TEST(NAME ./demo COMMAND ./demo)
22
+ if(NOT MSVC)
23
+ ADD_TEST(NAME ./test/test.run COMMAND ./test/test.run)
24
+ ADD_TEST(NAME ./load_test COMMAND ./load_test)
25
+ endif()
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.