consul 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of consul might be problematic. Click here for more details.

Files changed (42) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +1 -0
  3. data/README.md +6 -4
  4. data/Rakefile +15 -6
  5. data/consul.gemspec +1 -1
  6. data/lib/consul/util.rb +20 -4
  7. data/lib/consul/version.rb +1 -1
  8. data/spec/rails-2.3/Gemfile.lock +3 -3
  9. data/spec/rails-3.0/Gemfile.lock +3 -3
  10. data/spec/rails-3.2/Gemfile.lock +3 -3
  11. data/spec/rails-4.1/.rspec +2 -0
  12. data/spec/rails-4.1/Gemfile +12 -0
  13. data/spec/rails-4.1/Gemfile.lock +134 -0
  14. data/spec/rails-4.1/Rakefile +12 -0
  15. data/spec/rails-4.1/app_root/.gitignore +16 -0
  16. data/spec/rails-4.1/app_root/bin/bundle +3 -0
  17. data/spec/rails-4.1/app_root/bin/rails +8 -0
  18. data/spec/rails-4.1/app_root/bin/rake +8 -0
  19. data/spec/rails-4.1/app_root/bin/spring +18 -0
  20. data/spec/rails-4.1/app_root/config/application.rb +28 -0
  21. data/spec/rails-4.1/app_root/config/boot.rb +4 -0
  22. data/spec/rails-4.1/app_root/config/database.yml +4 -0
  23. data/spec/rails-4.1/app_root/config/environment.rb +5 -0
  24. data/spec/rails-4.1/app_root/config/environments/development.rb +37 -0
  25. data/spec/rails-4.1/app_root/config/environments/production.rb +83 -0
  26. data/spec/rails-4.1/app_root/config/environments/test.rb +39 -0
  27. data/spec/rails-4.1/app_root/config/initializers/backtrace_silencers.rb +7 -0
  28. data/spec/rails-4.1/app_root/config/initializers/cookies_serializer.rb +3 -0
  29. data/spec/rails-4.1/app_root/config/initializers/filter_parameter_logging.rb +4 -0
  30. data/spec/rails-4.1/app_root/config/initializers/inflections.rb +16 -0
  31. data/spec/rails-4.1/app_root/config/initializers/mime_types.rb +4 -0
  32. data/spec/rails-4.1/app_root/config/initializers/session_store.rb +3 -0
  33. data/spec/rails-4.1/app_root/config/initializers/wrap_parameters.rb +14 -0
  34. data/spec/rails-4.1/app_root/config/locales/en.yml +23 -0
  35. data/spec/rails-4.1/app_root/config/routes.rb +3 -0
  36. data/spec/rails-4.1/app_root/config/secrets.yml +22 -0
  37. data/spec/rails-4.1/log/test.log +0 -0
  38. data/spec/rails-4.1/rcov.opts +2 -0
  39. data/spec/rails-4.1/spec/spec_helper.rb +30 -0
  40. data/spec/shared/app_root/app/models/song.rb +2 -3
  41. data/spec/shared/consul/power_spec.rb +34 -34
  42. metadata +204 -81
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGJjOTg0MzEzODg3Mzc2Mjk1OGIyYzhmNTRlMDgwYzczZDFjNGY5Mw==
5
+ data.tar.gz: !binary |-
6
+ NjEwOTM0ZjMwNzllMWQxMTgzNzZmMDAwZWQ3ODk0NTA0NTU0N2U3YQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NmY4NzcxNDM2YTFmOGQxOGJhNzY2Mzc1M2UyZWFhNzMzZWEwNzVjNjNjYjU5
10
+ ODg0NTUzNmE4MmI3NzM5YWNmMjkzMjI3NjUzMzA3N2U5ZTZlNjM4YmE1OWJk
11
+ YTg5NGQ5NjNlYjM3Y2RhODZiZTUyZDNlZWIwZjQ3OGYyNTI2MWM=
12
+ data.tar.gz: !binary |-
13
+ Nzg4Nzc2NGU2Y2FlZjA5N2Y1YzBmMGYyZjhlMjIxZTU0ZDgyOGQ3YjZkNTM5
14
+ MWZkNDA0OTJhNjVjZTVkMTZlM2E0MDg4NWIwODFkZjQ5MGJiYzE4NWEyYTA2
15
+ ZjQ2NjJjMjc2N2RhZGE1NmZiZWVlZDdmYmY4NmIyOGRmMzQ3Mjg=
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - "1.8.7"
4
4
  - "1.9.3"
5
+ - "2.1.0"
5
6
  - ree
6
7
  before_script: rake travis_ci:prepare
7
8
  script: rake all:bundle all:spec
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
- Consul - A next gen authorization solution
1
+ Consul A next gen authorization solution
2
2
  ==========================================
3
3
 
4
4
  [![Build Status](https://secure.travis-ci.org/makandra/consul.png?branch=master)](https://travis-ci.org/makandra/consul) [![Code Climate](https://codeclimate.com/github/makandra/consul.png)](https://codeclimate.com/github/makandra/consul)
5
5
 
6
- Consul is a authorization solution for Ruby on Rails where you describe *sets of accessible things* to control what a user can see or edit.
6
+ Consul is an authorization solution for Ruby on Rails where you describe *sets of accessible things* to control what a user can see or edit.
7
7
 
8
8
  We have used Consul in combination with [assignable_values](https://github.com/makandra/assignable_values) to solve a variety of authorization requirements ranging from boring to bizarre.
9
9
  Also see our crash course video: [Solving bizare authorization requirements with Rails](http://bizarre-authorization.talks.makandra.com/).
10
10
 
11
+ Consul is tested with Rails 2.3, 3.0, 3.2 and 4.1 on Ruby 1.8.7, 1.9.3 and 2.1.0.
12
+
11
13
 
12
14
  Describing access to your application
13
15
  -------------------------------------
@@ -82,7 +84,7 @@ Or you can ask if the power is given (meaning it's not `nil`):
82
84
 
83
85
  Or you can raise an error unless a power its given, e.g. to guard access into a controller action:
84
86
 
85
- power.notes? # => returns true if Power#notes returns a scope, even if it's empty
87
+ power.notes! # => raises Consul::Powerless unless Power#notes returns a scope (even if it's empty)
86
88
 
87
89
  Or you ask whether a given record is included in its scope (can be [optimized](#optimizing-record-checks-for-scope-powers)):
88
90
 
@@ -361,7 +363,7 @@ You can use `:except` and `:only` options like in before filters.
361
363
  You can also map different powers to different actions:
362
364
 
363
365
  class NotesController < ApplicationController
364
- power :notes, :map => { [:edit, :update, :destroy] => :changable_notes }
366
+ power :notes, :map => { [:edit, :update, :destroy] => :changeable_notes }
365
367
  end
366
368
 
367
369
  Actions that are not listed in `:map` will get the default action `:notes`.
data/Rakefile CHANGED
@@ -7,11 +7,13 @@ task :default => 'all:spec'
7
7
  namespace :travis_ci do
8
8
 
9
9
  desc 'Things to do before Travis CI begins'
10
- task :prepare => :slimgems
10
+ task :prepare => [:compatible_rubygems]
11
11
 
12
- desc 'Install slimgems'
13
- task :slimgems do
14
- system('gem install slimgems')
12
+ desc 'Ensure compatible Rubygems version for Ruby 1.8'
13
+ task :compatible_rubygems do
14
+ if RUBY_VERSION == '1.8.7'
15
+ system "rvm rubygems latest-1.8 --force"
16
+ end
15
17
  end
16
18
 
17
19
  end
@@ -42,7 +44,14 @@ end
42
44
  def for_each_directory_of(path, &block)
43
45
  Dir[path].sort.each do |rakefile|
44
46
  directory = File.dirname(rakefile)
45
- puts '', "\033[44m#{directory}\033[0m", ''
46
- block.call(directory)
47
+ puts '', "\033[4;34m# #{directory}\033[0m", '' # blue underline
48
+
49
+ if directory.include?('rails-2.3') and RUBY_VERSION != '1.8.7'
50
+ puts 'Skipping - Rails 2.3 requires Ruby 1.8.7'
51
+ elsif directory.include?('rails-4.1') and RUBY_VERSION == '1.8.7'
52
+ puts 'Skipping - Rails 4.1 does not support Ruby 1.8'
53
+ else
54
+ block.call(directory)
55
+ end
47
56
  end
48
57
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency('memoizer')
20
20
  s.add_dependency('rails')
21
- s.add_dependency('edge_rider')
21
+ s.add_dependency('edge_rider', '>= 0.3.0')
22
22
  end
@@ -22,11 +22,27 @@ module Consul
22
22
  value.is_a?(Array) || value.is_a?(Set)
23
23
  end
24
24
 
25
- def define_scope(klass, name, options)
26
- if Rails.version.to_i < 3
27
- klass.send(:named_scope, name, options)
25
+ def define_scope(klass, name, lambda)
26
+ if Rails.version.to_i < 4 # Rails 2/3
27
+ scope_definition = Rails.version.to_i < 3 ? :named_scope : :scope
28
+ klass.send scope_definition, name, lambda
29
+ else
30
+ klass.send :scope, name, lambda { |*args|
31
+ options = lambda.call(*args)
32
+ klass.scoped(options.slice *EdgeRider::Scoped::VALID_FIND_OPTIONS)
33
+ }
34
+ end
35
+ end
36
+
37
+ # This method does not support dynamic default scopes via lambdas
38
+ # (as does #define_scope), because it is currently not required.
39
+ def define_default_scope(klass, conditions)
40
+ if Rails.version.to_i < 4 # Rails 2/3
41
+ klass.send :default_scope, conditions
28
42
  else
29
- klass.send(:scope, name, options)
43
+ klass.send :default_scope do
44
+ klass.scoped(conditions)
45
+ end
30
46
  end
31
47
  end
32
48
 
@@ -1,3 +1,3 @@
1
1
  module Consul
2
- VERSION = '0.11.2'
2
+ VERSION = '0.12.0'
3
3
  end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- consul (0.11.1)
5
- edge_rider
4
+ consul (0.12.0)
5
+ edge_rider (>= 0.3.0)
6
6
  memoizer
7
7
  rails
8
8
 
@@ -21,7 +21,7 @@ GEM
21
21
  activesupport (2.3.18)
22
22
  assignable_values (0.7.1)
23
23
  activerecord
24
- edge_rider (0.2.3)
24
+ edge_rider (0.3.0)
25
25
  activerecord
26
26
  hoe (2.8.0)
27
27
  rake (>= 0.8.7)
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- consul (0.11.1)
5
- edge_rider
4
+ consul (0.12.0)
5
+ edge_rider (>= 0.3.0)
6
6
  memoizer
7
7
  rails
8
8
 
@@ -43,7 +43,7 @@ GEM
43
43
  mocha (~> 0.13.2)
44
44
  builder (2.1.2)
45
45
  diff-lcs (1.2.4)
46
- edge_rider (0.2.3)
46
+ edge_rider (0.3.0)
47
47
  activerecord
48
48
  erubis (2.6.6)
49
49
  abstract (>= 1.0.0)
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- consul (0.11.1)
5
- edge_rider
4
+ consul (0.12.0)
5
+ edge_rider (>= 0.3.0)
6
6
  memoizer
7
7
  rails
8
8
 
@@ -43,7 +43,7 @@ GEM
43
43
  mocha (~> 0.13.2)
44
44
  builder (3.0.4)
45
45
  diff-lcs (1.2.4)
46
- edge_rider (0.2.3)
46
+ edge_rider (0.3.0)
47
47
  activerecord
48
48
  erubis (2.7.0)
49
49
  hike (1.2.2)
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format progress
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'minitest' # fix MiniTest deprecation warnings
4
+ gem 'assignable_values'
5
+ gem 'rails', '4.1.0'
6
+ gem 'rspec'
7
+ gem 'rspec-rails'
8
+ gem 'shoulda-matchers'
9
+ gem 'sqlite3'
10
+ gem 'rspec_candy'
11
+
12
+ gem 'consul', :path => '../..'
@@ -0,0 +1,134 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ consul (0.12.0)
5
+ edge_rider (>= 0.3.0)
6
+ memoizer
7
+ rails
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (4.1.0)
13
+ actionpack (= 4.1.0)
14
+ actionview (= 4.1.0)
15
+ mail (~> 2.5.4)
16
+ actionpack (4.1.0)
17
+ actionview (= 4.1.0)
18
+ activesupport (= 4.1.0)
19
+ rack (~> 1.5.2)
20
+ rack-test (~> 0.6.2)
21
+ actionview (4.1.0)
22
+ activesupport (= 4.1.0)
23
+ builder (~> 3.1)
24
+ erubis (~> 2.7.0)
25
+ activemodel (4.1.0)
26
+ activesupport (= 4.1.0)
27
+ builder (~> 3.1)
28
+ activerecord (4.1.0)
29
+ activemodel (= 4.1.0)
30
+ activesupport (= 4.1.0)
31
+ arel (~> 5.0.0)
32
+ activesupport (4.1.0)
33
+ i18n (~> 0.6, >= 0.6.9)
34
+ json (~> 1.7, >= 1.7.7)
35
+ minitest (~> 5.1)
36
+ thread_safe (~> 0.1)
37
+ tzinfo (~> 1.1)
38
+ arel (5.0.1.20140414130214)
39
+ assignable_values (0.9.0)
40
+ activerecord
41
+ builder (3.2.2)
42
+ diff-lcs (1.2.5)
43
+ edge_rider (0.3.0)
44
+ activerecord
45
+ erubis (2.7.0)
46
+ hike (1.2.3)
47
+ i18n (0.6.9)
48
+ json (1.8.1)
49
+ mail (2.5.4)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ memoizer (1.0.1)
53
+ mime-types (1.25.1)
54
+ minitest (5.3.4)
55
+ multi_json (1.10.1)
56
+ polyglot (0.3.5)
57
+ rack (1.5.2)
58
+ rack-test (0.6.2)
59
+ rack (>= 1.0)
60
+ rails (4.1.0)
61
+ actionmailer (= 4.1.0)
62
+ actionpack (= 4.1.0)
63
+ actionview (= 4.1.0)
64
+ activemodel (= 4.1.0)
65
+ activerecord (= 4.1.0)
66
+ activesupport (= 4.1.0)
67
+ bundler (>= 1.3.0, < 2.0)
68
+ railties (= 4.1.0)
69
+ sprockets-rails (~> 2.0)
70
+ railties (4.1.0)
71
+ actionpack (= 4.1.0)
72
+ activesupport (= 4.1.0)
73
+ rake (>= 0.8.7)
74
+ thor (>= 0.18.1, < 2.0)
75
+ rake (10.3.2)
76
+ rspec (3.0.0)
77
+ rspec-core (~> 3.0.0)
78
+ rspec-expectations (~> 3.0.0)
79
+ rspec-mocks (~> 3.0.0)
80
+ rspec-core (3.0.0)
81
+ rspec-support (~> 3.0.0)
82
+ rspec-expectations (3.0.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.0.0)
85
+ rspec-mocks (3.0.0)
86
+ rspec-support (~> 3.0.0)
87
+ rspec-rails (3.0.0)
88
+ actionpack (>= 3.0)
89
+ activesupport (>= 3.0)
90
+ railties (>= 3.0)
91
+ rspec-core (~> 3.0.0)
92
+ rspec-expectations (~> 3.0.0)
93
+ rspec-mocks (~> 3.0.0)
94
+ rspec-support (~> 3.0.0)
95
+ rspec-support (3.0.0)
96
+ rspec_candy (0.3.1)
97
+ rspec
98
+ sneaky-save
99
+ shoulda-matchers (2.6.1)
100
+ activesupport (>= 3.0.0)
101
+ sneaky-save (0.0.5)
102
+ activerecord (>= 3.2.0)
103
+ sprockets (2.11.0)
104
+ hike (~> 1.2)
105
+ multi_json (~> 1.0)
106
+ rack (~> 1.0)
107
+ tilt (~> 1.1, != 1.3.0)
108
+ sprockets-rails (2.1.3)
109
+ actionpack (>= 3.0)
110
+ activesupport (>= 3.0)
111
+ sprockets (~> 2.8)
112
+ sqlite3 (1.3.9)
113
+ thor (0.19.1)
114
+ thread_safe (0.3.4)
115
+ tilt (1.4.1)
116
+ treetop (1.4.15)
117
+ polyglot
118
+ polyglot (>= 0.3.1)
119
+ tzinfo (1.2.1)
120
+ thread_safe (~> 0.1)
121
+
122
+ PLATFORMS
123
+ ruby
124
+
125
+ DEPENDENCIES
126
+ assignable_values
127
+ consul!
128
+ minitest
129
+ rails (= 4.1.0)
130
+ rspec
131
+ rspec-rails
132
+ rspec_candy
133
+ shoulda-matchers
134
+ sqlite3
@@ -0,0 +1,12 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Default: Run all specs for a specific rails version.'
5
+ task :default => :spec
6
+
7
+ desc "Run all specs for a specific rails version"
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = defined?(SPEC) ? SPEC : ['**/*_spec.rb', '../shared/**/*_spec.rb']
10
+ t.verbose = false
11
+ t.rspec_opts = "-b"
12
+ end
@@ -0,0 +1,16 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
7
+ require_relative '../config/boot'
8
+ require 'rails/commands'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ require_relative '../config/boot'
7
+ require 'rake'
8
+ Rake.application.run
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast
4
+ # It gets overwritten when you run the `spring binstub` command
5
+
6
+ unless defined?(Spring)
7
+ require "rubygems"
8
+ require "bundler"
9
+
10
+ if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11
+ ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12
+ ENV["GEM_HOME"] = ""
13
+ Gem.paths = ENV
14
+
15
+ gem "spring", match[1]
16
+ require "spring/binstub"
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module SpecApp
10
+ class Application < Rails::Application
11
+ config.encoding = "utf-8"
12
+
13
+ config.cache_classes = true
14
+ config.whiny_nils = true
15
+
16
+ config.consider_all_requests_local = true
17
+ config.action_controller.perform_caching = false
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ config.action_dispatch.show_exceptions = false
21
+
22
+ config.action_mailer.delivery_method = :test
23
+
24
+ config.active_support.deprecation = :stderr
25
+
26
+ config.root = File.expand_path('../..', __FILE__)
27
+ end
28
+ end