wordexp 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c5227dbd1fe02c9c03ef7fa283634660059075218e1d10d7fec6c6a1a3a42de
4
- data.tar.gz: 28783e67617dccb31263ae595398575301901984f95254d57d202be05238c002
3
+ metadata.gz: 06fa4b34723046bd70933eec52d7f4f1b049788feda8c77db1768e0efae3be23
4
+ data.tar.gz: f955c4b0b8f835bc34b423593102493805d04b7e45789e208e748dec02ec764b
5
5
  SHA512:
6
- metadata.gz: 7c1c96cf134ea3cdea803f06e96ebdaec59d7ccfddd7a1ffe501da41ef64e25cb1324972ac1c0bbb723512a980b3515ebfad21706e7ec4a7fe91d1abcb0e8714
7
- data.tar.gz: 12157e951a1e929dd08c45244cb9982213762d9859df1fadbae183fd70d1453de2407f91203c638fd19fd3d820f9960abe42f98ec6bbba2dc235ae84e906545b
6
+ metadata.gz: 07bf18ec5393dc40f89a43b811a2548cc91dce8612b79c23cc716b5d3275734dd677bb44ffb134cc930118d68b002cabcf93cde2c3ccde11cc499fb8fb4e05c9
7
+ data.tar.gz: 6b4e62ffd9a506cd213a83eb6e607b1d44b4fc59efac65c770330d8253da591abcf1976e7a953bcb592e58e5e9a7f213685f16081d2ad62a303b0f615b2cca6d
@@ -0,0 +1,20 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: monthly
7
+ time: "06:00"
8
+ timezone: America/Los_Angeles
9
+ open-pull-requests-limit: 10
10
+ labels:
11
+ - "🏠 Housekeeping"
12
+ - package-ecosystem: github-actions
13
+ directory: "/"
14
+ schedule:
15
+ interval: monthly
16
+ time: "06:00"
17
+ timezone: America/Los_Angeles
18
+ open-pull-requests-limit: 10
19
+ labels:
20
+ - "🏠 Housekeeping"
@@ -0,0 +1,23 @@
1
+ name-template: "$RESOLVED_VERSION"
2
+ tag-template: "v$RESOLVED_VERSION"
3
+ categories:
4
+ - title: "⚠️ Breaking Changes"
5
+ label: "⚠️ Breaking"
6
+ - title: "✨ New Features"
7
+ label: "✨ Feature"
8
+ - title: "🐛 Bug Fixes"
9
+ label: "🐛 Bug Fix"
10
+ - title: "📚 Documentation"
11
+ label: "📚 Docs"
12
+ - title: "🏠 Housekeeping"
13
+ label: "🏠 Housekeeping"
14
+ version-resolver:
15
+ minor:
16
+ labels:
17
+ - "⚠️ Breaking"
18
+ - "✨ Feature"
19
+ default: patch
20
+ change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
21
+ no-changes-template: "- No changes"
22
+ template: |
23
+ $CHANGES
@@ -0,0 +1,53 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ rubocop:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 4.0.0
17
+ - name: Cache Ruby gems
18
+ uses: actions/cache@v3
19
+ with:
20
+ path: vendor/bundle
21
+ key: ${{ runner.os }}-bundle-4.0.0-${{ hashFiles('Gemfile.lock') }}
22
+ restore-keys: |
23
+ ${{ runner.os }}-bundle-4.0.0-
24
+ - name: Install dependencies
25
+ run: |
26
+ bundle config set --local path vendor/bundle
27
+ bundle install --jobs 8 --retry 3
28
+ - name: Run RuboCop
29
+ run: bundle exec rubocop
30
+
31
+ test:
32
+ runs-on: ubuntu-latest
33
+ strategy:
34
+ matrix:
35
+ ruby-version: ["3.2.9", "3.3.10", "3.4.8", "4.0.0"]
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby-version }}
41
+ - name: Cache Ruby gems
42
+ uses: actions/cache@v3
43
+ with:
44
+ path: vendor/bundle
45
+ key: ${{ runner.os }}-bundle-${{ matrix.ruby-version }}-${{ hashFiles('Gemfile.lock') }}
46
+ restore-keys: |
47
+ ${{ runner.os }}-bundle-${{ matrix.ruby-version }}-
48
+ - name: Install dependencies
49
+ run: |
50
+ bundle config set --local path vendor/bundle
51
+ bundle install --jobs 8 --retry 3
52
+ - name: Run tests
53
+ run: bundle exec rake test
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [main]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [main]
20
+ schedule:
21
+ - cron: "27 19 * * 2"
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: ["ruby"]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v6
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v4
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v4
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v4
@@ -0,0 +1,14 @@
1
+ name: Release Drafter
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ update_release_draft:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: release-drafter/release-drafter@v6
13
+ env:
14
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /site/
8
+ /spec/reports/
9
+ /tmp/
10
+ ext/**/Makefile
11
+ ext/**/*.o
12
+ **/wordexp*.bundle
13
+ *.gem
14
+ Gemfile.lock
data/.overcommit.yml ADDED
@@ -0,0 +1,32 @@
1
+ # Overcommit hooks run automatically on certain git operations, like "git commit".
2
+ # For a complete list of options that you can use to customize hooks, see:
3
+ # https://github.com/sds/overcommit
4
+
5
+ gemfile: false
6
+ verify_signatures: false
7
+
8
+ PreCommit:
9
+ BundleCheck:
10
+ enabled: true
11
+
12
+ FixMe:
13
+ enabled: true
14
+ keywords: ["FIXME"]
15
+ exclude:
16
+ - .overcommit.yml
17
+
18
+ LocalPathsInGemfile:
19
+ enabled: true
20
+
21
+ RuboCop:
22
+ enabled: true
23
+ required_executable: bundle
24
+ command: ["bundle", "exec", "rubocop"]
25
+ on_warn: fail
26
+
27
+ YamlSyntax:
28
+ enabled: true
29
+
30
+ PostCheckout:
31
+ ALL:
32
+ quiet: true
data/.prettierignore ADDED
@@ -0,0 +1 @@
1
+ /CODE_OF_CONDUCT.md
data/.rubocop.yml ADDED
@@ -0,0 +1,31 @@
1
+ plugins:
2
+ - rubocop-minitest
3
+ - rubocop-rake
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+ TargetRubyVersion: 3.0
8
+
9
+ Layout/EmptyLineAfterGuardClause:
10
+ Enabled: false
11
+
12
+ Layout/FirstHashElementIndentation:
13
+ EnforcedStyle: consistent
14
+
15
+ Metrics/AbcSize:
16
+ Max: 25
17
+
18
+ Metrics/MethodLength:
19
+ Max: 20
20
+
21
+ Style/Documentation:
22
+ Enabled: false
23
+
24
+ Style/FrozenStringLiteralComment:
25
+ Enabled: false
26
+
27
+ Style/HashSyntax:
28
+ EnforcedShorthandSyntax: never
29
+
30
+ Style/TrailingCommaInHashLiteral:
31
+ EnforcedStyleForMultiline: consistent_comma
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 4.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ [Release notes][gh] for this project are [also available on GitHub][gh].
4
+
5
+ [gh]: https://github.com/samsonjs/wordexp/releases
6
+
7
+ # 0.2.1
8
+ # 2026-01-02
9
+
10
+ - Ship source-only gem artifacts to ensure the native extension is built locally
11
+
12
+ # 0.2.0
13
+ # 2023-10-05
14
+
15
+ - Drop support for Ruby 2.7 because it's no longer supported
16
+
17
+ # 0.1.2
18
+ # 2023-01-08
19
+
20
+ - Add support for Ruby 3.2
21
+ - Drop support for Ruby 2.6
22
+
23
+ # 0.1.1
24
+ # 2022-01-16
25
+
26
+ - Add native extension and command line executable to gemspec
27
+
28
+ # 0.1.0
29
+ # 2022-01-16
30
+
31
+ First release. Implements the most basic API without any options.
32
+
33
+ Command line executable and native extension are broken.
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sami@samhuri.net. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'minitest', '~> 6.0'
5
+ gem 'minitest-ci', '~> 3.4'
6
+ gem 'minitest-reporters', '~> 1.6'
7
+ gem 'rake', '~> 13.3'
8
+ gem 'rake-compiler', '~> 1.2'
9
+ gem 'rubocop', '~> 1.81'
10
+ gem 'rubocop-minitest', '~> 0.38'
11
+ gem 'rubocop-packaging', '~> 0.5'
12
+ gem 'rubocop-performance', '~> 1.26'
13
+ gem 'rubocop-rake', '~> 0.6'
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # wordexp
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/wordexp.svg)](https://rubygems.org/gems/wordexp)
4
- [![Circle](https://circleci.com/gh/samsonjs/wordexp/tree/main.svg?style=shield)](https://app.circleci.com/pipelines/github/samsonjs/wordexp?branch=main)
5
- [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/21cc24badf15d19b5cec/maintainability)](https://codeclimate.com/github/samsonjs/wordexp/maintainability)
4
+ [![CI](https://github.com/samsonjs/wordexp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/samsonjs/wordexp/actions/workflows/ci.yml?query=branch%3Amain)
5
+ [![0 dependencies!](https://0dependencies.dev/0dependencies.svg)](https://0dependencies.dev)
6
6
 
7
7
  A Ruby gem for performing shell word expansion using [wordexp][]. It's like [Shellwords][] turned up to 11. Not only does it split taking quotes into account, but it also expands environment variables and tildes, and runs subcommands in `` `backticks` `` or `$(dollar parentheses)`.
8
8
 
data/Rakefile ADDED
@@ -0,0 +1,141 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'English'
3
+ require 'minitest/test_task'
4
+ require 'open3'
5
+ require 'rake/extensiontask'
6
+ require 'rubocop/rake_task'
7
+
8
+ desc 'Clean build files'
9
+ task :clean do
10
+ `cd ext/wordexp_ext && make clean && rm -f Makefile`
11
+ end
12
+
13
+ Rake::ExtensionTask.new 'wordexp_ext' do |ext|
14
+ ext.lib_dir = 'lib/wordexp'
15
+ end
16
+
17
+ Minitest::TestTask.create(test: :compile) do |t|
18
+ t.libs << 'test'
19
+ t.libs << 'lib'
20
+ t.warning = false
21
+ t.test_globs = ['test/**/*_test.rb']
22
+ end
23
+
24
+ RuboCop::RakeTask.new
25
+
26
+ task default: %i[test rubocop]
27
+
28
+ # == "rake release" enhancements ==============================================
29
+
30
+ Rake::Task['release'].enhance do
31
+ puts "Don't forget to publish the release on GitHub!"
32
+ system 'open https://github.com/samsonjs/wordexp/releases'
33
+ end
34
+
35
+ desc 'Set environment variable OVERCOMMIT_DISABLE to 1'
36
+ task :disable_overcommit do
37
+ ENV['OVERCOMMIT_DISABLE'] = '1'
38
+ end
39
+
40
+ Rake::Task[:build].enhance [:disable_overcommit]
41
+
42
+ desc 'Ensure that files in the gemspec are tracked with git'
43
+ task :verify_gemspec_files do
44
+ git_files = `git ls-files -z`.split("\x0")
45
+ ext_files = Dir['**/*.bundle']
46
+ gemspec_files = Gem::Specification.load('wordexp.gemspec').files.sort
47
+ ignored_by_git = gemspec_files - git_files - ext_files
48
+ next if ignored_by_git.empty?
49
+
50
+ raise <<~ERROR
51
+
52
+ The `spec.files` specified in wordexp.gemspec include the following files
53
+ that are being ignored by git. Did you forget to add them to the repo? If
54
+ not, you may need to delete these files or modify the gemspec to ensure
55
+ that they are not included in the gem by mistake:
56
+
57
+ #{ignored_by_git.join("\n").gsub(/^/, ' ')}
58
+
59
+ ERROR
60
+ end
61
+
62
+ Rake::Task[:build].enhance [:verify_gemspec_files]
63
+
64
+ # == "rake bump" tasks ========================================================
65
+
66
+ task bump: %w[bump:bundler bump:ruby bump:year]
67
+
68
+ namespace :bump do
69
+ desc 'Update to the latest bundler version in .circleci/config.yml and Gemfile.lock'
70
+ task :bundler do
71
+ version = Gem.latest_version_for('bundler').to_s
72
+ replace_in_file '.circleci/config.yml', /bundler -v (\S+)/ => version
73
+ replace_in_file 'Gemfile.lock', /^BUNDLED WITH\n\s+(\d\S+)$/ => version
74
+ end
75
+
76
+ desc 'Update ruby versions in wordexp.gemspec, .rubocop.yml, and .circleci/config.yml'
77
+ task :ruby do
78
+ lowest = RubyVersions.lowest_supported
79
+ lowest_minor = RubyVersions.lowest_supported_minor
80
+ latest = RubyVersions.latest
81
+ latest_patches = RubyVersions.latest_supported_patches
82
+
83
+ replace_in_file 'wordexp.gemspec', /ruby_version = .*">= (.*)"/ => lowest
84
+ replace_in_file '.rubocop.yml', /TargetRubyVersion: (.*)/ => lowest_minor
85
+ replace_in_file '.circleci/config.yml', /default: "([\d.]+)"/ => latest
86
+ replace_in_file '.circleci/config.yml', /version: (\[.+\])/ => latest_patches.inspect
87
+ end
88
+
89
+ desc 'Update to the latest year in LICENSE.txt'
90
+ task :year do
91
+ replace_in_file 'LICENSE.txt', /\(c\) (\d+)/ => Date.today.year.to_s
92
+ end
93
+ end
94
+
95
+ require 'date'
96
+ require 'open-uri'
97
+ require 'yaml'
98
+
99
+ def replace_in_file(path, replacements)
100
+ contents = File.read(path)
101
+ orig_contents = contents.dup
102
+ replacements.each do |regexp, text|
103
+ raise "Can't find #{regexp} in #{path}" unless regexp.match?(contents)
104
+
105
+ contents.gsub!(regexp) do |match|
106
+ match[regexp, 1] = text
107
+ match
108
+ end
109
+ end
110
+ File.write(path, contents) if contents != orig_contents
111
+ end
112
+
113
+ module RubyVersions
114
+ class << self
115
+ def lowest_supported
116
+ "#{lowest_supported_minor}.0"
117
+ end
118
+
119
+ def lowest_supported_minor
120
+ latest_supported_patches.first[/\d+\.\d+/]
121
+ end
122
+
123
+ def latest
124
+ latest_supported_patches.last
125
+ end
126
+
127
+ def latest_supported_patches
128
+ patches = [versions[:stable], versions[:security_maintenance]].flatten
129
+ patches.map { |p| Gem::Version.new(p) }.sort.map(&:to_s)
130
+ end
131
+
132
+ private
133
+
134
+ def versions
135
+ @versions ||= begin
136
+ yaml = URI.open('https://raw.githubusercontent.com/ruby/www.ruby-lang.org/HEAD/_data/downloads.yml')
137
+ YAML.safe_load(yaml, symbolize_names: true)
138
+ end
139
+ end
140
+ end
141
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'wordexp'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ which overcommit > /dev/null 2>&1 && overcommit --install
7
+ bundle install
8
+
9
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @file wordexp_ext.c
3
+ * @author Sami Samhuri (sami@samhuri.net)
4
+ * @brief Ruby wrapper for the standard Unix wordexp function, used to expand shell command lines in many useful ways.
5
+ * @version 0.1
6
+ * @date 2022-01-16
7
+ *
8
+ * @copyright Copyright (c) Sami Samhuri 2022
9
+ *
10
+ * Released under the terms of the MIT license: https://sjs.mit-license.org
11
+ *
12
+ */
13
+
14
+ #include <ruby.h>
15
+ #include <string.h>
16
+ #include <wordexp.h>
17
+
18
+ static VALUE ext_wordexp(VALUE self, VALUE rstring) {
19
+ Check_Type(rstring, T_STRING);
20
+ char *string = RSTRING_PTR(rstring);
21
+
22
+ /* Split and expand words, showing errors and failing on undefined variables */
23
+ wordexp_t words;
24
+ int result = wordexp(string, &words, WRDE_SHOWERR | WRDE_UNDEF);
25
+
26
+ /* failure */
27
+ if (result != 0) {
28
+ switch (result) {
29
+ case WRDE_BADCHAR:
30
+ return ID2SYM(rb_intern("wrde_badchar"));
31
+ case WRDE_BADVAL:
32
+ return ID2SYM(rb_intern("wrde_badval"));
33
+ case WRDE_CMDSUB:
34
+ return ID2SYM(rb_intern("wrde_cmdsub"));
35
+ case WRDE_NOSPACE:
36
+ return ID2SYM(rb_intern("wrde_nospace"));
37
+ case WRDE_SYNTAX:
38
+ return ID2SYM(rb_intern("wrde_syntax"));
39
+ default:
40
+ return ID2SYM(rb_intern("unknown_error"));
41
+ }
42
+ }
43
+
44
+ /* success */
45
+ VALUE rwords = rb_ary_new2(words.we_wordc);
46
+ for (size_t i = 0; i < words.we_wordc; i++) {
47
+ VALUE rword = rb_str_new2(words.we_wordv[i]);
48
+ rb_ary_push(rwords, rword);
49
+ }
50
+ wordfree(&words);
51
+ return rwords;
52
+ }
53
+
54
+ void Init_wordexp_ext(void) {
55
+ VALUE Wordexp = rb_define_module("Wordexp");
56
+
57
+ VALUE Ext = rb_define_class_under(Wordexp, "Ext", rb_cObject);
58
+ rb_define_singleton_method(Ext, "wordexp", ext_wordexp, 1);
59
+ }
@@ -1,3 +1,3 @@
1
1
  module Wordexp
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
@@ -0,0 +1,6 @@
1
+ # Generate XML test reports that can be parsed by CircleCI
2
+ if ENV['CIRCLECI']
3
+ require 'minitest/ci'
4
+
5
+ Minitest::Ci.report_dir = './reports'
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'minitest/reporters'
2
+
3
+ if ENV['CI']
4
+ Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
5
+ else
6
+ Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)
7
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.expand_path('../ext', __dir__)
2
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
3
+ require 'wordexp'
4
+
5
+ require 'minitest/autorun'
6
+ Dir[File.expand_path('support/**/*.rb', __dir__)].each { |rb| require(rb) }
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class WordexpVersionTest < Minitest::Test
4
+ def test_that_it_has_a_version_number
5
+ refute_nil ::Wordexp::VERSION
6
+ end
7
+ end
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class WordexpTest < Minitest::Test
4
+ def test_constants
5
+ assert_equal %w[hello wordexp], ::Wordexp.expand('hello wordexp')
6
+ end
7
+
8
+ def test_quotation
9
+ assert_equal ['hello wordexp', 'more words'], ::Wordexp.expand("'hello wordexp' \"more words\"")
10
+ end
11
+
12
+ def test_environment_variable_expansion
13
+ assert_equal [Dir.home], ::Wordexp.expand('$HOME')
14
+ end
15
+
16
+ def test_tilde_expansion
17
+ assert_equal [File.join(Dir.home, 'bin')], ::Wordexp.expand('~/bin')
18
+ end
19
+
20
+ def test_command_substitution_backticks
21
+ assert_equal [File.join(Dir.home, 'bin')], ::Wordexp.expand('`echo ~/bin`')
22
+ end
23
+
24
+ def test_command_substitution_dollar_parentheses
25
+ assert_equal [File.join(Dir.home, 'bin')], ::Wordexp.expand('$(echo ~/bin)')
26
+ end
27
+
28
+ def test_error_badchar
29
+ assert_raises(Wordexp::BadCharacterError) do
30
+ ::Wordexp.expand('<nope>')
31
+ end
32
+ end
33
+
34
+ def test_error_badval
35
+ assert_raises(Wordexp::BadValueError) do
36
+ ::Wordexp.expand('$DEFINITELY_DOES_NOT_EXIST')
37
+ end
38
+ end
39
+
40
+ def test_error_cmdsub
41
+ # cannot test this until there's a way to disable command substitution
42
+ end
43
+
44
+ def test_error_syntax
45
+ assert_raises(Wordexp::SyntaxError) do
46
+ ::Wordexp.expand('$(this is the command that never ends')
47
+ end
48
+ end
49
+ end
data/wordexp.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ require_relative 'lib/wordexp/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'wordexp'
5
+ spec.version = Wordexp::VERSION
6
+ spec.authors = ['Sami Samhuri']
7
+ spec.email = ['sami@samhuri.net']
8
+
9
+ spec.summary = 'A Ruby gem for performing shell word expansion using wordexp'
10
+ spec.homepage = 'https://github.com/samsonjs/wordexp'
11
+ spec.license = 'MIT'
12
+ spec.required_ruby_version = '>= 3.0.0'
13
+
14
+ spec.metadata = {
15
+ 'bug_tracker_uri' => 'https://github.com/samsonjs/wordexp/issues',
16
+ 'changelog_uri' => 'https://github.com/samsonjs/wordexp/releases',
17
+ 'source_code_uri' => 'https://github.com/samsonjs/wordexp',
18
+ 'homepage_uri' => spec.homepage,
19
+ 'rubygems_mfa_required' => 'true',
20
+ }
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ files = `git ls-files -z`.split("\x0")
24
+ if files.empty?
25
+ glob = %w[LICENSE.txt README.md exe/**/* lib/**/* ext/**/*]
26
+ files = Dir.glob(glob).reject do |f|
27
+ File.directory?(f) ||
28
+ f.end_with?('.bundle', '.o', '.so') ||
29
+ f.end_with?('Makefile')
30
+ end
31
+ end
32
+ spec.files = files
33
+ spec.bindir = 'exe'
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.extensions = %w[ext/wordexp_ext/extconf.rb]
36
+ spec.require_paths = %w[ext lib]
37
+ end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordexp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sami Samhuri
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-10-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description:
14
12
  email:
15
13
  - sami@samhuri.net
16
14
  executables:
@@ -19,14 +17,36 @@ extensions:
19
17
  - ext/wordexp_ext/extconf.rb
20
18
  extra_rdoc_files: []
21
19
  files:
20
+ - ".github/dependabot.yml"
21
+ - ".github/release-drafter.yml"
22
+ - ".github/workflows/ci.yml"
23
+ - ".github/workflows/codeql-analysis.yml"
24
+ - ".github/workflows/push.yml"
25
+ - ".gitignore"
26
+ - ".overcommit.yml"
27
+ - ".prettierignore"
28
+ - ".rubocop.yml"
29
+ - ".ruby-version"
30
+ - CHANGELOG.md
31
+ - CODE_OF_CONDUCT.md
32
+ - Gemfile
22
33
  - LICENSE.txt
23
34
  - README.md
35
+ - Rakefile
36
+ - bin/console
37
+ - bin/setup
24
38
  - exe/wordexp
25
39
  - ext/wordexp_ext/extconf.rb
40
+ - ext/wordexp_ext/wordexp_ext.c
26
41
  - lib/wordexp.rb
27
42
  - lib/wordexp/cli.rb
28
43
  - lib/wordexp/version.rb
29
- - lib/wordexp/wordexp_ext.bundle
44
+ - test/support/circleci.rb
45
+ - test/support/reporters.rb
46
+ - test/test_helper.rb
47
+ - test/wordexp/version_test.rb
48
+ - test/wordexp_test.rb
49
+ - wordexp.gemspec
30
50
  homepage: https://github.com/samsonjs/wordexp
31
51
  licenses:
32
52
  - MIT
@@ -36,7 +56,6 @@ metadata:
36
56
  source_code_uri: https://github.com/samsonjs/wordexp
37
57
  homepage_uri: https://github.com/samsonjs/wordexp
38
58
  rubygems_mfa_required: 'true'
39
- post_install_message:
40
59
  rdoc_options: []
41
60
  require_paths:
42
61
  - ext
@@ -52,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
71
  - !ruby/object:Gem::Version
53
72
  version: '0'
54
73
  requirements: []
55
- rubygems_version: 3.4.10
56
- signing_key:
74
+ rubygems_version: 4.0.3
57
75
  specification_version: 4
58
76
  summary: A Ruby gem for performing shell word expansion using wordexp
59
77
  test_files: []
Binary file