synthra 0.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 +7 -0
- data/.rspec +4 -0
- data/.rubocop.yml +40 -0
- data/.yardopts +18 -0
- data/ACCESS_DOCS.md +116 -0
- data/ADVANCED_FEATURES_SUMMARY.md +245 -0
- data/CHANGELOG.md +498 -0
- data/CODE_OF_CONDUCT.md +122 -0
- data/CONTRIBUTING.md +307 -0
- data/DOCUMENTATION.md +204 -0
- data/DOCUMENTATION_GUIDE.md +194 -0
- data/LICENSE +22 -0
- data/README.md +1458 -0
- data/Rakefile +128 -0
- data/benchmark/README.md +591 -0
- data/benchmark/batch_generation.rb +63 -0
- data/benchmark/engine_comparison.rb +295 -0
- data/benchmark/single_record.rb +108 -0
- data/benchmark/streaming.rb +74 -0
- data/docs/ACTIVERECORD_INFERENCE.md +524 -0
- data/docs/API_SERVER.md +278 -0
- data/docs/CONFIG_FILE.md +315 -0
- data/docs/DATA_CONTRACTS.md +312 -0
- data/docs/ENHANCED_REPL.md +304 -0
- data/docs/FACTORY_BOT.md +271 -0
- data/docs/GITHUB_ACTION.md +420 -0
- data/docs/GRAPHQL_EXPORT.md +303 -0
- data/docs/GRAPHQL_FEDERATION.md +651 -0
- data/docs/HOW_TO_GENERATE_DOCS.md +252 -0
- data/docs/LSP.md +189 -0
- data/docs/MIGRATION_GENERATOR.md +547 -0
- data/docs/MOCK_SERVER.md +280 -0
- data/docs/NATIVE_ENGINE.md +298 -0
- data/docs/OPENAPI_EXPORT.md +252 -0
- data/docs/PERFORMANCE_MODE.md +228 -0
- data/docs/PERSONAS.md +547 -0
- data/docs/PROPERTY_TESTING.md +284 -0
- data/docs/PROTOBUF_EXPORT.md +276 -0
- data/docs/QUALITY_METRICS.md +555 -0
- data/docs/QUICK_REFERENCE.md +88 -0
- data/docs/RAILS_ENGINE.md +404 -0
- data/docs/RAILS_INTEGRATION.md +454 -0
- data/docs/README.md +175 -0
- data/docs/REPL_QUICK_REFERENCE.md +149 -0
- data/docs/RUST_INTEGRATION_GUIDE.md +1376 -0
- data/docs/SCENARIOS.md +576 -0
- data/docs/SECURITY_TESTING.md +318 -0
- data/docs/SNAPSHOT_TESTING.md +308 -0
- data/docs/STRING_TEXT_TYPES_REFERENCE.md +512 -0
- data/docs/TERRAFORM_EXPORT.md +447 -0
- data/docs/TIME_TRAVEL.md +507 -0
- data/docs/USAGE_GUIDE.md +980 -0
- data/docs/WEBHOOK_SIMULATOR.md +579 -0
- data/docs/advanced_features.md +183 -0
- data/docs/api_reference.md +153 -0
- data/docs/behaviors.md +138 -0
- data/docs/best_practices.md +191 -0
- data/docs/dsl_reference.md +172 -0
- data/docs/examples.md +162 -0
- data/docs/generation_modes.md +125 -0
- data/docs/getting_started.md +92 -0
- data/docs/index.html +177 -0
- data/docs/strategic/CLOUD_REGISTRY_ARCHITECTURE.md +268 -0
- data/docs/strategic/SIMD_OPTIMIZATION_STRATEGY.md +153 -0
- data/docs/troubleshooting.md +215 -0
- data/docs/type_reference.md +224 -0
- data/examples/hostile_mode_demo.rb +64 -0
- data/exe/synthra +6 -0
- data/ext/synthra_native/Cargo.lock +972 -0
- data/ext/synthra_native/Cargo.toml +46 -0
- data/ext/synthra_native/extconf.rb +41 -0
- data/ext/synthra_native/src/generator.rs +397 -0
- data/ext/synthra_native/src/lib.rs +229 -0
- data/ext/synthra_native/src/types.rs +1485 -0
- data/lib/generators/synthra/install_generator.rb +86 -0
- data/lib/generators/synthra/templates/api_response.dsl +15 -0
- data/lib/generators/synthra/templates/fake_data.rake +116 -0
- data/lib/generators/synthra/templates/synthra.yml +31 -0
- data/lib/generators/synthra/templates/synthra_support.rb +19 -0
- data/lib/generators/synthra/templates/user.dsl +11 -0
- data/lib/synthra/activerecord_inference.rb +394 -0
- data/lib/synthra/api.rb +381 -0
- data/lib/synthra/api_server.rb +718 -0
- data/lib/synthra/behaviors/applicator.rb +165 -0
- data/lib/synthra/behaviors/base.rb +155 -0
- data/lib/synthra/behaviors/close_connection.rb +60 -0
- data/lib/synthra/behaviors/deprecated.rb +100 -0
- data/lib/synthra/behaviors/failure.rb +69 -0
- data/lib/synthra/behaviors/latency.rb +103 -0
- data/lib/synthra/behaviors/partial_data.rb +83 -0
- data/lib/synthra/behaviors/randomize_order.rb +74 -0
- data/lib/synthra/behaviors/registry.rb +238 -0
- data/lib/synthra/behaviors/simulate_error.rb +79 -0
- data/lib/synthra/cli/commands/base.rb +105 -0
- data/lib/synthra/cli/commands/diff.rb +227 -0
- data/lib/synthra/cli/commands/docs.rb +67 -0
- data/lib/synthra/cli/commands/export.rb +150 -0
- data/lib/synthra/cli/commands/generate.rb +72 -0
- data/lib/synthra/cli/commands/import.rb +80 -0
- data/lib/synthra/cli/commands/lint.rb +53 -0
- data/lib/synthra/cli/commands/live.rb +57 -0
- data/lib/synthra/cli/commands/seed.rb +99 -0
- data/lib/synthra/cli/commands/validate.rb +28 -0
- data/lib/synthra/cli.rb +2471 -0
- data/lib/synthra/config_file.rb +129 -0
- data/lib/synthra/configuration.rb +281 -0
- data/lib/synthra/contracts_registry.rb +408 -0
- data/lib/synthra/database_seeder.rb +268 -0
- data/lib/synthra/deterministic_ids.rb +218 -0
- data/lib/synthra/documentation_generator.rb +414 -0
- data/lib/synthra/engine.rb +251 -0
- data/lib/synthra/errors.rb +1169 -0
- data/lib/synthra/export/base.rb +85 -0
- data/lib/synthra/export/csv.rb +101 -0
- data/lib/synthra/export/graphql.rb +266 -0
- data/lib/synthra/export/graphql_federation.rb +377 -0
- data/lib/synthra/export/graphviz.rb +258 -0
- data/lib/synthra/export/javascript.rb +327 -0
- data/lib/synthra/export/json_data.rb +61 -0
- data/lib/synthra/export/json_schema.rb +290 -0
- data/lib/synthra/export/openapi.rb +514 -0
- data/lib/synthra/export/protobuf.rb +483 -0
- data/lib/synthra/export/python.rb +560 -0
- data/lib/synthra/export/sql.rb +381 -0
- data/lib/synthra/export/sql_insert.rb +152 -0
- data/lib/synthra/export/terraform.rb +501 -0
- data/lib/synthra/export/type_mapping.rb +389 -0
- data/lib/synthra/export/typescript.rb +300 -0
- data/lib/synthra/export/xml_data.rb +104 -0
- data/lib/synthra/export/yaml_data.rb +56 -0
- data/lib/synthra/export.rb +404 -0
- data/lib/synthra/factory_bot_integration.rb +157 -0
- data/lib/synthra/field.rb +440 -0
- data/lib/synthra/functions/registry.rb +104 -0
- data/lib/synthra/generator/context.rb +372 -0
- data/lib/synthra/generator/engine.rb +336 -0
- data/lib/synthra/generator/faker_adapter.rb +425 -0
- data/lib/synthra/generator/modes.rb +444 -0
- data/lib/synthra/generator/resolver.rb +256 -0
- data/lib/synthra/generator/rng.rb +273 -0
- data/lib/synthra/generator/streamer.rb +63 -0
- data/lib/synthra/generator/uniqueness.rb +118 -0
- data/lib/synthra/initializer.rb +97 -0
- data/lib/synthra/limits.rb +279 -0
- data/lib/synthra/live_preview.rb +518 -0
- data/lib/synthra/loader_config.rb +78 -0
- data/lib/synthra/lsp/server.rb +689 -0
- data/lib/synthra/migration_generator.rb +301 -0
- data/lib/synthra/mixin.rb +174 -0
- data/lib/synthra/mock_server.rb +458 -0
- data/lib/synthra/native_engine.rb +304 -0
- data/lib/synthra/openapi_importer.rb +228 -0
- data/lib/synthra/output/json_formatter.rb +40 -0
- data/lib/synthra/output/ndjson_formatter.rb +55 -0
- data/lib/synthra/parser/ast.rb +1287 -0
- data/lib/synthra/parser/lexer.rb +1152 -0
- data/lib/synthra/parser/parser.rb +1664 -0
- data/lib/synthra/parser/tokens.rb +461 -0
- data/lib/synthra/performance_mode.rb +364 -0
- data/lib/synthra/personas.rb +397 -0
- data/lib/synthra/property_testing.rb +172 -0
- data/lib/synthra/quality_metrics.rb +405 -0
- data/lib/synthra/rails_test_helper.rb +248 -0
- data/lib/synthra/registry.rb +533 -0
- data/lib/synthra/relationships.rb +193 -0
- data/lib/synthra/repl/enhanced_repl.rb +607 -0
- data/lib/synthra/repl/formatter.rb +191 -0
- data/lib/synthra/scenarios.rb +423 -0
- data/lib/synthra/schema.rb +605 -0
- data/lib/synthra/schema_inheritance.rb +104 -0
- data/lib/synthra/schema_versioning.rb +212 -0
- data/lib/synthra/snapshot_testing.rb +199 -0
- data/lib/synthra/time_travel.rb +338 -0
- data/lib/synthra/type_definitions.rb +274 -0
- data/lib/synthra/types/address_location/addresses.rb +125 -0
- data/lib/synthra/types/address_location/airports.rb +200 -0
- data/lib/synthra/types/address_location/banks_hospitals.rb +207 -0
- data/lib/synthra/types/address_location/locations.rb +406 -0
- data/lib/synthra/types/base.rb +48 -0
- data/lib/synthra/types/commerce_products/commerce.rb +119 -0
- data/lib/synthra/types/commerce_products/companies.rb +71 -0
- data/lib/synthra/types/commerce_products/construction.rb +126 -0
- data/lib/synthra/types/commerce_products/products.rb +205 -0
- data/lib/synthra/types/core/collections.rb +513 -0
- data/lib/synthra/types/core/defaults.rb +76 -0
- data/lib/synthra/types/core/enums.rb +102 -0
- data/lib/synthra/types/core/identifiers.rb +445 -0
- data/lib/synthra/types/core/primitives.rb +586 -0
- data/lib/synthra/types/core/references.rb +466 -0
- data/lib/synthra/types/core/sequences.rb +304 -0
- data/lib/synthra/types/crypto/crypto.rb +162 -0
- data/lib/synthra/types/date_time/dates.rb +387 -0
- data/lib/synthra/types/finance_banking/banking.rb +424 -0
- data/lib/synthra/types/finance_banking/credit_cards.rb +24 -0
- data/lib/synthra/types/finance_banking/identifiers.rb +93 -0
- data/lib/synthra/types/formula.rb +184 -0
- data/lib/synthra/types/health_medical/medical.rb +150 -0
- data/lib/synthra/types/hostile_payloads.rb +122 -0
- data/lib/synthra/types/json_array.rb +51 -0
- data/lib/synthra/types/media_entertainment/media.rb +62 -0
- data/lib/synthra/types/naughty_string.rb +30 -0
- data/lib/synthra/types/personal_names/chinese.rb +41 -0
- data/lib/synthra/types/personal_names/identifiers.rb +187 -0
- data/lib/synthra/types/personal_names/names.rb +246 -0
- data/lib/synthra/types/personal_names/national_id.rb +89 -0
- data/lib/synthra/types/personal_names/titles_suffixes.rb +41 -0
- data/lib/synthra/types/regex.rb +248 -0
- data/lib/synthra/types/registry.rb +182 -0
- data/lib/synthra/types/repeating_element.rb +50 -0
- data/lib/synthra/types/scenario.rb +29 -0
- data/lib/synthra/types/technology_internet/apps.rb +67 -0
- data/lib/synthra/types/technology_internet/communication.rb +162 -0
- data/lib/synthra/types/technology_internet/devices.rb +80 -0
- data/lib/synthra/types/technology_internet/formats.rb +139 -0
- data/lib/synthra/types/technology_internet/networking.rb +143 -0
- data/lib/synthra/types/template.rb +92 -0
- data/lib/synthra/types/text_content/business.rb +128 -0
- data/lib/synthra/types/text_content/colors.rb +70 -0
- data/lib/synthra/types/text_content/misc.rb +237 -0
- data/lib/synthra/types/text_content/security.rb +130 -0
- data/lib/synthra/types/text_content/text_generation.rb +532 -0
- data/lib/synthra/types/travel/travel.rb +150 -0
- data/lib/synthra/utils/string_distance.rb +133 -0
- data/lib/synthra/validator/dsl_validator.rb +339 -0
- data/lib/synthra/validator/path_validator.rb +615 -0
- data/lib/synthra/version.rb +35 -0
- data/lib/synthra/webhook_simulator.rb +341 -0
- data/lib/synthra.rb +259 -0
- data/schemas/address.dsl +16 -0
- data/schemas/api_response.dsl +8 -0
- data/schemas/error_payload.dsl +9 -0
- data/schemas/order.dsl +10 -0
- data/schemas/order_item.dsl +8 -0
- data/schemas/payment.dsl +11 -0
- data/schemas/social_post.dsl +13 -0
- data/schemas/user.dsl +10 -0
- data/scripts/batch_fix_all.rb +96 -0
- data/scripts/delete_old_files.rb +32 -0
- data/scripts/fix_all_grouped_files.rb +137 -0
- data/scripts/fix_all_indentation.rb +48 -0
- data/scripts/fix_all_syntax.rb +124 -0
- data/scripts/fix_grouped_files.rb +184 -0
- data/scripts/fix_syntax_errors.rb +108 -0
- data/scripts/group_domain_types.rb +112 -0
- data/scripts/group_domain_types_fixed.rb +150 -0
- data/scripts/merge_domains_to_one_file.rb +68 -0
- data/scripts/move_existing_types.rb +130 -0
- data/scripts/split_grouped_types.rb +142 -0
- data/tech_docs/README.md +134 -0
- data/tech_docs/advanced/streaming.md +405 -0
- data/tech_docs/advanced/thread_safety.md +253 -0
- data/tech_docs/api/overview.md +485 -0
- data/tech_docs/appendices/type_chart.md +193 -0
- data/tech_docs/basic_concepts.md +383 -0
- data/tech_docs/behaviors/overview.md +346 -0
- data/tech_docs/dsl/complex_types.md +790 -0
- data/tech_docs/dsl/core_types.md +464 -0
- data/tech_docs/dsl/datetime_types.md +325 -0
- data/tech_docs/dsl/field_modifiers.md +414 -0
- data/tech_docs/dsl/grammar.md +431 -0
- data/tech_docs/dsl/schema_definition.md +399 -0
- data/tech_docs/export/README.md +276 -0
- data/tech_docs/installation.md +273 -0
- data/tech_docs/integration/ci_cd.md +707 -0
- data/tech_docs/integration/ci_cd_guide.md +579 -0
- data/tech_docs/integration/factory_bot.md +485 -0
- data/tech_docs/integration/rails.md +630 -0
- data/tech_docs/integration/rspec.md +449 -0
- data/tech_docs/modes/overview.md +350 -0
- data/tech_docs/performance/NATIVE_RUST_EXTENSION.md +1270 -0
- data/tech_docs/performance/OPTIMIZATION_GUIDE.md +901 -0
- data/tech_docs/quick_start.md +256 -0
- data/tech_docs/templates/README.md +805 -0
- data/tech_docs/tutorials/advanced.md +371 -0
- data/tech_docs/tutorials/getting_started.md +189 -0
- data/tech_docs/tutorials/intermediate.md +231 -0
- data/tech_docs/tutorials/template_gallery.md +569 -0
- data/tech_example/01_basic_usage.rb +238 -0
- data/tech_example/02_types_demo.rb +336 -0
- data/tech_example/04_cli_usage.md +429 -0
- data/tech_example/05_database_seeding.rb +283 -0
- data/tech_example/07_rspec_integration.rb +359 -0
- data/tech_example/10_custom_types.rb +387 -0
- data/tech_example/12_behaviors.rb +372 -0
- data/tech_example/13_twitter_dm_example.rb +120 -0
- data/tech_example/14_exact_json_structure.rb +253 -0
- data/tech_example/16_lsp_server.rb +56 -0
- data/tech_example/17_property_testing.rb +92 -0
- data/tech_example/18_enhanced_repl.rb +120 -0
- data/tech_example/19_security_fuzzing.rb +145 -0
- data/tech_example/NEW_FEATURES.md +169 -0
- data/tech_example/README.md +118 -0
- data/tech_example/schemas/api_response.dsl +123 -0
- data/tech_example/schemas/ecommerce.dsl +121 -0
- data/tech_example/schemas/twitter_dm.dsl +109 -0
- data/tech_example/schemas/user.dsl +36 -0
- data/vscode-extension/README.md +246 -0
- data/vscode-extension/language-configuration.json +31 -0
- data/vscode-extension/package.json +55 -0
- data/vscode-extension/snippets/fakedatadsl.json +198 -0
- data/vscode-extension/syntaxes/fakedatadsl.tmLanguage.json +128 -0
- metadata +478 -0
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# FakeDataDSL: String & Text Types Reference
|
|
2
|
+
|
|
3
|
+
Complete reference for all string-related types in the FakeDataDSL gem. Each type inherits from `Types::Base` and implements `generate_random`, `generate_edge`, and `generate_invalid`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
1. [Core Text Types](#1-core-text-types)
|
|
10
|
+
2. [Structured Text (Words, Sentences, Paragraphs)](#2-structured-text-words-sentences-paragraphs)
|
|
11
|
+
3. [Business & Marketing Text](#3-business--marketing-text)
|
|
12
|
+
4. [Message & Social Text](#4-message--social-text)
|
|
13
|
+
5. [Security & Hash Types](#5-security--hash-types)
|
|
14
|
+
6. [Color Types](#6-color-types)
|
|
15
|
+
7. [Miscellaneous String Types](#7-miscellaneous-string-types)
|
|
16
|
+
8. [Special-Purpose String Types](#8-special-purpose-string-types)
|
|
17
|
+
9. [Parser Argument Reference](#9-parser-argument-reference)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 1. Core Text Types
|
|
22
|
+
|
|
23
|
+
### `text` / `string`
|
|
24
|
+
|
|
25
|
+
**Location:** `lib/fake_data_dsl/types/core/primitives.rb`
|
|
26
|
+
**Alias:** `string` maps to `text` for OpenAPI/contract compatibility
|
|
27
|
+
|
|
28
|
+
**Description:** Generates random readable text with optional length constraints and locale support. Uses Faker for locale-specific text.
|
|
29
|
+
|
|
30
|
+
#### Arguments (from parser)
|
|
31
|
+
|
|
32
|
+
| Arg | Type | DSL Example | Description |
|
|
33
|
+
|-----|------|-------------|-------------|
|
|
34
|
+
| `:range` | `Range` | `text(1..10)` | Character length range |
|
|
35
|
+
| `:min` | Integer | `text(min: 50, max: 200)` | Minimum character length |
|
|
36
|
+
| `:max` | Integer | `text(min: 50, max: 200)` | Maximum character length |
|
|
37
|
+
| `:value` | Integer | `text(100)` | Exact character length |
|
|
38
|
+
| `:locale` | Symbol | `text(ar)` | Locale code (stored when `text(ar)` parsed) |
|
|
39
|
+
| `:language` | Symbol | `text(locale: :ar)` | Locale alias |
|
|
40
|
+
| `:lang` | Symbol | `text(lang: :ar)` | Locale alias |
|
|
41
|
+
|
|
42
|
+
#### Implementation
|
|
43
|
+
|
|
44
|
+
- **Length extraction:** `extract_length(args)` reads `:range`, `:min`/`:max`, or `:value` (default `[10, 100]`)
|
|
45
|
+
- **Locale resolution:** `args[:locale] || args[:language] || args[:lang] || args[:value]` (when `:value` is a Symbol like `:ar`)
|
|
46
|
+
- **Generation:** Uses `faker_english_words` (Lovecraft, Company.bs, Commerce) for English; `faker_localized_words` (Name, Address, Company) for other locales
|
|
47
|
+
- **Truncation:** When explicit length is set, output is truncated to `[min_len, max_len]` characters
|
|
48
|
+
|
|
49
|
+
#### Supported locales
|
|
50
|
+
|
|
51
|
+
`en`, `ar`, `es`, `fr`, `de`, `it`, `pt`, `ru`, `zh`, `ja`, `ko`, `hi` (and extended forms like `en_us`, `ar_sa`, etc.)
|
|
52
|
+
|
|
53
|
+
#### DSL examples
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
bio: text(50..200)
|
|
57
|
+
reason_ar: text(ar)
|
|
58
|
+
reason_ar: text(ar, 1..10)
|
|
59
|
+
title: text(en, 5..50)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. Structured Text (Words, Sentences, Paragraphs)
|
|
65
|
+
|
|
66
|
+
**Location:** `lib/fake_data_dsl/types/text_content/text_generation.rb`
|
|
67
|
+
|
|
68
|
+
### `words`
|
|
69
|
+
|
|
70
|
+
**Description:** Space-separated words (3–10 by default).
|
|
71
|
+
|
|
72
|
+
#### Arguments
|
|
73
|
+
|
|
74
|
+
| Arg | Type | Default | Description |
|
|
75
|
+
|-----|------|---------|-------------|
|
|
76
|
+
| `:min` | Integer | 3 | Minimum word count |
|
|
77
|
+
| `:max` | Integer | 10 | Maximum word count |
|
|
78
|
+
|
|
79
|
+
#### Implementation
|
|
80
|
+
|
|
81
|
+
- Uses `faker_adapter(context)` if available → `adapter.characters(number: rng.int(3, 10))` per word
|
|
82
|
+
- Else `Faker::Lorem.words(number: count).join(" ")`
|
|
83
|
+
|
|
84
|
+
#### DSL example
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
tags: words(min: 2, max: 5)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### `sentences`
|
|
93
|
+
|
|
94
|
+
**Description:** One or more sentences (1–5 by default).
|
|
95
|
+
|
|
96
|
+
#### Arguments
|
|
97
|
+
|
|
98
|
+
| Arg | Type | Default | Description |
|
|
99
|
+
|-----|------|---------|-------------|
|
|
100
|
+
| `:min` | Integer | 1 | Minimum sentence count |
|
|
101
|
+
| `:max` | Integer | 5 | Maximum sentence count |
|
|
102
|
+
|
|
103
|
+
#### Implementation
|
|
104
|
+
|
|
105
|
+
- With adapter: `count.times.map { adapter.characters(number: rng.int(20, 100)) }.join(". ") + "."`
|
|
106
|
+
- Else: `Faker::Lorem.sentences(number: count).join(" ")`
|
|
107
|
+
|
|
108
|
+
#### DSL example
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
summary: sentences(min: 1, max: 3)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### `paragraphs`
|
|
117
|
+
|
|
118
|
+
**Description:** One or more paragraphs separated by `\n\n` (1–3 by default).
|
|
119
|
+
|
|
120
|
+
#### Arguments
|
|
121
|
+
|
|
122
|
+
| Arg | Type | Default | Description |
|
|
123
|
+
|-----|------|---------|-------------|
|
|
124
|
+
| `:min` | Integer | 1 | Minimum paragraph count |
|
|
125
|
+
| `:max` | Integer | 3 | Maximum paragraph count |
|
|
126
|
+
|
|
127
|
+
#### Implementation
|
|
128
|
+
|
|
129
|
+
- With adapter: `count.times.map { adapter.characters(number: rng.int(50, 200)) }.join("\n\n")`
|
|
130
|
+
- Else: `Faker::Lorem.paragraphs(number: count).join("\n\n")`
|
|
131
|
+
|
|
132
|
+
#### DSL example
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
article: paragraphs(min: 2, max: 5)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 3. Business & Marketing Text
|
|
141
|
+
|
|
142
|
+
**Location:** `lib/fake_data_dsl/types/text_content/business.rb`
|
|
143
|
+
|
|
144
|
+
### `buzzword`
|
|
145
|
+
|
|
146
|
+
**Description:** Single business buzzword (e.g. "Synergy", "Leverage", "Disrupt").
|
|
147
|
+
|
|
148
|
+
- Uses `Faker::Company.buzzword` or adapter's `buzzword`
|
|
149
|
+
- Fallback: hardcoded `BUZZWORDS` array
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### `catch_phrase`
|
|
154
|
+
|
|
155
|
+
**Description:** Company-style catch phrase (e.g. "Think Different", "Just Do It").
|
|
156
|
+
|
|
157
|
+
- Uses `Faker::Company.catch_phrase` or adapter
|
|
158
|
+
- Fallback: hardcoded `PHRASES` array
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
### `slogan`
|
|
163
|
+
|
|
164
|
+
**Description:** Brand slogan (e.g. "I'm Lovin' It", "Finger Lickin' Good").
|
|
165
|
+
|
|
166
|
+
- Uses adapter's `slogan` or `Faker::Company.catch_phrase`
|
|
167
|
+
- Fallback: hardcoded `SLOGANS` array
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### `fake_company_name`
|
|
172
|
+
|
|
173
|
+
**Description:** Company name.
|
|
174
|
+
|
|
175
|
+
- Uses adapter's `company_name` or `Faker::Company.name`
|
|
176
|
+
- Fallback: hardcoded list
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 4. Message & Social Text
|
|
181
|
+
|
|
182
|
+
**Location:** `lib/fake_data_dsl/types/text_content/text_generation.rb`
|
|
183
|
+
|
|
184
|
+
### `message_text`
|
|
185
|
+
|
|
186
|
+
**Description:** Chat/DM-style messages with locale support.
|
|
187
|
+
|
|
188
|
+
#### Arguments
|
|
189
|
+
|
|
190
|
+
| Arg | Type | Description |
|
|
191
|
+
|-----|------|-------------|
|
|
192
|
+
| `:locale` | Symbol/String | `en`, `ar`, `es`, `fr` |
|
|
193
|
+
| `:language` | Symbol | Locale alias |
|
|
194
|
+
| `:lang` | Symbol | Locale alias |
|
|
195
|
+
| `:locales` | Array | Mixed locales |
|
|
196
|
+
| `:mixed` | Array | Mixed locales |
|
|
197
|
+
| `locale: "en,ar"` | String | Comma-separated locales |
|
|
198
|
+
|
|
199
|
+
#### Implementation
|
|
200
|
+
|
|
201
|
+
- Static per-locale pools: `SAMPLE_MESSAGES_EN`, `SAMPLE_MESSAGES_AR`, `SAMPLE_MESSAGES_ES`, `SAMPLE_MESSAGES_FR`
|
|
202
|
+
- 50% Faker, 50% static; Faker uses `Lorem`, `Company.catch_phrase`, `Quote.famous_last_words`, etc.
|
|
203
|
+
- Arabic: templates with `Faker::Name`, `Faker::Company`, `Faker::Address` in `:ar`
|
|
204
|
+
- Mixed: randomly selects locale then picks message from that pool
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### `hashtag_text`
|
|
209
|
+
|
|
210
|
+
**Description:** Hashtag-style text without `#`.
|
|
211
|
+
|
|
212
|
+
- Uses adapter's `internet.slug` (hyphens removed) or hardcoded `HASHTAGS` list
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### `social_handle`
|
|
217
|
+
|
|
218
|
+
**Description:** Username-style handle without `@`.
|
|
219
|
+
|
|
220
|
+
- Uses adapter's `internet.username` or `Faker::Internet.username(specifier: 5..15)`
|
|
221
|
+
- Fallback: `"user_#{rng.int(1000, 99999)}"`
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 5. Security & Hash Types
|
|
226
|
+
|
|
227
|
+
**Location:** `lib/fake_data_dsl/types/text_content/security.rb`
|
|
228
|
+
|
|
229
|
+
### `password`
|
|
230
|
+
|
|
231
|
+
**Description:** Random password with configurable character requirements.
|
|
232
|
+
|
|
233
|
+
#### Arguments
|
|
234
|
+
|
|
235
|
+
| Arg | Type | Default | Description |
|
|
236
|
+
|-----|------|---------|-------------|
|
|
237
|
+
| `:min_length` | Integer | 8 | Minimum length |
|
|
238
|
+
| `:min_upper` | Integer | 1 | Minimum uppercase letters |
|
|
239
|
+
| `:min_lower` | Integer | 1 | Minimum lowercase letters |
|
|
240
|
+
| `:min_numbers` | Integer | 1 | Minimum digits |
|
|
241
|
+
| `:min_symbols` | Integer | 0 | Minimum symbols |
|
|
242
|
+
|
|
243
|
+
#### Implementation
|
|
244
|
+
|
|
245
|
+
- Builds password from required char sets, then shuffles with RNG
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### `password_hash`
|
|
250
|
+
|
|
251
|
+
**Description:** bcrypt-like hash string (60 chars, `$2a$10$` prefix).
|
|
252
|
+
|
|
253
|
+
- Random alphanumeric + `./` for the hash part
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
### `md5`
|
|
258
|
+
|
|
259
|
+
**Description:** 32-character hex MD5-like string.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
### `sha1`
|
|
264
|
+
|
|
265
|
+
**Description:** 40-character hex SHA1-like string.
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### `sha256`
|
|
270
|
+
|
|
271
|
+
**Description:** 64-character hex SHA256-like string.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### `encrypt`
|
|
276
|
+
|
|
277
|
+
**Description:** Base64-like encrypted-looking string (20–40 chars).
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 6. Color Types
|
|
282
|
+
|
|
283
|
+
**Location:** `lib/fake_data_dsl/types/text_content/colors.rb`
|
|
284
|
+
|
|
285
|
+
### `color`
|
|
286
|
+
|
|
287
|
+
**Description:** Color name (e.g. "Red", "Blue").
|
|
288
|
+
|
|
289
|
+
- Uses `Faker::Commerce.color` or adapter's `color`
|
|
290
|
+
- Fallback: hardcoded `COLORS` array
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### `hex_color`
|
|
295
|
+
|
|
296
|
+
**Description:** 6-digit hex color (e.g. `#A1B2C3`).
|
|
297
|
+
|
|
298
|
+
- Random hex digits
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
### `short_hex_color`
|
|
303
|
+
|
|
304
|
+
**Description:** 3-digit short hex color (e.g. `#F00`).
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 7. Miscellaneous String Types
|
|
309
|
+
|
|
310
|
+
**Location:** `lib/fake_data_dsl/types/text_content/misc.rb`
|
|
311
|
+
|
|
312
|
+
### `avatar`
|
|
313
|
+
|
|
314
|
+
**Description:** Avatar image URL (pravatar.cc).
|
|
315
|
+
|
|
316
|
+
#### Arguments
|
|
317
|
+
|
|
318
|
+
| Arg | Type | Default |
|
|
319
|
+
|-----|------|---------|
|
|
320
|
+
| `:height` | Integer | 200 |
|
|
321
|
+
| `:width` | Integer | 200 |
|
|
322
|
+
|
|
323
|
+
- Format: `https://i.pravatar.cc/#{width}?img=#{rng.int(1, 70)}`
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
### `file_name`
|
|
328
|
+
|
|
329
|
+
**Description:** File name with extension (e.g. `document_42.pdf`).
|
|
330
|
+
|
|
331
|
+
- Name from fixed list; random number; extension from `EXTENSIONS`
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### `frequency`
|
|
336
|
+
|
|
337
|
+
**Description:** Frequency label ("Daily", "Weekly", "Monthly", etc.).
|
|
338
|
+
|
|
339
|
+
- From hardcoded `FREQUENCIES` array
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
### `linkedin_skill`
|
|
344
|
+
|
|
345
|
+
**Description:** Skill label (e.g. "JavaScript", "React", "AWS").
|
|
346
|
+
|
|
347
|
+
- From hardcoded `SKILLS` array
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
### `nato_phonetic`
|
|
352
|
+
|
|
353
|
+
**Description:** NATO phonetic alphabet words (e.g. "Alpha Bravo Charlie").
|
|
354
|
+
|
|
355
|
+
#### Arguments
|
|
356
|
+
|
|
357
|
+
| Arg | Type | Default |
|
|
358
|
+
|-----|------|---------|
|
|
359
|
+
| `:min` | Integer | 1 |
|
|
360
|
+
| `:max` | Integer | 5 |
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
### `university`
|
|
365
|
+
|
|
366
|
+
**Description:** University name (e.g. "Harvard University").
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
### `blank`
|
|
371
|
+
|
|
372
|
+
**Description:** Always returns `""`.
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
### `race`
|
|
377
|
+
|
|
378
|
+
**Description:** Race/ethnicity category string.
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
### `department_corporate`
|
|
383
|
+
|
|
384
|
+
**Description:** Corporate department name (e.g. "Engineering", "Sales").
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
### `department_retail`
|
|
389
|
+
|
|
390
|
+
**Description:** Retail department name (e.g. "Electronics", "Clothing").
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## 8. Special-Purpose String Types
|
|
395
|
+
|
|
396
|
+
### `naughty_string`
|
|
397
|
+
|
|
398
|
+
**Location:** `lib/fake_data_dsl/types/naughty_string.rb`
|
|
399
|
+
|
|
400
|
+
**Description:** Strings for security/edge-case testing.
|
|
401
|
+
|
|
402
|
+
#### Arguments
|
|
403
|
+
|
|
404
|
+
| Arg | Type | Values | Description |
|
|
405
|
+
|-----|------|--------|-------------|
|
|
406
|
+
| `:category` | Symbol | `:sql`, `:xss`, `:path`, `:default` | Attack category |
|
|
407
|
+
|
|
408
|
+
- `sql`: SQL injection samples
|
|
409
|
+
- `xss`: XSS samples
|
|
410
|
+
- `path`: Path traversal samples
|
|
411
|
+
- `default`: empty, null, undefined, control chars
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
### `regex`
|
|
416
|
+
|
|
417
|
+
**Location:** `lib/fake_data_dsl/types/regex.rb`
|
|
418
|
+
|
|
419
|
+
**Description:** String matching a regex pattern (limited support).
|
|
420
|
+
|
|
421
|
+
#### Arguments
|
|
422
|
+
|
|
423
|
+
| Arg | Type | Description |
|
|
424
|
+
|-----|------|-------------|
|
|
425
|
+
| `:pattern` | String/Regexp | Regex pattern |
|
|
426
|
+
|
|
427
|
+
- Supports simple patterns (e.g. phone `^\d{3}-\d{3}-\d{4}$`, digits)
|
|
428
|
+
- Fallback: `"generated_string"`
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
### `indices_pair`
|
|
433
|
+
|
|
434
|
+
**Location:** `lib/fake_data_dsl/types/text_content/text_generation.rb`
|
|
435
|
+
|
|
436
|
+
**Description:** `[start, end]` pair for text entity positions.
|
|
437
|
+
|
|
438
|
+
- `start = rng.int(0, 100)`, `length = rng.int(5, 30)` → `[start, start + length]`
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
### `empty_array`
|
|
443
|
+
|
|
444
|
+
**Location:** `lib/fake_data_dsl/types/text_content/text_generation.rb`
|
|
445
|
+
|
|
446
|
+
**Description:** Always returns `[]` (not a string; listed for completeness).
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## 9. Parser Argument Reference
|
|
451
|
+
|
|
452
|
+
The parser (`lib/fake_data_dsl/parser/parser.rb`) produces `type_args` from DSL:
|
|
453
|
+
|
|
454
|
+
| Token | Stored as | Example |
|
|
455
|
+
|-------|-----------|---------|
|
|
456
|
+
| `1..10` | `args[:range] = 1..10` | `text(1..10)` |
|
|
457
|
+
| `min: 5, max: 20` | `args[:min]=5`, `args[:max]=20` | `text(min: 5, max: 20)` |
|
|
458
|
+
| `100` | `args[:value] = 100` | `text(100)` |
|
|
459
|
+
| `ar` (locale code) | `args[:locale] = :ar` | `text(ar)` |
|
|
460
|
+
| `name: value` | `args[name] = value` | `text(locale: :ar)` |
|
|
461
|
+
| `"string"` | `args[:path] = "string"` | Used by references |
|
|
462
|
+
| `30%` | `args[:probability] = 30` | Used by boolean |
|
|
463
|
+
|
|
464
|
+
**Multiple args (comma-separated):**
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
text(ar, 1..10) → { locale: :ar, range: 1..10 }
|
|
468
|
+
text(1..10, ar) → { range: 1..10, locale: :ar }
|
|
469
|
+
words(min: 2, max: 5) → { min: 2, max: 5 }
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## Type Base Contract
|
|
475
|
+
|
|
476
|
+
All types extend `Types::Base`:
|
|
477
|
+
|
|
478
|
+
```ruby
|
|
479
|
+
def generate(rng, context, args, mode)
|
|
480
|
+
case mode
|
|
481
|
+
when :random then generate_random(rng, context, args)
|
|
482
|
+
when :edge then generate_edge(rng, context, args)
|
|
483
|
+
when :invalid then generate_invalid(rng, context, args)
|
|
484
|
+
when :hostile then generate_hostile(rng, context, args)
|
|
485
|
+
else generate_random(rng, context, args)
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
- **`generate_random`** – normal fake data (required)
|
|
491
|
+
- **`generate_edge`** – edge cases (empty, single char, etc.)
|
|
492
|
+
- **`generate_invalid`** – invalid values (nil, wrong type)
|
|
493
|
+
- **`generate_hostile`** – security-style payloads (optional; `text` overrides)
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## File Locations Summary
|
|
498
|
+
|
|
499
|
+
| Category | File |
|
|
500
|
+
|----------|------|
|
|
501
|
+
| Core text | `types/core/primitives.rb` |
|
|
502
|
+
| Words, sentences, paragraphs, message_text, hashtag_text, social_handle, indices_pair, empty_array | `types/text_content/text_generation.rb` |
|
|
503
|
+
| Buzzword, catch_phrase, slogan, fake_company_name | `types/text_content/business.rb` |
|
|
504
|
+
| Avatar, file_name, frequency, linkedin_skill, nato_phonetic, row_number, sql_expression, university, blank, race, department_* | `types/text_content/misc.rb` |
|
|
505
|
+
| Password, password_hash, md5, sha1, sha256, encrypt | `types/text_content/security.rb` |
|
|
506
|
+
| Color, hex_color, short_hex_color | `types/text_content/colors.rb` |
|
|
507
|
+
| Naughty string | `types/naughty_string.rb` |
|
|
508
|
+
| Regex | `types/regex.rb` |
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
*Last updated: 2026-02*
|