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 +8 -8
- data/app/controllers/pbw/registrations_controller.rb +13 -0
- data/app/controllers/pbw/sessions_controller.rb +11 -0
- data/app/models/pbw/ability.rb +1 -1
- data/app/models/pbw/area.rb +2 -2
- data/app/models/pbw/attached_process.rb +1 -1
- data/app/models/pbw/item.rb +0 -1
- data/app/models/pbw/item_container.rb +1 -1
- data/app/models/pbw/process.rb +1 -1
- data/app/models/pbw/token.rb +1 -1
- data/config/routes.rb +1 -0
- data/lib/generators/pbw/install/install_generator.rb +8 -0
- data/lib/generators/pbw/install/templates/lifecycle.rb +13 -0
- data/lib/generators/pbw/install/templates/pbw.rb +12 -0
- data/lib/pbw/engine.rb +8 -0
- data/lib/pbw/version.rb +1 -1
- metadata +5 -4
- data/app/controllers/pbw/item_transfers_controller.rb +0 -7
- data/app/controllers/pbw/user_tokens_controller.rb +0 -7
- data/app/models/pbw/item_transfer.rb +0 -25
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGY3YTY5ZTM0ZDc4OTQzNzQzM2UyNGU1ZjQzYTA3ZDljZTgyOGY2OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTY3M2U0ODRmMGUwYjE4YTNlYTVkYWQ5ZjM1Yjg4N2ZhYmMyYzA2Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGU5MTEwNGNmMGNkNWI3YWY1OWVkMzBmY2ExZDRiNzRiMWIxMTcyZWMwNzkx
|
10
|
+
MzVlNTMwNWRlYzExOTk1N2Y3OGIyMDgyY2UzYzk4MThjZTgzZjk2ODM4NWRl
|
11
|
+
NTYyZmI2MDQ4MzdjMzA3NzJhOTIwNmYxNzZmMWMxODE5OTE4MzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
data/app/models/pbw/ability.rb
CHANGED
@@ -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,
|
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
|
data/app/models/pbw/area.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
14
|
+
|
15
15
|
attr_accessible :name
|
16
16
|
|
17
17
|
def self.viewable_by?(user, subject)
|
data/app/models/pbw/item.rb
CHANGED
@@ -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?(
|
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
|
data/app/models/pbw/process.rb
CHANGED
data/app/models/pbw/token.rb
CHANGED
@@ -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
|
-
|
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
data/lib/pbw/version.rb
CHANGED
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.
|
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,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
|