myrails 3.2.0 → 3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed411978cf30a8e66c37d173a9ae0fe4561b98cf
4
- data.tar.gz: 31fbf6c05b7cb4924d6f98395c06626618749ec6
3
+ metadata.gz: e68cebfb6cb817f8d85aa5b540d19dccac6999ca
4
+ data.tar.gz: e1f16d66475ca8625e428ef1daf2a391d3555ac4
5
5
  SHA512:
6
- metadata.gz: 7896e5d9acbeb096cf7308a64b60b42443e27bd611ba7d2ca6f74ea4f7c8aceffaf65600637e7e204ca78e282bddf89892d68064682c636e5caee4af949e0ef7
7
- data.tar.gz: 641c334f61fe76fa4c520e848313fa73fcb5399b89b8c421d68e2cbf2e8435715dbafdd7817f9d2b6153515558f5a73ca57e7dceda6e24ce1991be056c81a102
6
+ metadata.gz: bcf47925aa8bab0924b0975219973a8b2faf7bd61b9dde345354531d0c48a18a64341924039004e53c8989f53d14bec220841afe520f2131fc3c8380cd1b406f
7
+ data.tar.gz: 494f297b3b4913ae58d610dd958317a580b46612a56ddc12c1c83d09e2b57b7aafb1a9f758b1aa9e1c943c76b54c20467b4d3c6a57ec416ba3598ea2b4851344
data/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  This gem was created to make generating rails related files and other rails gem files (that I use) a lot easier. It is a thor backed gem that was designed with rails 5 in mind but most of it "should" work with rails 4.
4
4
 
5
- This gem is not endorsed by 37signals. I wrote it as a convenience for generating files that I would otherwise have written by hand.
5
+ This gem is not endorsed by the rails core team. I wrote it as a convenience for generating files that I would otherwise have written by hand.
6
6
 
7
7
  ## Disclaimer
8
8
 
9
- `user at your own risk!`
9
+ `user at your own risk!` I am not held responsible for using this gem. If you are not usre it will work for you, install it on a vagrant vm and give it a try there. You can use even use the Vagrantfile that is in this repo to take care of configuring a useable vm.
10
10
 
11
11
  This gem is not compatible with ruby 2.3 (yet).
12
12
 
@@ -18,9 +18,9 @@ Use the latest version if are primarily developing in rails 5
18
18
 
19
19
  ## Examples
20
20
 
21
- Here is an example of the gem in action:
21
+ Here is an example of the gem works:
22
22
 
23
- For example, I use pundit. With this gem I am able to run the following:
23
+ Lets say I use pundit. With this gem I am able to run the following:
24
24
 
25
25
  ```ruby
26
26
  myrails policy --name=article
@@ -46,6 +46,66 @@ with corresponding files:
46
46
  └── article_policy_spec.rb
47
47
  ```
48
48
 
49
+ Inside app/policies/articles_policy.rb is boiler plate code like:
50
+
51
+ ```
52
+ class ArticlePolicy < ApplicationPolicy
53
+ # Allow all users to access new article
54
+ def new?
55
+ true
56
+ end
57
+
58
+ # Allows owner to edit Article
59
+ def edit?
60
+ user == record.user
61
+ end
62
+
63
+ # Allows all users to create Article
64
+ alias_method :create?, :new?
65
+
66
+ # Allows all users to view Article
67
+ alias_method :show?, :new?
68
+
69
+ # Allows owner to update an Article
70
+ alias_method :update?, :edit?
71
+
72
+ # Allows owner to remove an Article
73
+ alias_method :destroy?, :edit?
74
+ end
75
+ ```
76
+
77
+ Inside the spec/policies/articles_policy_spec.rb is boiler plate code like:
78
+
79
+ ```
80
+ # Use with Pundit Matches: https://github.com/chrisalley/pundit-matchers
81
+ require 'rails_helper'
82
+ describe ArticlePolicy do
83
+ subject { ArticlePolicy.new(user, article) }
84
+
85
+ let(:article) { create :article }
86
+
87
+ context 'for a visitor' do
88
+ it {is_expected.to permit_action(:new)}
89
+ it {is_expected.to permit_action(:create)}
90
+ it {is_expected.to permit_action(:show)}
91
+ it {is_expected.to forbid_action(:edit)}
92
+ it {is_expected.to forbid_action(:update)}
93
+ it {is_expected.to forbid_action(:destroy)}
94
+ end
95
+
96
+ context "for an admin" do
97
+
98
+ let(:user) { article.user }
99
+
100
+ it {is_expected.to permit_action(:new)}
101
+ it {is_expected.to permit_action(:create)}
102
+ it {is_expected.to permit_action(:show)}
103
+ it {is_expected.to permit_action(:edit)}
104
+ it {is_expected.to permit_action(:update)}
105
+ it {is_expected.to permit_action(:destroy)}
106
+ end
107
+ end
108
+ ```
49
109
 
50
110
  ## Installation
51
111
 
@@ -63,7 +123,7 @@ gem install myrails
63
123
 
64
124
  ## Usage
65
125
 
66
- simple type `myrails` to see the help menu
126
+ Simply type `myrails` to see the help menu
67
127
 
68
128
  ```ruby
69
129
  # Example for generating a presenter class
data/lib/myrails.rb CHANGED
@@ -204,7 +204,7 @@ gem 'record_tag_helper'
204
204
  desc 'install_devise', 'Generate devise files'
205
205
  def install_devise
206
206
  insert_into_file 'Gemfile', after: "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n" do <<-CODE
207
- gem 'devise', '~> 4.2.0'
207
+ gem 'devise'
208
208
  CODE
209
209
  end
210
210
  run 'bundle update'
@@ -593,7 +593,7 @@ require 'database_cleaner'
593
593
  say "Unknown Action!"
594
594
  end
595
595
  end
596
-
596
+
597
597
  end
598
598
  end
599
599
 
@@ -1,5 +1,3 @@
1
- # @author Lovell McIlwain
2
- #
3
1
  # Mail interceptor for development and test emails
4
2
  require 'socket'
5
3
  class DevMailInterceptor
@@ -1,5 +1,3 @@
1
- # @author Lovell McIlwain
2
- #
3
1
  # Class every presenter class should inherit from
4
2
  class BasePresenter
5
3
  # Initialize class with object to be presented and the view it is to be presented on
@@ -1,5 +1,3 @@
1
- # @author Lovell McIlwain
2
- #
3
1
  # Presenter class for object views
4
2
  class <%= options[:name].camelize %>Presenter < BasePresenter
5
3
  # Reference initialized object_presenter as object
@@ -1,4 +1,3 @@
1
-
2
1
  require 'rails_helper'
3
2
  #
4
3
  describe <%= options[:name].camelize %>Presenter do
@@ -1,5 +1,3 @@
1
- # @author Lovell McIlwain
2
- #
3
1
  # Authorization for <%= options[:name] %> objects
4
2
  class <%= options[:name].camelize %>Policy < ApplicationPolicy
5
3
  # Allow all users to access new <%= options[:name] %>
@@ -1,4 +1,3 @@
1
- # @author Lovell McIlwain
2
1
  # Handles HTTP actions for UI
3
2
  class UiController < ApplicationController
4
3
  # Before filter to check if application is running in development
@@ -1,3 +1,3 @@
1
1
  module Myrails
2
- VERSION = "3.2.0"
2
+ VERSION = "3.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2017-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -171,7 +171,6 @@ files:
171
171
  - lib/myrails/templates/ui/ui_controller.rb
172
172
  - lib/myrails/version.rb
173
173
  - myrails.gemspec
174
- - spec/controllers/sam_controller_spec.rb
175
174
  - spec/myrails_spec.rb
176
175
  - spec/spec_helper.rb
177
176
  homepage: https://github.com/vmcilwain/myrails
@@ -195,12 +194,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
194
  version: '0'
196
195
  requirements: []
197
196
  rubyforge_project:
198
- rubygems_version: 2.6.10
197
+ rubygems_version: 2.6.12
199
198
  signing_key:
200
199
  specification_version: 4
201
200
  summary: A thor backed generator for generating rails related files based on my style
202
201
  of coding
203
202
  test_files:
204
- - spec/controllers/sam_controller_spec.rb
205
203
  - spec/myrails_spec.rb
206
204
  - spec/spec_helper.rb
@@ -1,98 +0,0 @@
1
- require 'rails_helper'
2
-
3
- # Does this controller require authentication?
4
- describe SamController do
5
- # let(:user) {create :user}
6
- let(:sams) {[]}
7
- let(:sam) {create :sam}
8
-
9
- # before {sign_in user}
10
-
11
- describe 'GET index' do
12
- before do
13
- 3.times {sams << create(:sam)}
14
- get :index
15
- end
16
-
17
- it 'sets @sams' do
18
- expect(assigns[:sams]).to eq sams
19
- end
20
- end
21
-
22
- describe 'GET show' do
23
- before {get :show, params: {id: sam.id}}
24
-
25
- it 'sets @sam' do
26
- expect(assigns[:sam]).to eq sam
27
- end
28
- end
29
-
30
- describe 'GET new' do
31
- before {get :new}
32
-
33
- it 'sets @sam' do
34
- expect(assigns[:sam]).to be_a_new Sam
35
- end
36
- end
37
-
38
- describe 'POST create' do
39
- context 'successful create' do
40
- before {post :create, params: {sam: attributes_for(:sam)}}
41
-
42
- subject(:s){assigns[:sam]}
43
-
44
- it 'redirects to :show'
45
- it 'sets @sam'
46
- it 'sets flash[:success]'
47
- it 'tags the current_user as creator'
48
- end
49
-
50
- context 'unsuccessful create' do
51
- before {post :create, params: {sam: attributes_for(:sam, attr: nil)}}
52
-
53
- it 'renders :new template'
54
- it 'sets @sam'
55
- it 'sets flash[:error]'
56
- end
57
- end
58
-
59
- describe 'GET edit' do
60
- before {get :edit, params: {id: sam.id}}
61
-
62
- it 'sets @sam' do
63
- expect(assigns[:sam]).to eq sam
64
- end
65
- end
66
-
67
- describe 'PUT/PATCH update' do
68
- context 'successful update' do
69
- before {put :update, params: {id: sam.id, sam: attributes_for(:sam)}}
70
-
71
- subject(:s) {assigns[:sam]}
72
-
73
- it 'redirects to :show'
74
- it 'sets @sam'
75
- it 'sets flash[:success]'
76
- it 'tags current_user as updater'
77
- end
78
-
79
- context 'unsuccessful update' do
80
- before {put :update, params: {id: sam.id, sam: attributes_for(:sam, attr: nil)}}
81
-
82
- it 'renders :edit template'
83
- it 'sets @sam'
84
- it 'sets flash[:error]'
85
- end
86
- end
87
-
88
- describe 'DELETE destroy' do
89
- before {delete :destroy, params: {id: sam.id}}
90
-
91
- it 'redirects to :index' do
92
- expect(response).to redirect_to sams_path
93
- end
94
- it 'sets @sam'
95
- it 'deletes @sam'
96
- it 'sets flash[success]'
97
- end
98
- end