rails-canhaz 0.4.0 → 0.4.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.
data/README.md CHANGED
@@ -35,6 +35,12 @@ add_index :can_haz_permissions, :csubject_id, :name => 'subject_id_ix'
35
35
  add_index :can_haz_permissions, :cobject_id, :name => 'object_id_ix'
36
36
  ```
37
37
 
38
+ Or you can run this command to automatically create one:
39
+
40
+ ```
41
+ rails g can_haz:install
42
+ ```
43
+
38
44
  ## How to use it ?
39
45
 
40
46
  The rails-canhaz gem defines two static functions for ActiveRecord models which allow them to act as a subject or an object.
@@ -77,4 +83,11 @@ user.cannot!(:read, article)
77
83
 
78
84
  ```
79
85
 
80
- More coming soon ...
86
+ ## Changelog
87
+
88
+ * 0.4.0 :
89
+ * Aliasing can to can! and deprecating can
90
+ * Aliasing cannot to cannot! and deprecating cannot
91
+
92
+ * 0.3.0 :
93
+ * Removing rights from the database before destroying a subject or object model
@@ -0,0 +1,26 @@
1
+ module CanHaz
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc "Generates the default migrations for rails-canhaz"
5
+
6
+ include Rails::Generators::Migration
7
+
8
+ def self.source_root
9
+ @_can_haz_source_root ||= File.expand_path("../templates", __FILE__)
10
+ end
11
+
12
+ def self.next_migration_number(dirname)
13
+ Time.now.strftime("%Y%m%d%H%M%S")
14
+ end
15
+
16
+ def create_migrations
17
+ Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
18
+ name = File.basename(filepath)
19
+ migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
20
+ sleep 1
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ class DefaultCanHaz < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :can_haz_permissions do |t|
4
+ t.integer :csubject_id
5
+ t.string :csubject_type
6
+
7
+ t.integer :cobject_id
8
+ t.string :cobject_type
9
+
10
+ t.string :permission_name
11
+ end
12
+
13
+ add_index :can_haz_permissions, :csubject_id, :name => 'subject_id_ix'
14
+ add_index :can_haz_permissions, :cobject_id, :name => 'object_id_ix'
15
+ end
16
+
17
+ def self.down
18
+ drop_table :can_haz_permissions
19
+ end
20
+ end
data/rails-canhaz.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rails-canhaz'
3
- s.version = '0.4.0'
4
- s.date = '2012-05-30'
3
+ s.version = '0.4.1'
4
+ s.date = '2012-05-31'
5
5
  s.summary = "A simple gem for managing permissions between rails models"
6
6
  s.description = "A simple gem for managing permissions between rails models"
7
7
  s.authors = ["Adrien Siami (Intrepidd)"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-canhaz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -37,6 +37,8 @@ files:
37
37
  - Gemfile
38
38
  - README.md
39
39
  - Rakefile
40
+ - lib/generators/can_haz/install/install_generator.rb
41
+ - lib/generators/can_haz/install/templates/migrations/1_default_can_haz.rb
40
42
  - lib/rails-canhaz.rb
41
43
  - lib/rails-canhaz/canhaz_permission.rb
42
44
  - lib/rails-canhaz/exceptions.rb