evnt 3.2.6 → 3.3.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 +4 -4
- data/README.md +15 -1
- data/lib/evnt/event.rb +25 -2
- data/lib/evnt/version.rb +1 -1
- data/lib/generators/evnt/event_generator.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef1b5762fd449d75c4ae69dc161adcbb551d447c660e818e99b99a017fa31df
|
4
|
+
data.tar.gz: 54abf9e98b18f38fa5c11b3dd04413f0acad251840b48d234452f1575128e504
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d95dcf19b416dc055707153fae3ef77abd188e8291417f39966677677523084665db75842b4dc2ee592e583acb2d63955176027aa87e1ca7135b8658aef82437
|
7
|
+
data.tar.gz: 3fd2d0dfc03ed1b5431358bfc52bf6eb125b6dfc067c8808f8e7ed2aa8bece0cb7f96ea58780cc916955ec306c7b42cea7e8d7b51fe426c5423f3713627c048e
|
data/README.md
CHANGED
@@ -29,10 +29,24 @@ gem 'evnt'
|
|
29
29
|
|
30
30
|
## Development
|
31
31
|
|
32
|
+
### RDoc documentation
|
33
|
+
|
32
34
|
To update the rdoc documentation run:
|
33
35
|
|
34
36
|
```console
|
35
|
-
|
36
37
|
rdoc --op rdoc
|
38
|
+
```
|
39
|
+
|
40
|
+
### Docsify documentation
|
41
|
+
|
42
|
+
Install docsify as global node dependency
|
43
|
+
|
44
|
+
```shell
|
45
|
+
npm install -g docsify
|
46
|
+
```
|
47
|
+
|
48
|
+
See documentation on local machine
|
37
49
|
|
50
|
+
```shell
|
51
|
+
docsify serve ./docs
|
38
52
|
```
|
data/lib/evnt/event.rb
CHANGED
@@ -50,7 +50,7 @@ module Evnt
|
|
50
50
|
_init_event_data(params)
|
51
51
|
_validate_payload
|
52
52
|
_run_event_steps
|
53
|
-
_notify_handlers
|
53
|
+
_notify_handlers if @state[:saved]
|
54
54
|
end
|
55
55
|
|
56
56
|
# Public functions:
|
@@ -65,6 +65,27 @@ module Evnt
|
|
65
65
|
@state[:reloaded]
|
66
66
|
end
|
67
67
|
|
68
|
+
##
|
69
|
+
# This function tells if the event is saved or not.
|
70
|
+
# As default an event is considered saved. It should be updated to
|
71
|
+
# not saved when the to_write_event has some problems.
|
72
|
+
##
|
73
|
+
def saved?
|
74
|
+
@state[:saved]
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# This function can be used to set the event as not saved.
|
79
|
+
# A not saved event should not notify handlers.
|
80
|
+
# If the exceptions option is active, it should raise a new error.
|
81
|
+
##
|
82
|
+
def set_not_saved
|
83
|
+
@state[:saved] = false
|
84
|
+
|
85
|
+
# raise error if event needs exceptions
|
86
|
+
raise 'Event can not be saved' if @options[:exceptions]
|
87
|
+
end
|
88
|
+
|
68
89
|
# Private functions:
|
69
90
|
############################################################################
|
70
91
|
|
@@ -74,11 +95,13 @@ module Evnt
|
|
74
95
|
def _init_event_data(params)
|
75
96
|
# set state
|
76
97
|
@state = {
|
77
|
-
reloaded: !params[:evnt].nil
|
98
|
+
reloaded: !params[:evnt].nil?,
|
99
|
+
saved: true
|
78
100
|
}
|
79
101
|
|
80
102
|
# set options
|
81
103
|
initial_options = {
|
104
|
+
exceptions: false,
|
82
105
|
silent: false
|
83
106
|
}
|
84
107
|
default_options = _safe_default_options || {}
|
data/lib/evnt/version.rb
CHANGED
@@ -15,7 +15,7 @@ module Evnt
|
|
15
15
|
path = informations.first.split('::')
|
16
16
|
@event_class = path.last.camelize
|
17
17
|
@event_modules = path - [path.last]
|
18
|
-
@event_name = path.map(&:underscore).join('_')
|
18
|
+
@event_name = event_name_clean(path.map(&:underscore).join('_'))
|
19
19
|
@event_attributes = (informations - [informations.first]).map { |a| ":#{a}" }.join(', ')
|
20
20
|
|
21
21
|
template(
|
@@ -31,6 +31,12 @@ module Evnt
|
|
31
31
|
path
|
32
32
|
end
|
33
33
|
|
34
|
+
def event_name_clean(event_name)
|
35
|
+
return event_name unless event_name.end_with?('_event')
|
36
|
+
|
37
|
+
event_name.gsub('_event', '')
|
38
|
+
end
|
39
|
+
|
34
40
|
end
|
35
41
|
|
36
42
|
end
|