danica 3.0.0 → 3.1.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: 33b478d12b45fbf2d5ee53170698e864ba3bf0aedf21030ae406642b2f3e84c0
4
- data.tar.gz: 767d15a104e9cc04c0e7fa2856d11d8c80dad4df1f8367f11e8264144ec2f913
3
+ metadata.gz: 204f95ee5b153c0c1f6eaa51f35d33e4342a246714a9796e94ba979239cda6e5
4
+ data.tar.gz: de5c5d3540efcef064af396bb3338c29b2fcf906dc47bcf7175e1a5191dd4ea2
5
5
  SHA512:
6
- metadata.gz: f0c759124e7c44377d1403000ca5bb6a23a162cde749777c28f7791cf7add1e892b01126e8648b42f1f3761b58f4334d8ebd801382e8c0de83a14817628af75e
7
- data.tar.gz: 708dc6c0096c3c17adcfb2868d670dc2bd926a06439fc418fac8b34c6825fe5a89a669368efc72e36a3a451a09bc5ecb998a9c0f61882bfba01c5d5b27ca4299
6
+ metadata.gz: 8343355dcbe1b6949505d6419634607ef231e70f6a3d487e066e2fb2b8c78d8f31c69ccea4f435cbe297fd274a0fa15113635371be016db760a120f09ae9e58b
7
+ data.tar.gz: 2c8c574d3eaf8f14bc266833dd623b21de4bc4458aafeaef6e7c39f30983ae09a90d9b206cbca1a2e21d2d63726ec5dc764acd3cac3ab08f8933babb4493436a
data/.circleci/config.yml CHANGED
@@ -1,6 +1,5 @@
1
- version: 2
1
+ version: 2.1
2
2
  workflows:
3
- version: 2
4
3
  test-and-build:
5
4
  jobs:
6
5
  - test:
@@ -18,11 +17,11 @@ workflows:
18
17
  only: /\d+\.\d+\.\d+/
19
18
  branches:
20
19
  only:
21
- - master
20
+ - main
22
21
  jobs:
23
22
  test:
24
23
  docker:
25
- - image: darthjee/circleci_ruby_331:1.0.2
24
+ - image: darthjee/circleci_ruby_3412:1.0.0
26
25
  environment:
27
26
  PROJECT: danica
28
27
  steps:
@@ -32,10 +31,13 @@ jobs:
32
31
  command: bundle install
33
32
  - run:
34
33
  name: RSpec
35
- command: COVERAGE_JSON=true bundle exec rspec
34
+ command: bundle exec rspec
35
+ - run:
36
+ name: Upload coverage to Codacy
37
+ command: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r coverage/lcov/project.lcov
36
38
  checks:
37
39
  docker:
38
- - image: darthjee/circleci_ruby_331:1.0.2
40
+ - image: darthjee/circleci_ruby_3412:1.0.0
39
41
  environment:
40
42
  PROJECT: danica
41
43
  steps:
@@ -51,7 +53,7 @@ jobs:
51
53
  command: bundle exec rake verify_measurements
52
54
  - run:
53
55
  name: Check version documentation
54
- command: check_readme.sh
56
+ command: PROJECT=danica check_readme.sh
55
57
  - run:
56
58
  name: Rubycritcs check
57
59
  command: rubycritic.sh
@@ -60,7 +62,7 @@ jobs:
60
62
  command: check_specs
61
63
  build-and-release:
62
64
  docker:
63
- - image: darthjee/circleci_ruby_331:1.0.2
65
+ - image: darthjee/circleci_ruby_3412:1.0.0
64
66
  environment:
65
67
  PROJECT: danica
66
68
  steps:
@@ -73,7 +75,7 @@ jobs:
73
75
  command: build_gem.sh signin
74
76
  - run:
75
77
  name: Build Gem
76
- command: build_gem.sh build
78
+ command: PROJECT=danica build_gem.sh build
77
79
  - run:
78
80
  name: Push Gem
79
- command: build_gem.sh push
81
+ command: PROJECT=danica build_gem.sh push
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: architect
3
+ description: Danica architect and coordinator. Use for cross-cutting tasks, multi-agent coordination, documentation, root-level files, or any task that spans more than one agent's scope.
4
+ tools: Read, Edit, Write, Bash, Agent
5
+ ---
6
+
7
+ You are the architect and coordinator for the Danica project — a Ruby gem for building, formatting and evaluating math expressions.
8
+
9
+ ## Your scope
10
+
11
+ - `docs/agents/` — all project documentation
12
+ - Root-level files: `README.md`, `AGENTS.md`, `CLAUDE.md`, `Gemfile`, `danica.gemspec`, `Makefile`, `Dockerfile`, `docker-compose.yml`, `.circleci/`, `.rubocop*.yml`
13
+ - Cross-cutting decisions that span multiple layers
14
+ - Coordination of the other specialist agents
15
+
16
+ ## Specialist agents
17
+
18
+ Delegate implementation, exploration, and planning work to the right agent. Never implement, explore, or plan what belongs to a specialist yourself.
19
+
20
+ | Agent | Scope |
21
+ |-------|-------|
22
+ | `ruby` | `lib/`, `spec/`, `config/`, `scripts/` — gem source code, tests and quality tooling (the only agent that edits code) |
23
+ | `mathematician` | Reviewer — validates the mathematical correctness of operators, expressions, formulas and specs |
24
+ | `gnuplot` | Reviewer — validates gnuplot output (`to_gnu`) |
25
+ | `latex` | Reviewer — validates LaTeX output (`to_tex`) |
26
+
27
+ ## How to coordinate
28
+
29
+ When a task spans multiple agents:
30
+
31
+ 1. **Break it down** — identify which parts belong to which agent.
32
+ 2. **Delegate exploration first** — dispatch the specialist(s) whose scope covers the relevant area to investigate, rather than reading the code yourself.
33
+ 3. **Sequence or parallelize** — run independent work in parallel; sequence dependent work.
34
+ 4. **Validate** — after `ruby` changes operators, expressions or formatting, ask `mathematician`, `gnuplot` and/or `latex` to review the result.
35
+ 5. **Integrate** — verify cross-cutting concerns.
36
+ 6. **Update docs** — reflect any architectural change in `docs/agents/`.
37
+
38
+ ## Documentation (`docs/agents/`)
39
+
40
+ See the Documentation table in `AGENTS.md`. Keep documentation up to date after any architectural change. When a new agent is created or its scope changes, update this file and `AGENTS.md`.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: gnuplot
3
+ description: Danica gnuplot expert. Use to validate that the gnuplot output generated by the gem (to_gnu and related formatting) is valid gnuplot syntax and plots the intended function.
4
+ tools: Read, Grep, Glob, Bash
5
+ ---
6
+
7
+ You are the gnuplot specialist for the Danica project — a Ruby gem for building, formatting and evaluating math expressions. You are a **reviewer**: you validate, you do not edit code.
8
+
9
+ ## What you validate
10
+
11
+ - Strings produced by `to_gnu` (see `lib/danica/wrapper/`, `operator/`, `expression/`, `formatted.rb`) are valid gnuplot expressions: operators (`**` for power, `exp()`, `sqrt()`, `sin()`, `cos()`), parentheses and precedence, variable names, constants and functions such as `pi`.
12
+ - Integer-vs-float division pitfalls in gnuplot (e.g. `1/2` is `0`) are handled.
13
+ - Expected strings in specs and `README.md` are correct gnuplot.
14
+
15
+ ## How to work
16
+
17
+ - Read the code and specs; generate sample output with `bundle exec ruby` / `rspec` when helpful.
18
+ - If `gnuplot` is installed, verify expressions by evaluating them (e.g. `gnuplot -e "print <expr>"`); otherwise reason from the gnuplot grammar and say so.
19
+ - Report findings as: location, the offending string, why it is wrong, and a suggested fix.
20
+ - Do NOT edit files. Hand required changes to the `ruby` agent via `architect`.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: latex
3
+ description: Danica LaTeX expert. Use to validate that the LaTeX output generated by the gem (to_tex and related formatting) is valid LaTeX math syntax and renders the intended formula.
4
+ tools: Read, Grep, Glob, Bash
5
+ ---
6
+
7
+ You are the LaTeX specialist for the Danica project — a Ruby gem for building, formatting and evaluating math expressions. You are a **reviewer**: you validate, you do not edit code.
8
+
9
+ ## What you validate
10
+
11
+ - Strings produced by `to_tex` (see `lib/danica/wrapper/`, `operator/`, `expression/`, `formatted.rb`) are valid LaTeX math-mode: `\frac{}{}`, `^{}`, `\sqrt{}`, `\sin`, `\cos`, `\left(`/`\right)`, `\pm`, Greek letters and subscripts, balanced braces and parentheses.
12
+ - Grouping and precedence render the intended formula (e.g. braces around multi-character exponents).
13
+ - Expected strings in specs and `README.md` are correct LaTeX.
14
+
15
+ ## How to work
16
+
17
+ - Read the code and specs; generate sample output with `bundle exec ruby` / `rspec` when helpful.
18
+ - If a TeX engine (`pdflatex`, `latex`) is installed, compile a minimal document to confirm; otherwise reason from LaTeX rules and say so.
19
+ - Report findings as: location, the offending string, why it is wrong, and a suggested fix.
20
+ - Do NOT edit files. Hand required changes to the `ruby` agent via `architect`.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: mathematician
3
+ description: Danica mathematics expert. Use to validate mathematical correctness — operator semantics, formulas (e.g. Gauss), evaluation results, precedence/grouping, edge cases (division by zero, domains) and the expected values in specs.
4
+ tools: Read, Grep, Glob, Bash
5
+ ---
6
+
7
+ You are the mathematician for the Danica project — a Ruby gem for building, formatting and evaluating math expressions. You are a **reviewer**: you validate, you do not edit code.
8
+
9
+ ## What you validate
10
+
11
+ - Operators in `lib/danica/operator/` (addition, multiplication, division, power, exponential, sin, cos, squared root) implement the correct mathematics, including operator precedence, grouping and sign handling.
12
+ - Expressions and functions (`lib/danica/expression/`, `function/`, `equation/`) represent the intended formulas and compute correct numeric results.
13
+ - Expected values and formulas in `spec/` and `README.md` examples are mathematically right.
14
+ - Edge cases: division by zero, domains (e.g. square root of negatives), identities, simplifications.
15
+
16
+ ## How to work
17
+
18
+ - Read the code and specs; recompute results independently (e.g. with `ruby -e` or other CLI tools) to confirm.
19
+ - Report findings as: location, what is wrong or correct, the correct math, and a suggested fix.
20
+ - Do NOT edit files. Hand required changes to the `ruby` agent via `architect`.
21
+ - For formatted output syntax (LaTeX, gnuplot), only check the math it expresses; syntax belongs to `latex` and `gnuplot`.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: ruby
3
+ description: Danica Ruby specialist. Use for any task involving Ruby code, RSpec specs, RuboCop, YARD or the gem's source under lib/, spec/, config/ and scripts/.
4
+ tools: Read, Edit, Write, Bash
5
+ ---
6
+
7
+ You are the ruby specialist for the Danica project — a Ruby gem for building, formatting and evaluating math expressions.
8
+
9
+ ## Your scope
10
+
11
+ You own everything inside:
12
+
13
+ - `lib/` — gem source (`danica.rb` and `danica/`: dsl, operator, wrapper, function, equation, expression, variables_holder)
14
+ - `spec/` — RSpec specs (`lib/` unit specs mirroring the source, `integration/`, `support/`)
15
+ - `config/` — yardstick, rubycritic and spec-check configuration
16
+ - `scripts/` — helper scripts
17
+
18
+ Do NOT touch `docs/agents/`, root-level files or `.claude/`; leave those to `architect`. Mathematical, gnuplot and LaTeX validation is done by the reviewer agents, but you implement any fixes they request.
19
+
20
+ ## Stack
21
+
22
+ - Ruby >= 3.3.1, ActiveSupport ~> 7.2, darthjee-core_ext ~> 3
23
+ - RSpec, RuboCop (+ rubocop-rspec), YARD/yardstick, RubyCritic
24
+
25
+ ## Commands
26
+
27
+ ```bash
28
+ bundle exec rspec
29
+ rubocop
30
+ bundle exec rake verify_measurements
31
+ check_readme.sh
32
+ rubycritic.sh
33
+ check_specs
34
+ ```
35
+
36
+ Commands can be run inside the container via `make dev` / `make ci`.
37
+
38
+ ## Conventions
39
+
40
+ - `# frozen_string_literal: true` at the top of every Ruby file.
41
+ - snake_case file names matching the class; specs mirror the path under `spec/lib/`.
42
+ - Public methods before private ones; small, single-purpose methods.
43
+ - Document public API with YARD (enforced by `verify_measurements`).
44
+ - Do not add RuboCop todo entries to hide new offenses.
45
+ - See `docs/agents/contributing.md`.
@@ -0,0 +1,3 @@
1
+ {
2
+ "version": "2.4.0"
3
+ }
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ set -x
4
+
5
+ bundle exec rspec
6
+ rubocop
7
+ bundle exec rake verify_measurements
8
+ check_readme.sh
9
+ rubycritic.sh
10
+ check_specs
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(auto-fix-all/scripts/wait_ci_and_merge.sh *)",
5
+ "Bash(auto-fix-issue/scripts/commit_change.sh *)",
6
+ "Bash(auto-fix-issue/scripts/run_checks.sh *)",
7
+ "Bash(git add *)"
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,32 @@
1
+ ```text
2
+ <type>(<scope>): <subject> (issue #<id>)
3
+
4
+ <optional body: what was done and why, if not obvious>
5
+
6
+ Addresses-Comment: <optional: URL of the PR comment this commit addresses>
7
+
8
+ Co-Authored-By: <AI model name> <AI model email>
9
+ Co-Authored-By: <agent> agent <agent email>
10
+ ```
11
+
12
+ Note: unlike the model line above (always the running AI model's own
13
+ canonical noreply address), the agent line's email is independently
14
+ configurable per agent via the "git.email" key (a template such as
15
+ "you+{agent}@example.com", with "{agent}" substituted for the actual
16
+ agent name, e.g. "architect" or "backend") in
17
+ .claude/state/arcanum-config.json (local) or
18
+ .claude/configuration/arcanum-repo-config.json (repo) — see
19
+ docs/guides/arcanum-repo-config.md. When "git.email" is unset, the agent
20
+ line falls back to the same address as the model line, reproducing the
21
+ old, single-shared-email template's output.
22
+
23
+ The model line above can be omitted entirely by setting the
24
+ "git.omit_model_coauthor" key to "true" in the same three locations
25
+ (local state, repo config, or global config — see
26
+ docs/guides/arcanum-repo-config.md) — the agent line is always still
27
+ emitted regardless of this setting.
28
+
29
+ This file's mere presence (as "commit_message_template-2.0.md", not its
30
+ content) is what switches the commit scripts onto this new, two-distinct-
31
+ email behavior — the content itself is never parsed at runtime, it is
32
+ purely human-facing documentation of the shape above.
@@ -0,0 +1,10 @@
1
+ ```text
2
+ <type>(<scope>): <subject> (issue #<id>)
3
+
4
+ <optional body: what was done and why, if not obvious>
5
+
6
+ Addresses-Comment: <optional: URL of the PR comment this commit addresses>
7
+
8
+ Co-Authored-By: <AI model name> <AI model email>
9
+ Co-Authored-By: <agent> agent <AI model email>
10
+ ```
@@ -0,0 +1 @@
1
+ See [AGENTS.md](../AGENTS.md) for project instructions.
@@ -0,0 +1,17 @@
1
+ ## Summary
2
+
3
+ <!-- One sentence describing what this PR does -->
4
+
5
+ ## Problem
6
+
7
+ <!-- What problem does this solve? Why is this change needed? -->
8
+
9
+ ## Solution
10
+
11
+ <!-- How was the problem solved? What approach was taken? -->
12
+
13
+ ## Details
14
+
15
+ <!-- Optional: implementation notes, migration steps, caveats. Remove this section if not needed. -->
16
+
17
+ Fixes #
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ pkg
6
6
  measurement
7
7
  **/*.swp
8
8
  rubycritic/
9
+ .claude/state
data/.rubocop.yml CHANGED
@@ -17,3 +17,7 @@ Style/HashTransformKeys:
17
17
 
18
18
  Style/HashTransformValues:
19
19
  Enabled: true
20
+
21
+ RSpec/SpecFilePathFormat:
22
+ Exclude:
23
+ - 'spec/integration/**/*_spec.rb'
data/AGENTS.md ADDED
@@ -0,0 +1,53 @@
1
+ # Project Instructions
2
+
3
+ Danica is a Ruby gem for building and formatting math expressions (a DSL for math formulation on docs). Expressions are built via `Danica.build { ... }` and can be rendered/formatted (e.g. LaTeX, plain text) and evaluated.
4
+
5
+ ## Stack
6
+
7
+ - Ruby >= 3.3.1 (gem)
8
+ - ActiveSupport ~> 7.2, darthjee-core_ext ~> 3
9
+ - RSpec for tests, RuboCop (with rubocop-rspec) for linting
10
+ - CircleCI for CI; Docker / docker-compose for development (`make dev`, `make ci`)
11
+
12
+ ## Conventions
13
+
14
+ - Source lives in `lib/danica/`, specs in `spec/` mirroring the `lib/` layout.
15
+ - Follow `.rubocop.yml`; run RuboCop and RSpec before committing.
16
+ - Keep `# frozen_string_literal: true` at the top of Ruby files and document public APIs with YARD.
17
+
18
+ ## Documentation
19
+
20
+ All project documentation lives under [`docs/agents/`](docs/agents/):
21
+
22
+ | File | Contents |
23
+ |------|----------|
24
+ | [Folder Structure](docs/agents/folder-structure.md) | Top-level directory layout and the role of each folder. |
25
+ | [Architecture](docs/agents/architecture.md) | Source layout, modules, code style, and implementation guidelines. |
26
+ | [Flow](docs/agents/flow.md) | Main runtime flow of the application. |
27
+ | [Plans](docs/agents/plans/) | Implementation plans for ongoing or upcoming features. |
28
+ | [Issues](docs/agents/issues/) | Detailed specs for open issues. |
29
+
30
+ ### Issues (`docs/agents/issues/`)
31
+
32
+ Each file documents an issue in detail. Naming convention:
33
+
34
+ ```
35
+ docs/agents/issues/<issue_id>_<issue_name>.md
36
+ ```
37
+
38
+ Example: `docs/agents/issues/5_release_docker_image.md` for issue #5.
39
+
40
+ ### Plans (`docs/agents/plans/`)
41
+
42
+ Each plan is a directory named after the issue ID and topic, containing one or more related files:
43
+
44
+ ```
45
+ docs/agents/plans/<issue_id>_<topic>/<related_files>.md
46
+ ```
47
+
48
+ Example: `docs/agents/plans/12_add-auth/plan.md` for issue #12.
49
+ | [Contributing](docs/agents/contributing.md) | Commit guidelines, PR standards, code organization, and refactoring rules. |
50
+
51
+ ## Commit Attribution
52
+
53
+ Commit co-author trailers follow arcanum's resolved `git.omit_model_coauthor` and `git.remove_coauthors` config (check them with `/arcanum-check-config`); this overrides Claude Code's own attribution reminder for every commit, including ones written by hand.
data/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ See [AGENTS.md](AGENTS.md) for project instructions.
data/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
- FROM darthjee/scripts:0.4.2 as scripts
1
+ FROM darthjee/scripts:0.15.0 as scripts
2
2
 
3
- FROM darthjee/ruby_331:1.0.2 as base
3
+ FROM darthjee/ruby_3412:1.0.0 as base
4
4
 
5
5
  COPY --chown=app:app ./ /home/app/app/
6
6
 
data/Gemfile CHANGED
@@ -2,20 +2,24 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in credential_builder.gemspec
5
+ # Specify your gem's dependencies in danica.gemspec
6
6
  gemspec
7
7
 
8
- gem 'bundler', '~> 2.6.8'
9
- gem 'pry-nav', '~> 1.0.0'
10
- gem 'rake', '>= 13.2.1'
11
- gem 'rspec', '>= 3.13.0'
12
- gem 'rspec-core', '>= 3.13.3'
13
- gem 'rspec-expectations', '>= 3.13.3'
14
- gem 'rspec-mocks', '>= 3.13.2'
15
- gem 'rspec-support', '>= 3.13.2'
16
- gem 'rubocop', '1.75.5'
17
- gem 'rubocop-rspec', '3.6.0'
18
- gem 'rubycritic', '>= 4.9.2'
19
- gem 'simplecov', '~> 0.22.0'
20
- gem 'yard', '>= 0.9.37'
21
- gem 'yardstick', '>= 0.9.9'
8
+ gem 'bundler', '>= 4.0.24'
9
+ gem 'pry', '0.14.2'
10
+ gem 'pry-nav', '1.0.0'
11
+ gem 'rake', '13.4.2'
12
+ gem 'rspec', '3.13.2'
13
+ gem 'rspec-core', '3.13.7'
14
+ gem 'rspec-expectations', '3.13.6'
15
+ gem 'rspec-mocks', '3.13.9'
16
+ gem 'rspec-support', '3.13.8'
17
+ gem 'rubocop', '1.92.2'
18
+ gem 'rubocop-rake', '0.7.1'
19
+ gem 'rubocop-rspec', '3.10.2'
20
+ gem 'rubycritic', '5.0.0'
21
+ gem 'simplecov', '0.22.0'
22
+ gem 'simplecov-html', '0.13.2'
23
+ gem 'simplecov-lcov', '0.9.0'
24
+ gem 'yard', '0.9.45'
25
+ gem 'yardstick', '0.9.9'
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # danica
2
- [![Code Climate](https://codeclimate.com/github/darthjee/danica/badges/gpa.svg)](https://codeclimate.com/github/darthjee/danica)
3
- [![Test Coverage](https://codeclimate.com/github/darthjee/danica/badges/coverage.svg)](https://codeclimate.com/github/darthjee/danica/coverage)
4
- [![Issue Count](https://codeclimate.com/github/darthjee/danica/badges/issue_count.svg)](https://codeclimate.com/github/darthjee/danica)
1
+ # Danica
2
+
3
+ [![CircleCI](https://dl.circleci.com/status-badge/img/gh/darthjee/danica/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/darthjee/danica/tree/main)
4
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/7990acf6e4404787995fff3c0d6eb1dc)](https://app.codacy.com/gh/darthjee/danica/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
5
+ [![Codacy Badge](https://app.codacy.com/project/badge/Coverage/7990acf6e4404787995fff3c0d6eb1dc)](https://app.codacy.com/gh/darthjee/danica/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
5
6
  [![Gem Version](https://badge.fury.io/rb/danica.svg)](https://badge.fury.io/rb/danica)
6
- [![Codacy Badge](https://app.codacy.com/project/badge/Grade/7990acf6e4404787995fff3c0d6eb1dc)](https://www.codacy.com/gh/darthjee/danica/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=darthjee/danica&amp;utm_campaign=Badge_Grade)
7
7
  [![Inline docs](http://inch-ci.org/github/darthjee/danica.svg?branch=master)](http://inch-ci.org/github/darthjee/danica)
8
8
 
9
9
  ![danica](https://raw.githubusercontent.com/darthjee/danica/master/danica.png)
@@ -16,7 +16,11 @@ Current Release: [3.0.0](https://github.com/darthjee/danica/tree/3.0.0)
16
16
 
17
17
  Yard Documentation
18
18
  -------------------
19
- [https://www.rubydoc.info/gems/danica/3.0.0](https://www.rubydoc.info/gems/danica/3.0.0)
19
+ [https://www.rubydoc.info/gems/danica/3.1.0](https://www.rubydoc.info/gems/danica/3.1.0)
20
+
21
+ **Current Release**: [3.1.0](https://github.com/darthjee/danica/tree/3.1.0)
22
+
23
+ **Next release**: [3.2.0](https://github.com/darthjee/danica/compare/3.1.0...main)
20
24
 
21
25
  ## How to use
22
26
  Add the gem to your project or just install the gem
data/danica.gemspec CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |spec|
16
16
  spec.require_paths = ['lib']
17
17
  spec.required_ruby_version = '>= 3.3.1'
18
18
 
19
- spec.add_dependency 'activesupport', '~> 7.2.x'
20
- spec.add_dependency 'darthjee-core_ext', '~> 3.x'
19
+ spec.add_dependency 'activesupport', '~> 7.x'
20
+ spec.add_dependency 'darthjee-core_ext', '>= 3.2.0'
21
21
  end
@@ -0,0 +1,9 @@
1
+ # Arcanum Split Issue
2
+
3
+ A checklist of concerns to consider when splitting a broad issue into sub-issues via `/arcanum-split-issue`. Not exhaustive — adjust or extend the list for this project's needs.
4
+
5
+ - **Sub-issue granularity** — is each sub-issue independently workable, or does it still depend on another sub-issue landing first?
6
+ - **Standalone clarity** — does each sub-issue stand on its own, without requiring the reader to have the parent issue open to understand it?
7
+ - **Shared contracts** — interfaces, schemas, or config keys touched by more than one sub-issue, and who owns getting them right first.
8
+ - **Sequencing** — is there a natural order sub-issues should be implemented/merged in, or can they proceed in parallel?
9
+ - **Responsible agents** — which specialist agent(s) each sub-issue is likely to fall to.
@@ -0,0 +1,27 @@
1
+ # Architecture
2
+
3
+ ## Overview
4
+
5
+ Danica is a Ruby gem for building, formatting and evaluating math expressions. Users compose expressions with the `Danica.build` DSL. Each expression is a tree of operators, wrappers and variables that can be rendered to text or LaTeX and calculated.
6
+
7
+ ## Source Code Layout
8
+
9
+ All source code lives under `lib/`. `lib/danica.rb` is the entry point.
10
+
11
+ ### `lib/danica/`
12
+ Top-level building blocks: `builder.rb`, `common.rb`, `base_operations.rb`, `expressable.rb`, `formatted.rb`, `exception.rb`, `version.rb`.
13
+
14
+ ### `dsl/`
15
+ `Danica.build` DSL (`DSL::Builder`) used to write expressions.
16
+
17
+ ### `operator/`
18
+ Operations as tree nodes: addition, multiplication, division, power, exponential, sin, cos, squared root, plus chained and functional bases.
19
+
20
+ ### `wrapper/`
21
+ Leaf and wrapping nodes: number, constant, variable, group, negative, plus/minus, container.
22
+
23
+ ### `function/`, `equation/`, `expression/`
24
+ Named functions, equations (`Equation::Builder`) and ready-made expressions (e.g. `Gauss`).
25
+
26
+ ### `variables_holder/`
27
+ Variable management: store, calculator, aliasing and variable builders.
@@ -0,0 +1,127 @@
1
+ # Contributing
2
+
3
+ ## Commit Guidelines
4
+
5
+ - **Atomic and Unitary:** Each commit must represent a single logical change.
6
+ *Example:*
7
+ - Good: `Add Danica::Operator::Cos#to_tex`
8
+ - Bad: `Add Cos#to_tex and refactor VariablesHolder::Store`
9
+ - **No Unrelated Changes:** Do not mix unrelated changes in the same commit.
10
+ - **Separate Refactoring:** Whenever possible, separate refactoring commits from new feature or bugfix commits.
11
+
12
+ ## Pull Requests
13
+
14
+ - **Descriptive Summary:** Every PR must include a clear and descriptive summary of its purpose and changes.
15
+ - **PR Description Files:** If a description cannot be provided directly in the PR, generate a file with the PR description (e.g., `docs/issues/<pr_number>_description.md`), but do not commit this file.
16
+
17
+ ## Definition of Done for PRs
18
+
19
+ A PR is considered complete when:
20
+
21
+ - The stated objective has been achieved.
22
+ - All tests are passing.
23
+ - Linting passes without errors.
24
+ - Code coverage is as high as reasonably possible.
25
+ - Code is not overly complex:
26
+ - Classes and methods should have clear, focused responsibilities.
27
+ - Methods should be small and do exactly one thing. If a method is growing, extract parts into private helper methods or separate classes.
28
+ - *Example:*
29
+
30
+ ```ruby
31
+ # Good: each method does one thing
32
+ class Worker
33
+ def fetch_job; end
34
+ def process_job(job); end
35
+ end
36
+
37
+ # Bad: method does too much
38
+ class Worker
39
+ def run
40
+ fetch_job
41
+ process_job
42
+ send_metrics
43
+ cleanup
44
+ end
45
+ end
46
+ ```
47
+
48
+ - This requirement applies primarily to source code. For specs, refactor only if there is excessive duplication.
49
+
50
+ ### CI Checks
51
+
52
+ Before a PR is considered complete, all CI checks must pass locally. CircleCI (`.circleci/config.yml`) runs two relevant jobs on every change:
53
+
54
+ | Modified folder | CircleCI job | Local commands |
55
+ | --- | --- | --- |
56
+ | `lib/`, `spec/` | `test` | `bundle exec rspec` |
57
+ | `lib/`, `spec/`, `config/`, `scripts/`, `README.md` | `checks` | `rubocop`, `bundle exec rake verify_measurements`, `check_readme.sh`, `rubycritic.sh`, `check_specs` |
58
+
59
+ The `build-and-release` job only runs on tags and `master`. Commands can be run inside the dev container (`make dev` / `make ci`).
60
+
61
+ This same process must be followed when **planning how to resolve an issue**: include a final step in the plan that identifies the affected folders and lists the CI commands to run before opening a PR.
62
+
63
+ ## Code Organization
64
+
65
+ ### File Responsibility
66
+
67
+ Every source file under `lib/` must declare classes or modules. Files must not execute logic or cause side effects at load time. `lib/danica.rb` is the only entrypoint (it loads/requires the namespace).
68
+
69
+ ### File Naming: snake_case for Class Files
70
+
71
+ Files that define a class use **snake_case** matching the class name, and their specs mirror the path.
72
+
73
+ *Examples:*
74
+
75
+ - `lib/danica/operator/squared_root.rb` for `Danica::Operator::SquaredRoot`
76
+ - spec: `spec/lib/danica/operator/squared_root_spec.rb`
77
+
78
+ ### Method Order: Public Before Private
79
+
80
+ Within a class, declare public methods before `private` ones; private methods are implementation helpers at the end of the class body.
81
+
82
+ ```ruby
83
+ # Good
84
+ class Worker
85
+ def run
86
+ prepare
87
+ execute
88
+ end
89
+
90
+ private
91
+
92
+ def prepare; end
93
+ def execute; end
94
+ end
95
+ ```
96
+
97
+ ## Dependency Injection
98
+
99
+ Classes must receive their dependencies (data, configuration, collaborators) as constructor arguments. A class must never reach out to load files, read environment variables, or fetch configuration on its own. This keeps every class independently testable.
100
+
101
+ ```ruby
102
+ # Good
103
+ class Router
104
+ def initialize(data)
105
+ @data = data
106
+ end
107
+ end
108
+
109
+ # Bad
110
+ class Router
111
+ def build
112
+ data = YAML.load_file('./data.yml')
113
+ end
114
+ end
115
+ ```
116
+
117
+ ## Documentation
118
+
119
+ Public classes and methods must be documented with YARD; the `verify_measurements` rake task enforces documentation coverage. Update `README.md` when behavior or version changes (`check_readme.sh` verifies the version).
120
+
121
+ ## Refactoring Guidelines
122
+
123
+ When refactoring, aim to:
124
+
125
+ - **Reduce Code Duplication:** e.g. move repeated spec setup into `let`/shared contexts or factory helpers in `spec/support/`.
126
+ - **Keep Classes Focused:** extract collaborators when a class takes on more than one responsibility.
127
+ - **Keep RuboCop and RubyCritic Green:** do not add entries to `.rubocop_todo.yml` to hide new offenses.
@@ -0,0 +1,5 @@
1
+ # Flow
2
+
3
+ ## Overview
4
+
5
+ _Describe the main runtime flow of the application here._
@@ -0,0 +1,15 @@
1
+ # Folder Structure
2
+
3
+ ## Project Root
4
+
5
+ | Directory / File | Description |
6
+ |---|---|
7
+ | `lib/` | Gem source code (`danica.rb` entry point and `danica/` namespace). |
8
+ | `spec/` | RSpec tests: `lib/` unit specs mirroring the source, `integration/` specs, and `support/` helpers. |
9
+ | `config/` | Quality-tool configuration (yardstick, rubycritic, spec checks). |
10
+ | `scripts/` | Helper scripts (`check_readme.sh`, `rubycritic.sh`). |
11
+ | `.circleci/`, `circle.yml` | CI configuration. |
12
+ | `Dockerfile`, `docker-compose.yml`, `Makefile` | Dev/CI containers; `make dev` and `make ci` open shells in them. |
13
+ | `danica.gemspec`, `Gemfile` | Gem definition and dependencies. |
14
+ | `.rubocop.yml`, `.rubocop_todo.yml` | Lint configuration. |
15
+ | `docs/agents/` | Agent documentation, issues and plans. |
@@ -0,0 +1,10 @@
1
+ # Issue Enhancement
2
+
3
+ A checklist of concerns to consider when fleshing out a vague issue idea (tagged `Idea`/`Writting`) before it reaches the `Created` stage. Not exhaustive — adjust or extend the list for this project's needs.
4
+
5
+ - **Scope boundaries** — what's explicitly in scope and what's explicitly out.
6
+ - **Alternative solutions** — other ways to solve the same problem, and why this one was chosen.
7
+ - **Edge cases** — inputs, states, or timing the happy path doesn't cover.
8
+ - **Backward compatibility** — whether this breaks existing behavior, data, or integrations.
9
+ - **Testing strategy** — how the change will be verified.
10
+ - **Performance & security considerations** — anything relevant to load, latency, or attack surface.
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+
data/lib/danica/common.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  module Danica
4
4
  module Common
5
5
  extend ::ActiveSupport::Concern
6
+
6
7
  included do
7
8
  include Wrapper
8
9
  include DSL
@@ -10,9 +10,9 @@ module Danica
10
10
 
11
11
  def exp
12
12
  - (
13
- ((x - average)**2) /
14
- (num(2) * variance)
15
- )
13
+ ((x - average)**2) /
14
+ (num(2) * variance)
15
+ )
16
16
  end
17
17
 
18
18
  def variance
@@ -3,6 +3,7 @@
3
3
  module Danica
4
4
  class Function::Name
5
5
  include Common
6
+
6
7
  attr_reader :name, :containers
7
8
 
8
9
  def initialize(name:, variables:)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Danica
4
- VERSION = '3.0.0'
4
+ VERSION = '3.1.0'
5
5
  end
@@ -3,6 +3,7 @@
3
3
  module Danica
4
4
  class Wrapper::Container
5
5
  include Common
6
+
6
7
  attr_accessor :content
7
8
 
8
9
  delegate :to_f, :contentd?, :to, :to_tex, :to_gnu, :priority, :grouped?,
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ # Usage: scripts/bump_version.sh [major|minor|patch|X.Y.Z]
3
+ # Without arguments, bumps the patch version of the current version.
4
+
5
+ set -euo pipefail
6
+
7
+ ROOT="$(git rev-parse --show-toplevel)"
8
+ README="$ROOT/README.md"
9
+ VERSION_FILE="$ROOT/lib/danica/version.rb"
10
+ LOCKFILE="$ROOT/Gemfile.lock"
11
+ GEM="danica"
12
+
13
+ current=$(grep -oE "VERSION = '[0-9]+\.[0-9]+\.[0-9]+'" "$VERSION_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
14
+ IFS='.' read -r cmajor cminor cpatch <<< "$current"
15
+
16
+ arg="${1:-patch}"
17
+
18
+ case "$arg" in
19
+ major) new_version="$((cmajor + 1)).0.0" ;;
20
+ minor) new_version="${cmajor}.$((cminor + 1)).0" ;;
21
+ patch) new_version="${cmajor}.${cminor}.$((cpatch + 1))" ;;
22
+ *) new_version="$arg" ;;
23
+ esac
24
+
25
+ # Validate semver format
26
+ if ! echo "$new_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
27
+ echo "Error: version must be major, minor, patch or X.Y.Z" >&2
28
+ exit 1
29
+ fi
30
+
31
+ # Next release: following minor
32
+ IFS='.' read -r major minor _patch <<< "$new_version"
33
+ next_release="${major}.$((minor + 1)).0"
34
+
35
+ echo "Current version: $current"
36
+ echo "New version: $new_version"
37
+ echo "Next release: $next_release"
38
+
39
+ # version.rb
40
+ sed -i '' "s|VERSION = '[0-9.]*'|VERSION = '${new_version}'|" "$VERSION_FILE"
41
+
42
+ # README: YARD docs link
43
+ sed -i '' \
44
+ "s|rubydoc.info/gems/${GEM}/[0-9.]*|rubydoc.info/gems/${GEM}/${new_version}|g" \
45
+ "$README"
46
+
47
+ # README: Current Release line
48
+ sed -i '' \
49
+ "s|\*\*Current Release\*\*: \[[0-9.]*\](https://github.com/darthjee/danica/tree/[0-9.]*)|**Current Release**: [${new_version}](https://github.com/darthjee/danica/tree/${new_version})|" \
50
+ "$README"
51
+
52
+ # README: Next release line
53
+ sed -i '' \
54
+ "s|\*\*Next release\*\*: \[[0-9.]*\](https://github.com/darthjee/danica/compare/[0-9.]*\.\.\.main)|**Next release**: [${next_release}](https://github.com/darthjee/danica/compare/${new_version}...main)|" \
55
+ "$README"
56
+
57
+ # Gemfile.lock
58
+ if [ -f "$LOCKFILE" ]; then
59
+ sed -i '' "s|^\( *${GEM} (\)[0-9.]*)|\1${new_version})|" "$LOCKFILE"
60
+ fi
61
+
62
+ echo "Done."
@@ -77,7 +77,7 @@ describe Danica::Common do
77
77
 
78
78
  context 'when passing options' do
79
79
  it 'passes the options ahead' do
80
- expect(dummy.to(:gnu, opt: 1)).to eq('gnu {:opt=>1}')
80
+ expect(dummy.to(:gnu, opt: 1)).to eq('gnu {opt: 1}')
81
81
  end
82
82
  end
83
83
  end
@@ -159,12 +159,12 @@ describe Danica::Common do
159
159
  end
160
160
 
161
161
  it 'knows how to return a tex string' do
162
- expect(dummy.tex.to_s).to eq('tex {:format=>:tex}')
162
+ expect(dummy.tex.to_s).to eq('tex {format: :tex}')
163
163
  end
164
164
 
165
165
  context 'when passing options' do
166
166
  it 'uses the arguments' do
167
- expect(dummy.tex(decimals: 3).to_s).to eq('tex {:format=>:tex, :decimals=>3}')
167
+ expect(dummy.tex(decimals: 3).to_s).to eq('tex {format: :tex, decimals: 3}')
168
168
  end
169
169
  end
170
170
  end
@@ -175,12 +175,12 @@ describe Danica::Common do
175
175
  end
176
176
 
177
177
  it 'knows how to return a gnu string' do
178
- expect(dummy.gnu.to_s).to eq('gnu {:format=>:gnu}')
178
+ expect(dummy.gnu.to_s).to eq('gnu {format: :gnu}')
179
179
  end
180
180
 
181
181
  context 'when passing options' do
182
182
  it 'uses the arguments' do
183
- expect(dummy.gnu(decimals: 3).to_s).to eq('gnu {:format=>:gnu, :decimals=>3}')
183
+ expect(dummy.gnu(decimals: 3).to_s).to eq('gnu {format: :gnu, decimals: 3}')
184
184
  end
185
185
  end
186
186
  end
@@ -191,7 +191,7 @@ describe Danica::Common do
191
191
  end
192
192
 
193
193
  it 'knows how to return to build the string string' do
194
- expect(dummy.formatted(format: :gnu, decimals: 3).to_s).to eq('gnu {:format=>:gnu, :decimals=>3}')
194
+ expect(dummy.formatted(format: :gnu, decimals: 3).to_s).to eq('gnu {format: :gnu, decimals: 3}')
195
195
  end
196
196
  end
197
197
  end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'simplecov'
4
+ require 'simplecov-lcov'
4
5
 
5
- SimpleCov.start do
6
- add_filter '/spec/'
6
+ if ENV['CI']
7
+ SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
8
+ SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
9
+ end
7
10
 
8
- SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter if ENV['COVERAGE_JSON'] == 'true'
11
+ SimpleCov.profiles.define 'gem' do
12
+ add_filter '/spec/'
9
13
  end
10
14
 
15
+ SimpleCov.start 'gem'
16
+
11
17
  require 'pry-nav'
12
18
  require 'danica'
13
19
 
@@ -28,7 +28,7 @@ shared_examples 'a operator that knows how to calculate' do |arguments|
28
28
  end
29
29
 
30
30
  context 'when one variable is a number' do
31
- let(:variables) { (1..4) }
31
+ let(:variables) { 1..4 }
32
32
 
33
33
  it do
34
34
  expect(subject.to_f).to eq(calculated)
@@ -53,6 +53,7 @@ shared_examples 'a operator that knows how to write to a string' do |format, arg
53
53
  subject { described_class.new(*variables) }
54
54
 
55
55
  let(:numeric_variables) { arguments[:numeric_variables] }
56
+
56
57
  include_context 'when variables are initialized', arguments[format], 'integer_expected', 'string_expected', 'float_expected'
57
58
 
58
59
  describe "#to(#{format})" do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danica
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darthjee
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-07-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -16,29 +15,28 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 7.2.x
18
+ version: 7.x
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 7.2.x
25
+ version: 7.x
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: darthjee-core_ext
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: 3.x
32
+ version: 3.2.0
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - "~>"
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: 3.x
41
- description:
39
+ version: 3.2.0
42
40
  email:
43
41
  - darthjee@gmail.com
44
42
  executables: []
@@ -46,10 +44,24 @@ extensions: []
46
44
  extra_rdoc_files: []
47
45
  files:
48
46
  - ".circleci/config.yml"
47
+ - ".claude/agents/architect.md"
48
+ - ".claude/agents/gnuplot.md"
49
+ - ".claude/agents/latex.md"
50
+ - ".claude/agents/mathematician.md"
51
+ - ".claude/agents/ruby.md"
52
+ - ".claude/configuration/arcanum-repo-config.json"
53
+ - ".claude/scripts/check_ruby.sh"
54
+ - ".claude/settings.json"
55
+ - ".github/commit_message_template-2.0.md"
56
+ - ".github/commit_message_template.md"
57
+ - ".github/copilot-instructions.md"
58
+ - ".github/pull_request_template.md"
49
59
  - ".gitignore"
50
60
  - ".rspec"
51
61
  - ".rubocop.yml"
52
62
  - ".rubocop_todo.yml"
63
+ - AGENTS.md
64
+ - CLAUDE.md
53
65
  - Dockerfile
54
66
  - Gemfile
55
67
  - LICENSE
@@ -64,6 +76,14 @@ files:
64
76
  - danica.gemspec
65
77
  - danica.png
66
78
  - docker-compose.yml
79
+ - docs/agents/arcanum-split-issue.md
80
+ - docs/agents/architecture.md
81
+ - docs/agents/contributing.md
82
+ - docs/agents/flow.md
83
+ - docs/agents/folder-structure.md
84
+ - docs/agents/issue-enhancement.md
85
+ - docs/agents/issues/.gitkeep
86
+ - docs/agents/plans/.gitkeep
67
87
  - lib/danica.rb
68
88
  - lib/danica/base_operations.rb
69
89
  - lib/danica/builder.rb
@@ -104,6 +124,7 @@ files:
104
124
  - lib/danica/wrapper/number.rb
105
125
  - lib/danica/wrapper/plus_minus.rb
106
126
  - lib/danica/wrapper/variable.rb
127
+ - scripts/bump_version.sh
107
128
  - scripts/check_readme.sh
108
129
  - scripts/rubycritic.sh
109
130
  - spec/integration/global/danica/formatted_spec.rb
@@ -174,10 +195,8 @@ files:
174
195
  - spec/support/shared_examples/operator/dual_term.rb
175
196
  - spec/support/shared_examples/operator/single_input.rb
176
197
  - spec/support/shared_examples/variable.rb
177
- homepage:
178
198
  licenses: []
179
199
  metadata: {}
180
- post_install_message:
181
200
  rdoc_options: []
182
201
  require_paths:
183
202
  - lib
@@ -192,8 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
211
  - !ruby/object:Gem::Version
193
212
  version: '0'
194
213
  requirements: []
195
- rubygems_version: 3.5.9
196
- signing_key:
214
+ rubygems_version: 4.0.23
197
215
  specification_version: 4
198
216
  summary: Danica
199
217
  test_files: []