selfies 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -5
- data/lib/selfies/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b6804ef3c20e8b2da7b66a7eedb281dcb916614
|
4
|
+
data.tar.gz: ff9a72cca796a7887f4886f528316e7d500ef3f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d17ed4e3ba64e58b6f6051091525cd906f1f4c88eb9fe01f42ab7b22bda4b5a8ab6fcbe322acd291b5c89e87e9e08eaf50f52ba3b9f8e7cec7b4acb3f82d8a
|
7
|
+
data.tar.gz: f0ba4aba97b195398efccc335dd4339d4e7c83890fd0874c72105eadbcb4a101af892f9b27c8db3fc9e09dbb5a0abcc16964fef77b57f4991c235de6f890c757
|
data/README.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
[![CircleCI](https://circleci.com/gh/mariodarco/
|
1
|
+
[![CircleCI](https://circleci.com/gh/mariodarco/selfies/tree/master.svg?style=shield)](https://circleci.com/gh/mariodarco/selfies/tree/master)
|
2
2
|
|
3
3
|
# Selfies
|
4
|
+
**A collection of macros for quicker development**
|
5
|
+
|
6
|
+
Another day at work, or on your personal project, and you need to create yet another class, which comes with the user boilerplate:
|
7
|
+
- The initialiser needs to be defined, with n parameters
|
8
|
+
- Inside that, the usual ```@param = param```, multiplied for how many params you've got there
|
9
|
+
- Then it's the turn of the attr_reader for those parameters
|
10
|
+
- Then you are likely to need a class method that does nothing else than initialising the class and calling an instance method of the same name
|
11
|
+
- more?
|
12
|
+
|
13
|
+
This gets boring with the years. So boring that someone might decide to write some macros to reduce the boilerplate.
|
14
|
+
|
15
|
+
## Disclaimer
|
16
|
+
In this project you will likely read me using both ```initialize``` and ```initialise```. I'm Italian, I learnt to code from American books and now live in UK, to me they both make sense. As a rule of thumb, it's the ```ize``` form in code and ```ise``` form everywhere else. But might mix them so bear with me. Thanks!
|
4
17
|
|
5
|
-
A collection of macros for quicker development.
|
6
18
|
|
7
19
|
## Installation
|
8
20
|
|
@@ -14,15 +26,46 @@ gem 'selfies'
|
|
14
26
|
|
15
27
|
And then execute:
|
16
28
|
|
17
|
-
|
29
|
+
```
|
30
|
+
$ bundle
|
31
|
+
```
|
18
32
|
|
19
33
|
Or install it yourself as:
|
20
34
|
|
21
|
-
|
35
|
+
```
|
36
|
+
$ gem install selfies
|
37
|
+
```
|
22
38
|
|
23
39
|
## Usage
|
24
40
|
|
25
|
-
|
41
|
+
***self_init***: can be used to automatically generate an initialiser for your class
|
42
|
+
|
43
|
+
This code:
|
44
|
+
```ruby
|
45
|
+
class Search
|
46
|
+
self_init :term, :page, :limit
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
Is equivalent to:
|
51
|
+
```ruby
|
52
|
+
class Search
|
53
|
+
attr_reader :term, :page, :limit
|
54
|
+
|
55
|
+
def initialize(term, page, limit)
|
56
|
+
@term = term
|
57
|
+
@page = page
|
58
|
+
@limit = limit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
## Next Steps
|
64
|
+
|
65
|
+
***self_init***:
|
66
|
+
- Implement the possibility to pass defaults
|
67
|
+
- Specify which parameters will get an attr_reader, attr_accessor or none
|
68
|
+
- Specify wich parameters on attr_reader are to consider private
|
26
69
|
|
27
70
|
## Development
|
28
71
|
|
data/lib/selfies/version.rb
CHANGED