swhid 0.1.0 → 0.2.0

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: 36bebc03a91e8eecaa94a9dacb8496ab76fd8b2f2d4858b6088288a3b1195cbd
4
- data.tar.gz: 71f64f03c285c8f445b5e5e74938d7d08141e91bc0cc914506fcdfb6dd970448
3
+ metadata.gz: 2e8ae785868bf80c7a8b2bc15f286302b611316df6c52fbabbc1faff844ca0c0
4
+ data.tar.gz: 3ea6b94b32f84c296b0760c1bc25868c832512526102fc8d1ebb66c9987374ba
5
5
  SHA512:
6
- metadata.gz: 1aa17852be20170334a2d45cc7affc4d133e08eba03289a1e2269d0d0faec60b5367ed81396336ac4f26ea8d781bbb2bdf2cb60fac0db8f2ee0ff6f494ab30ed
7
- data.tar.gz: 9fed39916ba99f2c3fa44c26fb266b7e465138c80aa200f368c6c89cc57c00b91c9753975688ff292ad47c30f2fa9c13c395526f439fb87c388253e2bd7c65a5
6
+ metadata.gz: 2a2d3c60e494e729d268fb95c1b103a1bf836a47b57c21a6dc30f289404ccea61b2177473f2cd4246f8769e5a3b998347faad03ba910f3ba955783c96e896da6
7
+ data.tar.gz: d7feee822626182bcf69aba5ae90a9e3c252a69eebc786a961e7758319356af6cf5bbb2f485ef1c20d48bda52c382507f18d5d32538b65b808f89b79252c15cc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2025-11-09
4
+
5
+ - Full implementation of all SWHID object types (content, directory, revision, release, snapshot)
6
+ - Cross-implementation validation against Python swh-model library
7
+ - CLI tool with JSON output support
8
+ - Performance benchmarks
9
+ - Bug fixes for directory permissions and revision timestamp handling
10
+ - 100% test pass rate (67 tests, 108 assertions)
11
+
3
12
  ## [0.1.0] - 2025-11-09
4
13
 
5
14
  - Initial release
data/README.md CHANGED
@@ -234,8 +234,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
234
234
 
235
235
  ## Contributing
236
236
 
237
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/swhid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/swhid/blob/main/CODE_OF_CONDUCT.md).
237
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andrew/swhid. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/andrew/swhid/blob/main/CODE_OF_CONDUCT.md).
238
238
 
239
239
  ## Code of Conduct
240
240
 
241
- Everyone interacting in the Swhid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/swhid/blob/main/CODE_OF_CONDUCT.md).
241
+ Everyone interacting in the Swhid project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/andrew/swhid/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "swhid"
6
+ require "benchmark"
7
+
8
+ puts "SWHID Performance Benchmarks"
9
+ puts "=" * 60
10
+ puts
11
+
12
+ # Benchmark content hashing
13
+ puts "Content (blob) hashing:"
14
+ content_small = "Hello, World!"
15
+ content_medium = "x" * 10_000
16
+ content_large = "x" * 1_000_000
17
+
18
+ Benchmark.bm(30) do |x|
19
+ x.report("Small content (13 bytes):") do
20
+ 10_000.times { Swhid.from_content(content_small) }
21
+ end
22
+
23
+ x.report("Medium content (10 KB):") do
24
+ 1_000.times { Swhid.from_content(content_medium) }
25
+ end
26
+
27
+ x.report("Large content (1 MB):") do
28
+ 100.times { Swhid.from_content(content_large) }
29
+ end
30
+ end
31
+
32
+ puts
33
+ puts "=" * 60
34
+ puts
35
+
36
+ # Benchmark directory hashing
37
+ puts "Directory (tree) hashing:"
38
+
39
+ entries_small = [
40
+ { name: "README.md", type: :file, target: "94a9ed024d3859793618152ea559a168bbcbb5e2" }
41
+ ]
42
+
43
+ entries_medium = 10.times.map do |i|
44
+ { name: "file#{i}.txt", type: :file, target: "94a9ed024d3859793618152ea559a168bbcbb5e2" }
45
+ end
46
+
47
+ entries_large = 100.times.map do |i|
48
+ { name: "file#{i}.txt", type: :file, target: "94a9ed024d3859793618152ea559a168bbcbb5e2" }
49
+ end
50
+
51
+ Benchmark.bm(30) do |x|
52
+ x.report("Small directory (1 entry):") do
53
+ 10_000.times { Swhid.from_directory(entries_small) }
54
+ end
55
+
56
+ x.report("Medium directory (10 entries):") do
57
+ 5_000.times { Swhid.from_directory(entries_medium) }
58
+ end
59
+
60
+ x.report("Large directory (100 entries):") do
61
+ 1_000.times { Swhid.from_directory(entries_large) }
62
+ end
63
+ end
64
+
65
+ puts
66
+ puts "=" * 60
67
+ puts
68
+
69
+ # Benchmark revision hashing
70
+ puts "Revision (commit) hashing:"
71
+
72
+ revision_metadata = {
73
+ directory: "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
74
+ author: "John Doe <john@example.com>",
75
+ author_timestamp: 1234567890,
76
+ committer: "Jane Smith <jane@example.com>",
77
+ committer_timestamp: 1234567890,
78
+ message: "Initial commit"
79
+ }
80
+
81
+ Benchmark.bm(30) do |x|
82
+ x.report("Revision (simple):") do
83
+ 10_000.times { Swhid.from_revision(revision_metadata) }
84
+ end
85
+
86
+ x.report("Revision (with parents):") do
87
+ 10_000.times do
88
+ Swhid.from_revision(revision_metadata.merge(
89
+ parents: ["94a9ed024d3859793618152ea559a168bbcbb5e2"]
90
+ ))
91
+ end
92
+ end
93
+ end
94
+
95
+ puts
96
+ puts "=" * 60
97
+ puts
98
+
99
+ # Benchmark SWHID parsing
100
+ puts "SWHID parsing:"
101
+
102
+ swhid_simple = "swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2"
103
+ swhid_with_qualifiers = "swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2;origin=https://github.com/example/repo;lines=1-10"
104
+
105
+ Benchmark.bm(30) do |x|
106
+ x.report("Parse simple SWHID:") do
107
+ 10_000.times { Swhid.parse(swhid_simple) }
108
+ end
109
+
110
+ x.report("Parse SWHID with qualifiers:") do
111
+ 10_000.times { Swhid.parse(swhid_with_qualifiers) }
112
+ end
113
+ end
114
+
115
+ puts
116
+ puts "=" * 60
117
+ puts "Benchmark complete!"
@@ -18,13 +18,15 @@ module Swhid
18
18
  def default_perms
19
19
  case type
20
20
  when :dir
21
- "040000"
21
+ "40000"
22
22
  when :file
23
23
  "100644"
24
24
  when :exec
25
25
  "100755"
26
26
  when :symlink
27
27
  "120000"
28
+ when :rev
29
+ "160000"
28
30
  else
29
31
  raise ValidationError, "Unknown entry type: #{type}"
30
32
  end
data/lib/swhid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Swhid
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swhid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
@@ -23,6 +23,7 @@ files:
23
23
  - CODE_OF_CONDUCT.md
24
24
  - README.md
25
25
  - Rakefile
26
+ - benchmark/benchmark.rb
26
27
  - exe/swhid
27
28
  - lib/swhid.rb
28
29
  - lib/swhid/identifier.rb