CanCanCanSee 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b8f8d1d948b2f9e478567e0dd3d5232b780bad1
4
+ data.tar.gz: facb4a6ec257267d28861a77215b8a9309510e06
5
+ SHA512:
6
+ metadata.gz: 72e91981291c0983e05c0583d758646490401194a4e6bebbafedac0dd3b159ea282636828f4917213a08250a08052d7fb74dc4c1b93ef461fa88251fdab6fc5e
7
+ data.tar.gz: 95d69df88461a1aadf7a68c37331a6c7534d200e8a574bc53b12792530ff19a1bf89d2b96de5fa335cb0685ca4cb15ab392d64297a7c0bf6236fa06829006dc7
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at nicholas.schwaderer@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'CanCanCanSee/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "CanCanCanSee"
8
+ spec.version = CanCanCanSee::VERSION
9
+ spec.authors = ["Nick Schwaderer"]
10
+ spec.email = ["nicholas.schwaderer@gmail.com"]
11
+
12
+ spec.summary = %q{Allows user to access read-only list of roles and abilities in controller and view}
13
+ spec.description = %q{Allows user to access read-only list of roles and abilities in controller and vie}
14
+ spec.homepage = "https://github.com/schwad/cancancansee"
15
+ spec.license = "SCHWAD LICENSE"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "pry", "~> 0.10.3"
34
+
35
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in CanCanCanSee.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,26 @@
1
+ The SCHWAD License (SCHWAD)
2
+
3
+ Copyright (c) 2016 Nick Schwaderer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ 1. The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ 2. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ 3. This software shall not be used in any way to violate Isaac Asimov's "Three Laws of Robotics"
24
+
25
+ 4. This software shall not be used by any organizations, corporations or entities that have violated
26
+ Isaac Asimov's "Three Laws of Robotics" with other products or actions.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # CanCanCanSee
2
+
3
+ #THIS GEM IS IN DEVELOPMENT AND NOT RUNNING YET
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'CanCanCanSee'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install CanCanCanSee
20
+
21
+ ## Usage
22
+
23
+ N/A
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/schwad/CanCanCanSee. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [SCHWAD License](https://github.com/schwad/cancancansee/LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "CanCanCanSee"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module CanCanCanSee
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,176 @@
1
+ require "CanCanCanSee/version"
2
+
3
+ module CanCanCanSee
4
+
5
+ MY_GLOBAL_HOLDER_OF_ABILITY = Hash.new
6
+
7
+ def self.initiate_gem
8
+
9
+ user_answer = "none"
10
+
11
+ while user_answer.downcase != "single" && user_answer.downcase != "multiple"
12
+ # puts "Single or multiple ability file?"
13
+ user_answer = "multiple"
14
+ end
15
+
16
+ type = user_answer
17
+
18
+
19
+ if type == "single"
20
+
21
+ my_file = File.read('app/models/ability.rb') # for single
22
+ read_file(my_file)
23
+
24
+ elsif type == "multiple"
25
+
26
+ my_arr = []
27
+
28
+ Dir.foreach('lib/ability_slugs') do |item|
29
+ if item == "." || item == ".."
30
+ else
31
+ my_file = File.read("lib/ability_slugs/#{item}")
32
+ #formatting keeps the helper file from being read here
33
+ if my_file[0..6] == 'require'
34
+ else
35
+ my_arr << my_file
36
+ end
37
+ end
38
+ end
39
+
40
+ my_arr.each do |file|
41
+ #MULTIPLES FILES WILL NEED TO BE FORMATTED WITH SLUG IN DEF MY_SLUG_ABILITY
42
+ check_slug = /def (.*)_ability/.match(file)[1]
43
+ read_file(file, check_slug)
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ def self.read_file(file, check_slug=nil)
50
+
51
+
52
+ @current_file = file
53
+
54
+ #capture in between text
55
+ chunk_start = /when/ =~ @current_file
56
+ #=> 119
57
+ chunk_end = /when/ =~ @current_file[(chunk_start + 1)..-1]
58
+ #=> 2554
59
+ role_text = @current_file[chunk_start..chunk_end]
60
+
61
+ #capture all roles
62
+ all_text = Hash.new
63
+ counter = 0
64
+ roles = @current_file.scan(/when(.*)($|[ do])/)
65
+ roles.map! { |item| item.to_s.gsub(/[^0-9a-z ]/i, '') }
66
+ roles.map! { |item| item[1..-1]}
67
+
68
+ role_count = roles.length
69
+ chunk_start = /when/ =~ @current_file
70
+ chunk_end = /when/ =~ @current_file[(chunk_start + 1)..-1]
71
+ all_text[roles[counter]] = @current_file[chunk_start..chunk_end]
72
+ counter += 1
73
+ while counter < role_count
74
+ chunk_start = chunk_end + 1
75
+ chunk_end = /when/ =~ @current_file[(chunk_start + 1)..-1]
76
+ all_text[roles[counter]] = @current_file[chunk_start..chunk_end]
77
+
78
+ counter += 1
79
+ end
80
+
81
+ #capture text of ability
82
+ # cannot_abilities = all_text[[" 'Assistant Registrar'"]].scan(/cannot(.*)($|[ do])/)
83
+ #=> [[" :create_csr, Vessel do |vessel|"], [" [:create, :destroy, :update], [SpecificCertificate, PortStateControl, Certificate, Violation,"], [" [:create, :destroy], Document do |d|"], [" :update, Document do |d|"], [" [:create], [GeneratedCertificates::GeneratedCertificate] do |b|"], [" :read, ExternalNotification do |e|"], [" :manual_verified, Vessel do |e|"], [" [:update], SpecificCertificate do |e|"], [" :manage_inspection_resources, Inspection do |inspection|"], [" [:update, :destroy], Vessel do |v|"], [" [:create], MinimumSafeManning do |msm|"], [" [:update], MinimumSafeManning do |msm|"], [" [:create], MlcShipowner do |ms|"], [" [:update, :destroy], MlcShipowner do |ms|"], [" :update_classification_society, Vessel"], [" :upload_original, [GeneratedCertificates::MlcCertificate, GeneratedCertificates::DocOfComplianceCertificate] do |c|"], [" :destroy, [GeneratedCertificates::MlcCertificate, GeneratedCertificates::DmlcCertificate] do |c|"]]
84
+ # can_abilities = all_text[[" 'Assistant Registrar'"]].scan(/can (.*)($|[ do])/)
85
+ #=> [[" :manage, :all"], [" :change_registry, Registry"], ["not :create_csr, Vessel do |vessel|"], ["not [:create, :destroy, :update], [SpecificCertificate, PortStateControl, Certificate, Violation,"], ["not [:create, :destroy], Document do |d|"], ["not :update, Document do |d|"], ["not [:create], [GeneratedCertificates::GeneratedCertificate] do |b|"], ["not :read, ExternalNotification do |e|"], ["not :manual_verified, Vessel do |e|"], ["not [:update], SpecificCertificate do |e|"], [" :manage, Registry do |r|"], [" :manage, [Inspection] do |res|"], ["not :manage_inspection_resources, Inspection do |inspection|"], [" :print_history, Vessel"], ["not [:update, :destroy], Vessel do |v|"], ["not [:create], MinimumSafeManning do |msm|"], ["not [:update], MinimumSafeManning do |msm|"], ["not [:create], MlcShipowner do |ms|"], ["not [:update, :destroy], MlcShipowner do |ms|"], ["not :update_classification_society, Vessel"], ["not :upload_original, [GeneratedCertificates::MlcCertificate, GeneratedCertificates::DocOfComplianceCertificate] do |c|"], ["not :destroy, [GeneratedCertificates::MlcCertificate, GeneratedCertificates::DmlcCertificate] do |c|"]]
86
+ #store in hash with array in can, array in cannot, array in an array if has condition in text.
87
+
88
+ new_counter = 0
89
+ if check_slug == nil
90
+
91
+ while new_counter < roles.length
92
+ MY_GLOBAL_HOLDER_OF_ABILITY[roles[new_counter]] = Hash.new
93
+
94
+ array_of_can = []
95
+
96
+ #establish can
97
+ can_abilities = all_text[roles[new_counter]].scan(/can (.*)($|[ do])/)
98
+
99
+ can_abilities.each do |can_ability|
100
+ can_ability = can_ability[0]
101
+ array_of_can << can_ability.gsub(/[^0-9a-z ]/i, '')
102
+ end
103
+
104
+ MY_GLOBAL_HOLDER_OF_ABILITY[roles[new_counter]]["can"] = array_of_can
105
+ array_of_cannot = []
106
+
107
+ #establish cannot
108
+ cannot_abilities = all_text[roles[new_counter]].scan(/cannot(.*)($|[ do])/)
109
+
110
+ cannot_abilities.each do |cannot_ability|
111
+ cannot_ability = cannot_ability[0]
112
+ array_of_cannot << cannot_ability.gsub(/[^0-9a-z ]/i, '')
113
+ end
114
+
115
+ MY_GLOBAL_HOLDER_OF_ABILITY[roles[new_counter]]["cannot"] = array_of_cannot
116
+
117
+
118
+ new_counter += 1
119
+
120
+ end
121
+ else
122
+
123
+ MY_GLOBAL_HOLDER_OF_ABILITY[check_slug] = Hash.new
124
+
125
+ while new_counter < roles.length
126
+
127
+ MY_GLOBAL_HOLDER_OF_ABILITY[check_slug][roles[new_counter]] = Hash.new
128
+
129
+ array_of_can = []
130
+
131
+ #establish can
132
+ can_abilities = all_text[roles[new_counter]].scan(/can (.*)($|[ do])/)
133
+
134
+ can_abilities.each do |can_ability|
135
+ can_ability = can_ability[0]
136
+ array_of_can << can_ability.gsub(/[^0-9a-z ]/i, '')
137
+ end
138
+
139
+ MY_GLOBAL_HOLDER_OF_ABILITY[check_slug][roles[new_counter]]["can"] = array_of_can
140
+ array_of_cannot = []
141
+
142
+ #establish cannot
143
+ cannot_abilities = all_text[roles[new_counter]].scan(/cannot(.*)($|[ do])/)
144
+
145
+ cannot_abilities.each do |cannot_ability|
146
+ cannot_ability = cannot_ability[0]
147
+ array_of_cannot << cannot_ability.gsub(/[^0-9a-z ]/i, '')
148
+ end
149
+
150
+ MY_GLOBAL_HOLDER_OF_ABILITY[check_slug][roles[new_counter]]["cannot"] = array_of_cannot
151
+
152
+
153
+ new_counter += 1
154
+
155
+ end
156
+ end
157
+ end
158
+
159
+ #public methods
160
+
161
+ def self.all_roles
162
+ initiate_gem
163
+ return MY_GLOBAL_HOLDER_OF_ABILITY.keys
164
+
165
+ end
166
+
167
+ def self.all_abilities(desired_slug="all")
168
+ initiate_gem
169
+ if desired_slug == "all"
170
+ return MY_GLOBAL_HOLDER_OF_ABILITY
171
+ else
172
+ return MY_GLOBAL_HOLDER_OF_ABILITY[desired_slug]
173
+ end
174
+ end
175
+
176
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CanCanCanSee
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Schwaderer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.3
69
+ description: Allows user to access read-only list of roles and abilities in controller
70
+ and vie
71
+ email:
72
+ - nicholas.schwaderer@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - CanCanCanSee.gemspec
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/CanCanCanSee.rb
89
+ - lib/CanCanCanSee/version.rb
90
+ homepage: https://github.com/schwad/cancancansee
91
+ licenses:
92
+ - SCHWAD LICENSE
93
+ metadata:
94
+ allowed_push_host: https://rubygems.org
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Allows user to access read-only list of roles and abilities in controller
115
+ and view
116
+ test_files: []