proxes 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/lib/proxes.rb +1 -0
  4. data/lib/proxes/app.rb +1 -0
  5. data/lib/proxes/container.rb +13 -7
  6. data/lib/proxes/controllers/application.rb +4 -3
  7. data/lib/proxes/controllers/audit_logs.rb +1 -0
  8. data/lib/proxes/controllers/auth_identity.rb +1 -0
  9. data/lib/proxes/controllers/component.rb +4 -3
  10. data/lib/proxes/controllers/permissions.rb +1 -0
  11. data/lib/proxes/controllers/roles.rb +1 -0
  12. data/lib/proxes/controllers/users.rb +2 -1
  13. data/lib/proxes/db.rb +1 -0
  14. data/lib/proxes/forwarder.rb +4 -4
  15. data/lib/proxes/helpers/authentication.rb +4 -3
  16. data/lib/proxes/helpers/component.rb +1 -0
  17. data/lib/proxes/helpers/indices.rb +3 -2
  18. data/lib/proxes/helpers/pundit.rb +1 -0
  19. data/lib/proxes/helpers/views.rb +1 -0
  20. data/lib/proxes/helpers/wisper.rb +1 -0
  21. data/lib/proxes/listener.rb +4 -4
  22. data/lib/proxes/loggers/elasticsearch.rb +1 -0
  23. data/lib/proxes/models/audit_log.rb +1 -0
  24. data/lib/proxes/models/identity.rb +1 -0
  25. data/lib/proxes/models/permission.rb +3 -2
  26. data/lib/proxes/models/role.rb +1 -0
  27. data/lib/proxes/models/user.rb +1 -0
  28. data/lib/proxes/policies/application_policy.rb +1 -0
  29. data/lib/proxes/policies/audit_log_policy.rb +1 -0
  30. data/lib/proxes/policies/identity_policy.rb +1 -0
  31. data/lib/proxes/policies/permission_policy.rb +1 -0
  32. data/lib/proxes/policies/request/root_policy.rb +1 -0
  33. data/lib/proxes/policies/request/search_policy.rb +2 -1
  34. data/lib/proxes/policies/request/snapshot_policy.rb +1 -0
  35. data/lib/proxes/policies/request/stats_policy.rb +2 -1
  36. data/lib/proxes/policies/request_policy.rb +8 -14
  37. data/lib/proxes/policies/role_policy.rb +1 -0
  38. data/lib/proxes/policies/token_policy.rb +1 -0
  39. data/lib/proxes/policies/user_policy.rb +1 -0
  40. data/lib/proxes/proxes.rb +6 -6
  41. data/lib/proxes/rake_tasks.rb +2 -1
  42. data/lib/proxes/request.rb +2 -1
  43. data/lib/proxes/request/root.rb +1 -0
  44. data/lib/proxes/request/search.rb +4 -3
  45. data/lib/proxes/request/snapshot.rb +1 -0
  46. data/lib/proxes/request/stats.rb +4 -3
  47. data/lib/proxes/security.rb +1 -0
  48. data/lib/proxes/seed.rb +1 -3
  49. data/lib/proxes/services/logger.rb +3 -2
  50. data/lib/proxes/version.rb +2 -1
  51. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 701cef47d840b7a98b029c49b0669549df8d24fe
4
- data.tar.gz: beefb8e479b990c177976245a03d2f401d10861a
3
+ metadata.gz: a432c5f7cf196ae210e756336857117d3fe59a85
4
+ data.tar.gz: c7a4e4dd8fee71ebc927256e2d7a3eb531ee2be7
5
5
  SHA512:
6
- metadata.gz: d95b0bf8b05afe16014fdeb90c88c8860462d5c240f0e5f0c0483f869403430e81e8724b9d6fa031dd5777cb466a0992dbbd93192fb45f5b799968cf3ee219e9
7
- data.tar.gz: aa3fffe5fe4deb819ecaa8e2f13562da5e881dca04e4c2e0ea449c239d1d16d27fc1e2b6b06dc6e05a8f28ec5bdd8f8474fcad11c20be981fcc83d1d8102764d
6
+ metadata.gz: e545194da1aa7c629959d8a8d12334e44d959f12f98fef5eccaf97d39912660a0751a13407c84761b67a595216da757f34fc2f0d32368304978c724cf9a101f9
7
+ data.tar.gz: 22377b50360e7658ebb3f175d8024cef68415103538b767549d02eb2e1edc0fdaef21bd6959023118fd11e5d4b34206a060f4c3e55bc63c03eb2949a048d0b79
data/.rubocop.yml CHANGED
@@ -10,3 +10,6 @@ Style/NumericPredicate:
10
10
  Style/LeadingCommentSpace:
11
11
  Exclude:
12
12
  - 'config.ru'
13
+
14
+ AllCops:
15
+ TargetRubyVersion: 1.9
data/lib/proxes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/version'
3
4
  require 'proxes/container'
4
5
  require 'proxes/db'
data/lib/proxes/app.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/application'
3
4
 
4
5
  module ProxES
@@ -14,20 +14,20 @@ module ProxES
14
14
 
15
15
  # Make getting value from underlying hash thread safe.
16
16
  def [](key)
17
- @mutex.synchronize{@hash[key]}
17
+ @mutex.synchronize { @hash[key] }
18
18
  end
19
19
 
20
20
  # Make setting value in underlying hash thread safe.
21
21
  def []=(key, value)
22
- @mutex.synchronize{@hash[key] = value}
22
+ @mutex.synchronize { @hash[key] = value }
23
23
  end
24
24
 
25
25
  def map(&block)
26
- @mutex.synchronize{@hash.map(&block)}
26
+ @mutex.synchronize { @hash.map(&block) }
27
27
  end
28
28
 
29
29
  def inject(memo, &block)
30
- @mutex.synchronize{@hash.inject(memo, &block)}
30
+ @mutex.synchronize { @hash.inject(memo, &block) }
31
31
  end
32
32
  end
33
33
 
@@ -70,7 +70,7 @@ module ProxES
70
70
  # Container.plugin PluginModule
71
71
  # Container.plugin :csrf
72
72
  def plugin(plugin, *args, &block)
73
- raise ContainerError, "Cannot add a plugin to a frozen Container class" if frozen?
73
+ raise ContainerError, 'Cannot add a plugin to a frozen Container class' if frozen?
74
74
  plugin = Plugins.load_plugin(plugin) if plugin.is_a?(Symbol)
75
75
  plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
76
76
  include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
@@ -88,11 +88,11 @@ module ProxES
88
88
  def routes
89
89
  Plugins.plugins.inject({}) do |memo, plugin|
90
90
  memo.merge!(plugin[1].route_mappings) if plugin[1].respond_to?(:route_mappings)
91
- memo
92
91
  end
93
92
  end
94
93
 
95
- # Return an ordered list of navigation items: `[{order:0, link:'/users/', text:'Users'}, {order:1, link:'/roles/', text:'Roles'}]
94
+ # Return an ordered list of navigation items:
95
+ # `[{order:0, link:'/users/', text:'Users'}, {order:1, link:'/roles/', text:'Roles'}]
96
96
  def navigation
97
97
  Plugins.plugins.map do |_key, plugin|
98
98
  plugin.nav_items if plugin.respond_to?(:nav_items)
@@ -110,6 +110,12 @@ module ProxES
110
110
  plugin.seeder if plugin.respond_to?(:seeder)
111
111
  end.compact
112
112
  end
113
+
114
+ def workers
115
+ Plugins.plugins.map do |_key, plugin|
116
+ plugin.run_workers if plugin.respond_to?(:run_workers)
117
+ end.compact
118
+ end
113
119
  end
114
120
 
115
121
  module InstanceMethods
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'wisper'
3
4
  require 'sinatra/base'
4
5
  require 'sinatra/flash'
@@ -52,10 +53,10 @@ module ProxES
52
53
  redirect '/auth/identity'
53
54
  end
54
55
 
55
- before (/.*/) do
56
- if request.url.match(/.json/)
56
+ before(/.*/) do
57
+ if request.url =~ /.json/
57
58
  request.accept.unshift('application/json')
58
- request.path_info = request.path_info.gsub(/.json/,'')
59
+ request.path_info = request.path_info.gsub(/.json/, '')
59
60
  end
60
61
  end
61
62
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/component'
3
4
  require 'proxes/models/audit_log'
4
5
  require 'proxes/policies/audit_log_policy'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/application'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/application'
3
4
  require 'proxes/helpers/component'
4
5
 
@@ -21,11 +22,11 @@ module ProxES
21
22
  respond_to do |format|
22
23
  format.html do
23
24
  haml :"#{view_location}/index",
24
- locals: { list: list, title: heading(:list), actions: actions }
25
+ locals: { list: list, title: heading(:list), actions: actions }
25
26
  end
26
27
  format.json do
27
28
  {
28
- 'items' => list.map { |entity| entity.values },
29
+ 'items' => list.map(&:values),
29
30
  'page' => params[:page],
30
31
  'count' => params[:count],
31
32
  'total' => list.to_a.size
@@ -79,7 +80,7 @@ module ProxES
79
80
  respond_to do |format|
80
81
  format.html do
81
82
  haml :"#{view_location}/display",
82
- locals: { entity: entity, title: heading, actions: actions }
83
+ locals: { entity: entity, title: heading, actions: actions }
83
84
  end
84
85
  format.json { entity.values.to_json }
85
86
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/component'
3
4
  require 'proxes/models/permission'
4
5
  require 'proxes/policies/permission_policy'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/component'
3
4
  require 'proxes/models/role'
4
5
  require 'proxes/policies/role_policy'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/controllers/component'
3
4
  require 'proxes/models/user'
4
5
  require 'proxes/policies/user_policy'
@@ -121,7 +122,7 @@ module ProxES
121
122
  identity.set values
122
123
  if identity.valid? && identity.save
123
124
  log_action("#{dehumanized}_update_password".to_sym) if settings.track_actions
124
- flash[:success] = "Password Updated"
125
+ flash[:success] = 'Password Updated'
125
126
  redirect '/_proxes/users/profile'
126
127
  else
127
128
  haml :"#{view_location}/profile", locals: { entity: entity, identity: identity, title: heading }
data/lib/proxes/db.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'sequel'
3
4
  require 'proxes/services/logger'
4
5
 
@@ -6,20 +6,20 @@ module ProxES
6
6
  class Forwarder
7
7
  attr_reader :backend, :streaming
8
8
 
9
- def initialize(opts= {})
9
+ def initialize(opts = {})
10
10
  @backend = URI(opts[:backend]) if opts[:backend]
11
11
  end
12
12
 
13
13
  def call(env)
14
14
  source_request = Rack::Request.new(env)
15
- full_path = source_request.fullpath == "" ? URI.parse(env['REQUEST_URI']).request_uri : source_request.fullpath
15
+ full_path = source_request.fullpath == '' ? URI.parse(env['REQUEST_URI']).request_uri : source_request.fullpath
16
16
  target_request = Net::HTTP.const_get(source_request.request_method.capitalize).new(full_path)
17
17
 
18
18
  http = Net::HTTP.new(backend.host, backend.port)
19
19
  target_response = http.request(target_request)
20
20
 
21
21
  headers = (target_response.respond_to?(:headers) && target_response.headers) || self.class.normalize_headers(target_response.to_hash)
22
- body = target_response.body || [""]
22
+ body = target_response.body || ['']
23
23
  body = [body] unless body.respond_to?(:each)
24
24
 
25
25
  # Not sure where this is coming from, but it causes timeouts on the client
@@ -31,7 +31,7 @@ module ProxES
31
31
  class << self
32
32
  def normalize_headers(headers)
33
33
  mapped = headers.map do |k, v|
34
- [k, if v.is_a? Array then v.join("\n") else v end]
34
+ [k, v.is_a?(Array) ? v.join("\n") : v]
35
35
  end
36
36
  Rack::Utils::HeaderHash.new Hash[mapped]
37
37
  end
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  module Helpers
4
5
  module Authentication
5
6
  def current_user
6
7
  return nil unless env['rack.session'] && env['rack.session']['user_id']
7
- @users ||= Hash.new {|h,k| h[k] = User[k]}
8
+ @users ||= Hash.new { |h, k| h[k] = User[k] }
8
9
  @users[env['rack.session']['user_id']]
9
10
  end
10
11
 
@@ -17,11 +18,11 @@ module ProxES
17
18
  end
18
19
 
19
20
  def authenticated?
20
- !env['rack.session']['user_id'].nil?
21
+ current_user.nil?
21
22
  end
22
23
 
23
24
  def authenticate!
24
- raise NotAuthenticated unless env['rack.session']['user_id']
25
+ raise NotAuthenticated unless current_user
25
26
  true
26
27
  end
27
28
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'active_support'
3
4
  require 'active_support/inflector'
4
5
 
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  module Helpers
4
5
  module Indices
5
6
  def filter(asked, against)
6
- return against.map { |a| a.gsub(%r{\.\*}, '*') } if asked == ['*'] || asked == []
7
+ return against.map { |a| a.gsub(/\.\*/, '*') } if asked == ['*'] || asked == []
7
8
 
8
9
  answer = []
9
10
  against.each do |pattern|
10
- answer.concat asked.select { |idx| idx =~ %r{#{pattern}} }
11
+ answer.concat(asked.select { |idx| idx =~ /#{pattern}/ })
11
12
  end
12
13
  answer
13
14
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'pundit'
3
4
  require 'proxes/request'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  module Helpers
4
5
  module Views
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'wisper'
3
4
  require 'proxes/request'
4
5
 
@@ -6,14 +6,14 @@ module ProxES
6
6
  @mutex = Mutex.new
7
7
  end
8
8
 
9
- def method_missing(method, *args, &block)
9
+ def method_missing(method, *args)
10
10
  vals = { action: method }
11
- vals[:user] = args[0][:user] if (args[0] && args[0].has_key?(:user))
12
- vals[:details] = args[0][:details] if (args[0] && args[0].has_key?(:details))
11
+ vals[:user] = args[0][:user] if args[0] && args[0].key?(:user)
12
+ vals[:details] = args[0][:details] if args[0] && args[0].key?(:details)
13
13
  @mutex.synchronize { AuditLog.create vals }
14
14
  end
15
15
 
16
- def respond_to_missing?(method, include_private = false)
16
+ def respond_to_missing?(_method, _include_private = false)
17
17
  true
18
18
  end
19
19
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'logger'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/models/base'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/models/base'
3
4
  require 'omniauth-identity'
4
5
  require 'active_support'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/models/base'
3
4
 
4
5
  module ProxES
@@ -8,7 +9,7 @@ module ProxES
8
9
 
9
10
  dataset_module do
10
11
  def for_user(a_user, action)
11
- where(verb: action).where{Sequel.|({role: a_user.roles}, {user_id: a_user.id})}
12
+ where(verb: action).where { Sequel.|({ role: a_user.roles }, { user_id: a_user.id }) }
12
13
  end
13
14
  end
14
15
 
@@ -20,7 +21,7 @@ module ProxES
20
21
  end
21
22
 
22
23
  def self.verbs
23
- ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'INDEX']
24
+ %w[GET POST PUT DELETE HEAD OPTIONS TRACE INDEX]
24
25
  end
25
26
  end
26
27
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/models/base'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/models/base'
3
4
  require 'bcrypt'
4
5
  require 'digest/md5'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  class ApplicationPolicy
4
5
  attr_reader :user, :record
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/policies/application_policy'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'application_policy'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/policies/application_policy'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  class Request
4
5
  class RootPolicy < RequestPolicy
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  class Request
4
5
  class SearchPolicy < RequestPolicy
5
6
  class Scope < RequestPolicy::Scope
6
7
  def resolve
7
8
  patterns = Permission.for_user(user, 'INDEX').map do |permission|
8
- permission.pattern.gsub(/\{user.(.*)\}/) { |match| user.send(Regexp.last_match[1].to_sym) }
9
+ permission.pattern.gsub(/\{user.(.*)\}/) { |_match| user.send(Regexp.last_match[1].to_sym) }
9
10
  end
10
11
  filter scope.index, patterns
11
12
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  class Request
4
5
  class SnapshotPolicy < RequestPolicy
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
4
  class Request
4
5
  class StatsPolicy < RequestPolicy
5
6
  class Scope < RequestPolicy::Scope
6
7
  def resolve
7
8
  patterns = Permission.for_user(user, 'INDEX').map do |permission|
8
- permission.pattern.gsub(/\{user.(.*)\}/) { |match| user.send(Regexp.last_match[1].to_sym) }
9
+ permission.pattern.gsub(/\{user.(.*)\}/) { |_match| user.send(Regexp.last_match[1].to_sym) }
9
10
  end
10
11
  filter scope.index, patterns
11
12
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/db'
3
4
  require 'proxes/models/permission'
4
5
  require 'proxes/services/logger'
@@ -16,31 +17,24 @@ module ProxES
16
17
  end
17
18
 
18
19
  def method_missing(method_sym, *arguments, &block)
19
- if method_sym.to_s[-1] == '?'
20
- return false if user.nil?
20
+ return super if method_sym.to_s[-1] != '?'
21
21
 
22
- if record.indices?
23
- return true if index_allowed?
24
- else
25
- return true if action_allowed? method_sym[0..-2].upcase
26
- end
27
- false
28
- else
29
- super
30
- end
22
+ return false if user.nil?
23
+ return true if record.indices? && index_allowed?
24
+ action_allowed? method_sym[0..-2].upcase
31
25
  end
32
26
 
33
27
  def index_allowed?
34
28
  patterns = Permission.for_user(user, 'INDEX').map do |permission|
35
- permission.pattern.gsub(/\{user.(.*)\}/) { |match| user.send(Regexp.last_match[1].to_sym) }
29
+ permission.pattern.gsub(/\{user.(.*)\}/) { |_match| user.send(Regexp.last_match[1].to_sym) }
36
30
  end
37
- return filter(record.index, patterns).count.positive?
31
+ filter(record.index, patterns).count.positive?
38
32
  end
39
33
 
40
34
  def action_allowed?(action)
41
35
  # Give me all the user's permissions that match the verb
42
36
  Permission.for_user(user, action).each do |permission|
43
- return true if record.path =~ %r{#{permission.pattern}}
37
+ return true if record.path =~ /#{permission.pattern}/
44
38
  end
45
39
  false
46
40
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/policies/application_policy'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'application_policy'
3
4
 
4
5
  module ProxES
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/policies/application_policy'
3
4
 
4
5
  module ProxES
data/lib/proxes/proxes.rb CHANGED
@@ -18,23 +18,23 @@ module ProxES
18
18
  '/users' => ::ProxES::Users,
19
19
  '/roles' => ::ProxES::Roles,
20
20
  '/permissions' => ::ProxES::Permissions,
21
- '/audit-logs' => ::ProxES::AuditLogs,
21
+ '/audit-logs' => ::ProxES::AuditLogs
22
22
  }
23
23
  end
24
24
 
25
25
  def self.nav_items
26
26
  [
27
- { order: 0, link:'/users/', text: 'Users', target: User, icon: 'user' },
28
- { order: 1, link:'/roles/', text: 'Roles', target: Role, icon: 'group' },
29
- { order: 2, link:'/permissions/', text: 'Permissions', target: Permission, icon: 'check-square' },
27
+ { order: 0, link: '/users/', text: 'Users', target: User, icon: 'user' },
28
+ { order: 1, link: '/roles/', text: 'Roles', target: Role, icon: 'group' },
29
+ { order: 2, link: '/permissions/', text: 'Permissions', target: Permission, icon: 'check-square' }
30
30
  ]
31
31
  end
32
32
 
33
33
  def self.seeder
34
- Proc.new do
34
+ proc do
35
35
  ::ProxES::Role.find_or_create(name: 'user')
36
36
  sa = ::ProxES::Role.find_or_create(name: 'super_admin')
37
- %w(GET POST PUT DELETE HEAD OPTIONS INDEX).each do |verb|
37
+ %w[GET POST PUT DELETE HEAD OPTIONS INDEX].each do |verb|
38
38
  ::ProxES::Permission.find_or_create(role: sa, verb: verb, pattern: '.*')
39
39
  end
40
40
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rake'
3
4
  require 'rake/tasklib'
4
5
 
@@ -22,7 +23,7 @@ module ProxES
22
23
 
23
24
  desc 'Prepare ProxES migrations'
24
25
  task :prep do
25
- Dir.mkdir 'migrations' unless File.exists?('migrations')
26
+ Dir.mkdir 'migrations' unless File.exist?('migrations')
26
27
  ::ProxES::Container.migrations.each do |path|
27
28
  FileUtils.cp_r "#{path}/.", 'migrations'
28
29
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rack'
3
4
 
4
5
  module ProxES
@@ -15,7 +16,7 @@ module ProxES
15
16
  require 'proxes/request/' + endpoint.downcase
16
17
  Request.const_get(endpoint).new(env)
17
18
  rescue LoadError
18
- self.new(env)
19
+ new(env)
19
20
  end
20
21
  end
21
22
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rack'
3
4
  require 'proxes/request'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rack'
3
4
  require 'proxes/request'
4
5
 
@@ -10,9 +11,9 @@ module ProxES
10
11
 
11
12
  def index=(idx)
12
13
  @index = idx
13
- self.path_info = '/' + [ index, type, id, endpoint ]
14
- .map { |v| v.is_a?(Array) ? v.join(',') : v }
15
- .select { |v| !v.nil? && v != '' }.join('/')
14
+ self.path_info = '/' + [index, type, id, endpoint]
15
+ .map { |v| v.is_a?(Array) ? v.join(',') : v }
16
+ .select { |v| !v.nil? && v != '' }.join('/')
16
17
  end
17
18
 
18
19
  def endpoint
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rack'
3
4
  require 'proxes/request'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rack'
3
4
  require 'proxes/request'
4
5
 
@@ -9,9 +10,9 @@ module ProxES
9
10
 
10
11
  def index=(idx)
11
12
  @index = idx
12
- self.path_info = '/' + [ index, endpoint ]
13
- .map { |v| v.is_a?(Array) ? v.join(',') : v }
14
- .select { |v| !v.nil? && v != '' }.join('/')
13
+ self.path_info = '/' + [index, endpoint]
14
+ .map { |v| v.is_a?(Array) ? v.join(',') : v }
15
+ .select { |v| !v.nil? && v != '' }.join('/')
15
16
  end
16
17
 
17
18
  def endpoint
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'proxes/services/logger'
3
4
  require 'proxes/request'
4
5
  require 'proxes/policies/request_policy'
data/lib/proxes/seed.rb CHANGED
@@ -2,6 +2,4 @@ require 'proxes/db'
2
2
  require 'proxes/models/role'
3
3
  require 'proxes/models/permission'
4
4
 
5
- ::ProxES::Container.seeders.each do |seeder|
6
- seeder.call
7
- end
5
+ ::ProxES::Container.seeders.each(&:call)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'logger'
3
4
  require 'yaml'
4
5
  require 'singleton'
@@ -12,7 +13,7 @@ module ProxES
12
13
  class Logger
13
14
  include Singleton
14
15
 
15
- CONFIG = './config/logger.yml'
16
+ CONFIG = './config/logger.yml'.freeze
16
17
  attr_reader :loggers
17
18
 
18
19
  def initialize
@@ -32,7 +33,7 @@ module ProxES
32
33
  loggers.each { |logger| logger.send(method, *args, &block) }
33
34
  end
34
35
 
35
- def respond_to_missing?(method, include_private = false)
36
+ def respond_to_missing?(method, _include_private = false)
36
37
  loggers.any? { |logger| logger.respond_to?(method) }
37
38
  end
38
39
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module ProxES
3
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'.freeze
4
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-11 00:00:00.000000000 Z
11
+ date: 2017-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler