mistiq 0.0.86 → 0.0.87

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWQxMTc1YjE2OTNjODliYjI4NWFkODIzNDExZDkwMmNiNWQ5NGUyNg==
4
+ NTNiMWMxZWQxNmViNzAwOTc0OTc1NjMzNDAyMmM5ZWQzOWNjMTgzMQ==
5
5
  data.tar.gz: !binary |-
6
- ZjY4ZDNiMWY4MzY4NTllZjFjM2ZlZWNlNWZkMjcxNjgyNGY4NDkwYw==
6
+ OGNmZGJkZjg0NDg3N2U4MDYwNmVhYjI5NzFhODkyYmIzZWU2NDhlZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmVlYzQ0NGE2MzAzNTdmMzE4MzcwODAzYzEzNmFkNDFhZWEyZDM2NzA0Y2Qx
10
- Y2JlNDNhN2E3OGJhMjI4NDI5NDhjZTZhNWQ1YTc2MTczZjA1MDE2N2U4ZTNi
11
- YzYzY2M0NTQwY2U3OWI3NzMzMjgwYzgzNmQ3ZDUyNDE2MzYyNTY=
9
+ MWVmNGM1ZDZlMDdhNzU5NmU1MzNiNGYyNTEwMzk2ODc5N2JkMTU5MDk4OTAw
10
+ YzQzNzA4NTIzYzcwMTBjNDE4MGUyZWNjYmZjNWM4ZTI1NjkwY2UyMzQ3YzZk
11
+ MzAzYzc5ZmQyNjA5NzM1NmI1YTM2YThhYTkyYWNhNzQxMDU4MDI=
12
12
  data.tar.gz: !binary |-
13
- MmMyYzVlYmQ0ZGZhOWJmMGI3ODAwOTZiMTRmYjA5YjM2MGIyZDUwMjgwNzNi
14
- MzUzMjIyNzkyZjA3NzcyNGExNzQ4MTVmMDM1MWQzNzgwNWM1MDA5ZTgzZjBm
15
- NmE1YmQxZDQ1N2Q3NzhlMDQ3ZDU5NjVkZjkyMDQzMDg0ODc5YzY=
13
+ ZjRkZGJhMTA0Y2UyYTdjNmM3MzA1NTMyNWI0ZGM0NDEwNTQ3OTc4ZDUyOTQ0
14
+ NTMwMTM1MTExMDRmY2RkYmViMWY4MWY0MjI5MTM1ODlkZjk4MGVhZDFiN2Uz
15
+ YmY5N2I1YmY5ZDE1ZjI4MTJkNzM1MDZjMzI0MjM0NGIyNmJkYzk=
data/lib/mistiq.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'mistiq/base'
2
+ require 'mistiq/defaults'
2
3
  require 'mistiq/init' if defined? Rails
3
4
  require 'mistiq/middleware' if defined? Rails
data/lib/mistiq/base.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  module Mistiq
2
- def self.included(base)
3
- #base.send(:before_filter, :set_guard_on)
4
- end
5
-
6
2
  def initialize
7
3
  super
8
4
  @mode_class = self.class
@@ -41,7 +37,7 @@ module Mistiq
41
37
  #only disable view if the current controller
42
38
  #and view are the ones that need to be disabled
43
39
  if(current_controller == pair_array[0] && current_action == pair_array[1])
44
- disable(pair_array[0],pair_array[1],pair[2])
40
+ disable(pair_array[0],pair_array[1])
45
41
  else
46
42
  remove_links(pair_array[0],pair_array[1])
47
43
  end
@@ -50,29 +46,20 @@ module Mistiq
50
46
  end
51
47
 
52
48
  #add a new rule to look out for
53
- #takes in an optional parameter for the view to
54
- #be rendered in place of the current one
55
- def set_guard_rule(condition, consequence, alternate_view='denied')
56
- pair = [condition,consequence,alternate_view]
49
+ def set_guard_rule(condition, consequence)
50
+ pair = [condition,consequence]
57
51
  @@rules["#{@@count+=1}"] = pair
58
52
 
59
- puts "New rule has been added: #{consequence}, render #{alternate_view}"
53
+ puts "New rule has been added: #{consequence}"
60
54
  end
61
55
 
62
56
  private
63
57
 
64
58
  #disable both the view and the action (links for the action in other views)
65
- def disable(controller,action,alternate_view)
66
- #disable_view(controller,action,alternate_view)
59
+ def disable(controller,action)
67
60
  disable_action(controller,action)
68
61
  remove_links(controller,action)
69
62
  end
70
-
71
- #disable the view when url is requested
72
- def disable_view(controller,action,alternate_view)
73
- render :text => action, :layout => alternate_view
74
- puts "Disabled view for action #{action}, controller #{controller}"
75
- end
76
63
 
77
64
  #disable access to the action/controller by rerouting
78
65
  def disable_action(controller,action)
@@ -1,24 +1,38 @@
1
1
  module Mistiq
2
- def self.included(base)
3
- #base.send(:before_filter, :set_guard_on)
2
+ #disable all 'action' operations across
3
+ #the rails application
4
+ def disable_action_ops(action)
5
+ Railtie.get_regex_hash.each {
6
+ |r,p|
7
+ set_guard_rule(true,r) if r.match(/.*#{action}/)
8
+ }
4
9
  end
5
-
6
- def initialize
7
- super
8
- @mode_class = self.class
9
- #create hash of keys and condition/consequence pairs
10
+
11
+ #disable all destroy operations across
12
+ #the rails application
13
+ def disable_create_ops()
14
+ Railtie.get_regex_hash.each {
15
+ |r,p|
16
+ set_guard_rule(true,r) if r.match(/.*#add/) || r.match(/.*#create/) || r.match(/.*#new/)
17
+ }
18
+ end
19
+
20
+ #disable all edit operations across
21
+ #the rails application
22
+ def disable_update_ops()
23
+ Railtie.get_regex_hash.each {
24
+ |r,p|
25
+ set_guard_rule(true,r) if r.match(/.*#edit/) || r.match(/.*#update/)
26
+ puts p
27
+ }
10
28
  end
11
-
12
- #add a new rule to look out for
13
- #takes in an optional parameter for the view to
14
- #be rendered in place of the current one
15
- def disable_edit_ops()
29
+
30
+ #disable all destroy operations across
31
+ #the rails application
32
+ def disable_destroy_ops()
16
33
  Railtie.get_regex_hash.each {
17
- |r|
18
- if(r.match(/.*#edit/))
19
- ENV['REGEX'] += Railtie.get_regex_hash[to_disable]+"@@@"
34
+ |r,p|
35
+ set_guard_rule(true,r) if r.match(/.*#destroy/) || r.match(/.*#delete/) || r.match(/.*#remove/)
20
36
  }
21
- #ENV['REGEX'] += Railtie.get_regex_hash[to_disable]+"@@@"
22
- puts "All edit operations have been disabled."
23
37
  end
24
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mistiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.86
4
+ version: 0.0.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Papancea
@@ -45,5 +45,6 @@ rubyforge_project:
45
45
  rubygems_version: 2.1.5
46
46
  signing_key:
47
47
  specification_version: 3
48
- summary: Dynamically restrict access to your Rails application
48
+ summary: Dynamically restrict access to your Rails application and while automatically
49
+ adjusting the view of your application.
49
50
  test_files: []