poml 0.0.7 → 0.0.8

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: 2b093fb2077a5a12052a817a3b71038b81c97892bd8ba888165bbbed56cf21d4
4
- data.tar.gz: 46cb25b278be930f116c97b46263dead78057289f200274daee79320045b8984
3
+ metadata.gz: 70dc9fc51326dadbeaf4ac370e2d336d8c84dd588c3fd8fa5dccc81b78c30dc6
4
+ data.tar.gz: 5bcee8ab87e81a98104cfb85cd44f55f6993c1c9d389e905c71442d9d1db806e
5
5
  SHA512:
6
- metadata.gz: 66b01f839ae216447b86d45c8cb49d016e569e3d42fc91bd82e777abdb4fab466644d4610756f4cedb1bdd4e6171f6e2c177b3773afd2ad5a08c4b9328e9c44f
7
- data.tar.gz: 2f107a45b2ee752c6303b6cc64d385bb3c77aa345c9697eeb0942a4221c1984054d4bd256658358b6732d37b44e0ff70112e6d9b84c8b39a6c4392bb93c80938
6
+ metadata.gz: 80a0bcb96bc46410dc54865ca8a36465c8776a58bb47732525c9630900229187f62ed926e64502058f679643532e677c267de2192e83eb36fb27d682dc1918e8
7
+ data.tar.gz: 0e8a9b993696d736ef5fec917661bc11e1b593f0c0723823ad10a3f753eeea3c31f18bfecb41ad4479a3b1ee5206b2e314d2e683f75f5193d7b5f99df11a3bae
@@ -650,16 +650,16 @@ class SafeToolProcessor
650
650
  valid_tools = tools.select { |tool| valid_tool?(tool) }
651
651
 
652
652
  {
653
- success: true,
654
- tools: valid_tools,
655
- invalid_count: tools.length - valid_tools.length
653
+ 'success' => true,
654
+ 'tools' => valid_tools,
655
+ 'invalid_count' => tools.length - valid_tools.length
656
656
  }
657
657
 
658
658
  rescue StandardError => e
659
659
  {
660
- success: false,
661
- error: e.message,
662
- tools: []
660
+ 'success' => false,
661
+ 'error' => e.message,
662
+ 'tools' => []
663
663
  }
664
664
  end
665
665
  end
@@ -676,10 +676,10 @@ end
676
676
 
677
677
  # Usage
678
678
  result = SafeToolProcessor.process_tools(markup, context)
679
- if result[:success]
680
- puts "Processed #{result[:tools].length} valid tools"
679
+ if result['success']
680
+ puts "Processed #{result['tools'].length} valid tools"
681
681
  else
682
- puts "Error: #{result[:error]}"
682
+ puts "Error: #{result['error']}"
683
683
  end
684
684
  ```
685
685
 
@@ -33,9 +33,10 @@ Text with **bold** and *italic* formatting.
33
33
  ```ruby
34
34
  markup = <<~POML
35
35
  <poml>
36
- <h1>Main Title</h1>
37
- <p>Text with <b>bold</b> and <i>italic</i> formatting.</p>
38
- <output format="html"/>
36
+ <output format="html">
37
+ <h1>Main Title</h1>
38
+ <p>Text with <b>bold</b> and <i>italic</i> formatting.</p>
39
+ </output>
39
40
  </poml>
40
41
  POML
41
42
 
@@ -55,9 +56,10 @@ puts result['output']
55
56
  ```ruby
56
57
  markup = <<~POML
57
58
  <poml>
58
- <h1>Main Title</h1>
59
- <p>Text with <b>bold</b> and <i>italic</i> formatting.</p>
60
- <output format="text"/>
59
+ <output format="text">
60
+ <h1>Main Title</h1>
61
+ <p>Text with <b>bold</b> and <i>italic</i> formatting.</p>
62
+ </output>
61
63
  </poml>
62
64
  POML
63
65
 
@@ -68,9 +70,7 @@ puts result['output']
68
70
  **Output:**
69
71
 
70
72
  ```text
71
- Main Title
72
-
73
- Text with bold and italic formatting.
73
+ # Main TitleText with **bold** and *italic* formatting.
74
74
  ```
75
75
 
76
76
  ## Text Formatting
@@ -13,9 +13,9 @@ POML is a markup language designed for creating structured, reusable AI prompts.
13
13
  The Ruby POML gem uses a **format-aware rendering system**:
14
14
 
15
15
  - **Default rendering**: Produces Markdown-like output optimized for readability
16
- - **HTML components**: Use `<output format="html"/>` for HTML output (`<h1>`, `<b>`, `<i>` tags)
17
- - **JSON/XML formats**: Use `<output format="json"/>` or `<output format="xml"/>` for structured data
18
- - **Text format**: Use `<output format="text"/>` for plain text output
16
+ - **HTML components**: Use `<output format="html">content</output>` for HTML output (`<h1>`, `<b>`, `<i>` tags)
17
+ - **JSON/XML formats**: Use `<output format="json">content</output>` or `<output format="xml">content</output>` for structured data
18
+ - **Text format**: Use `<output format="text">content</output>` for plain text output
19
19
 
20
20
  **Example - Getting HTML Output:**
21
21
 
@@ -23,9 +23,10 @@ The Ruby POML gem uses a **format-aware rendering system**:
23
23
  markup = <<~POML
24
24
  <poml>
25
25
  <role>Documentation Writer</role>
26
- <h1>Main Title</h1>
27
- <p>Content with <b>bold</b> and <i>italic</i> text.</p>
28
- <output format="html"/>
26
+ <output format="html">
27
+ <h1>Main Title</h1>
28
+ <p>Content with <b>bold</b> and <i>italic</i> text.</p>
29
+ </output>
29
30
  </poml>
30
31
  POML
31
32
 
@@ -19,7 +19,7 @@ Control the **overall structure** of the result (API format):
19
19
 
20
20
  ### 2. Content Rendering Formats
21
21
 
22
- Control how **components render** within the content using `<output format="..."/>`:
22
+ Control how **components render** within the content using `<output format="...">content</output>`:
23
23
 
24
24
  - `format="markdown"` - Markdown syntax (default): `# Header`, `**bold**`
25
25
  - `format="html"` - HTML tags: `<h1>Header</h1>`, `<b>bold</b>`
@@ -33,9 +33,10 @@ Control how **components render** within the content using `<output format="..."
33
33
  markup = <<~POML
34
34
  <poml>
35
35
  <role>Writer</role>
36
- <h1>Article Title</h1>
37
- <p>Content with <b>emphasis</b></p>
38
- <output format="html"/> <!-- Content format -->
36
+ <output format="html">
37
+ <h1>Article Title</h1>
38
+ <p>Content with <b>emphasis</b></p>
39
+ </output>
39
40
  </poml>
40
41
  POML
41
42
 
data/readme.md CHANGED
@@ -23,87 +23,6 @@ For comprehensive documentation, tutorials, and examples, please refer to the **
23
23
 
24
24
  The original documentation is an excellent resource for learning POML concepts, syntax, and best practices that apply to this Ruby implementation as well.
25
25
 
26
- ## Recent Development Findings
27
-
28
- ### XML Parsing and Component Rendering
29
-
30
- During test-driven development, several critical insights were discovered about POML's dual-mode architecture:
31
-
32
- #### Code Component Behavior in XML Mode
33
-
34
- **Key Discovery**: The original POML TypeScript implementation uses `SimpleMarkupComponent` with `tagName='code'` which preserves XML attributes when `syntax="xml"` is specified. This means:
35
-
36
- - **Tutorial formatting tests** expect plain HTML: `<code>content</code>`
37
- - **Markup component tests** expect XML with attributes: `<code inline="true">content</code>`
38
- - Both behaviors are correct depending on context - the `syntax="xml"` mode should preserve XML structure with attributes
39
-
40
- #### XML Parsing Boundary Issues
41
-
42
- **Critical Fix**: The regex pattern `/<code\b[^>]*>/` was incorrectly matching `<code-block>` tags, causing XML parsing failures. Fixed with negative lookahead: `/<code(?!-)[^>]*>/`
43
-
44
- - Word boundaries (`\b`) don't prevent hyphenated extensions
45
- - Negative lookahead (`(?!-)`) provides precise disambiguation
46
- - This fix resolved multiple XML parsing test failures
47
-
48
- #### Dual Output Modes
49
-
50
- The Ruby implementation now correctly handles:
51
-
52
- 1. **Markdown Mode**: Components render to Markdown syntax (`` `code` ``, `**bold**`, etc.)
53
- 2. **XML Mode**: Components preserve HTML/XML structure for `syntax="xml"` contexts
54
- 3. **Attribute Preservation**: XML mode maintains component attributes like `inline="true"`
55
-
56
- ### Test-Driven Architecture Validation
57
-
58
- The comprehensive test suite revealed the importance of:
59
-
60
- - **Boundary condition testing** for regex patterns
61
- - **Context-aware rendering** based on `syntax` attributes
62
- - **Dual compatibility** between chat and XML syntax modes
63
- - **Progressive complexity** in template and component interactions
64
-
65
- ### Implementation status
66
-
67
- Please refer to [ROADMAP.md](https://github.com/GhennadiiMir/poml/blob/main/ROADMAP.md) for understanding which features are already implemented.
68
-
69
- ## Key Differences from Original Implementation
70
-
71
- ### Presentation Modes and Output Formats
72
-
73
- The **original POML library** uses a sophisticated presentation system with multiple rendering modes:
74
-
75
- - **`markup`** - Renders to markup languages (Markdown by default, configurable)
76
- - **`serialize`** - Renders to serialized data formats (JSON, XML, etc.)
77
- - **`free`** - Flexible rendering mode
78
- - **`multimedia`** - Media-focused rendering
79
-
80
- The **Ruby implementation** currently uses a simplified approach:
81
-
82
- - **Default rendering** - Produces Markdown-like output for readability
83
- - **Output format components** - Use `<output format="html|json|xml|text|markdown"/>` for specific formats
84
- - **XML mode** - Components can render HTML when in XML context
85
-
86
- ### Header Components
87
-
88
- **Original Implementation:**
89
-
90
- - Uses generic `<h>` tags with `level` attributes
91
- - Presentation mode determines output format (HTML vs Markdown)
92
-
93
- **Ruby Implementation:**
94
-
95
- - Supports both `<h>` and `<h1>`-`<h6>` tag syntax
96
- - Defaults to Markdown output (`# text`) unless in XML mode
97
- - Use `<output format="html"/>` for HTML output (`<h1>text</h1>`)
98
-
99
- ### Migration Notes
100
-
101
- If migrating from the original TypeScript/JavaScript implementation:
102
-
103
- 1. **Output Formats**: Explicitly specify output format for HTML rendering
104
- 2. **Presentation Context**: Ruby gem uses output format components instead of presentation context
105
- 3. **Component Mapping**: Most components work identically, but output format may differ
106
-
107
26
  ## Installation
108
27
 
109
28
  ```bash
@@ -207,6 +126,87 @@ poml markup.poml --format raw
207
126
 
208
127
  > **Note**: While this Ruby implementation aims for compatibility with the original POML library, the output format structures may differ slightly from the original TypeScript/Python implementations. The format names are kept consistent for API compatibility, but the Ruby gem provides its own implementation of each format suitable for Ruby applications.
209
128
 
129
+ ## Recent Development Findings
130
+
131
+ ### XML Parsing and Component Rendering
132
+
133
+ During test-driven development, several critical insights were discovered about POML's dual-mode architecture:
134
+
135
+ #### Code Component Behavior in XML Mode
136
+
137
+ **Key Discovery**: The original POML TypeScript implementation uses `SimpleMarkupComponent` with `tagName='code'` which preserves XML attributes when `syntax="xml"` is specified. This means:
138
+
139
+ - **Tutorial formatting tests** expect plain HTML: `<code>content</code>`
140
+ - **Markup component tests** expect XML with attributes: `<code inline="true">content</code>`
141
+ - Both behaviors are correct depending on context - the `syntax="xml"` mode should preserve XML structure with attributes
142
+
143
+ #### XML Parsing Boundary Issues
144
+
145
+ **Critical Fix**: The regex pattern `/<code\b[^>]*>/` was incorrectly matching `<code-block>` tags, causing XML parsing failures. Fixed with negative lookahead: `/<code(?!-)[^>]*>/`
146
+
147
+ - Word boundaries (`\b`) don't prevent hyphenated extensions
148
+ - Negative lookahead (`(?!-)`) provides precise disambiguation
149
+ - This fix resolved multiple XML parsing test failures
150
+
151
+ #### Dual Output Modes
152
+
153
+ The Ruby implementation now correctly handles:
154
+
155
+ 1. **Markdown Mode**: Components render to Markdown syntax (`` `code` ``, `**bold**`, etc.)
156
+ 2. **XML Mode**: Components preserve HTML/XML structure for `syntax="xml"` contexts
157
+ 3. **Attribute Preservation**: XML mode maintains component attributes like `inline="true"`
158
+
159
+ ### Test-Driven Architecture Validation
160
+
161
+ The comprehensive test suite revealed the importance of:
162
+
163
+ - **Boundary condition testing** for regex patterns
164
+ - **Context-aware rendering** based on `syntax` attributes
165
+ - **Dual compatibility** between chat and XML syntax modes
166
+ - **Progressive complexity** in template and component interactions
167
+
168
+ ### Implementation status
169
+
170
+ Please refer to [ROADMAP.md](https://github.com/GhennadiiMir/poml/blob/main/ROADMAP.md) for understanding which features are already implemented.
171
+
172
+ ## Key Differences from Original Implementation
173
+
174
+ ### Presentation Modes and Output Formats
175
+
176
+ The **original POML library** uses a sophisticated presentation system with multiple rendering modes:
177
+
178
+ - **`markup`** - Renders to markup languages (Markdown by default, configurable)
179
+ - **`serialize`** - Renders to serialized data formats (JSON, XML, etc.)
180
+ - **`free`** - Flexible rendering mode
181
+ - **`multimedia`** - Media-focused rendering
182
+
183
+ The **Ruby implementation** currently uses a simplified approach:
184
+
185
+ - **Default rendering** - Produces Markdown-like output for readability
186
+ - **Output format components** - Use `<output format="html|json|xml|text|markdown"/>` for specific formats
187
+ - **XML mode** - Components can render HTML when in XML context
188
+
189
+ ### Header Components
190
+
191
+ **Original Implementation:**
192
+
193
+ - Uses generic `<h>` tags with `level` attributes
194
+ - Presentation mode determines output format (HTML vs Markdown)
195
+
196
+ **Ruby Implementation:**
197
+
198
+ - Supports both `<h>` and `<h1>`-`<h6>` tag syntax
199
+ - Defaults to Markdown output (`# text`) unless in XML mode
200
+ - Use `<output format="html"/>` for HTML output (`<h1>text</h1>`)
201
+
202
+ ### Migration Notes
203
+
204
+ If migrating from the original TypeScript/JavaScript implementation:
205
+
206
+ 1. **Output Formats**: Explicitly specify output format for HTML rendering
207
+ 2. **Presentation Context**: Ruby gem uses output format components instead of presentation context
208
+ 3. **Component Mapping**: Most components work identically, but output format may differ
209
+
210
210
  ## 🔄 Migration Guide (Breaking Change)
211
211
 
212
212
  ### Tools Structure Change
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ghennadii Mirosnicenco
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-08-29 00:00:00.000000000 Z
10
+ date: 2025-08-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rexml
@@ -51,6 +51,62 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2.1'
54
+ - !ruby/object:Gem::Dependency
55
+ name: csv
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: base64
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.1'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.1'
82
+ - !ruby/object:Gem::Dependency
83
+ name: net-http
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.3'
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.3'
96
+ - !ruby/object:Gem::Dependency
97
+ name: uri
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.12'
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.12'
54
110
  description: "POML is a Ruby gem that implements POML (Prompt Oriented Markup Language),
55
111
  \na markup language for structured prompt engineering. This is a Ruby port of \nthe
56
112
  original Microsoft POML library, providing comprehensive tools for creating, \nprocessing,