ruby-c2pa 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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -2
  3. data/lib/c2pa/version.rb +1 -1
  4. data/lib/c2pa.rb +8 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abf1a09586e233e0bbd47b8917ef9ff2e5f45af8d440575b55a4281f7cbbce8b
4
- data.tar.gz: bdfee13cb10722e6d4265c5a0a302efd262f1bf313868638c27c0720125db1a9
3
+ metadata.gz: bc05300f370b0f4e0ac3edf08d92b55b305e8a16d6554342a077f0ac3f397eea
4
+ data.tar.gz: c790eb285655a76e3fbe9ae46c0803718b5b08bbda9ff0841e4716775811ac9a
5
5
  SHA512:
6
- metadata.gz: d0c2c0ca8d3b98b5b668adf0acd4cc37116a5bb7bc6ffa59b08e7b9b84195c09aba15b2440602f655ffca721461a59b9f468a45246c9ebb093e802421b90f19c
7
- data.tar.gz: 7059e66ff87f11eef2a44715bf0052b23fe2db6056c097eae666ba55ec74b2ccdb5cedfb9cabdd49d56c62700b4914fa32771a9cb79e31201b089674bcc19f62
6
+ metadata.gz: 144409841d84d8a311ffb785e60a5f59a0616d420df89c0daf03da4c0f772e005e6a4bc93da375fcfa5a078856bb2182f133be9d4a79319850f62c7324474343
7
+ data.tar.gz: 0c8b604f64fd03404bbb031478047859a965f40ed1328bd061d64ae68acef999d0ad351f3f365167c4bd36d96888a772b26056d1daff94772992f5d4d79dd13b
data/README.md CHANGED
@@ -179,7 +179,7 @@ manifest.add_ingredient(
179
179
 
180
180
  ### Signing a file
181
181
 
182
- The `output` path must not already exist — c2pa-rs will raise an error rather than overwrite an existing file.
182
+ The `output` path must not already exist — `C2PA.sign` will raise a `C2PA::SigningError` if the file is already there.
183
183
 
184
184
  ```ruby
185
185
  manifest = C2PA::Manifest.new(title: "Sunset over the bay")
@@ -243,6 +243,8 @@ rescue C2PA::ReadError => e
243
243
  end
244
244
 
245
245
  # Or rescue any C2PA error broadly
246
+ begin
247
+ C2PA.sign(file: "photo.jpg", output: "photo_signed.jpg", certificate: "cert.pem", key: "key.pem", manifest: manifest)
246
248
  rescue C2PA::Error => e
247
249
  puts "C2PA error: #{e.message}"
248
250
  end
@@ -289,7 +291,7 @@ The Rust extension (`ext/c2pa_native/src/lib.rs`) defines `C2PA::Native` with th
289
291
  | `C2PA::Native.read_file` | Read and return the manifest JSON |
290
292
  | `C2PA::Native.sdk_version` | Return the c2pa-rs version string |
291
293
 
292
- Errors are raised as Ruby exceptions directly from Rust and surfaced as typed `C2PA::Error` subclasses.
294
+ Input validation (missing files, invalid manifests) is handled in Ruby before calling into Rust. Errors from the native layer are caught and re-raised as typed `C2PA::Error` subclasses.
293
295
 
294
296
  ## License
295
297
 
data/lib/c2pa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module C2PA
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/c2pa.rb CHANGED
@@ -28,7 +28,14 @@ module C2PA
28
28
  # manifest: manifest
29
29
  # )
30
30
  def self.sign(file:, output:, certificate:, key:, algorithm: "es256", manifest:)
31
- Native.sign_file(file, output, certificate, key, algorithm, manifest.to_json)
31
+ manifest_json = manifest.to_json
32
+
33
+ raise SigningError, "Source file not found: '#{file}'" unless File.exist?(file)
34
+ raise SigningError, "Certificate file not found: '#{certificate}'" unless File.exist?(certificate)
35
+ raise SigningError, "Key file not found: '#{key}'" unless File.exist?(key)
36
+ raise SigningError, "Output file already exists: '#{output}'" if File.exist?(output)
37
+
38
+ Native.sign_file(file, output, certificate, key, algorithm, manifest_json)
32
39
  rescue RuntimeError => e
33
40
  raise SigningError, e.message
34
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-c2pa
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
  - Carlos Rodriguez