pbw 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDE5MzY0MTBlZjgxMjU3OGMxMGMwZTAzMzk4ZThlZmQ4ZGE3YjVhZg==
4
+ ZGY3YTY5ZTM0ZDc4OTQzNzQzM2UyNGU1ZjQzYTA3ZDljZTgyOGY2OA==
5
5
  data.tar.gz: !binary |-
6
- NWFlMzkxMjY1MDFjYzZiNjljYjU1MWZiN2JiZjhlYTgzZTcxNzk4YQ==
6
+ MTY3M2U0ODRmMGUwYjE4YTNlYTVkYWQ5ZjM1Yjg4N2ZhYmMyYzA2Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWNkMzU1NWIyMDEyYTg1YTY0OTQ1YTIzZWI3ZDAxNmVlYmM5ZTNiNTdjNjQy
10
- MDA3MWQ0Y2JlYzIyMTQzODRkZWJiNmI4ZmFmODAyYjI2MzNlNjRiMWExYzRm
11
- ZDJlMmJiNWM4MDczN2IxN2IzYmU4ZDI5YTg2ZDI2YmUxNDg3OWI=
9
+ MGU5MTEwNGNmMGNkNWI3YWY1OWVkMzBmY2ExZDRiNzRiMWIxMTcyZWMwNzkx
10
+ MzVlNTMwNWRlYzExOTk1N2Y3OGIyMDgyY2UzYzk4MThjZTgzZjk2ODM4NWRl
11
+ NTYyZmI2MDQ4MzdjMzA3NzJhOTIwNmYxNzZmMWMxODE5OTE4MzU=
12
12
  data.tar.gz: !binary |-
13
- NzI0YjMyZjI5ZWEzZGZjYWQ4NWQ3MThlMzQzM2VmMjI0NTU4ZGZlZjM2ZTUw
14
- NDM5Zjk4MDkzYTMwZDk2Zjg1MWY2Yzc0ZjNjYTAwNTdiM2EwODFkMzIwNmY0
15
- Y2Y0OTNhMDJjMjI2ODU3MzMyNDBmODkwY2NiOWEzMzdmNzQ5NGU=
13
+ NzYwZTRjY2FiMGM1Y2Y0YWJmMDM1MmE0ZmM4MzNmYjA5MGU3YWNjNWVmZDc1
14
+ ZTk0NjU5MWM4OGFhZjU0MDZlZjRjNmYyYTQ3NDQwMjRlYzFmZmMxOGYyMjVk
15
+ OWUwMjMwOTQ4ZTJkZDg3NTAwNTg4MTgzOTU0Y2MxNWZlYWVmOTU=
@@ -0,0 +1,13 @@
1
+ module Pbw
2
+ class RegistrationsController < Devise::RegistrationsController
3
+ after_filter :add_user, :only => [:create]
4
+
5
+ protected
6
+
7
+ def add_user
8
+ if resource.persisted?
9
+ Pbw::Engine.user_lifecycle_class.after_signup(resource)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Pbw
2
+ class SessionsController < Devise::SessionsController
3
+ after_filter :login_user, :only => [:create]
4
+
5
+ protected
6
+
7
+ def login_user
8
+ Pbw::Engine.user_lifecycle_class.after_signup(current_user)
9
+ end
10
+ end
11
+ end
@@ -3,7 +3,7 @@ require 'cancan'
3
3
  class Ability
4
4
  include CanCan::Ability
5
5
 
6
- MANAGED_CLASSES = [Area, Capability, Command, Constraint, Item, ItemContainer, ItemConversion, ItemTransfer, Process, Rule, Token, Trigger, User]
6
+ MANAGED_CLASSES = [Area, Capability, Command, Constraint, Item, ItemContainer, ItemConversion, Process, Rule, Token, Trigger, User]
7
7
 
8
8
  def initialize(user)
9
9
  user ||= User.new
@@ -8,10 +8,10 @@ module Pbw
8
8
 
9
9
  has_many :tokens
10
10
  has_many :item_containers
11
+ has_many :attached_processes
11
12
  has_and_belongs_to_many :constraints
12
13
  has_and_belongs_to_many :triggers
13
- has_and_belongs_to_many :attached_processes
14
-
14
+
15
15
  attr_accessible :name
16
16
 
17
17
  def self.viewable_by?(user, subject)
@@ -1,5 +1,5 @@
1
1
  module Pbw
2
- class AttachedProcess < Rule
2
+ class AttachedProcess
3
3
  belongs_to :token
4
4
  belongs_to :area
5
5
  belongs_to :process
@@ -7,7 +7,6 @@ module Pbw
7
7
  validates_uniqueness_of :name
8
8
 
9
9
  has_many :item_containers
10
- has_many :item_transfers
11
10
  has_many :item_conversions
12
11
 
13
12
  attr_accessible :name
@@ -83,7 +83,7 @@ module Pbw
83
83
  container = find_or_create_for_area(to, self.item, quantity)
84
84
  elsif to.class.ancestors.include?(Token)
85
85
  container = find_or_create_for_token(to, self.item, quantity)
86
- elsif to.class.ancestors.include?(User)
86
+ elsif to.class.ancestors.include?(Pbw::Engine.user_class)
87
87
  container = find_or_create_for_user(to, self.item, quantity)
88
88
  else
89
89
  return false
@@ -1,7 +1,7 @@
1
1
  module Pbw
2
2
  class Process < Rule
3
3
  has_many :triggers
4
- has_and_belongs_to_many :attached_processes
4
+ has_many :attached_processes
5
5
 
6
6
  def self.viewable_by?(user, subject)
7
7
  user.admin?
@@ -10,7 +10,7 @@ module Pbw
10
10
  has_and_belongs_to_many :capabilities
11
11
  has_and_belongs_to_many :constraints
12
12
  has_and_belongs_to_many :triggers
13
- has_and_belongs_to_many :attached_processes
13
+ has_many :attached_processes
14
14
  has_many :item_containers
15
15
 
16
16
  attr_accessible :name
data/config/routes.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  Pbw::Engine.routes.draw do
2
2
  devise_for :users, {
3
3
  class_name: 'Pbw::User',
4
+ controllers: { registrations: 'pbw/registrations', :sessions => 'pbw/sessions'},
4
5
  module: :devise
5
6
  }
6
7
  %W{areas capabilities constraints processes items tokens triggers commands}.each do |controller|
@@ -41,6 +41,14 @@ module Pbw
41
41
  def engine_layout
42
42
  template "application.html.erb", "app/views/pbw/layouts/application.html.erb"
43
43
  end
44
+
45
+ def pbw_config
46
+ template "pbw.rb", "config/initializers/pbw.rb"
47
+ end
48
+
49
+ def user_lifecycle
50
+ template "lifecycle.rb", "app/models/user/lifecycle.rb"
51
+ end
44
52
  end
45
53
  end
46
54
  end
@@ -0,0 +1,13 @@
1
+ module User
2
+ class Lifecycle
3
+
4
+ def self.after_signup(user)
5
+ # do anything that needs to happen immediately after a user signs up
6
+ end
7
+
8
+ def self.after_login(user)
9
+ # do anything that needs to happen immediately after a user logs in
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ Pbw.setup do |config|
2
+ # User lifecycle class
3
+ # default is generated class from rails g pbw:install
4
+ # if you use another class it needs to implement the following:
5
+ # def self.after_signup(user)
6
+ # # do anything that needs to happen immediately after a user signs up
7
+ # end
8
+ # def self.after_login(user)
9
+ # # do anything that needs to happen immediately after a user logs in
10
+ # end
11
+ config.user_lifecycle_class = User::Lifecycle
12
+ end
data/lib/pbw/engine.rb CHANGED
@@ -36,5 +36,13 @@ module Pbw
36
36
  def self.version
37
37
  Pbw::VERSION
38
38
  end
39
+
40
+ def self.user_lifecycle_class
41
+ self.config.user_lifecycle_class || User::Lifecycle
42
+ end
43
+ end
44
+
45
+ def self.setup
46
+ yield Engine.config
39
47
  end
40
48
  end
data/lib/pbw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pbw
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seyed P. Razavi
@@ -221,12 +221,12 @@ files:
221
221
  - app/controllers/pbw/constraints_controller.rb
222
222
  - app/controllers/pbw/item_containers_controller.rb
223
223
  - app/controllers/pbw/item_conversions_controller.rb
224
- - app/controllers/pbw/item_transfers_controller.rb
225
224
  - app/controllers/pbw/items_controller.rb
226
225
  - app/controllers/pbw/processes_controller.rb
226
+ - app/controllers/pbw/registrations_controller.rb
227
+ - app/controllers/pbw/sessions_controller.rb
227
228
  - app/controllers/pbw/tokens_controller.rb
228
229
  - app/controllers/pbw/triggers_controller.rb
229
- - app/controllers/pbw/user_tokens_controller.rb
230
230
  - app/helpers/pbw/application_helper.rb
231
231
  - app/models/pbw/ability.rb
232
232
  - app/models/pbw/area.rb
@@ -238,7 +238,6 @@ files:
238
238
  - app/models/pbw/item.rb
239
239
  - app/models/pbw/item_container.rb
240
240
  - app/models/pbw/item_conversion.rb
241
- - app/models/pbw/item_transfer.rb
242
241
  - app/models/pbw/process.rb
243
242
  - app/models/pbw/rule.rb
244
243
  - app/models/pbw/token.rb
@@ -266,6 +265,8 @@ files:
266
265
  - lib/generators/pbw/install/install_generator.rb
267
266
  - lib/generators/pbw/install/templates/app.coffee
268
267
  - lib/generators/pbw/install/templates/application.html.erb
268
+ - lib/generators/pbw/install/templates/lifecycle.rb
269
+ - lib/generators/pbw/install/templates/pbw.rb
269
270
  - lib/generators/pbw/install/USAGE
270
271
  - lib/generators/pbw/item/item_generator.rb
271
272
  - lib/generators/pbw/item/templates/index.erb
@@ -1,7 +0,0 @@
1
- module Pbw
2
- class ItemTransfersController < BaseModelsController
3
- def set_model_class
4
- self.model_class = ItemTransfer
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Pbw
2
- class UserTokensController < BaseModelsController
3
- def set_model_class
4
- self.model_class = UserToken
5
- end
6
- end
7
- end
@@ -1,25 +0,0 @@
1
- module Pbw
2
- class ItemTransfer
3
- include ::Mongoid::Document
4
- include ::Mongoid::Timestamps
5
- belongs_to :item
6
- field :from_class, :type => String
7
- field :to_class, :type => String
8
-
9
- def self.viewable_by?(user, subject)
10
- true
11
- end
12
-
13
- def self.creatable_by?(user, subject)
14
- user.admin?
15
- end
16
-
17
- def self.editable_by?(user, subject)
18
- user.admin?
19
- end
20
-
21
- def self.deletable_by?(user, subject)
22
- user.admin?
23
- end
24
- end
25
- end