Skip to content

Commit 8e26246

Browse files
Added cursor rules and skill files
1 parent a7c919a commit 8e26246

File tree

12 files changed

+365
-21
lines changed

12 files changed

+365
-21
lines changed

.cursor/rules/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Cursor (optional)
2+
3+
**Cursor** users: start at **[AGENTS.md](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**.
4+
5+
This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs.

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6
1+
3.1.4

AGENTS.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contentstack Utils Ruby – Agent guide
2+
3+
**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**.
4+
5+
## What this repo is
6+
7+
| Field | Detail |
8+
|--------|--------|
9+
| **Name:** | [contentstack/contentstack-utils-ruby](https://github.com/contentstack/contentstack-utils-ruby) |
10+
| **Purpose:** | Ruby gem that renders Contentstack rich text and JSON RTE (including GraphQL-shaped payloads) to HTML, with pluggable rendering via `ContentstackUtils::Model::Options` subclasses. |
11+
| **Out of scope (if any):** | This package does not ship an HTTP client or stack SDK; it pairs with the separate Contentstack Ruby delivery client for entry data and `_embedded_items`. |
12+
13+
## Tech stack (at a glance)
14+
15+
| Area | Details |
16+
|------|---------|
17+
| Language | Ruby **≥ 3.1** (see `contentstack_utils.gemspec` and `.ruby-version` for local dev) |
18+
| Build | **Bundler** + **RubyGems**; `contentstack_utils.gemspec`, `Gemfile` |
19+
| Tests | **RSpec**; specs under `spec/**/*_spec.rb`, loaded via `spec/spec_helper.rb` |
20+
| Lint / coverage | No RuboCop in-repo; **SimpleCov** in `spec/spec_helper.rb`; API docs via **YARD** (`.yardopts`, `rake yard`) |
21+
| Runtime deps | **activesupport** (7.x), **nokogiri** (HTML / XML for legacy RTE strings) |
22+
23+
## Commands (quick reference)
24+
25+
| Command type | Command |
26+
|--------------|---------|
27+
| Install deps | `bundle install` |
28+
| Build (default task) | `bundle exec rake` (runs **spec**) |
29+
| Test | `bundle exec rake spec` or `bundle exec rspec` |
30+
| Docs | `bundle exec rake yard` |
31+
32+
**CI / automation:** There is no dedicated workflow that runs `rspec` on every push; local verification is `bundle exec rake`. Other workflows include branch checks (PRs into `master`), release publish, CodeQL, policy/SCA scans—see `.github/workflows/`.
33+
34+
## Where the documentation lives: skills
35+
36+
| Skill | Path | What it covers |
37+
|-------|------|----------------|
38+
| Code review | `skills/code-review/SKILL.md` | PR checklist for this gem |
39+
| Contentstack Utils SDK | `skills/contentstack-utils/SKILL.md` | Public API, models, CDA vs GQL paths, versioning |
40+
| Development workflow | `skills/dev-workflow/SKILL.md` | Branches, Bundler/Rake, gem build, workflows |
41+
| Framework & packaging | `skills/framework/SKILL.md` | Gemspec, dependencies, Ruby version, release |
42+
| Ruby style and layout | `skills/ruby-style/SKILL.md` | Module layout, naming, matching existing code |
43+
| Testing | `skills/testing/SKILL.md` | RSpec layout, mocks, SimpleCov, WebMock |
44+
45+
An index with “when to use” hints is in `skills/README.md`.
46+
47+
## Using Cursor (optional)
48+
49+
If you use **Cursor**, **`.cursor/rules/README.md`** is the only file under `.cursor/rules`; it points to **`AGENTS.md`**—same docs as everyone else.

Gemfile.lock

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@ PATH
22
remote: .
33
specs:
44
contentstack_utils (1.2.3)
5-
activesupport (>= 8.0)
6-
nokogiri (>= 1.19)
5+
activesupport (>= 7.0, < 8)
6+
nokogiri (>= 1.13, < 1.19)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
activesupport (8.1.3)
11+
activesupport (7.2.3.1)
1212
base64
13+
benchmark (>= 0.3)
1314
bigdecimal
1415
concurrent-ruby (~> 1.0, >= 1.3.1)
1516
connection_pool (>= 2.2.5)
1617
drb
1718
i18n (>= 1.6, < 2)
18-
json
1919
logger (>= 1.4.2)
20-
minitest (>= 5.1)
20+
minitest (>= 5.1, < 6)
2121
securerandom (>= 0.3)
2222
tzinfo (~> 2.0, >= 2.0.5)
23-
uri (>= 0.13.1)
24-
addressable (2.8.9)
23+
addressable (2.9.0)
2524
public_suffix (>= 2.0.2, < 8.0)
2625
base64 (0.3.0)
27-
bigdecimal (4.0.1)
26+
benchmark (0.5.0)
27+
bigdecimal (4.1.1)
2828
concurrent-ruby (1.3.6)
29-
connection_pool (3.0.2)
29+
connection_pool (2.5.5)
3030
crack (1.0.1)
3131
bigdecimal
3232
rexml
@@ -36,15 +36,11 @@ GEM
3636
hashdiff (1.2.1)
3737
i18n (1.14.8)
3838
concurrent-ruby (~> 1.0)
39-
json (2.19.3)
4039
logger (1.7.0)
41-
minitest (6.0.2)
42-
drb (~> 2.0)
43-
prism (~> 1.5)
44-
nokogiri (1.19.2-arm64-darwin)
40+
minitest (5.27.0)
41+
nokogiri (1.18.10-arm64-darwin)
4542
racc (~> 1.4)
46-
prism (1.9.0)
47-
public_suffix (7.0.5)
43+
public_suffix (6.0.2)
4844
racc (1.8.1)
4945
rake (13.3.1)
5046
rexml (3.4.4)
@@ -70,7 +66,6 @@ GEM
7066
simplecov_json_formatter (0.1.4)
7167
tzinfo (2.0.6)
7268
concurrent-ruby (~> 1.0)
73-
uri (1.1.1)
7469
webmock (3.26.2)
7570
addressable (>= 2.8.0)
7671
crack (>= 0.3.2)

contentstack_utils.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.authors = [%q{Contentstack}]
1010
s.email = ["support@contentstack.com"]
1111

12-
s.required_ruby_version = '>= 3.0'
12+
s.required_ruby_version = '>= 3.1'
1313

1414
s.license = "MIT"
1515
s.homepage = "https://github.com/contentstack/contentstack-utils-ruby"
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
2121
s.test_files = s.files.grep(%r{^spec/})
2222
s.require_paths = ["lib"]
2323

24-
s.add_dependency 'activesupport', '>= 8.0'
25-
s.add_dependency 'nokogiri', '>= 1.19'
24+
s.add_dependency 'activesupport', '>= 7.0', '< 8'
25+
s.add_dependency 'nokogiri', '>= 1.13', '< 1.19'
2626

2727
s.add_development_dependency 'rake', '~> 13.0'
2828
s.add_development_dependency 'rspec', '~> 3.13'

skills/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Skills – Contentstack Utils Ruby
2+
3+
Source of truth for detailed guidance. Read [AGENTS.md](../AGENTS.md) first, then open the skill that matches your task.
4+
5+
## When to use which skill
6+
7+
| Skill folder | Use when |
8+
|--------------|----------|
9+
| `code-review` | Preparing or reviewing a PR |
10+
| `contentstack-utils` | Changing rendering behavior, JSON RTE / GQL paths, options API, or public `lib/` entry points |
11+
| `dev-workflow` | Setting up the repo, running tests/docs, opening PRs, understanding CI and release |
12+
| `framework` | Gemspec, Bundler, Ruby version constraints, activesupport/nokogiri dependencies, gem build/release |
13+
| `ruby-style` | File layout, modules, or staying consistent with existing Ruby style in this repo |
14+
| `testing` | Adding or changing specs, fixtures, mocks, or coverage |
15+
16+
Each folder contains `SKILL.md` with YAML frontmatter (`name`, `description`).

skills/code-review/SKILL.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: code-review
3+
description: Use when reviewing or preparing a PR for this gem—behavior, tests, API compatibility, and release notes.
4+
---
5+
6+
# Code review – Contentstack Utils Ruby
7+
8+
## When to use
9+
10+
- Authoring a pull request that changes rendering, models, or dependencies
11+
- Reviewing someone else’s PR before merge
12+
- Checking release readiness (version + changelog)
13+
14+
## Instructions
15+
16+
### Blockers (fix before merge)
17+
18+
- **Tests:** `bundle exec rake` (or `bundle exec rspec`) passes locally
19+
- **Breaking API:** unintended removal or signature change of public methods on **`ContentstackUtils`**, **`ContentstackUtils::GQL`**, or **`ContentstackUtils::Model::Options`** without version bump and changelog entry
20+
- **Security:** no secrets in code, fixtures, or logs; HTML output changes reviewed for injection or XSS risk when embedding untrusted fields
21+
22+
### Major (should address)
23+
24+
- **CHANGELOG.md** updated for user-visible behavior fixes or features
25+
- **`lib/contentstack_utils/version.rb`** updated when publishing a release (if this PR is release-bound)
26+
- New JSON/RTE node types or GQL shapes covered by **`spec/lib/utils_spec.rb`** (or focused new spec files)
27+
- Dependency range changes in **`contentstack_utils.gemspec`** justified and compatible with Ruby **≥ 3.1**
28+
29+
### Minor (nice to have)
30+
31+
- **README.md** examples match actual class names (**`Options`**, not a non-existent **`Option`** unless aliased)
32+
- YARD or comments only where they clarify non-obvious RTE or GQL mapping
33+
34+
### Process
35+
36+
- Respect **CODEOWNERS** and branch policy (**`master`** vs **`staging`**) described in [dev-workflow](../dev-workflow/SKILL.md)
37+
38+
## References
39+
40+
- [AGENTS.md](../../AGENTS.md)
41+
- [Development workflow](../dev-workflow/SKILL.md)
42+
- [Contentstack Utils SDK](../contentstack-utils/SKILL.md)
43+
- [Framework & packaging](../framework/SKILL.md)
44+
- [Testing](../testing/SKILL.md)

skills/contentstack-utils/SKILL.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: contentstack-utils
3+
description: Use when changing the public Ruby API, RTE rendering (HTML string or JSON), GQL payloads, Model::Options/Metadata, or integration boundaries with the delivery client.
4+
---
5+
6+
# Contentstack Utils SDK – Contentstack Utils Ruby
7+
8+
## When to use
9+
10+
- Implementing or fixing HTML output for rich text / JSON RTE
11+
- Extending or subclassing rendering options (`ContentstackUtils::Model::Options`)
12+
- Parsing GraphQL-shaped RTE (`ContentstackUtils::GQL`)
13+
- Changing load paths or public entry points under `lib/` (gemspec and dependency ranges: see [framework](../framework/SKILL.md))
14+
15+
## Instructions
16+
17+
### Entry points
18+
19+
- **`lib/contentstack_utils.rb`** — requires version and `utils`
20+
- **`lib/contentstack_utils/utils.rb`** — main module **`ContentstackUtils`** with class methods:
21+
- **`render_content(content, options)`** — legacy HTML string RTE (array of strings or single string); uses Nokogiri and `_embedded_items` on the entry passed via options
22+
- **`json_to_html(content, options)`** — JSON RTE document tree (Hash/Array) for CDA-style payloads with embedded items on the entry
23+
- Internal helpers such as **`json_doc_to_html`** (used by GQL path)
24+
- **`ContentstackUtils::GQL`****`json_to_html(content, options)`** for GraphQL responses: expects keys like `json` and optional `embedded_itemsConnection.edges`; reuses `ContentstackUtils.json_doc_to_html` with a GQL-specific reference resolver
25+
26+
### Models and extension points
27+
28+
- **`ContentstackUtils::Model::Options`** (`lib/contentstack_utils/model/options.rb`) — default **`render_option`**, **`render_mark`**, **`render_node`**; subclass for custom HTML (see tests under `spec/mock/custom_render_option.rb`)
29+
- **`ContentstackUtils::Model::Metadata`** — built from DOM nodes (HTML path) or JSON reference nodes
30+
- **`ContentstackUtils::Interface::Rendarable`** (`lib/contentstack_utils/interface/renderable.rb`) — base for options; implement **`render_option`** in subclasses
31+
32+
### Data contracts
33+
34+
- **CDA / delivery JSON path:** options may carry an **`entry`** hash with **`_embedded_items`** keyed by field UIDs
35+
- **GQL path:** payload uses **`embedded_itemsConnection.edges`** with **`node`** objects; reference resolution matches **`metadata.item_uid`** to **`node.system.uid`**
36+
37+
### Boundaries
38+
39+
- HTTP and stack access belong to the separate **Contentstack Ruby** client; this gem only renders given content + embedded metadata
40+
41+
### Versioning
42+
43+
- Public API and behavior changes should be reflected in `CHANGELOG.md` and `lib/contentstack_utils/version.rb`
44+
45+
## References
46+
47+
- Product overview: [README.md](../../README.md)
48+
- [Framework & packaging](../framework/SKILL.md)
49+
- [Testing](../testing/SKILL.md)
50+
- [Ruby style and layout](../ruby-style/SKILL.md)
51+
- [Contentstack documentation](https://www.contentstack.com/docs/)

skills/dev-workflow/SKILL.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: dev-workflow
3+
description: Use when setting up the dev environment, running build/test/docs, or understanding CI, branches, and gem release for this repo.
4+
---
5+
6+
# Development workflow – Contentstack Utils Ruby
7+
8+
## When to use
9+
10+
- Cloning the repo or onboarding a new contributor
11+
- Running tests, generating docs, or building the gem locally
12+
- Understanding branch rules and GitHub Actions for this repository
13+
14+
## Instructions
15+
16+
### Prerequisites
17+
18+
- Ruby **≥ 3.1** (matches `s.required_ruby_version` in `contentstack_utils.gemspec`)
19+
- Bundler; install gems with `bundle install`
20+
21+
### Everyday commands
22+
23+
- **Run tests (default Rake task):** `bundle exec rake` or `bundle exec rake spec`
24+
- **RSpec directly:** `bundle exec rspec` (pattern `spec/**/*_spec.rb` is configured in `Rakefile`)
25+
- **YARD API docs:** `bundle exec rake yard` (see `.yardopts` for included paths)
26+
- **Build gem artifact:** `gem build contentstack_utils.gemspec` (also used in `.github/workflows/release-gem.yml`)
27+
28+
### Version and changelog
29+
30+
- Gem version lives in `lib/contentstack_utils/version.rb` as `ContentstackUtils::VERSION`
31+
- Document user-visible changes in `CHANGELOG.md` when releasing
32+
33+
### Branches and PRs
34+
35+
- `.github/workflows/check-branch.yml` blocks merging into **`master`** unless the head branch is **`staging`** (organizational policy). Prefer PRs that follow team conventions for `master` / `staging`.
36+
- Use `CODEOWNERS` for required reviewers when applicable
37+
38+
### CI and automation (no RSpec workflow today)
39+
40+
- **Release:** `.github/workflows/release-gem.yml` — on GitHub **release created**, builds and pushes to RubyGems (note: workflow pins Ruby 2.7 for publish; align with gemspec minimum when changing)
41+
- **Security / compliance:** CodeQL, policy scan, SCA scan — see `.github/workflows/`
42+
- **Issues:** Jira integration workflow in `.github/workflows/issues-jira.yml`
43+
44+
### Optional housekeeping
45+
46+
- `.talismanrc` is used for secret scanning hooks in some environments; do not commit credentials or tokens
47+
48+
## References
49+
50+
- [AGENTS.md](../../AGENTS.md)
51+
- [Contentstack Utils SDK](../contentstack-utils/SKILL.md)
52+
- [Framework & packaging](../framework/SKILL.md)
53+
- [Testing](../testing/SKILL.md)

skills/framework/SKILL.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: framework
3+
description: Use when changing the gemspec, Bundler setup, Ruby/runtime constraints, or runtime dependencies (activesupport, nokogiri) and native extension implications.
4+
---
5+
6+
# Framework & packaging – Contentstack Utils Ruby
7+
8+
## When to use
9+
10+
- Editing **`contentstack_utils.gemspec`** (dependencies, `required_ruby_version`, files list)
11+
- Changing **`Gemfile`** / **`Gemfile.lock`** workflow or documenting install for contributors
12+
- Evaluating impact of **nokogiri** (native extension) or **activesupport** version ranges on consumers
13+
14+
## Instructions
15+
16+
### Gem definition
17+
18+
- **`contentstack_utils.gemspec`** — canonical metadata: `s.files` from `git ls-files`, `spec/` as test files, `lib` as `require_paths`
19+
- **`Gemfile`**`gemspec` only; runtime and development dependencies are declared in the gemspec
20+
21+
### Runtime dependencies (as shipped)
22+
23+
- **activesupport** `>= 7.0`, `< 8`
24+
- **nokogiri** `>= 1.13`, `< 1.19` — HTML/XML parsing for legacy string RTE paths; consumers need a compatible platform build
25+
26+
### Development dependencies
27+
28+
- **rake**, **rspec**, **webmock**, **simplecov**, **yard** — see gemspec; used for tasks in `Rakefile` and CI-style local checks
29+
30+
### Ruby version
31+
32+
- **`s.required_ruby_version`** is **>= 3.1**; `.ruby-version` pins a team default for local dev
33+
- **Release workflow** (`.github/workflows/release-gem.yml`) uses its own Ruby pin for `gem build` / `gem push`; keep it aligned with gemspec when updating
34+
35+
### Build and publish
36+
37+
- Local artifact: `gem build contentstack_utils.gemspec`
38+
- Publishing is triggered by GitHub **release** per `release-gem.yml`
39+
40+
## References
41+
42+
- [Development workflow](../dev-workflow/SKILL.md)
43+
- [Contentstack Utils SDK](../contentstack-utils/SKILL.md)
44+
- [Ruby style and layout](../ruby-style/SKILL.md)

0 commit comments

Comments
 (0)