rails_apps_pages 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba3a1a31cdbd9801ce11a4c2f6770185edfb83b2
4
- data.tar.gz: 608cfffbc48fc019767260605bf2d5e8863ce06c
3
+ metadata.gz: dabd0b8953eea28a91d4e338405ec9246b063f63
4
+ data.tar.gz: 64fd9902b64d7ef3b45522b63c1fe8d91640f5ee
5
5
  SHA512:
6
- metadata.gz: c13ac0bb6597651c329ca3cedfa1e9d45faa9e7eabe3cdee228ce410aebdef5f0fc838739b3e686e2c9768541b01252053917d1118204067f82f45624bbb3422
7
- data.tar.gz: 3f2f2ae34a86c319a2659785ead8aa11661d7090baf3e96d575ebced6340a137846cdc7ab5d9e57e5f19112a4582f5ee38a9fbf30a63f40f78052da613c7f906
6
+ metadata.gz: 66d4cf28f09932dd29353eb59ccc520f1db3c6eeb2601ac90848e4392cc94dd1fbd134f0d9fc18155d99f3d6c3b8872b928ab928d6e9f154bed65892cd896d6c
7
+ data.tar.gz: 121b0a57c871377b70af93b0b2f8d282470f447decc419ede45051111d83cad1e2792982f6378ae71cf50f55af882c4d9d129b1fcc819dfb363259d62eeccfd3
data/CHANGELOG.textile CHANGED
@@ -1,5 +1,9 @@
1
1
  h1. CHANGELOG
2
2
 
3
+ h3. 0.2.0 May 1, 2014
4
+
5
+ * fixes for 'authorized' generator
6
+
3
7
  h3. 0.1.0 May 1, 2014
4
8
 
5
9
  * initial release
@@ -8,12 +8,15 @@ module Pages
8
8
  desc "Create pages to accompany a User model when authorization is available."
9
9
 
10
10
  def create_page
11
+ ### assumes we are using Devise for authentication
12
+ ### assumes we are using Pundit for authorization
11
13
  copy_file 'users/_user.html.erb', 'app/views/users/_user.html.erb'
12
14
  copy_file 'users/index.html.erb', 'app/views/users/index.html.erb'
13
15
  copy_file 'users/show.html.erb', 'app/views/users/show.html.erb'
14
16
  copy_file 'users_controller.rb', 'app/controllers/users_controller.rb'
17
+ copy_file 'user_policy.rb', 'app/policies/user_policy.rb'
15
18
  route = ' resources :users'
16
- inject_into_file 'config/routes.rb', route + "\n", :before => "end"
19
+ inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
17
20
  copy_file 'visitors/index.html.erb', 'app/views/visitors/index.html.erb'
18
21
  copy_file 'visitors_controller.rb', 'app/controllers/visitors_controller.rb'
19
22
  route = ' root :to => "visitors#index"'
@@ -0,0 +1,21 @@
1
+ class UserPolicy
2
+ attr_reader :user, :record
3
+
4
+ def initialize(user, record)
5
+ @user = user
6
+ @record = record
7
+ end
8
+
9
+ def index?
10
+ @user.admin?
11
+ end
12
+
13
+ def update?
14
+ @user.admin?
15
+ end
16
+
17
+ def destroy?
18
+ @user.admin?
19
+ end
20
+
21
+ end
@@ -8,12 +8,13 @@ module Pages
8
8
  desc "Create pages to accompany a User model when authentication is available."
9
9
 
10
10
  def create_page
11
+ ### assumes we are using Devise for authentication
11
12
  copy_file 'users/_user.html.erb', 'app/views/users/_user.html.erb'
12
13
  copy_file 'users/index.html.erb', 'app/views/users/index.html.erb'
13
14
  copy_file 'users/show.html.erb', 'app/views/users/show.html.erb'
14
15
  copy_file 'users_controller.rb', 'app/controllers/users_controller.rb'
15
16
  route = ' resources :users'
16
- inject_into_file 'config/routes.rb', route + "\n", :before => "end"
17
+ inject_into_file 'config/routes.rb', route + "\n", :after => "devise_for :users\n"
17
18
  copy_file 'visitors/index.html.erb', 'app/views/visitors/index.html.erb'
18
19
  copy_file 'visitors_controller.rb', 'app/controllers/visitors_controller.rb'
19
20
  route = ' root :to => "visitors#index"'
@@ -1,3 +1,3 @@
1
1
  module RailsAppsPages
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_apps_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Kehoe
@@ -57,6 +57,7 @@ files:
57
57
  - lib/generators/clean/gemfile_generator.rb
58
58
  - lib/generators/clean/routes_generator.rb
59
59
  - lib/generators/pages/authorized/authorized_generator.rb
60
+ - lib/generators/pages/authorized/templates/user_policy.rb
60
61
  - lib/generators/pages/authorized/templates/users/_user.html.erb
61
62
  - lib/generators/pages/authorized/templates/users/index.html.erb
62
63
  - lib/generators/pages/authorized/templates/users/show.html.erb