mainapp 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71fcd37c16b85e73d2c91e2b93c17a4f3d24a715c7eddb0f563aa293c2cc3031
4
- data.tar.gz: c0b14096ad1170b0357cc0cdc4d5b266affcca3f9c908d1f4cf47719bf09753b
3
+ metadata.gz: 5803520b0069145d56aa91989ec4813168317aea43e5b528e31854e4736559c6
4
+ data.tar.gz: 5e27b4f2d5a5d3ce924d8428c0c4d29b67167eb79cbde42aa66b7123090393c5
5
5
  SHA512:
6
- metadata.gz: cafed9f35f28c23434e1022181a28307cf71bd8600bd8b7f92763c94deba56e95eb4d58618cecb97efbbf4cdfeb80b58939ce714adf593b8ff9547631404870e
7
- data.tar.gz: 861ece9df679fa0f28f83b5203193b3ab325d0c658ddf3591002adf3a19481aa926a12412582fbdfa59b5d9dea0b9da1bb93168bb922d139c48024d43e3f7264
6
+ metadata.gz: 13875ebf27df4a38737bea6dcbbf1e67abe3b9026cde923582f843747fcd0366cbf5d01bc22ff65290d38d48f452c9488f476fce829152594d4342ddaafd878b
7
+ data.tar.gz: 6dd68bfd702f0abf0a4f72d4572478447256928aabc250b14c2111f8b4add58db75d9d8af2383a78d29391444f29c18c6ac02168dd858b0079dc8d80a49a1c37
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # development
2
+
3
+ # 1.1.1 (2022.11.17)
4
+
5
+ * add components module
6
+
7
+ # 1.0.3 (2022.06.24)
8
+
9
+ * update makefile
10
+
11
+ # 1.0.2 (2022.06.24)
12
+
13
+ * tunetune ci
14
+
1
15
  # 1.0.1 (2022.06.24)
2
16
 
3
17
  * gh integration
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/mainapp.svg)](http://badge.fury.io/rb/mainapp)
4
4
 
5
- `.set` method extracted from the Sinatra::Base
5
+ `.set` method extracted from the Sinatra::Base, and helper for the components
6
+ convention
6
7
 
7
8
  ## Installation
8
9
 
@@ -20,6 +21,8 @@ Or install it yourself as:
20
21
 
21
22
  ## Usage
22
23
 
24
+ ### Creating structure with components
25
+
23
26
  ```ruby
24
27
  class My
25
28
  extend ::Mainapp::Base
@@ -27,7 +30,23 @@ end
27
30
 
28
31
  My.set foo: 1
29
32
 
30
- My.foo => 1
33
+ My.foo #=> 1
34
+ ```
35
+
36
+ ### Working with components
37
+
38
+ ```ruby
39
+ class TestComponent
40
+ include ::Mainapp::Component
41
+ attr_struct :foo, :bar
42
+
43
+ def some_method
44
+ pp foo
45
+ end
46
+ end
47
+
48
+ components = {foo: 1, bar: 2, baz: 3}
49
+ handler = TestComponent.new components
31
50
  ```
32
51
 
33
52
  ## Versioning
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+
5
+ module Mainapp
6
+ module Component
7
+ def self.included(base)
8
+ base.extend ClassMethods
9
+ base.prepend PrepMethods
10
+ end
11
+
12
+ module PrepMethods
13
+ def initialize(config = {})
14
+ @config = OpenStruct.new(config.to_h).to_h
15
+ super if initialize_in_ancestor?
16
+ end
17
+
18
+ protected
19
+
20
+ def initialize_in_ancestor?
21
+ self.class.ancestors[1].private_instance_methods(false).include?(:initialize)
22
+ end
23
+ end
24
+
25
+ module ClassMethods
26
+ def attr_struct(*components)
27
+ components.each do |name|
28
+ next if method_defined?(name)
29
+ define_method name do
30
+ @config[name.to_sym]
31
+ end
32
+ private name
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mainapp
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mainapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Kopciewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -106,6 +106,7 @@ files:
106
106
  - LICENSE
107
107
  - README.md
108
108
  - lib/mainapp/base.rb
109
+ - lib/mainapp/component.rb
109
110
  - lib/mainapp/version.rb
110
111
  homepage: https://github.com/skopciewski/mainapp
111
112
  licenses: