selfies 1.5.1 → 1.6.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/.gitignore +2 -1
- data/.rubocop.yml +15 -2
- data/Gemfile +11 -1
- data/Gemfile.lock +88 -0
- data/README.md +31 -12
- data/lib/selfies/self_init.rb +1 -1
- data/lib/selfies/version.rb +1 -1
- data/selfies.gemspec +3 -6
- metadata +8 -81
- data/.circleci/config.yml +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7f9d0aff5a924bb8535316e2d6fc6d123ab6f27302aa521ef0fd49700ac9a75
|
4
|
+
data.tar.gz: 2a8100a1eeed137a8306f95f4e4d8279494f742da17d04a64b73308d22855f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53e453795ea787243a8a069c11f020c7704be923cbcd20736bab9bc92004906eaa72f5afa3760df925b63915cbff06cb65305aebd499b7636f3b9792ddc9c55c
|
7
|
+
data.tar.gz: a41071f35347019d785a13707d0c828da8eb9711a5c2b1e40c0785fdf487fc089e4a10e5fa4403e5e44c68672b054359f6dc7b3037606f8132c5189c4b54b758
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
plugins:
|
2
|
+
- rubocop-rake
|
3
|
+
|
1
4
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
5
|
+
TargetRubyVersion: 3.4
|
6
|
+
NewCops: enable
|
3
7
|
DisplayCopNames: true
|
8
|
+
SuggestExtensions: false
|
4
9
|
Exclude:
|
5
10
|
- bin/**/*
|
6
11
|
- vendor/**/*
|
@@ -8,9 +13,17 @@ AllCops:
|
|
8
13
|
Layout/LineLength:
|
9
14
|
Max: 100
|
10
15
|
|
16
|
+
Lint/ConstantDefinitionInBlock:
|
17
|
+
Exclude:
|
18
|
+
- "**/*_spec.rb"
|
19
|
+
|
20
|
+
Lint/EmptyClass:
|
21
|
+
Exclude:
|
22
|
+
- "**/*_spec.rb"
|
23
|
+
|
11
24
|
Metrics/BlockLength:
|
12
25
|
Exclude:
|
13
|
-
-
|
26
|
+
- "**/*_spec.rb"
|
14
27
|
|
15
28
|
Metrics/MethodLength:
|
16
29
|
Max: 15
|
data/Gemfile
CHANGED
@@ -2,9 +2,19 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
ruby '>=
|
5
|
+
ruby '>= 3.4'
|
6
6
|
|
7
7
|
Encoding.default_external = Encoding::UTF_8
|
8
8
|
Encoding.default_internal = Encoding::UTF_8
|
9
9
|
|
10
|
+
group :development do
|
11
|
+
gem 'pry'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'reline'
|
14
|
+
gem 'rspec'
|
15
|
+
gem 'rubocop'
|
16
|
+
gem 'rubocop-rake'
|
17
|
+
gem 'simplecov'
|
18
|
+
end
|
19
|
+
|
10
20
|
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
selfies (1.6.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
coderay (1.1.3)
|
11
|
+
diff-lcs (1.6.0)
|
12
|
+
docile (1.4.1)
|
13
|
+
io-console (0.8.0)
|
14
|
+
json (2.10.1)
|
15
|
+
language_server-protocol (3.17.0.4)
|
16
|
+
lint_roller (1.1.0)
|
17
|
+
method_source (1.1.0)
|
18
|
+
parallel (1.26.3)
|
19
|
+
parser (3.3.7.1)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
racc
|
22
|
+
pry (0.15.2)
|
23
|
+
coderay (~> 1.1)
|
24
|
+
method_source (~> 1.0)
|
25
|
+
racc (1.8.1)
|
26
|
+
rainbow (3.1.1)
|
27
|
+
rake (13.2.1)
|
28
|
+
regexp_parser (2.10.0)
|
29
|
+
reline (0.6.0)
|
30
|
+
io-console (~> 0.5)
|
31
|
+
rspec (3.13.0)
|
32
|
+
rspec-core (~> 3.13.0)
|
33
|
+
rspec-expectations (~> 3.13.0)
|
34
|
+
rspec-mocks (~> 3.13.0)
|
35
|
+
rspec-core (3.13.3)
|
36
|
+
rspec-support (~> 3.13.0)
|
37
|
+
rspec-expectations (3.13.3)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.13.0)
|
40
|
+
rspec-mocks (3.13.2)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.13.0)
|
43
|
+
rspec-support (3.13.2)
|
44
|
+
rubocop (1.73.2)
|
45
|
+
json (~> 2.3)
|
46
|
+
language_server-protocol (~> 3.17.0.2)
|
47
|
+
lint_roller (~> 1.1.0)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 3.3.0.2)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
52
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
53
|
+
ruby-progressbar (~> 1.7)
|
54
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
55
|
+
rubocop-ast (1.38.1)
|
56
|
+
parser (>= 3.3.1.0)
|
57
|
+
rubocop-rake (0.7.1)
|
58
|
+
lint_roller (~> 1.1)
|
59
|
+
rubocop (>= 1.72.1)
|
60
|
+
ruby-progressbar (1.13.0)
|
61
|
+
simplecov (0.22.0)
|
62
|
+
docile (~> 1.1)
|
63
|
+
simplecov-html (~> 0.11)
|
64
|
+
simplecov_json_formatter (~> 0.1)
|
65
|
+
simplecov-html (0.13.1)
|
66
|
+
simplecov_json_formatter (0.1.4)
|
67
|
+
unicode-display_width (3.1.4)
|
68
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
69
|
+
unicode-emoji (4.0.4)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
pry
|
76
|
+
rake
|
77
|
+
reline
|
78
|
+
rspec
|
79
|
+
rubocop
|
80
|
+
rubocop-rake
|
81
|
+
selfies!
|
82
|
+
simplecov
|
83
|
+
|
84
|
+
RUBY VERSION
|
85
|
+
ruby 3.4.2p28
|
86
|
+
|
87
|
+
BUNDLED WITH
|
88
|
+
2.6.2
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Selfies
|
2
|
-
[](https://badge.fury.io/rb/selfies) [](https://circleci.com/gh/mariodarco/selfies) [](https://codeclimate.com/github/mariodarco/selfies/maintainability) [](https://codeclimate.com/github/mariodarco/selfies/test_coverage)
|
3
2
|
|
4
3
|
**A collection of macros for quicker development**
|
5
4
|
|
6
5
|
Another day at work, or on your personal project, and you need to create yet another class, which comes with the user boilerplate:
|
6
|
+
|
7
7
|
- The initializer needs to be defined, with n parameters
|
8
|
-
- Inside that, the usual
|
8
|
+
- Inside that, the usual `@param = param`, multiplied for how many params you've got there
|
9
9
|
- Then it's the turn of the attr_reader for those parameters
|
10
10
|
- Then you are likely to need a class method that does nothing else than initializing the class and calling an instance method of the same name
|
11
11
|
- more?
|
@@ -15,11 +15,13 @@ This gets boring with the years. So boring that someone might decide to write so
|
|
15
15
|
## TL;DR
|
16
16
|
|
17
17
|
You add this:
|
18
|
+
|
18
19
|
```ruby
|
19
20
|
gem 'selfies'
|
20
21
|
```
|
21
22
|
|
22
23
|
You write this:
|
24
|
+
|
23
25
|
```ruby
|
24
26
|
class Rectangle
|
25
27
|
attr_accessor_init :width, :height, scale: 100
|
@@ -42,6 +44,7 @@ end
|
|
42
44
|
```
|
43
45
|
|
44
46
|
You get this:
|
47
|
+
|
45
48
|
```ruby
|
46
49
|
>> Rectangle.area(8, 4)
|
47
50
|
=> 32.0
|
@@ -73,9 +76,10 @@ $ gem install selfies
|
|
73
76
|
|
74
77
|
## Usage
|
75
78
|
|
76
|
-
|
79
|
+
**_attr_reader_init_**: can be used to automatically generate an initialiser for your class
|
77
80
|
|
78
81
|
This code:
|
82
|
+
|
79
83
|
```ruby
|
80
84
|
class Search
|
81
85
|
attr_reader_init :term, :page, :limit
|
@@ -83,6 +87,7 @@ end
|
|
83
87
|
```
|
84
88
|
|
85
89
|
Is equivalent to:
|
90
|
+
|
86
91
|
```ruby
|
87
92
|
class Search
|
88
93
|
attr_reader :term, :page, :limit
|
@@ -98,6 +103,7 @@ end
|
|
98
103
|
It is possible to specify a default for the last argument only:
|
99
104
|
|
100
105
|
This code:
|
106
|
+
|
101
107
|
```ruby
|
102
108
|
class Search
|
103
109
|
attr_reader_init :term, :page, limit: 5
|
@@ -105,6 +111,7 @@ end
|
|
105
111
|
```
|
106
112
|
|
107
113
|
Is equivalent to:
|
114
|
+
|
108
115
|
```ruby
|
109
116
|
class Search
|
110
117
|
attr_reader :term, :page, :limit
|
@@ -124,9 +131,10 @@ end
|
|
124
131
|
```
|
125
132
|
|
126
133
|
You can use any variable name that would make for a valid Ruby variable;
|
127
|
-
Only exception is
|
134
|
+
Only exception is `:args` which is used by `selfies` to define a splat operator:
|
128
135
|
|
129
136
|
This code:
|
137
|
+
|
130
138
|
```ruby
|
131
139
|
class Search
|
132
140
|
attr_reader_init :term, :args
|
@@ -134,6 +142,7 @@ end
|
|
134
142
|
```
|
135
143
|
|
136
144
|
Is equivalent to:
|
145
|
+
|
137
146
|
```ruby
|
138
147
|
class Search
|
139
148
|
attr_reader :term, :args
|
@@ -151,9 +160,10 @@ end
|
|
151
160
|
=> [2, 10]
|
152
161
|
```
|
153
162
|
|
154
|
-
|
163
|
+
**_attr_accessor_init_**: same as `attr_reader_init`, but generates accessors for the given attributes
|
155
164
|
|
156
165
|
This code:
|
166
|
+
|
157
167
|
```ruby
|
158
168
|
class Search
|
159
169
|
attr_accessor_init :term, :page, :limit
|
@@ -161,6 +171,7 @@ end
|
|
161
171
|
```
|
162
172
|
|
163
173
|
Is equivalent to:
|
174
|
+
|
164
175
|
```ruby
|
165
176
|
class Search
|
166
177
|
attr_accessor :term, :page, :limit
|
@@ -173,9 +184,10 @@ class Search
|
|
173
184
|
end
|
174
185
|
```
|
175
186
|
|
176
|
-
|
187
|
+
**_selfie_**: can be used to automatically create a class method that reference to the instance method of the same class
|
177
188
|
|
178
189
|
This code:
|
190
|
+
|
179
191
|
```ruby
|
180
192
|
class Search
|
181
193
|
attr_reader :term, :page, :limit
|
@@ -205,6 +217,7 @@ end
|
|
205
217
|
```
|
206
218
|
|
207
219
|
Can be written as:
|
220
|
+
|
208
221
|
```ruby
|
209
222
|
class Search
|
210
223
|
attr_reader_init :term, :page, :limit
|
@@ -222,6 +235,7 @@ end
|
|
222
235
|
```
|
223
236
|
|
224
237
|
If preferred, more methods can be 'selfied' in one liner:
|
238
|
+
|
225
239
|
```ruby
|
226
240
|
class Search
|
227
241
|
...
|
@@ -239,26 +253,32 @@ end
|
|
239
253
|
|
240
254
|
## Next Steps
|
241
255
|
|
242
|
-
|
256
|
+
**_attr_reader_init_** and **_attr_accessor_init:_**
|
257
|
+
|
243
258
|
- Improve message when raising ArgumentError;
|
244
259
|
|
245
|
-
|
260
|
+
**_selfie:_**
|
261
|
+
|
246
262
|
- Find a suitable syntax that would allow to 'selfie' an instance method that has arguments;
|
247
263
|
|
248
|
-
|
264
|
+
**_command line:_**
|
265
|
+
|
249
266
|
- Write a command that can initialize a whole class, from creating the file to stub the initial setup;
|
250
267
|
|
251
|
-
|
268
|
+
**_more?:_**
|
269
|
+
|
252
270
|
- If you also often write repetitive boilerplate, and would like some code to get smaller, drop me a line and we might be able to add more macros.
|
253
271
|
|
254
272
|
## Development
|
255
273
|
|
256
274
|
Ruby version:
|
275
|
+
|
257
276
|
```bash
|
258
|
-
>=
|
277
|
+
>= 3.4
|
259
278
|
```
|
260
279
|
|
261
280
|
Fork the project, clone the repository and bundle:
|
281
|
+
|
262
282
|
```bash
|
263
283
|
>> git clone https://{your_fork}/selfies
|
264
284
|
>> cd selfies
|
@@ -276,4 +296,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/mariod
|
|
276
296
|
## License
|
277
297
|
|
278
298
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
279
|
-
|
data/lib/selfies/self_init.rb
CHANGED
data/lib/selfies/version.rb
CHANGED
data/selfies.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.name = 'selfies'
|
10
10
|
spec.version = Selfies::VERSION
|
11
11
|
spec.authors = ['Mario D’Arco']
|
12
|
-
spec.email = ['mario.darco.
|
12
|
+
spec.email = ['mario.darco.@hey.com']
|
13
13
|
|
14
14
|
spec.summary = 'A collection of macros for quicker development.'
|
15
15
|
spec.homepage = 'https://github.com/mariodarco/selfies'
|
@@ -24,9 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
26
26
|
|
27
|
-
spec.
|
28
|
-
spec.
|
29
|
-
spec.add_development_dependency 'rspec'
|
30
|
-
spec.add_development_dependency 'rubocop'
|
31
|
-
spec.add_development_dependency 'simplecov'
|
27
|
+
spec.required_ruby_version = '>= 3.4'
|
28
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
32
29
|
end
|
metadata
CHANGED
@@ -1,98 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selfies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario D’Arco
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: pry
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: simplecov
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
description:
|
10
|
+
date: 2025-03-09 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
84
12
|
email:
|
85
|
-
- mario.darco.
|
13
|
+
- mario.darco.@hey.com
|
86
14
|
executables: []
|
87
15
|
extensions: []
|
88
16
|
extra_rdoc_files: []
|
89
17
|
files:
|
90
|
-
- ".circleci/config.yml"
|
91
18
|
- ".gitignore"
|
92
19
|
- ".rspec"
|
93
20
|
- ".rubocop.yml"
|
94
21
|
- CODE_OF_CONDUCT.md
|
95
22
|
- Gemfile
|
23
|
+
- Gemfile.lock
|
96
24
|
- LICENSE.txt
|
97
25
|
- README.md
|
98
26
|
- Rakefile
|
@@ -109,7 +37,7 @@ licenses:
|
|
109
37
|
- MIT
|
110
38
|
metadata:
|
111
39
|
allowed_push_host: https://rubygems.org
|
112
|
-
|
40
|
+
rubygems_mfa_required: 'true'
|
113
41
|
rdoc_options: []
|
114
42
|
require_paths:
|
115
43
|
- lib
|
@@ -117,15 +45,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
45
|
requirements:
|
118
46
|
- - ">="
|
119
47
|
- !ruby/object:Gem::Version
|
120
|
-
version: '
|
48
|
+
version: '3.4'
|
121
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
50
|
requirements:
|
123
51
|
- - ">="
|
124
52
|
- !ruby/object:Gem::Version
|
125
53
|
version: '0'
|
126
54
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
128
|
-
signing_key:
|
55
|
+
rubygems_version: 3.6.2
|
129
56
|
specification_version: 4
|
130
57
|
summary: A collection of macros for quicker development.
|
131
58
|
test_files: []
|
data/.circleci/config.yml
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
---
|
2
|
-
version: 2
|
3
|
-
jobs:
|
4
|
-
build:
|
5
|
-
environment:
|
6
|
-
CC_TEST_REPORTER_ID: '720c03bcc2eb17a5494a1e4bc18dfd0044b7a9819e0299f271278fd9a3da613f'
|
7
|
-
working_directory: ~/selfies
|
8
|
-
docker:
|
9
|
-
- image: circleci/ruby:2.5.1-node-browsers
|
10
|
-
steps:
|
11
|
-
- checkout
|
12
|
-
|
13
|
-
# Restore Cached Dependencies
|
14
|
-
- type: cache-restore
|
15
|
-
name: Restore bundle cache
|
16
|
-
key: selfies-{{ checksum "Gemfile.lock" }}
|
17
|
-
|
18
|
-
# Bundle install dependencies
|
19
|
-
- run: bundle install --path vendor/bundle
|
20
|
-
|
21
|
-
# Cache Dependencies
|
22
|
-
- type: cache-save
|
23
|
-
name: Store bundle cache
|
24
|
-
key: selfies-{{ checksum "Gemfile.lock" }}
|
25
|
-
paths:
|
26
|
-
- vendor/bundle
|
27
|
-
|
28
|
-
- run:
|
29
|
-
name: Setup Code Climate test-reporter
|
30
|
-
command: |
|
31
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
32
|
-
chmod +x ./cc-test-reporter
|
33
|
-
|
34
|
-
# Run the tests
|
35
|
-
- run:
|
36
|
-
name: Run tests
|
37
|
-
command: |
|
38
|
-
./cc-test-reporter before-build
|
39
|
-
bundle exec rspec
|
40
|
-
./cc-test-reporter after-build --exit-code $?
|
41
|
-
|
42
|
-
# Enforce better practices
|
43
|
-
- run: bundle exec rubocop
|
44
|
-
|
45
|
-
- store_test_results:
|
46
|
-
path: coverage
|