kar 0.1.2 → 5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +31 -7
- data/kar.gemspec +1 -1
- data/lib/kar/cargotask.rb +13 -11
- data/lib/kar/dsl.rb +2 -2
- data/lib/kar/uritask.rb +14 -84
- data/lib/kar.rb +2 -8
- metadata +1 -2
- data/CODE_OF_CONDUCT.md +0 -84
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7d4c9f840a7c81a217588a739049b7088d613bfecb47db8e9c015fa2fa3ad85
|
|
4
|
+
data.tar.gz: 26f82de197f880d8c5d8092059edeb995b8572b7fdd621b2627ae62ff2133f98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8e2ef380327503237a243d1401e262b7f149f6314f56675d02292052487313ab502d7b5a5637cb2a6666cecb33a4c75567ab4707f8f5b4d2e0413aa4ad75e92
|
|
7
|
+
data.tar.gz: dc8c7dcd9301f1d6394c934c404df765299e0b3585620f821f8eee096c0f366d58b13a70b8feb12cff16af9bb10aa393c244cf721e69e5bac6223dadf6c273a9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
# [5] - 2025-11-14
|
|
4
|
+
|
|
5
|
+
* Use open-uri for URITask
|
|
6
|
+
* Add Cargo.lock generate task in CargoTask
|
|
7
|
+
|
|
8
|
+
## [0.1.3] - 2025-10-26
|
|
9
|
+
|
|
10
|
+
- Make cargo task to be dependent on Rust source files
|
|
11
|
+
- cargo:validate -> cargo:check
|
|
12
|
+
|
|
3
13
|
## [0.1.2] - 2025-10-26
|
|
4
14
|
|
|
5
15
|
- CargoTask, build extension in Rust
|
data/README.md
CHANGED
|
@@ -19,23 +19,47 @@ Usage
|
|
|
19
19
|
|
|
20
20
|
# Rakefile
|
|
21
21
|
require "kar/dsl"
|
|
22
|
+
|
|
23
|
+
### Download task ###
|
|
24
|
+
|
|
25
|
+
It downloads a file and declares file task.
|
|
22
26
|
|
|
23
27
|
download "local/path/to/file" => "https://example.net/remote/path/to/file"
|
|
28
|
+
|
|
29
|
+
### Multiple files task ###
|
|
30
|
+
|
|
31
|
+
It declares multiple file tasks at a time.
|
|
32
|
+
|
|
33
|
+
# Rakefile
|
|
24
34
|
FILES = FileList["fileA", "fileB", "fileC"]
|
|
25
35
|
files FILES
|
|
36
|
+
|
|
37
|
+
### Cargo task ###
|
|
38
|
+
|
|
39
|
+
It declares a cargo task which builds extensions in Rust.
|
|
40
|
+
|
|
41
|
+
# Rakefile
|
|
26
42
|
cargo "my_gem"
|
|
27
43
|
|
|
44
|
+
Run the task:
|
|
45
|
+
|
|
46
|
+
% rake cargo
|
|
47
|
+
|
|
48
|
+
And cargo:check task which checks Rust source files and is useful for dependency of build task.
|
|
49
|
+
|
|
50
|
+
# Rakefile
|
|
51
|
+
task build: "cargo:check"
|
|
52
|
+
|
|
53
|
+
Run the task:
|
|
54
|
+
|
|
55
|
+
% rake build # invokes cargo:checks
|
|
56
|
+
|
|
28
57
|
Development
|
|
29
58
|
-----------
|
|
30
59
|
|
|
31
|
-
To install this gem onto your local machine, run `
|
|
60
|
+
To install this gem onto your local machine, run `rake install`. To release a new version, update the version number in `kar.gemspec`, and then run `rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
61
|
|
|
33
62
|
Contributing
|
|
34
63
|
------------
|
|
35
64
|
|
|
36
|
-
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/KitaitiMakoto/kar. This project is intended to be a safe, welcoming space for collaboration
|
|
37
|
-
|
|
38
|
-
Code of Conduct
|
|
39
|
-
---------------
|
|
40
|
-
|
|
41
|
-
Everyone interacting in the Kar project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/KitaitiMakoto/kar/blob/main/CODE_OF_CONDUCT.md).
|
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/KitaitiMakoto/kar. This project is intended to be a safe, welcoming space for collaboration.
|
data/kar.gemspec
CHANGED
data/lib/kar/cargotask.rb
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
require "rake/clean"
|
|
2
|
+
require "rake/tasklib"
|
|
2
3
|
require "rubygems/ext"
|
|
3
4
|
require "json"
|
|
4
5
|
require "shellwords"
|
|
5
6
|
require "stringio"
|
|
6
7
|
|
|
7
8
|
module Kar
|
|
8
|
-
class CargoTask
|
|
9
|
-
include Rake::DSL
|
|
10
|
-
|
|
9
|
+
class CargoTask < Rake::TaskLib
|
|
11
10
|
def initialize(target)
|
|
12
11
|
@target = target
|
|
13
12
|
|
|
@@ -21,7 +20,7 @@ module Kar
|
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
def define
|
|
24
|
-
file dl_path => [
|
|
23
|
+
file dl_path => [lock_file] + src do |t|
|
|
25
24
|
results = Results.new
|
|
26
25
|
begin
|
|
27
26
|
Gem::Ext::CargoBuilder.new.build t.source, ".", results, [], lib_dir, File.expand_path(ext_dir)
|
|
@@ -32,19 +31,22 @@ module Kar
|
|
|
32
31
|
end
|
|
33
32
|
CLEAN.include dl_name, dl_path
|
|
34
33
|
|
|
34
|
+
file lock_file => manifest do |t|
|
|
35
|
+
sh "cargo", "generate-lockfile", "--manifest-path", t.source
|
|
36
|
+
end
|
|
37
|
+
|
|
35
38
|
namespace :cargo do
|
|
36
39
|
task @target => dl_path
|
|
37
40
|
|
|
38
|
-
# TODO: Consider the case `target` is "
|
|
39
|
-
namespace :
|
|
41
|
+
# TODO: Consider the case `target` is "check"
|
|
42
|
+
namespace :check do
|
|
40
43
|
task @target => manifest do |t|
|
|
41
|
-
|
|
42
|
-
fail unless $?.success?
|
|
44
|
+
sh "cargo", "check", "--manifest-path", manifest, "--locked", "--quiet"
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
47
|
|
|
46
|
-
desc "
|
|
47
|
-
task
|
|
48
|
+
desc "Check Rust sources and manifests"
|
|
49
|
+
task check: "cargo:check:#{@target}"
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
desc "Build all extensions in Rust"
|
|
@@ -81,7 +83,7 @@ module Kar
|
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
def src
|
|
84
|
-
@src ||= FileList["#{ext_dir}/src
|
|
86
|
+
@src ||= FileList["#{ext_dir}/src/**/*.rs"]
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
class Results
|
data/lib/kar/dsl.rb
CHANGED
|
@@ -56,12 +56,12 @@ module Kar
|
|
|
56
56
|
# # Rakefile
|
|
57
57
|
# cargo "my_gem"
|
|
58
58
|
#
|
|
59
|
-
# task build: :
|
|
59
|
+
# task build: "cargo:check"
|
|
60
60
|
#
|
|
61
61
|
# # shell
|
|
62
62
|
# % rake cargo
|
|
63
63
|
#
|
|
64
|
-
# Also defines a cargo:
|
|
64
|
+
# Also defines a cargo:check task which check sources and manifests.
|
|
65
65
|
# It's useful to add them to the dependency of build task and prevent building invalid gem package.
|
|
66
66
|
#
|
|
67
67
|
# Uses {https://docs.ruby-lang.org/en/master/Gem/Ext/CargoBuilder.html Gem::Ext::CargoBuilder} internally unlike {https://oxidize-rb.org/docs/api-reference/rb-sys-gem-config#rbsysextensiontask RbSys::ExtensionTask}
|
data/lib/kar/uritask.rb
CHANGED
|
@@ -1,77 +1,11 @@
|
|
|
1
1
|
require "rake/tasklib"
|
|
2
|
-
require "rake/file_task"
|
|
3
2
|
require "uri"
|
|
4
|
-
require "net/https"
|
|
5
3
|
require "tempfile"
|
|
6
4
|
require "time"
|
|
7
5
|
|
|
8
6
|
module Kar
|
|
9
7
|
# Instanctiated in {DSL#download}
|
|
10
8
|
class URITask < Rake::TaskLib
|
|
11
|
-
module Util
|
|
12
|
-
REDIRECT_LIMIT = 3
|
|
13
|
-
|
|
14
|
-
module_function
|
|
15
|
-
|
|
16
|
-
# @todo Consider return value type
|
|
17
|
-
#
|
|
18
|
-
# @param uri [URI] URI to fetch content
|
|
19
|
-
# @param to [String] File path to save content
|
|
20
|
-
# @param headers [Hash<String, Object?>] HTTP headers
|
|
21
|
-
# @return [String] File path content saved, same to +to+
|
|
22
|
-
# @return [nil] if remote file responded with 304 Not Modified
|
|
23
|
-
def fetch_http(uri, to, headers = {}, redirected = 0)
|
|
24
|
-
if redirected > REDIRECT_LIMIT
|
|
25
|
-
raise "Too many HTTP redirects"
|
|
26
|
-
end
|
|
27
|
-
Net::HTTP.start uri.host, uri.port, use_ssl: uri.scheme == "https" do |http|
|
|
28
|
-
request = Net::HTTP::Get.new(uri, headers)
|
|
29
|
-
http.request request do |response|
|
|
30
|
-
case response
|
|
31
|
-
when Net::HTTPNotModified
|
|
32
|
-
# noop
|
|
33
|
-
when Net::HTTPOK
|
|
34
|
-
File.open to, "wb" do |file|
|
|
35
|
-
response.read_body do |chunk|
|
|
36
|
-
file.write chunk
|
|
37
|
-
end
|
|
38
|
-
now = Time.now
|
|
39
|
-
last_modified = response["last-modified"]
|
|
40
|
-
mtime = last_modified ? Time.httpdate(last_modified) : now
|
|
41
|
-
File.utime now, Time.httpdate(response["Last-Modified"]), to
|
|
42
|
-
end
|
|
43
|
-
when Net::HTTPRedirection
|
|
44
|
-
fetch_http URI(response["location"]), to, headers, redirected + 1
|
|
45
|
-
else
|
|
46
|
-
raise "#{response.code} #{response.message}\n#{response.body}"
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
to
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
private
|
|
55
|
-
|
|
56
|
-
def fetch_http_with_redirection_handling(uri, headers = {})
|
|
57
|
-
Net::HTTP.start uri.host, uri.port, use_ssl: uri.scheme == "https" do |http|
|
|
58
|
-
request = Net::HTTP::Get.new(uri, headers)
|
|
59
|
-
http.request request do |response|
|
|
60
|
-
case response
|
|
61
|
-
when Net::HTTPRedirection
|
|
62
|
-
return fetch_http_with_redirection_handling(URI(response["location"]), headers)
|
|
63
|
-
when Net::HTTPOK
|
|
64
|
-
return response
|
|
65
|
-
else
|
|
66
|
-
raise "#{response.code} #{response.message}\n#{response.body}"
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
include Util
|
|
74
|
-
|
|
75
9
|
def initialize(file_and_uri)
|
|
76
10
|
@to = file_and_uri.keys.first
|
|
77
11
|
@uri = URI(file_and_uri.values.first)
|
|
@@ -81,29 +15,25 @@ module Kar
|
|
|
81
15
|
private
|
|
82
16
|
|
|
83
17
|
def define
|
|
84
|
-
unless %w[http https].include? @uri.scheme
|
|
18
|
+
unless %w[http https ftp].include? @uri.scheme
|
|
85
19
|
raise ArgumentError, "Unsupported URI scheme: #{@uri}"
|
|
86
20
|
end
|
|
87
21
|
|
|
88
22
|
file @to do |t|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
false
|
|
102
|
-
end
|
|
23
|
+
require "open-uri"
|
|
24
|
+
|
|
25
|
+
@uri.open do |input|
|
|
26
|
+
tempfile =
|
|
27
|
+
if input.respond_to?(:to_path)
|
|
28
|
+
input.close
|
|
29
|
+
input
|
|
30
|
+
else
|
|
31
|
+
Tempfile.open {|output|
|
|
32
|
+
output.write input.read
|
|
33
|
+
output
|
|
34
|
+
}
|
|
103
35
|
end
|
|
104
|
-
|
|
105
|
-
else
|
|
106
|
-
raise ArgumentError, "Unsupported URI scheme: #{@uri}"
|
|
36
|
+
move tempfile.to_path, t.name
|
|
107
37
|
end
|
|
108
38
|
end
|
|
109
39
|
end
|
data/lib/kar.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: '5'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kitaiti Makoto
|
|
@@ -74,7 +74,6 @@ extensions: []
|
|
|
74
74
|
extra_rdoc_files: []
|
|
75
75
|
files:
|
|
76
76
|
- CHANGELOG.md
|
|
77
|
-
- CODE_OF_CONDUCT.md
|
|
78
77
|
- README.md
|
|
79
78
|
- Rakefile
|
|
80
79
|
- agpl-3.0.txt
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
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 KitaitiMakoto@gmail.com. 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.
|