htmlcsstoimage-api 1.0.0 → 1.1.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: fe88de5675da52a0325a6b46c0d223487bd6ff47d86df11c6bb26706ec1058ab
4
- data.tar.gz: '069102c0a4c9bb0434567df163d2e9daf246ab1c410e384ec54418564fb9c557'
3
+ metadata.gz: f7645759b1919274ad121be5126f491a6853b2bcef97f316c9632eb5159cf709
4
+ data.tar.gz: 49da073dc8e1cc1b059ecd232e701208fb134112684e9ffb489978f33b7dbdcc
5
5
  SHA512:
6
- metadata.gz: f39ad806edc68e1f47ab9e2edc3b04d02dca1a6dfa94d3f9ee88abb08fb9eae23fa914038c95bd0fa6b5f82f884700bcced11eeca24847eabbcdf7c6c8c70537
7
- data.tar.gz: c4d476e92f6ef02bac29152e8452d755cdc099ace8d4e34412abe60adac67e759d315f3cae24c0cbe770213a5d828129807cb3c0a9515ca548ea9ed8522a27c6
6
+ metadata.gz: 30f37bb2f20b6239bf9708f25a4423d68e25a0470b715de8794fe3a749bca73eb451f589e4fef9286277d8dd4a42873962e081b864805b372f8cca060125ab7f
7
+ data.tar.gz: a33cacbc3955d26756c94e2650a2b7212b239a65eee666f97bb8995c0e5c292f4fe4475c2aa17d273b0f62f94b72084e9d6a0eb02b0c23c71c7a6d93eedd43b4
@@ -0,0 +1,86 @@
1
+ name: Publish to RubyGems
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ version:
7
+ required: true
8
+ type: string
9
+
10
+ jobs:
11
+ publish:
12
+ if: >-
13
+ github.repository == 'htmlcsstoimage/ruby-client' &&
14
+ github.event_name == 'push' && github.ref == 'refs/heads/main'
15
+ runs-on: ubuntu-latest
16
+ concurrency: rubygems-${{ inputs.version }}
17
+ permissions:
18
+ contents: write
19
+ id-token: write
20
+ env:
21
+ VERSION: ${{ inputs.version }}
22
+ TAG: v${{ inputs.version }}
23
+ GEM_NAME: htmlcsstoimage-api
24
+
25
+ steps:
26
+ - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
27
+ with:
28
+ ref: ${{ github.sha }}
29
+ fetch-depth: 0
30
+ - uses: ruby/setup-ruby@78c62f2208e480ce3d5ae4dfd9b9e181acf48b63 # v1
31
+ with:
32
+ ruby-version: '3.3'
33
+
34
+ - name: Check the tag and RubyGems version
35
+ id: check
36
+ run: |
37
+ set -euo pipefail
38
+ git check-ref-format "refs/tags/$TAG"
39
+ tagged=false
40
+ if git show-ref --verify --quiet "refs/tags/$TAG"; then
41
+ if [[ "$(git rev-parse "refs/tags/$TAG^{commit}")" != "$GITHUB_SHA" ]]; then
42
+ echo "::error::$TAG already points to a different commit."
43
+ exit 1
44
+ fi
45
+ tagged=true
46
+ fi
47
+ status=$(curl --silent --show-error --retry 3 --output "$RUNNER_TEMP/gem.json" \
48
+ --write-out '%{http_code}' "https://rubygems.org/api/v2/rubygems/$GEM_NAME/versions/$VERSION.json")
49
+ case "$status" in
50
+ 404) echo "push_gem=true" >> "$GITHUB_OUTPUT" ;;
51
+ 200)
52
+ if [[ "$tagged" != true ]] || ! jq -e '.yanked == false' "$RUNNER_TEMP/gem.json" > /dev/null; then
53
+ echo "::error::RubyGems already has $VERSION. Check its status and the matching Git tag."
54
+ exit 1
55
+ fi
56
+ ;;
57
+ *) echo "::error::RubyGems version lookup returned HTTP $status."; exit 1 ;;
58
+ esac
59
+ echo "tagged=$tagged" >> "$GITHUB_OUTPUT"
60
+
61
+ - name: Build the gem
62
+ if: steps.check.outputs.push_gem == 'true'
63
+ run: |
64
+ gem build htmlcsstoimage.gemspec
65
+ test -f "$GEM_NAME-$VERSION.gem"
66
+
67
+ - name: Create the version tag
68
+ if: steps.check.outputs.tagged == 'false'
69
+ run: |
70
+ git config user.name "github-actions[bot]"
71
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
72
+ git tag --annotate "$TAG" "$GITHUB_SHA" --message "Release $TAG"
73
+ git push origin "refs/tags/$TAG"
74
+
75
+ - name: Authenticate with RubyGems
76
+ if: steps.check.outputs.push_gem == 'true'
77
+ uses: rubygems/configure-rubygems-credentials@c6ca7f4bac0e29c9bde8eeae0a0a986b27efa05f # v2.2.0
78
+ - name: Publish the gem
79
+ if: steps.check.outputs.push_gem == 'true'
80
+ run: gem push --host https://rubygems.org "$GEM_NAME-$VERSION.gem"
81
+
82
+ - name: Create GitHub Release
83
+ uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3
84
+ with:
85
+ tag_name: ${{ env.TAG }}
86
+ generate_release_notes: true
@@ -8,16 +8,48 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
-
12
11
  runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ outputs:
15
+ release_version: ${{ steps.version.outputs.version }}
13
16
 
14
17
  steps:
15
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
19
+ with:
20
+ fetch-depth: 0
16
21
  - name: Set up Ruby
17
- uses: ruby/setup-ruby@v1
22
+ uses: ruby/setup-ruby@78c62f2208e480ce3d5ae4dfd9b9e181acf48b63 # v1
18
23
  with:
19
24
  ruby-version: '3.3'
20
25
  - name: Install dependencies
21
26
  run: bundle install
22
27
  - name: Run tests
23
28
  run: bundle exec rake
29
+ - name: Check for a version bump
30
+ id: version
31
+ if: >-
32
+ github.repository == 'htmlcsstoimage/ruby-client' &&
33
+ github.event_name == 'push' && github.ref == 'refs/heads/main'
34
+ env:
35
+ BEFORE_SHA: ${{ github.event.before }}
36
+ run: |
37
+ set -euo pipefail
38
+ version_file=lib/htmlcsstoimage/version.rb
39
+ version=$(ruby -r "./$version_file" -e 'print HTMLCSSToImage::VERSION')
40
+ if [[ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ]]; then
41
+ git show "$BEFORE_SHA:$version_file" > "$RUNNER_TEMP/previous_version.rb"
42
+ previous=$(ruby -r "$RUNNER_TEMP/previous_version.rb" -e 'print HTMLCSSToImage::VERSION')
43
+ if [[ "$previous" == "$version" ]]; then exit 0; fi
44
+ fi
45
+ echo "version=$version" >> "$GITHUB_OUTPUT"
46
+
47
+ publish:
48
+ needs: test
49
+ if: needs.test.outputs.release_version != ''
50
+ permissions:
51
+ contents: write
52
+ id-token: write
53
+ uses: ./.github/workflows/publish.yml
54
+ with:
55
+ version: ${{ needs.test.outputs.release_version }}
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- htmlcsstoimage-api (1.0.0)
4
+ htmlcsstoimage-api (1.1.1)
5
5
  addressable (> 2.5.0)
6
6
  httparty (> 0.10)
7
7
 
data/README.md CHANGED
@@ -142,8 +142,9 @@ animation = client.create_html_css_recording(
142
142
  ```
143
143
 
144
144
  Both methods accept browser, timeline, and output options as hashes, following
145
- the image methods. Options pass through to the API without local validation.
146
- Omitted settings use API defaults. Recordings do not include audio.
145
+ the image methods. Omitted settings use API defaults.
146
+
147
+ To add a soundtrack to MP4 or WebM, pass `audio: { asset_id: "YOUR_ASSET_ID", delay_ms: 500 }` or `audio: { url: "https://cdn.example.com/audio/intro.mp3" }` to either recording method. [Audio sources and playback options](https://docs.htmlcsstoimage.com/parameters/audio/).
147
148
 
148
149
  Triggers and actions use a `type` discriminator. For example, wait until an
149
150
  element is visible, click a button, and hold the result:
@@ -367,7 +368,11 @@ and, for URL screenshots, `headers`, `additional_header_origins`,
367
368
 
368
369
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
369
370
 
370
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
371
+ To install the gem locally, run `bundle exec rake install`.
372
+
373
+ To release, bump `lib/htmlcsstoimage/version.rb`, run `bundle install` to update `Gemfile.lock`, and merge both changes into `main`. After the tests pass, GitHub Actions tags the tested commit as `v<version>`, publishes the gem to RubyGems.org, and creates a GitHub Release. If a step fails, rerun the original workflow for that commit.
374
+
375
+ The RubyGems trusted publisher for `htmlcsstoimage-api` uses the GitHub repository `htmlcsstoimage/ruby-client` and workflow filename `publish.yml`. Leave Environment, Workflow Repository Owner, and Workflow Repository Name blank. [RubyGems trusted publishing guide](https://guides.rubygems.org/trusted-publishing/).
371
376
 
372
377
  To generate the Yard docs, run `yard doc -o docs` and commit the changes.
373
378
 
@@ -8,6 +8,7 @@ class HTMLCSSToImage
8
8
  # @see https://docs.htmlcsstoimage.com/parameters/actions/
9
9
  # @see https://docs.htmlcsstoimage.com/parameters/trigger/
10
10
  # @see https://docs.htmlcsstoimage.com/parameters/output/
11
+ # @see https://docs.htmlcsstoimage.com/parameters/audio/
11
12
  #
12
13
  # @param html [String] HTML to record, as a fragment or a complete document
13
14
  # @param params [Hash] browser, timeline, and output options passed to the API
@@ -30,7 +31,11 @@ class HTMLCSSToImage
30
31
  # @option params [Array<Hash>] :request_overrides Browser request block rules. Requires a paid plan.
31
32
  # @option params [Hash] :trigger Start condition: `type: "immediate"` (default), `"element_visible"` with a `selector`, or `"function_call"` to wait for `window.RecordingReady()`. Waiting triggers accept `timeout_ms`.
32
33
  # @option params [Array<Hash>] :actions Ordered timeline interactions: `simple_scroll`, `scroll`, `stall`, `click`, `locate_selector`, `execute_javascript`, or `error`. Each action has a `type` discriminator. Each `scroll` action step requires `duration_ms` of at least 1. Omit or use an empty array to record without interactions.
33
- # @option params [Hash] :output Media `format` (`mp4`, `webm`, or `gif`), `fps`, and pixel `scale`. Defaults to MP4 at 30 fps; GIF defaults to 15 fps. Recordings have no audio.
34
+ # @option params [Hash] :output Media `format` (`mp4`, `webm`, or `gif`), `fps`, and pixel `scale`. Defaults to MP4 at 30 fps; GIF defaults to 15 fps.
35
+ # @option params [Hash] :audio Optional MP4 or WebM soundtrack. Supply exactly one source, an Asset Library `asset_id` or a public HTTP(S) `url`.
36
+ # `source_start_ms` skips into the track and `delay_ms` delays playback in the video. Both default to 0.
37
+ # `when_audio_ends` accepts `"silence"` (default), `"loop"`, or `"trim_video"`.
38
+ # Set `error_on_source_invalid: false` to return the full video silently if the track cannot play.
34
39
  # @option params [String] :duration_mode `at_most` (default) stops when actions finish or the duration is reached. `fixed` pads or cuts off at that duration. `at_least` lets actions finish up to 90 seconds. `target` adjusts playback speed to fit the duration.
35
40
  # @option params [Boolean] :defer_render Wait to render until media or storage is requested. Defaults to false; does not reset deduplicated recordings.
36
41
  # @option params [Boolean] :skip_scroll_preload Skip the preparation scroll that loads lazy content. Scrolling actions still run. Defaults to false.
@@ -1,4 +1,4 @@
1
1
  class HTMLCSSToImage
2
2
  # Current version of the Ruby client gem.
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmlcsstoimage-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Coutermarsh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-11-16 00:00:00.000000000 Z
12
+ date: 2026-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -160,6 +160,7 @@ executables: []
160
160
  extensions: []
161
161
  extra_rdoc_files: []
162
162
  files:
163
+ - ".github/workflows/publish.yml"
163
164
  - ".github/workflows/ruby.yml"
164
165
  - ".gitignore"
165
166
  - ".rspec"
@@ -201,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  - !ruby/object:Gem::Version
202
203
  version: '0'
203
204
  requirements: []
204
- rubygems_version: 3.5.16
205
+ rubygems_version: 3.5.22
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: Ruby client for the HTML/CSS to Image API.