rails_services 3.0.0 → 3.0.1
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +46 -41
- data/lib/rails_services/version.rb +1 -1
- metadata +7 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a03e068552adcb9e44d914b7387aee0823352a97344f5fedd2235769c9422d60
|
4
|
+
data.tar.gz: f4497409f14385d5dc43a31838aebbb634c545dcc4a1e9b589b76269e84b0219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f140478c96620b1a44b90a06594ac4f376c9e97f0e970067cdcac4e30facecab51a4f6f75b2805492dd90ccb99fc19d97d8728490fa7e0ffc416fd25489db07b
|
7
|
+
data.tar.gz: f1361bdc5334403134e7989790abf87a68273d7592e3c1ac380581a3eeed4eea9e24671067357a7f61f75f7008af6e185df6a4062b619731490473d40ac6c150
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [3.0.1] - 2021-12-21
|
6
|
+
### Added
|
7
|
+
- Updated gem spec to just require Rails (no more specific versions)
|
8
|
+
|
9
|
+
## [3.0.0] - 2020-04-12
|
10
|
+
### Added
|
11
|
+
- Added Form object option,
|
12
|
+
- Updated for Rails 6
|
13
|
+
|
14
|
+
## [2.5.0] - 2019-02-14
|
15
|
+
### Fixed
|
16
|
+
- Miscellaneous bug fixes
|
17
|
+
|
5
18
|
## [2.0.1] - 2017-07-16
|
6
19
|
### Added
|
7
20
|
- Updating gem for the Rails verions 4 AND 5
|
data/README.md
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
# RailsServices
|
2
2
|
|
3
3
|
[](https://codeclimate.com/github/imageaid/rails_service_generator)
|
4
|
-
[](https://codeclimate.com/github/imageaid/rails_service_generator)
|
5
4
|
[](http://badge.fury.io/rb/rails_services)
|
6
5
|
|
7
|
-
A
|
6
|
+
A gem for Rails that adds a generator for easily creating a service class and/or form object and its accompanying spec or test unit file.
|
8
7
|
|
9
8
|
## Requirements
|
10
|
-
|
11
9
|
Rails 4 and higher
|
12
10
|
|
13
11
|
## Installation
|
14
|
-
|
15
12
|
Add this line to your application's Gemfile:
|
16
13
|
|
17
14
|
gem 'rails_services'
|
@@ -25,48 +22,55 @@ Or install it yourself as:
|
|
25
22
|
$ gem install rails_services
|
26
23
|
|
27
24
|
## Usage
|
28
|
-
|
29
25
|
Examples:
|
30
26
|
|
31
|
-
$ rails generate rails_services:create Service
|
27
|
+
$ [bundle exec] rails generate rails_services:create Service ParentFolder --sub_folder SubFolder [opt]
|
32
28
|
|
33
|
-
$ rails generate rails_services:destroy Service
|
29
|
+
$ [bundle exec] rails generate rails_services:destroy Service ParentFolder --sub_folder SubFolder [opt]
|
34
30
|
|
35
|
-
$ rails generate rails_services:form Form
|
31
|
+
$ [bundle exec] rails generate rails_services:form Form ParentFolder --sub_folder SubFolder [opt] --accessors name email [opt]
|
32
|
+
|
33
|
+
## v3.0.0 CHANGES AND REMOVALS
|
34
|
+
### CHANGES
|
35
|
+
There are four primary changes in v3.0.0:
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
1. All services have `include BaseService`
|
38
|
+
2. The `call` method is an instance method rather than a class method
|
39
|
+
3. You may generate a `Form` model
|
40
|
+
4. An updated command line interface (see below)
|
40
41
|
|
41
|
-
|
42
|
-
Previous versions of the gem used plain old arguments to create or destroy the appropriate files. Over time, this became
|
43
|
-
more unwieldy than imagined. From version 3.0.0 forward, there are only two arguments: `object_name` and `parent_name`.
|
42
|
+
#### Updated command line interface
|
43
|
+
Previous versions of the gem used plain old arguments to create or destroy the appropriate files. Over time, this became more unwieldy than imagined. From v3.0.0 forward, there are only two arguments: `object_name` and `parent_name`. Additionally, the previously available optional argument, `instance`, was removed (see REMOVALS section, below).
|
44
44
|
|
45
|
-
If you would like to add a sub-folder to the service or form, you can now provide the `class_option` for it:
|
46
|
-
`--sub_folder NAME_OF_FOLDER`. Similarly, for the form generator, you can pass in an array of `attr_accessors` with
|
47
|
-
the following: `--accessors accessor_1_name accessor_2_name ...`.
|
45
|
+
If you would like to add a sub-folder to the service or form, you can now provide the `class_option` for it: `--sub_folder NAME_OF_FOLDER`. Similarly, for the form generator, you can pass in an array of `attr_accessors` with the following: `--accessors accessor_1_name accessor_2_name ...` (use regular strings as these will be 'converted' to symbols).
|
48
46
|
|
49
|
-
###
|
50
|
-
|
51
|
-
(new = service clases inherited from a `BaseService` class and instantiated the service), the version 3.x line removes this option. BE AWARE :).
|
47
|
+
### REMOVALS:
|
48
|
+
There was one significant removal from the gem:
|
52
49
|
|
53
|
-
|
54
|
-
There are two primary changes in version 3:
|
50
|
+
1. No more `instance` argument in the command line interface (see below)
|
55
51
|
|
56
|
-
|
57
|
-
|
52
|
+
#### Instance argument dropped
|
53
|
+
An instance argument was added in v2.0.0 which allowed users to choose what style of service class to create. The gem defaulted to using this new style.
|
58
54
|
|
59
|
-
|
55
|
+
While the v2.x line continued to allow users a choice between the old and new^ styles, the v3.x line removes this choice. All services will be created with the now-not-so-new style. BE AWARE :)!
|
60
56
|
|
61
|
-
|
62
|
-
|
57
|
+
^The new style creates service clases inherited from a `BaseService` class; allows for optional instantiation of the service (`Service.new(args*).call`), and uses an instance method for `call`.
|
58
|
+
|
59
|
+
## NOTES
|
60
|
+
### Upgrading to current service class style
|
61
|
+
Should you want to update your older/previously built services with this 'new' style, you only need to do the following:
|
63
62
|
|
64
63
|
# include the base service in your class
|
65
64
|
class ClassName
|
66
65
|
include BaseService
|
67
66
|
|
68
|
-
# Then ... optionally, add an initialize method
|
69
|
-
|
67
|
+
# Then ... optionally, add an initialize method
|
68
|
+
def initialize(*args)
|
69
|
+
# ...
|
70
|
+
super
|
71
|
+
end
|
72
|
+
|
73
|
+
# Finally, change the method signatures, simply removing `self.` from the definition(s), as follows:
|
70
74
|
def self.call
|
71
75
|
# ...
|
72
76
|
end
|
@@ -76,28 +80,29 @@ you only need to do the following:
|
|
76
80
|
end
|
77
81
|
# and so on for other, similarly defined methods
|
78
82
|
|
79
|
-
|
83
|
+
### Sub-folders
|
84
|
+
Sub-folders are optional but, at this time, you may only use one sub-folder. I generally only use the sub-folders when I have a naturally grouped set of services.
|
80
85
|
|
81
|
-
|
86
|
+
## Generator results
|
87
|
+
### Create service and create form
|
88
|
+
Two files are created: the requested class and either a spec or test class, based on your testing framework (minitest or rspec).
|
82
89
|
|
83
90
|
For services:
|
84
91
|
|
85
|
-
+ app/services/
|
86
|
-
+ spec/services/
|
87
|
-
+ test/services/
|
92
|
+
+ app/services/[parent-folder]/[sub-folder]/thing.rb
|
93
|
+
+ spec/services/[parent-folder]/[sub-folder]/thing_spec.rb OR
|
94
|
+
+ test/services/[parent-folder]/[sub-folder]/thing_test.rb
|
88
95
|
|
89
96
|
For forms:
|
90
97
|
|
91
|
-
+ app/forms/
|
92
|
-
+ spec/forms/
|
93
|
-
+ test/forms/
|
98
|
+
+ app/forms/[parent-folder]/[sub-folder]/thing_form.rb
|
99
|
+
+ spec/forms/[parent-folder]/[sub-folder]/thing_form_spec.rb OR
|
100
|
+
+ test/forms/[parent-folder]/[sub-folder]/thing_form_test.rb
|
94
101
|
|
95
|
-
|
96
|
-
|
97
|
-
Pretty simple here ... it just removes the files it created
|
102
|
+
### Destroy service
|
103
|
+
Pretty simple here ... it just removes the files it created!
|
98
104
|
|
99
105
|
## Contributing
|
100
|
-
|
101
106
|
1. Fork it ( https://github.com/imageaid/rails_services/fork )
|
102
107
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
103
108
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Kaminsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4'
|
20
|
-
- - "<"
|
17
|
+
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '4'
|
30
|
-
- - "<"
|
24
|
+
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: minitest
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
115
|
- !ruby/object:Gem::Version
|
122
116
|
version: '0'
|
123
117
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.1.6
|
125
119
|
signing_key:
|
126
120
|
specification_version: 4
|
127
121
|
summary: A Ruby gem that adds a rails generator for creating service classes and form
|