piko-tools 1.0.2 → 1.0.4

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: 9c9ae4a74e5273b80eaf96c47b449628d39ab61150bf92bfd9e2dbda159ec90c
4
- data.tar.gz: 8907d0f6812d7ddbd609322325e285502610a034cc2c95272414090f638c00b4
3
+ metadata.gz: 7bf8c65f75aad253dae581f3b224a307bae2ae11e6287c3c2a82ce669a68c6db
4
+ data.tar.gz: d6450a1138e28358eece0626d185b66a640230f32648567bce7f73d30039feaa
5
5
  SHA512:
6
- metadata.gz: 26f14abc9c411d268ebb72413be66b5a9e7deaade3bc936c37eb1ee6d961264bc0c3161e84f577e3fdcf33d3fdb580dd80cc0590de4c2b399074f5841f852178
7
- data.tar.gz: 4de4b2b6990eb2c983c703d5be91ce190e53a7120498090f6c518fc749bb4f87425726188c1cf217b585551b0940d522e87b6dfadbecb785ef56736a75c3d486
6
+ metadata.gz: 616e52664b0662f36a4ba8f633a13cc8347452d82cf947467cde6d5e6437df94263a61515b4c8257a18b5bc0741ba9fa6d54b49c24fc28f7185e5233546046b2
7
+ data.tar.gz: 8f9dffd341e6e134241ecbc70b2d10499bc65ae729fb992d90d0a26c18e9656f06b59b372a9537d089ab3fbf80b683b4095980077bf5d7937bc5874399fc5d9b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.3] - 2026-05-21
4
+
5
+ ### Changed
6
+
7
+ - Cleanup, tests, optimization
8
+
9
+ ## [1.0.2] - 2025-09-02
10
+
11
+ ### Fixed
12
+
13
+ - Fix state check
14
+
3
15
  ## [1.0.1] - 2025-09-02
4
16
 
5
17
  ### Added
@@ -14,6 +26,10 @@ Init
14
26
 
15
27
  - Init
16
28
 
29
+ [1.0.3]: https://gitlab.com/skopciewski/piko-tools/-/compare/1.0.2...1.0.3
30
+
31
+ [1.0.2]: https://gitlab.com/skopciewski/piko-tools/-/compare/1.0.1...1.0.2
32
+
17
33
  [1.0.1]: https://gitlab.com/skopciewski/piko-tools/-/compare/1.0.0...1.0.1
18
34
 
19
35
  [1.0.0]: https://gitlab.com/skopciewski/piko-tools/-/compare/0.0.0...1.0.0
data/README.md CHANGED
@@ -1,23 +1,85 @@
1
- # Piko-tools
1
+ # PikoTools
2
+
3
+ Micro-framework for building applications with data-driven architecture.
2
4
 
3
5
  ## Installation
4
6
 
5
- Add this line to your application's Gemfile:
7
+ Add to your Gemfile:
6
8
 
7
- gem 'piko-tools'
9
+ ```ruby
10
+ gem "piko-tools"
11
+ ```
8
12
 
9
- And then execute:
13
+ Or install directly:
10
14
 
11
- $ bundle
15
+ ```bash
16
+ gem install piko-tools
17
+ ```
12
18
 
13
- Or install it yourself as:
19
+ ## Usage
14
20
 
15
- $ gem install piko-tools
21
+ ### State
16
22
 
17
- ## Usage
23
+ Lazy lifecycle manager with start/stop semantics.
24
+
25
+ ```ruby
26
+ state = PikoTools::State.new do |s|
27
+ s.define(:db, -> { Database.connect }, stop: ->(conn) { conn.close })
28
+ s.define(:cache, -> { Cache.new }, stop: ->(c) { c.flush })
29
+ s.define(:logger, -> { Logger.new })
30
+ end
31
+
32
+ # Lazy start — connects on first access
33
+ logger = state[:logger]
34
+
35
+ # Query state
36
+ state.started?(:db) # => false
37
+ state.start_all
38
+ state.started?(:db) # => true
39
+
40
+ # Stop with teardown callback
41
+ state.stop(:db) # calls Database#close
42
+
43
+ # Reload (stop + start)
44
+ state.reload(:cache)
45
+
46
+ # Stop all in reverse order, then clear definitions
47
+ state.clear!
48
+ ```
49
+
50
+ ### Builder
51
+
52
+ Fluent builder for composing objects with keyword arguments.
53
+
54
+ ```ruby
55
+ class Handler
56
+ def initialize(args = {})
57
+ @args = args
58
+ end
59
+ end
60
+
61
+ handler = PikoTools::Builder.new(Handler)
62
+ .set(foo: 1, bar: 2)
63
+ .build(baz: 3)
64
+
65
+ handler # => #<Handler @args={foo: 1, bar: 2, build_args: {baz: 3}}>
66
+ ```
67
+
68
+ ### Component
69
+
70
+ Mixin providing config-based private attributes.
71
+
72
+ ```ruby
73
+ class MyComponent
74
+ include PikoTools::Component
75
+ attr_struct :host, :port
76
+ end
18
77
 
19
- ## Versioning
78
+ component = MyComponent.new(host: "localhost", port: 3000)
79
+ component.send(:host) # => "localhost"
80
+ component.send(:port) # => 3000
81
+ ```
20
82
 
21
- See [semver.org][semver]
83
+ ## Requirements
22
84
 
23
- [semver]: http://semver.org/
85
+ Ruby >= 3.2. No runtime dependencies.
@@ -1,5 +1,3 @@
1
- require "ostruct"
2
-
3
1
  module PikoTools
4
2
  module Component
5
3
  def self.included(base)
@@ -9,7 +7,7 @@ module PikoTools
9
7
 
10
8
  module PrepMethods
11
9
  def initialize(config = {})
12
- @config = OpenStruct.new(config.to_h).to_h
10
+ @config = config.to_h.transform_keys(&:to_sym)
13
11
  super if initialize_in_ancestor?
14
12
  end
15
13
 
@@ -18,13 +18,11 @@ module PikoTools
18
18
  def start(key)
19
19
  return @instances[key] if started?(key)
20
20
  raise KeyError, "Key not defined: '#{key}'" unless define?(key)
21
- # puts "[system] starting #{key}"
22
21
  @instances[key] = @definitions[key][:start].call
23
22
  end
24
23
 
25
24
  def stop(key)
26
25
  return unless started?(key)
27
- # puts "[system] stopping #{key}"
28
26
  @definitions[key][:stop]&.call(@instances[key])
29
27
  @instances.delete(key)
30
28
  end
@@ -1,3 +1,3 @@
1
1
  module PikoTools
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piko-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Kopciewski
@@ -65,7 +65,9 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
- description: Micro-framework for building applications with data-driven architecture
68
+ description: 'PikoTools bundles three foundational patterns for Ruby applications:
69
+ a lazy lifecycle manager (State), a fluent builder DSL (Builder), and a config-driven
70
+ mixin (Component). Designed for minimal overhead with no external dependencies.'
69
71
  email:
70
72
  - s.kopciewski@dlamnie.net
71
73
  executables: []
@@ -101,5 +103,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
103
  requirements: []
102
104
  rubygems_version: 3.6.9
103
105
  specification_version: 4
104
- summary: Micro-framework for building applications with data-driven architecture
106
+ summary: Data-driven application toolkit with lifecycle, builder, and component patterns
105
107
  test_files: []