mistiq 0.0.3 → 0.0.4

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
- N2ViOTRmYTg2NjU3YjRlOTU5ODRkODQwMjBmZjA2NzQ0Yjg5ZmIzZA==
4
+ NDI1MjA0MWNhZTAyZTI2M2JlNmZhNTdjODQzZDQ2OGIwNmE0ZDFjYw==
5
5
  data.tar.gz: !binary |-
6
- NTU1ODUyMGE0MjNjZDJlM2JiZjA5ZGU5MDIxZGRjMDkxZjQyYjljOQ==
6
+ NWJkYjNlOTUwY2Y5YzA3OTA4NDk3ZGI1YjEyNTdkYzBlNTJlNTRmZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmMyZGI4ZjBkNzdlNGVkYmU3ZjI1ZTZhZjMxYzAwMzhiNzg4YjdjY2VhMzNj
10
- Y2M4OGFhYjFhZjI1YjRlZTE4YjVlZTE3MzE4ZDBjMTRmNTYxOTJmYjRlOGNh
11
- YWI5YjE4MjE4ZTc2MDMwZDg1YzVkYjBlNWQzODFjNDc5MmI1NjM=
9
+ NWM4ZjFmYTBhZjFjNGJlMTVlMzAxNjljZTkyYjhhOGJjYTEyMGMwNmEwZmM1
10
+ MGNmODIzZTYwZWYyZWU5ZGEwMzkwMjEwZTQ1ZjhlMWIyMmNiYzA4MGUxMDMy
11
+ ZDMyMmJjZjlmNzhkNmQ1OTQ5Y2YyNzhmMGNlODliM2ZhYmYwOGQ=
12
12
  data.tar.gz: !binary |-
13
- YjJhZDg4NGE4YWY4ZjM1ZDg3Yzc3ZGM1OWY0NGE4NjdjNzkwYTQ2NjAxYTM3
14
- NmMzMjNjM2VmMzNmZWI1NDdjMTE4NGRjNGVkNDU0NWM1NGYwMDQ2YjliM2Q0
15
- NDkyMDYwMWE1MTcwMDA2OWQ3OWFiZWQ0NzUyYjhhOGU1YjJlNjg=
13
+ YTBjODRlYmNiZThmMDBhMzJkNzA0NWNhNmNkMmY3ZTBlNTEyN2E5YTA0MTAx
14
+ NmUzYzM0MDUzN2MzZWUxMGUyNmI1NGYyZmIwNzY0NjAwMDYxMmFkNDIxY2E3
15
+ ODhjODFiMDQ3NjUxYzI0YjA3OTZmYjIwMmVhOTc3ZTkwZWZkZmQ=
data/bin/rails/init.rb ADDED
@@ -0,0 +1,51 @@
1
+ Rails.application.config.after_initialize do
2
+ LINK_REGEX_HASH = Hash.new
3
+
4
+ #pre-load routes
5
+ Rails.application.reload_routes!
6
+
7
+ #get routes
8
+ routes = Rails.application.routes.routes
9
+
10
+ routes.each {
11
+ |r|
12
+ controller = r.defaults[:controller]
13
+ action = r.defaults[:action]
14
+
15
+ route = r.path.spec.to_s
16
+
17
+ #removes (.:format)
18
+ if route.match("(.:format)")
19
+ pattern = route.sub("(.:format)","")
20
+ else
21
+ pattern = route
22
+ end
23
+
24
+ #if there are any parameters in
25
+ #the route use regex to ignore them
26
+ if pattern.match(/(:.*\/)/)
27
+ pattern.gsub!(/(:.*\/)/,".*/")
28
+ end
29
+
30
+ #if there is a parameter at the end
31
+ if pattern.match(/(:.*)/)
32
+ pattern.gsub!(/(:.*)/,"[^\/\"]*")
33
+ end
34
+
35
+ if action == "destroy"
36
+ destroy_regex = "data-method=(\"|')delete(\"|')";
37
+ pattern = "<a.*#{destroy_regex}.*href=(\"|')#{pattern}(\"|').*>.*<\/a>"
38
+ #also check if destroy_regex occurs after the href attribute
39
+ pattern = pattern+"@@@<a.*href=(\"|')#{pattern}(\"|').*#{destroy_regex}.*>.*<\/a>"
40
+ else
41
+ pattern = "<a.*href=(\"|')#{pattern}(\"|').*>.*<\/a>"
42
+ end
43
+
44
+ #espace / characters
45
+ pattern.gsub!(/\//,"\\/")
46
+
47
+ LINK_REGEX_HASH["#{controller}##{action}"] = pattern
48
+ }
49
+
50
+ puts "Link REGEX hash has been computed"
51
+ end
data/lib/mistiq.rb CHANGED
@@ -1,2 +1 @@
1
- require 'mistiq/base'
2
- require 'mistiq/security'
1
+ require 'mistiq/base'
data/lib/mistiq/base.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Mistiq
2
- SITE_URL = "http://www.andreidesign.com"
2
+ include Security
3
+ puts "Mistiq has been loaded"
3
4
  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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Papancea
@@ -9,21 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-10-03 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: cancan
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ! '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
12
+ dependencies: []
27
13
  description: Dynamically restrict access to your Rails application
28
14
  email: alp2200@columbia.edu
29
15
  executables: []
@@ -36,6 +22,7 @@ files:
36
22
  - lib/mistiq/redactor.rb
37
23
  - lib/mistiq/security.rb
38
24
  - bin/mistiq
25
+ - bin/rails/init.rb
39
26
  - test/test_mistiq.rb
40
27
  homepage:
41
28
  licenses: []