Skip to content

Commit a7e3512

Browse files
authored
Add core Stroma functionality (#1)
1 parent 5abb414 commit a7e3512

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2415
-19
lines changed

Appraisals

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,56 @@
22

33
appraise "rails-5.1" do
44
gem "activesupport", "~> 5.1.0"
5+
6+
# warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
7+
gem "base64", ">= 0.2"
8+
9+
# warning: bigdecimal was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
10+
gem "bigdecimal", ">= 3.1"
11+
12+
# warning: mutex_m was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
13+
gem "mutex_m", ">= 0.3"
514
end
615

716
appraise "rails-5.2" do
817
gem "activesupport", "~> 5.2.0"
18+
19+
# warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
20+
gem "base64", ">= 0.2"
21+
22+
# warning: bigdecimal was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
23+
gem "bigdecimal", ">= 3.1"
24+
25+
# warning: mutex_m was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
26+
gem "mutex_m", ">= 0.3"
927
end
1028

1129
appraise "rails-6.0" do
1230
gem "activesupport", "~> 6.0.0"
1331
gem "concurrent-ruby", "1.3.4"
32+
33+
# warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
34+
gem "base64", ">= 0.2"
35+
36+
# warning: bigdecimal was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
37+
gem "bigdecimal", ">= 3.1"
38+
39+
# warning: mutex_m was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
40+
gem "mutex_m", ">= 0.3"
1441
end
1542

1643
appraise "rails-6.1" do
1744
gem "activesupport", "~> 6.1.0"
1845
gem "concurrent-ruby", "1.3.4"
46+
47+
# warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
48+
gem "base64", ">= 0.2"
49+
50+
# warning: bigdecimal was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
51+
gem "bigdecimal", ">= 3.1"
52+
53+
# warning: mutex_m was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
54+
gem "mutex_m", ">= 0.3"
1955
end
2056

2157
appraise "rails-7.0" do

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ PLATFORMS
124124

125125
DEPENDENCIES
126126
appraisal (>= 2.5)
127+
rake (>= 13.2)
127128
rspec (>= 3.13)
128129
servactory-rubocop (>= 0.9)
129130
stroma!

README.md

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
1-
# Stroma
1+
<h1 align="center">Stroma</h1>
22

3-
Soon
3+
<p align="center">
4+
A foundation for building modular, extensible DSLs in Ruby.
5+
</p>
6+
7+
<p align="center">
8+
<a href="https://rubygems.org/gems/stroma"><img src="https://img.shields.io/gem/v/stroma?logo=rubygems&logoColor=fff" alt="Gem version"></a>
9+
<a href="https://github.com/servactory/stroma/releases"><img src="https://img.shields.io/github/release-date/servactory/stroma" alt="Release Date"></a>
10+
<a href="https://rubygems.org/gems/stroma"><img src="https://img.shields.io/gem/dt/stroma" alt="Downloads"></a>
11+
<a href="https://www.ruby-lang.org"><img src="https://img.shields.io/badge/Ruby-3.2+-red" alt="Ruby version"></a>
12+
</p>
13+
14+
<!--
15+
## 📚 Documentation
16+
17+
See [stroma.servactory.com](https://stroma.servactory.com) for documentation, including:
18+
19+
- Architecture overview
20+
- Registry and DSL modules
21+
- Hooks and extensions
22+
- Settings hierarchy
23+
- API reference
24+
-->
25+
26+
## 💡 Why Stroma?
27+
28+
Building modular DSLs shouldn't require reinventing the wheel. Stroma provides a structured approach for library authors to compose DSL modules with:
29+
30+
- 🔌 **Module Registration** - Register DSL modules at boot time, compose them into a unified interface
31+
- 🧱 **Structured Composition** - Include all registered modules automatically via single DSL entry point
32+
- 🏛️ **Inheritance Safe** - Per-class state isolation with automatic deep copying
33+
- 🪝 **Extension Hooks** - Optional before/after hooks for user customization
34+
- ⚙️ **Extension Settings** - Three-level hierarchical storage for extension configuration
35+
- 🔒 **Thread Safe** - Immutable registry after finalization, safe concurrent reads
36+
37+
## 🧬 Concept
38+
39+
Stroma is a foundation for library authors building DSL-driven frameworks (service objects, form objects, decorators, etc.).
40+
41+
**Core lifecycle:**
42+
1. **Register** - Define DSL modules at boot time via `Stroma::Registry`
43+
2. **Compose** - Classes include `Stroma::DSL` to gain all registered modules automatically
44+
3. **Extend** (optional) - Users can add cross-cutting logic via `before`/`after` hooks
45+
46+
## 🚀 Quick Start
47+
48+
### Installation
49+
50+
```ruby
51+
gem "stroma"
52+
```
53+
54+
### Define your library's DSL
55+
56+
```ruby
57+
module MyLib
58+
module DSL
59+
# Register DSL modules at load time
60+
Stroma::Registry.register(:inputs, MyLib::Inputs::DSL)
61+
Stroma::Registry.register(:actions, MyLib::Actions::DSL)
62+
Stroma::Registry.finalize!
63+
64+
def self.included(base)
65+
base.include(Stroma::DSL)
66+
end
67+
end
68+
end
69+
```
70+
71+
### Create base class
72+
73+
```ruby
74+
module MyLib
75+
class Base
76+
include MyLib::DSL
77+
end
78+
end
79+
```
80+
81+
### Usage
82+
83+
```ruby
84+
class UserService < MyLib::Base
85+
input :email, type: String
86+
87+
make :create_user
88+
89+
private
90+
91+
def create_user
92+
# implementation
93+
end
94+
end
95+
```
96+
97+
## 🤝 Contributing
98+
99+
We welcome contributions! Check out our [Contributing Guide](https://github.com/servactory/stroma/blob/main/CONTRIBUTING.md) to get started.
100+
101+
**Ways to contribute:**
102+
- 🐛 Report bugs and issues
103+
- 💡 Suggest new features
104+
- 📝 Improve documentation
105+
- 🧪 Add test cases
106+
- 🔧 Submit pull requests
107+
108+
## 🙏 Acknowledgments
109+
110+
Special thanks to all our [contributors](https://github.com/servactory/stroma/graphs/contributors)!
111+
112+
## 📄 License
113+
114+
Stroma is available as open source under the terms of the [MIT License](./LICENSE).

gemfiles/rails_5.1.gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
source "https://rubygems.org"
66

77
gem "activesupport", "~> 5.1.0"
8-
gem "railties", "~> 5.1.0"
8+
gem "base64", ">= 0.2"
9+
gem "bigdecimal", ">= 3.1"
10+
gem "mutex_m", ">= 0.3"
911

1012
gemspec path: "../"

gemfiles/rails_5.2.gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
source "https://rubygems.org"
66

77
gem "activesupport", "~> 5.2.0"
8-
gem "railties", "~> 5.2.0"
8+
gem "base64", ">= 0.2"
9+
gem "bigdecimal", ">= 3.1"
10+
gem "mutex_m", ">= 0.3"
911

1012
gemspec path: "../"

gemfiles/rails_6.0.gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
source "https://rubygems.org"
66

77
gem "activesupport", "~> 6.0.0"
8+
gem "base64", ">= 0.2"
9+
gem "bigdecimal", ">= 3.1"
810
gem "concurrent-ruby", "1.3.4"
9-
gem "railties", "~> 6.0.0"
11+
gem "mutex_m", ">= 0.3"
1012

1113
gemspec path: "../"

gemfiles/rails_6.1.gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
source "https://rubygems.org"
66

77
gem "activesupport", "~> 6.1.0"
8+
gem "base64", ">= 0.2"
9+
gem "bigdecimal", ">= 3.1"
810
gem "concurrent-ruby", "1.3.4"
9-
gem "railties", "~> 6.1.0"
11+
gem "mutex_m", ">= 0.3"
1012

1113
gemspec path: "../"

gemfiles/rails_7.0.gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ source "https://rubygems.org"
66

77
gem "activesupport", "~> 7.0.0"
88
gem "concurrent-ruby", "1.3.4"
9-
gem "railties", "~> 7.0.0"
109

1110
gemspec path: "../"

gemfiles/rails_7.1.gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
source "https://rubygems.org"
66

77
gem "activesupport", "~> 7.1.0"
8-
gem "railties", "~> 7.1.0"
98

109
gemspec path: "../"

gemfiles/rails_7.2.gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
source "https://rubygems.org"
66

77
gem "activesupport", "~> 7.2.0"
8-
gem "railties", "~> 7.2.0"
98

109
gemspec path: "../"

0 commit comments

Comments
 (0)