punchbox 1.0.1 → 1.0.2
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 +26 -2
- data/lib/punchbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fff45d81bf026c8f5e9b9c556ae6903d99a0d62
|
4
|
+
data.tar.gz: 8b1a8bb998aca2812cb40955834abf971283306f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ceeb71abaa224bed0fd11e4b3230fd06754feb7522335e271afd6475a389cf2753ae13ecfdace59fc45f8f0126106253d02379018da41e4bf45a8a3b31d527
|
7
|
+
data.tar.gz: b8bc6c59f9abf51ab8b3829036f42f88ca88473a2d519a894856a1974ef76058f012f31725b8ab46a8a329e986c1d603b751f31649d1a1e538e301a2fbfbaf94
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ Punchbox automatically runs your code after your document is ready, negating the
|
|
65
65
|
|
66
66
|
`controller` should be a string or a function that returns a string. It should be the exact name of the controller (plus namespace) that you want your code to run on. It should be ClassCase (PascalCase) only.
|
67
67
|
|
68
|
-
For example, if your controller is `PostsController`, you'd enter
|
68
|
+
For example, if your controller is `PostsController`, you'd enter `Posts`. If your controller is `AdminPanelsController`, you'd enter `AdminPanels`.
|
69
69
|
|
70
70
|
#### Namespacing
|
71
71
|
|
@@ -83,7 +83,7 @@ Functions should be named after the actions on which they should run. A functio
|
|
83
83
|
|
84
84
|
The exception is `controller`. Punchbox treats functions named `controller` in a special way and runs them on every action in a given Rails controller.
|
85
85
|
|
86
|
-
|
86
|
+
### Examples
|
87
87
|
|
88
88
|
In all examples I'll be targeting the `Posts` controller. *Remember that the name of your `callable` or your JS filepath don't have anything to do with Punchbox's functionality. However, I'll be naming the callables after the controllers to keep up with the preferred convention.*
|
89
89
|
|
@@ -152,6 +152,30 @@ class Posts
|
|
152
152
|
Punchbox.on('Posts', Posts) # Notice that you don't instantiate the class
|
153
153
|
```
|
154
154
|
|
155
|
+
### Events
|
156
|
+
|
157
|
+
Every time a controller or action function is run, some events on `document` fire.
|
158
|
+
|
159
|
+
These events are `punchbox:<controller>:run` and `punchbox:<controller>:<action>:run`. These both run when their respective functions would run.
|
160
|
+
|
161
|
+
Keep in mind that the events are `snake_case` with slashes preserved.
|
162
|
+
|
163
|
+
For example, you would listen to the `Posts` controller trigger like so:
|
164
|
+
|
165
|
+
```javascript
|
166
|
+
document.addEventListener('punchbox:posts:run', () => {
|
167
|
+
console.log('Posts controller ran!');
|
168
|
+
})
|
169
|
+
```
|
170
|
+
|
171
|
+
and you'd listen to the `Posts` `index` trigger like so:
|
172
|
+
|
173
|
+
```javascript
|
174
|
+
document.addEventListener('punchbox:posts:index:run', () => {
|
175
|
+
console.log('Posts index ran!');
|
176
|
+
})
|
177
|
+
```
|
178
|
+
|
155
179
|
## Contributing
|
156
180
|
|
157
181
|
If you want to contribute, don't hesitate to create an issue or PR! Since this project is in it's infancy, your input could help shape the project as a whole!
|
data/lib/punchbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punchbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kieran Eglin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|