strong_service 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 582179b1f231b6a12ad5edeb1ed3734fa2ec79b8805299a77ad1f1d6030a18b4
4
+ data.tar.gz: d02f0dd4cc6417942716aa324f5a54046823f97dd869cf6e1739945014ca8e96
5
+ SHA512:
6
+ metadata.gz: 2a34f2c6358bb7ecdf9b84d1d9fd165564788392bf5f0ced695210e22d5bdc0110ef4578f06ef60fde9ea9257fc89c9bac67939457e6f8d203540e4ae1300e6c
7
+ data.tar.gz: 481ff4dfa3ea279fbbbca1838d8b2dd7b05bfb52cac7b9fae953acd33c6cc69e4fa137189cf1a251f41ce5b0df0295ce358d8c633d875319af4a2381e344f7f5
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/standardrb/standard
3
+ ruby_version: 3.1
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # ![Strong Service](./etc/logo.gif)
2
+
3
+ With zero dependencies, a minimal API, and virtually limitless configuration options, S̶o̶l̶i̶d̶ Strong Service\* is the gem you should use when you implement service objects in Ruby. It's compatible with Rails and all other Ruby frameworks — or no framework at all!
4
+
5
+ ## Why Strong Service?
6
+
7
+ After hours of furious online debate, you've decided that you want to use service objects, AKA the [Command pattern](https://en.wikipedia.org/wiki/Command_pattern), AKA classes that does things of actual value in your Ruby app. Great! But how should you implement them? There are dozens of libraries, all claiming to do a slightly different variation of the same thing.
8
+
9
+ Some might argue that a PORO is sufficient, but these people should be dismissed as purists; most of us warm-blooded Ruby engineers know that adding dependencies to our projects is the only way to make them better and deliver actual value.
10
+
11
+ Strong Service is what you need. If you're not convinced by the claims above, consider the name: it's Strong. It may or may not be related to the other gems in the popular S̶o̶l̶i̶d̶ Strong family (this made more sense before the rename). And, at the time of writing, it was made recently. Everyone knows that new things are better than old things, right? Exactly. You can trust Strong Service to push the bar on what is possible in the vibrant service object community, sprinkling a dash of that _je ne sais quoi_ that imitators can't capture.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ bundle add strong_service
17
+ ```
18
+
19
+ Alternatively, if you're still on a Pentium 4 and/or have no idea what you're doing, you can just use:
20
+
21
+ ```
22
+ gem install strong_service
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Standard usage is simple: just subclass `StrongService` and implement your `call` method:
28
+
29
+ ```ruby
30
+ class CoffeeService < StrongService
31
+ def call
32
+ puts "Brewing coffee!"
33
+ end
34
+ end
35
+ ```
36
+
37
+ Then, to run your service, just execute `call`:
38
+
39
+ ```ruby
40
+ CoffeeService.new.call # => "Brewing coffee!"
41
+ ```
42
+
43
+ ### Service Chaining
44
+
45
+ If that weren't enough, services can even call other services and they are guaranteed to run _in order_!:
46
+
47
+ ```ruby
48
+ class CoffeeService < StrongService
49
+ def call
50
+ puts "Brewing coffee!"
51
+ end
52
+ end
53
+
54
+ class ToastService < StrongService
55
+ def call
56
+ puts "Toasting bread!"
57
+ end
58
+ end
59
+
60
+ class BreakfastService < StrongService
61
+ def call
62
+ CoffeeService.new.call
63
+ ToastService.new.call
64
+ end
65
+ end
66
+
67
+ BreakfastService.new.call # => "Brewing coffee!"
68
+ # => "Toasting bread!"
69
+ ```
70
+
71
+ ### Instance Variable Access
72
+
73
+ You can configure StrongService to have access to instance variables on the service by defining parameters on a special `#initialize` method:
74
+
75
+ ```ruby
76
+ class GreeterService < StrongService
77
+ def initialize(name)
78
+ @name = name
79
+ end
80
+
81
+ def call
82
+ puts "Hello, #{@name}!"
83
+ end
84
+ end
85
+ ```
86
+
87
+ Then, pass arguments into the `new` method:
88
+
89
+ ```ruby
90
+ GreeterService.new("Jamie").call # => "Hello, Jamie!"
91
+ ```
92
+
93
+ ### Configuring the Call Method
94
+
95
+ StrongService includes an advanced [DSL](https://en.wikipedia.org/wiki/Domain-specific_language) which allows you to configure any aspect of the `call` method — even going as far as to rename it.
96
+
97
+ ```ruby
98
+ class MyService < StrongService
99
+ configure do
100
+ method_name :execute
101
+ end
102
+
103
+ def execute
104
+ puts "This service is STRONG."
105
+ end
106
+ end
107
+ ```
108
+
109
+ ### Super Advanced Usage
110
+
111
+ Strong Service's powerful DSL includes an experimental feature, which allows you to inherit the full library of functionality from Strong Service without formally subclassing it. Example:
112
+
113
+ ```ruby
114
+ class CoffeeService
115
+ def call
116
+ puts "Brewing coffee!"
117
+ end
118
+ end
119
+ ```
120
+
121
+ This is equivalent to the previous example defining `CoffeeService`, but without the explicit subclassing of `StrongService`.
122
+
123
+ How is this possible? I could explain, but you probably wouldn't understand. Just 🌈 embrace 🪄 the magic 💫.
124
+
125
+ Subclassing `StrongService` gives you access to many useful methods, which you can read about more [at the documentation](https://docs.ruby-lang.org/en/3.4/BasicObject.html).
126
+
127
+ ## Strong Service Premium / Hire an Expert
128
+
129
+ In order to fund development, I am now offering a premium version of Strong Service alongside consulting services. Contact me for more details
130
+
131
+ ## Development
132
+
133
+ As of 1.0.0, development on Strong Service is finished. This is because it is perfect software with zero bugs. I know that this is a difficult claim to make, and that others claim that all software has bugs, but this software does not. It's done. End of discussion.
134
+
135
+ As such, development instructions are completely unnecessary, because no one will ever need to develop on top of this.
136
+
137
+ ## Contributing
138
+
139
+ See the development section above: there is no need to contribute, because the gem is already perfect. Your contributions would be superfluous and only smudge the proverbial windows of this masterwork.
140
+
141
+ ## Credits
142
+
143
+ The chief visionary and architect behind Strong Service is [Jamie Schembri](https://github.com/shkm/github). You can contact him on [Bluesky](https://bsky.app/profile/jamie.schembri.me) or read more of his nonsense on [his blog](https://schembri.me).
144
+
145
+ ## License
146
+
147
+ This open-source version is available under the the [WTFPL](https://www.wtfpl.net/about/).
148
+
149
+ \*This gem was originally called Strong Service, but Rubygems has no chill:
150
+
151
+ ```text
152
+ Pushing gem to https://rubygems.org...
153
+ There was a problem saving your gem: Name 'solid_service' is too similar to an existing gem named 'solidservice'
154
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[test standard]
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ class StrongService; end
@@ -0,0 +1,2 @@
1
+ class StrongService
2
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strong_service
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jamie Schembri
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: The lightweight, zero-dependency, infinitely configurable Service Object
13
+ Ruby gem.
14
+ email:
15
+ - jamie@schembri.me
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".standard.yml"
21
+ - LICENSE.txt
22
+ - README.md
23
+ - Rakefile
24
+ - lib/strong_service.rb
25
+ - sig/strong_service.rbs
26
+ homepage: https://github.com/shkm/strong_service
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ allowed_push_host: https://rubygems.org
31
+ homepage_uri: https://github.com/shkm/strong_service
32
+ source_code_uri: https://github.com/shkm/strong_service
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.6.9
48
+ specification_version: 4
49
+ summary: The best Ruby gem for service objects.
50
+ test_files: []