cantango-core 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cantango-core"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup", "Stanislaw Pankevich"]
@@ -56,13 +56,6 @@ Gem::Specification.new do |s|
56
56
  "lib/cantango/macros/user.rb",
57
57
  "lib/cantango/model.rb",
58
58
  "lib/cantango/model/guest.rb",
59
- "lib/cantango/rails.rb",
60
- "lib/cantango/rails/engine.rb",
61
- "lib/cantango/rails/helpers/base_helper.rb",
62
- "lib/cantango/rails/helpers/controller_helper.rb",
63
- "lib/cantango/rails/helpers/rest_helper.rb",
64
- "lib/cantango/rails/helpers/view_helper.rb",
65
- "lib/cantango/rails/railtie.rb",
66
59
  "lib/cantango/rspec.rb",
67
60
  "lib/cantango/rspec/config.rb",
68
61
  "lib/cantango/rspec/matchers.rb",
data/lib/cantango/core.rb CHANGED
@@ -20,7 +20,7 @@ AutoLoader.namespaces = {:CanTango => 'cantango'}
20
20
  module CanTango
21
21
  autoload_modules :Ability, :Engine, :Filter
22
22
  autoload_modules :Helpers, :Loader, :Macros, :Model
23
- autoload_modules :Rails, :Rules, :Scope
23
+ autoload_modules :Rules, :Scope
24
24
 
25
25
  class << self
26
26
  def configure &block
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cantango-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2011-11-25 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &895827720 !ruby/object:Gem::Requirement
17
+ requirement: &881856320 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *895827720
25
+ version_requirements: *881856320
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: cancan
28
- requirement: &895827350 !ruby/object:Gem::Requirement
28
+ requirement: &881855990 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *895827350
36
+ version_requirements: *881855990
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sugar-high
39
- requirement: &895827050 !ruby/object:Gem::Requirement
39
+ requirement: &881855650 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.6.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *895827050
47
+ version_requirements: *881855650
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: sweetloader
50
- requirement: &895826690 !ruby/object:Gem::Requirement
50
+ requirement: &881855280 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.1.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *895826690
58
+ version_requirements: *881855280
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: hashie
61
- requirement: &895826120 !ruby/object:Gem::Requirement
61
+ requirement: &881854930 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *895826120
69
+ version_requirements: *881854930
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-rails
72
- requirement: &895825430 !ruby/object:Gem::Requirement
72
+ requirement: &881854480 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 2.6.1
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *895825430
80
+ version_requirements: *881854480
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: forgery
83
- requirement: &895824780 !ruby/object:Gem::Requirement
83
+ requirement: &881853830 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0.3'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *895824780
91
+ version_requirements: *881853830
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: factory_girl
94
- requirement: &895824040 !ruby/object:Gem::Requirement
94
+ requirement: &881853470 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *895824040
102
+ version_requirements: *881853470
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: sqlite3
105
- requirement: &895823270 !ruby/object:Gem::Requirement
105
+ requirement: &881853030 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *895823270
113
+ version_requirements: *881853030
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rspec
116
- requirement: &895822590 !ruby/object:Gem::Requirement
116
+ requirement: &881852620 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 2.6.0
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *895822590
124
+ version_requirements: *881852620
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: jeweler
127
- requirement: &895821960 !ruby/object:Gem::Requirement
127
+ requirement: &881852060 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: 1.6.4
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *895821960
135
+ version_requirements: *881852060
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: bundler
138
- requirement: &895821430 !ruby/object:Gem::Requirement
138
+ requirement: &881851460 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ! '>='
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: 1.1.rc
144
144
  type: :development
145
145
  prerelease: false
146
- version_requirements: *895821430
146
+ version_requirements: *881851460
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: rdoc
149
- requirement: &895820740 !ruby/object:Gem::Requirement
149
+ requirement: &881850810 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ! '>='
@@ -154,10 +154,10 @@ dependencies:
154
154
  version: '0'
155
155
  type: :development
156
156
  prerelease: false
157
- version_requirements: *895820740
157
+ version_requirements: *881850810
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: rake
160
- requirement: &895809210 !ruby/object:Gem::Requirement
160
+ requirement: &881850390 !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
163
  - - ! '>='
@@ -165,7 +165,7 @@ dependencies:
165
165
  version: 0.9.2.2
166
166
  type: :development
167
167
  prerelease: false
168
- version_requirements: *895809210
168
+ version_requirements: *881850390
169
169
  description: ! 'Define your permission rules as role- or role group specific permits.
170
170
 
171
171
  Integrates well with multiple Devise user acounts.
@@ -219,13 +219,6 @@ files:
219
219
  - lib/cantango/macros/user.rb
220
220
  - lib/cantango/model.rb
221
221
  - lib/cantango/model/guest.rb
222
- - lib/cantango/rails.rb
223
- - lib/cantango/rails/engine.rb
224
- - lib/cantango/rails/helpers/base_helper.rb
225
- - lib/cantango/rails/helpers/controller_helper.rb
226
- - lib/cantango/rails/helpers/rest_helper.rb
227
- - lib/cantango/rails/helpers/view_helper.rb
228
- - lib/cantango/rails/railtie.rb
229
222
  - lib/cantango/rspec.rb
230
223
  - lib/cantango/rspec/config.rb
231
224
  - lib/cantango/rspec/matchers.rb
@@ -294,7 +287,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
287
  version: '0'
295
288
  segments:
296
289
  - 0
297
- hash: 979131823
290
+ hash: -209669203
298
291
  required_rubygems_version: !ruby/object:Gem::Requirement
299
292
  none: false
300
293
  requirements:
@@ -1,63 +0,0 @@
1
- module CanTango
2
- # Include helpers in the given scope to AC and AV.
3
- # "Borrowed" from devise
4
- def self.include_helpers(scope)
5
- # Seems like the order of initializers is important! ActiveRecord should go first!
6
- ActiveSupport.on_load(:active_record) do
7
- RailsAutoLoader.load_models! if CanTango.config.autoload.models?
8
- end
9
-
10
- ActiveSupport.on_load(:action_controller) do
11
- include scope::Rails::Helpers::ControllerHelper
12
- end
13
-
14
- ActiveSupport.on_load(:action_view) do
15
- include scope::Rails::Helpers::ViewHelper
16
- end
17
- end
18
-
19
- # http://edgeguides.rubyonrails.org/configuring.html
20
- # - before_configuration: This is run as soon as the application constant inherits from Rails::Application. The config calls are evaluated before this happens.
21
- # - before_initialize: This is run directly before the initialization process of the application occurs with the :bootstrap_hook initializer near the beginning of the Rails initialization process.
22
- # - to_prepare: Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built. More importantly, will run upon every request in development, but only once (during boot-up) in production and test.
23
- # - before_eager_load: This is run directly before eager loading occurs, which is the default behaviour for the production environment and not for the development environment.
24
- # - after_initialize: Run directly after the initialization of the application, but before the application initializers are run.
25
- class RailsEngine < ::Rails::Engine
26
- initializer "cantango.helpers" do
27
- CanTango.include_helpers(CanTango)
28
-
29
- # load all models
30
- # this is needed in order to register all users and accounts with CanTango using the user/account macros!
31
- end
32
-
33
- config.to_prepare do
34
- CanTango.to_prepare
35
-
36
- # load all permits (development mode: EVERY request!)
37
- RailsAutoLoader.load_permits! if CanTango.config.autoload.permits?
38
- end
39
-
40
- config.after_initialize do
41
- CanTango.after_initialize
42
- end
43
- end
44
-
45
- module RailsAutoLoader
46
- def self.load_models!
47
- load_files! :models
48
- end
49
-
50
- def self.load_permits!
51
- load_files! :permits
52
- end
53
-
54
- private
55
-
56
- def self.load_files! path
57
- Dir[::Rails.root + "app/#{path}/**/*.rb"].each do |path|
58
- require_dependency path
59
- end
60
- end
61
- end
62
- end
63
-
@@ -1,29 +0,0 @@
1
- module CanTango
2
- module Rails
3
- module Helpers
4
- module BaseHelper
5
- def self.included(base)
6
- include_apis(base)
7
- # base.send :include, CanTango::Rails::Helpers::RestHelper
8
- base.extend ClassMethods
9
- end
10
-
11
- module ClassMethods
12
- def include_apis(clazz)
13
- return if !respond_to?(:apis) || !apis
14
- apis.each do |api|
15
- # puts "include API: #{api}"
16
- clazz.send :include, "CanTango::Api::User::#{api}".constantize
17
- clazz.send :include, "CanTango::Api::UserAccount::#{api}".constantize
18
- end
19
- end
20
-
21
- def apis
22
- [:Can, :Scope, :Ability, :Session]
23
- end
24
- end
25
- extend ClassMethods
26
- end
27
- end
28
- end
29
- end
@@ -1,17 +0,0 @@
1
- module CanTango
2
- module Rails
3
- module Helpers
4
- module ControllerHelper
5
- include CanTango::Rails::Helpers::BaseHelper
6
-
7
- def self.included(base)
8
- include_apis(self)
9
- end
10
-
11
- def self.apis
12
- [] # [:Can, :Active, :Scope]
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,76 +0,0 @@
1
- module CanTango::Rails::Helpers::RestHelper
2
- CanTango.config.models.actions.registered.each_pair do |model, actions|
3
- actions.actions_for :member do |member_action|
4
- class_eval %{
5
- def #{member_action}_#{model.to_s.underscore}_path obj, options = {}
6
- return unless can_perform_action?(user_type, :#{member_action}, obj)
7
- # use i18n translation on label
8
- link_to t(".#{member_action}"), rest_obj_action(obj, :#{member_action}, options)
9
- end
10
- }
11
- end
12
-
13
- actions.actions_for :collection do |collection_action|
14
- class_eval %{
15
- def #{collection_action}_#{model.to_s.underscore}_path obj, options = {}
16
- clazz = obj.kind_of?(Class) ? obj : obj.class
17
- return unless can_perform_action?(user_type, :#{collection_action}, clazz)
18
- # use i18n translation on label
19
- link_to t(".#{collection_action}"), send(action_method clazz, :#{collection_action}, options)
20
- end
21
- }
22
- end
23
- end
24
-
25
- CanTango.config.models.available_models.each do |model|
26
- class_eval %{
27
- def delete_#{model.to_s.underscore}_path obj, options = {}
28
- #{model}_path obj, {:method => 'delete'}.merge(options)
29
- end
30
- }
31
- end
32
-
33
- def link_to_new obj, user_type, options = {}
34
- clazz = obj.kind_of?(Class) ? obj : obj.class
35
- return unless can_perform_action?(user_type, :create, clazz)
36
- # use i18n translation on label
37
- link_to t(".create"), send(action_method clazz, :new, options)
38
- end
39
-
40
- def link_to_delete obj, user_type, options = {}
41
- return unless can_perform_action?(user_type, :delete, obj)
42
- # use i18n translation on label
43
- link_to t(".delete"), rest_obj_action(obj, :delete, options)
44
- end
45
-
46
- def link_to_edit obj, user_type, options = {}
47
- return unless can_perform_action?(user_type, :edit, obj)
48
- # use i18n translation on label
49
- link_to t(".edit"), rest_obj_action(obj, :edit, options)
50
- end
51
-
52
- def link_to_view obj, user_type, options = {}
53
- return unless can_perform_action?(user_type, :view, obj)
54
- # use i18n translation on label
55
- link_to t(".view"), send(view_method(obj), obj, options)
56
- end
57
-
58
- protected
59
-
60
- def can_perform_action? user_type, action, obj
61
- send(:"#{user_type}_can?", action, obj)
62
- end
63
-
64
- def view_method obj
65
- "#{obj.class.to_s.underscore}_path"
66
- end
67
-
68
- def rest_obj_action obj, action, options
69
- send action_method(obj, :edit), obj, options
70
- end
71
-
72
- def action_method obj, action
73
- "#{action}_#{obj.class.to_s.underscore}_path"
74
- end
75
- end
76
-
@@ -1,17 +0,0 @@
1
- module CanTango
2
- module Rails
3
- module Helpers
4
- module ViewHelper
5
- include CanTango::Rails::Helpers::BaseHelper
6
-
7
- def self.included(base)
8
- include_apis(self)
9
- end
10
-
11
- def self.apis
12
- [] # [:Can, :Active, :Scope]
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,7 +0,0 @@
1
- module CanTango
2
- class Railtie < Rails::Railtie
3
- initializer "cantango" do |app|
4
- # puts "initializing CanTango..."
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module CanTango
2
- module Rails
3
- module Helpers
4
- autoload_modules :ControllerHelper, :ViewHelper, :BaseHelper, :RestHelper
5
- end
6
- end
7
- end