handy_generators 0.1.2 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcf3d89962e30889ab8c36e231d46468202b02ac160b5625a11e70032805475c
4
- data.tar.gz: 874a43d1680a71c25d5dc9afc61cbb8ff6a7dfa6c9eb0ce890333bf7fc00a296
3
+ metadata.gz: d7d113f211bbdd551a0fd23fec01458efd1d89b4499716f9680c9c90dffa25a1
4
+ data.tar.gz: 8db9774519f008564b2416c58dfea6941a1d687eb4bb0fa4e7a30647e385d0d9
5
5
  SHA512:
6
- metadata.gz: 724b65ddc218cee6bf02df0b2baa17740f7b2236929cc2f61ddf412806548a6dfc5f995c2512cf0d09c6d78f9030145f17e34387aa7e0f2c84a5998a53223e7f
7
- data.tar.gz: f8ca90337a8cbe3dc9ba1b2d9d9b8872f1e68bd6f76a46b2b96f34881b05d1c54b333243ce8e581944dd6153c571119fd147bd36263e0f22f1942b62e49dfe9d
6
+ metadata.gz: e1fc413a078fd5f613c4223b8972b7d6c37e4782eefb59b4dbd01c7e941d0f63ac3958188d8a8aab19596febf91b66898822128d544785f6a720f09da08ce233
7
+ data.tar.gz: e1adc6a24e7cd2573a2c23299558546fb6008803744e87fe974256da11033f5eb7c66dbeb8b0b14b284f15cc40e0fd278c187a716e019a48f8c0d39918f8dc49
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- handy_generators (0.1.2)
4
+ handy_generators (0.1.8)
5
5
  rails (> 4.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # HandyGenerators
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/handy_generators`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This gem adds some handy generators to your Rails app.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,44 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ### Edit Links Helper
24
+
25
+ #### Generators
26
+
27
+ ```
28
+ rails generate handy_generators:edit_links_helper
29
+ ```
30
+
31
+ This generator will add a helper and a partial for displaying edit and
32
+ delete links for a record. This uses pundit by default to check
33
+ whether a user should be able to edit and/or delete the record before
34
+ displaying the link. If you'd like to always display these links when
35
+ you use the helper in the view or handle the logic yourself, simply
36
+ add --pundit false to your command.
37
+
38
+ ```
39
+ rails generate handy_generators:edit_links_helper --pundit false
40
+ ```
41
+
42
+ #### Helpers
43
+
44
+ `edit_links(record:, edit_classes: '', delete_classes: '')`
45
+
46
+ The `edit_links` helper receives three parameters `record`, `edit_classes`,
47
+ and `delete_classes`. Record is the only required parameter,
48
+ `edit_classes` and `delete_classes` will be empty by default, if you'd
49
+ like to add classes you can pass them as parameters to the helper. The
50
+ default helper uses pundit, and it will check if the logged in user has
51
+ permission to edit or delete the record before displaying the links. If
52
+ not, it will display the edit or delete links to all users.
53
+
54
+ `edit_record_link(record:, classes: '')`
55
+
56
+ The `edit_record_link` helper will just display an edit link, it won't check if the user has permission before displaying the link. Classes that you pass in as a parameter will be applied to the link.
57
+
58
+ `delete_record_link(record:, classes: '')`
59
+
60
+ The `delete_record_link` helper will display just display a delete link, with a confirm. It also doesn't check if the user has permission before displaying the link. Classes that you pass in as a parameter will be applied to the link.
26
61
 
27
62
  ## Development
28
63
 
@@ -0,0 +1,14 @@
1
+ Description:
2
+ This generator will add a helper and a partial for displaying edit and
3
+ delete links for a record. This uses pundit by default to check
4
+ whether a user should be able to edit and/or delete the record before
5
+ displaying the link. If you'd like to always display these links when
6
+ you use the helper in the view or handle the logic yourself, simply
7
+ add --pundit false to your command.
8
+
9
+ Example:
10
+ rails generate edit_links_helper add [--pundit false]
11
+
12
+ This will create:
13
+ app/helpers/edit_delete_links_helper.rb
14
+ app/views/shared/_edit_delete_links.html.erb
@@ -1,5 +1,5 @@
1
1
  class HandyGenerators::EditLinksHelperGenerator < Rails::Generators::Base
2
- source_root File.expand_path('templates/edit_delete_links', __dir__)
2
+ source_root File.expand_path('templates', __dir__)
3
3
  class_option :pundit, type: :boolean, default: true
4
4
 
5
5
  def generate
@@ -2,5 +2,5 @@ require "handy_generators/version"
2
2
 
3
3
  module HandyGenerators
4
4
  require "rails/generators"
5
- require_relative "./generators/edit_links_helper_generator"
5
+ require_relative "./edit_links_helper/edit_links_helper_generator"
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module HandyGenerators
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handy_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - DakotaLMartinez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,11 +99,11 @@ files:
99
99
  - bin/console
100
100
  - bin/setup
101
101
  - handy_generators.gemspec
102
- - lib/generators/USAGE
103
- - lib/generators/edit_links_helper_generator.rb
104
- - lib/generators/templates/edit_delete_links/edit_delete_links_helper.template
105
- - lib/generators/templates/edit_delete_links/edit_delete_links_partial.template
106
- - lib/generators/templates/edit_delete_links/edit_delete_links_partial_no_pundit.template
102
+ - lib/edit_links_helper/USAGE
103
+ - lib/edit_links_helper/edit_links_helper_generator.rb
104
+ - lib/edit_links_helper/templates/edit_delete_links_helper.template
105
+ - lib/edit_links_helper/templates/edit_delete_links_partial.template
106
+ - lib/edit_links_helper/templates/edit_delete_links_partial_no_pundit.template
107
107
  - lib/handy_generators.rb
108
108
  - lib/handy_generators/version.rb
109
109
  homepage: https://github.com/DakotaLMartinez/handy_generators
data/lib/generators/USAGE DELETED
@@ -1,12 +0,0 @@
1
- Description:
2
- This generator will add a helper and a partial for displaying edit and delete links
3
- for a record. This uses pundit by default to check whether a user should be able to
4
- edit and/or delete the record before displaying the link. If you'd like to always
5
- display these links when you use the helper in the view or handle the logic yourself, simply add --pundit false to your command.
6
-
7
- Example:
8
- rails generate edit_links_helper add [--pundit false]
9
-
10
- This will create:
11
- app/helpers/edit_delete_links_helper.rb
12
- app/views/shared/_edit_delete_links.html.erb