punk 0.3.6 → 0.4.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.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/.rubocop.yml +1091 -93
  4. data/.standard.yml +2 -0
  5. data/Gemfile +60 -60
  6. data/Gemfile.lock +22 -17
  7. data/README.md +7 -3
  8. data/Rakefile +9 -7
  9. data/VERSION +1 -1
  10. data/app/migrations/001_lets_punk.rb +1 -1
  11. data/app/routes/hello.rb +1 -1
  12. data/bin/punk +5 -5
  13. data/lib/punk.rb +7 -7
  14. data/lib/punk/actions/sessions/create.rb +3 -3
  15. data/lib/punk/actions/sessions/verify.rb +2 -2
  16. data/lib/punk/commands/auth.rb +4 -4
  17. data/lib/punk/commands/generate.rb +5 -5
  18. data/lib/punk/commands/http.rb +4 -4
  19. data/lib/punk/commands/list.rb +10 -10
  20. data/lib/punk/core/app.rb +41 -41
  21. data/lib/punk/core/boot.rb +5 -5
  22. data/lib/punk/core/cli.rb +3 -3
  23. data/lib/punk/core/commander.rb +28 -28
  24. data/lib/punk/core/commands.rb +8 -8
  25. data/lib/punk/core/env.rb +27 -27
  26. data/lib/punk/core/exec.rb +8 -8
  27. data/lib/punk/core/interface.rb +19 -19
  28. data/lib/punk/core/load.rb +2 -2
  29. data/lib/punk/core/logger.rb +3 -3
  30. data/lib/punk/core/monkey.rb +1 -1
  31. data/lib/punk/core/pry.rb +2 -2
  32. data/lib/punk/core/settings.rb +4 -4
  33. data/lib/punk/core/version.rb +1 -1
  34. data/lib/punk/core/worker.rb +6 -6
  35. data/lib/punk/framework/all.rb +8 -8
  36. data/lib/punk/framework/model.rb +6 -5
  37. data/lib/punk/framework/plugins/all.rb +1 -1
  38. data/lib/punk/framework/plugins/validation.rb +8 -8
  39. data/lib/punk/framework/service.rb +5 -3
  40. data/lib/punk/framework/worker.rb +3 -3
  41. data/lib/punk/helpers/all.rb +5 -5
  42. data/lib/punk/helpers/loggable.rb +3 -3
  43. data/lib/punk/helpers/publishable.rb +1 -1
  44. data/lib/punk/helpers/renderable.rb +10 -10
  45. data/lib/punk/helpers/validatable.rb +7 -6
  46. data/lib/punk/migrations/001_punk.rb +12 -12
  47. data/lib/punk/models/group.rb +1 -1
  48. data/lib/punk/models/identity.rb +1 -1
  49. data/lib/punk/models/session.rb +7 -7
  50. data/lib/punk/models/tenant.rb +1 -1
  51. data/lib/punk/models/user.rb +2 -2
  52. data/lib/punk/plugins/all.rb +2 -2
  53. data/lib/punk/plugins/cors.rb +2 -2
  54. data/lib/punk/plugins/ssl.rb +1 -1
  55. data/lib/punk/routes/groups.rb +1 -1
  56. data/lib/punk/routes/plivo.rb +1 -1
  57. data/lib/punk/routes/sessions.rb +2 -2
  58. data/lib/punk/routes/swagger.rb +2 -2
  59. data/lib/punk/routes/tenants.rb +1 -1
  60. data/lib/punk/routes/users.rb +1 -1
  61. data/lib/punk/services/challenge_claim.rb +5 -5
  62. data/lib/punk/services/generate_swagger.rb +6 -6
  63. data/lib/punk/services/prove_claim.rb +1 -1
  64. data/lib/punk/startup/cache.rb +3 -3
  65. data/lib/punk/startup/database.rb +4 -4
  66. data/lib/punk/startup/environment.rb +6 -6
  67. data/lib/punk/startup/logger.rb +2 -2
  68. data/lib/punk/startup/task.rb +5 -5
  69. data/lib/punk/views/fail.rb +2 -2
  70. data/lib/punk/views/groups/list.rb +2 -2
  71. data/lib/punk/views/info.rb +2 -2
  72. data/lib/punk/views/plivo_store.rb +2 -2
  73. data/lib/punk/views/sessions/list.rb +2 -2
  74. data/lib/punk/views/sessions/pending.rb +2 -2
  75. data/lib/punk/views/tenants/list.rb +2 -2
  76. data/lib/punk/views/users/list.rb +2 -2
  77. data/lib/punk/views/users/show.rb +2 -2
  78. data/lib/punk/workers/geocode_session_worker.rb +3 -3
  79. data/lib/punk/workers/identify_session_worker.rb +1 -1
  80. data/lib/punk/workers/send_email_worker.rb +3 -3
  81. data/lib/punk/workers/send_sms_worker.rb +3 -3
  82. data/punk.gemspec +8 -4
  83. data/spec/actions/groups/punk/list_groups_action_spec.rb +9 -9
  84. data/spec/actions/sessions/punk/clear_session_action_spec.rb +11 -11
  85. data/spec/actions/sessions/punk/create_session_action_spec.rb +9 -9
  86. data/spec/actions/sessions/punk/list_sessions_action_spec.rb +8 -8
  87. data/spec/actions/sessions/punk/verify_session_action_spec.rb +24 -24
  88. data/spec/actions/tenants/punk/list_tenants_action_spec.rb +6 -6
  89. data/spec/actions/users/punk/list_group_users_action_spec.rb +6 -6
  90. data/spec/actions/users/punk/list_tenant_users_action_spec.rb +6 -6
  91. data/spec/factories/group.rb +1 -1
  92. data/spec/factories/group_user_metadata.rb +1 -1
  93. data/spec/factories/identity.rb +4 -4
  94. data/spec/factories/session.rb +1 -1
  95. data/spec/factories/tenant.rb +1 -1
  96. data/spec/factories/tenant_user_metadata.rb +1 -1
  97. data/spec/factories/user.rb +1 -1
  98. data/spec/lib/commands/generate_spec.rb +2 -2
  99. data/spec/lib/commands/list_spec.rb +2 -2
  100. data/spec/lib/commands/swagger_spec.rb +2 -2
  101. data/spec/lib/engine/punk_env_spec.rb +4 -4
  102. data/spec/lib/engine/punk_exec_spec.rb +2 -2
  103. data/spec/lib/engine/punk_init_spec.rb +2 -2
  104. data/spec/lib/engine/punk_store_spec.rb +2 -2
  105. data/spec/models/punk/group_spec.rb +4 -4
  106. data/spec/models/punk/group_user_metadata_spec.rb +2 -2
  107. data/spec/models/punk/identity_spec.rb +17 -17
  108. data/spec/models/punk/session_spec.rb +4 -4
  109. data/spec/models/punk/tenant_spec.rb +3 -3
  110. data/spec/models/punk/tenant_user_metadata_spec.rb +2 -2
  111. data/spec/models/punk/user_spec.rb +9 -9
  112. data/spec/routes/groups/get_groups_spec.rb +4 -4
  113. data/spec/routes/plivo/get_plivo_spec.rb +1 -1
  114. data/spec/routes/sessions/delete_session_spec.rb +1 -1
  115. data/spec/routes/sessions/get_sessions_spec.rb +5 -5
  116. data/spec/routes/sessions/patch_session_spec.rb +1 -1
  117. data/spec/routes/sessions/post_session_spec.rb +1 -1
  118. data/spec/routes/swagger/get_swagger_spec.rb +1 -1
  119. data/spec/routes/tenants/get_tenants_spec.rb +5 -5
  120. data/spec/routes/users/get_users_spec.rb +6 -6
  121. data/spec/services/punk/challenge_claim_service_spec.rb +2 -2
  122. data/spec/services/punk/create_identities_service_spec.rb +1 -1
  123. data/spec/services/punk/generate_swagger_service_spec.rb +2 -2
  124. data/spec/services/punk/prove_claim_service_spec.rb +2 -2
  125. data/spec/services/punk/secret_service_spec.rb +2 -2
  126. data/spec/spec_helper.rb +27 -27
  127. data/spec/views/punk/plivo_store_spec.rb +2 -2
  128. data/spec/views/sessions/punk/list_sessions_view_spec.rb +2 -2
  129. data/spec/views/sessions/punk/pending_session_view_spec.rb +2 -2
  130. data/spec/views/tenants/punk/list_tenants_view_spec.rb +2 -2
  131. data/spec/views/users/punk/list_groups_view_spec.rb +2 -2
  132. data/spec/views/users/punk/list_users_view_spec.rb +2 -2
  133. data/spec/workers/punk/geocode_session_worker_spec.rb +2 -2
  134. data/spec/workers/punk/identify_session_worker_spec.rb +3 -3
  135. data/spec/workers/punk/send_email_worker_spec.rb +1 -1
  136. metadata +18 -3
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../framework/command'
3
+ require_relative "../framework/command"
4
4
 
5
5
  module PUNK
6
- def self.commands(target, scope=nil)
7
- path = File.expand_path(File.join(__dir__, '..', 'commands'))
6
+ def self.commands(target, scope = nil)
7
+ path = File.expand_path(File.join(__dir__, "..", "commands"))
8
8
  PUNK.profile_debug("commands", path: path) do
9
- Dir.glob(File.join(path, '**/*.rb')).sort.each { |file| require(file) }
9
+ Dir.glob(File.join(path, "**/*.rb")).sort.each { |file| require(file) }
10
10
  end
11
- path = File.expand_path(File.join(PUNK.get.app.path, 'commands'))
11
+ path = File.expand_path(File.join(PUNK.get.app.path, "commands"))
12
12
  PUNK.profile_debug("commands", path: path) do
13
- Dir.glob(File.join(path, '**/*.rb')).sort.each { |file| require(file) }
13
+ Dir.glob(File.join(path, "**/*.rb")).sort.each { |file| require(file) }
14
14
  end
15
15
  case target
16
16
  when :commander
17
- require_relative 'commander'
17
+ require_relative "commander"
18
18
  Command.commander
19
19
  when :pry
20
- require_relative 'pry'
20
+ require_relative "pry"
21
21
  Command.pry
22
22
  when :spec
23
23
  Command.spec(scope)
data/lib/punk/core/env.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/string_inquirer'
3
+ require "active_support/string_inquirer"
4
4
 
5
- require 'date'
6
- require 'fileutils'
7
- require 'dotenv'
5
+ require "date"
6
+ require "fileutils"
7
+ require "dotenv"
8
8
 
9
9
  module PUNK
10
10
  class Env < Settings
11
11
  def logger
12
- SemanticLogger['PUNK::Env']
12
+ SemanticLogger["PUNK::Env"]
13
13
  end
14
14
 
15
15
  def initialize(*args)
@@ -47,10 +47,10 @@ module PUNK
47
47
  private
48
48
 
49
49
  def _load
50
- _load_environment(File.join(PUNK.store.args.path, '..', 'env'), ENV.fetch('PUNK_ENV'), PUNK.store.args.task)
50
+ _load_environment(File.join(PUNK.store.args.path, "..", "env"), ENV.fetch("PUNK_ENV"), PUNK.store.args.task)
51
51
  @schema = {}
52
- _load_schemas(File.join(__dir__, '..', 'config'), ENV.fetch('PUNK_ENV'), PUNK.store.args.task)
53
- _load_schemas(File.join(PUNK.store.args.path, 'config'), ENV.fetch('PUNK_ENV'), PUNK.store.args.task)
52
+ _load_schemas(File.join(__dir__, "..", "config"), ENV.fetch("PUNK_ENV"), PUNK.store.args.task)
53
+ _load_schemas(File.join(PUNK.store.args.path, "config"), ENV.fetch("PUNK_ENV"), PUNK.store.args.task)
54
54
  @values = @schema.keys.zip(Array.new(@schema.length, nil)).to_h
55
55
  _add_config(
56
56
  task: PUNK.store.args.task,
@@ -58,8 +58,8 @@ module PUNK
58
58
  path: PUNK.store.args.path
59
59
  }
60
60
  )
61
- _load_configs(File.join(__dir__, '..', 'config'), ENV.fetch('PUNK_ENV'), PUNK.store.args.task)
62
- _load_configs(File.join(PUNK.store.args.path, 'config'), ENV.fetch('PUNK_ENV'), PUNK.store.args.task)
61
+ _load_configs(File.join(__dir__, "..", "config"), ENV.fetch("PUNK_ENV"), PUNK.store.args.task)
62
+ _load_configs(File.join(PUNK.store.args.path, "config"), ENV.fetch("PUNK_ENV"), PUNK.store.args.task)
63
63
  _add_environment
64
64
  _add_arguments
65
65
  _validate
@@ -84,7 +84,7 @@ module PUNK
84
84
  def _unflatten(data)
85
85
  results = {}
86
86
  data.each do |key, value|
87
- name = key.join('.')
87
+ name = key.join(".")
88
88
  search = results
89
89
  while key.length > 1
90
90
  item = key.shift
@@ -108,12 +108,12 @@ module PUNK
108
108
  required = false
109
109
  key.map! do |name|
110
110
  match = /^(_?)([a-z_]+)(!?)$/.match(name)
111
- raise InternalServerError, "Invalid schema key: #{key.join('.')}" if match.nil?
112
- override &&= match[1] != '_'
113
- required ||= match[3] == '!'
111
+ raise InternalServerError, "Invalid schema key: #{key.join(".")}" if match.nil?
112
+ override &&= match[1] != "_"
113
+ required ||= match[3] == "!"
114
114
  match[2].to_sym
115
115
  end
116
- raise InternalServerError, "Duplicate schema key: #{key.join('.')}" if @schema.key?(key)
116
+ raise InternalServerError, "Duplicate schema key: #{key.join(".")}" if @schema.key?(key)
117
117
  @schema[key] = {
118
118
  required: required,
119
119
  override: override,
@@ -122,9 +122,9 @@ module PUNK
122
122
  end
123
123
  end
124
124
 
125
- def _load_schemas(base, name=nil, dir=nil)
125
+ def _load_schemas(base, name = nil, dir = nil)
126
126
  base = File.expand_path(base)
127
- _load_schema(File.join(base, 'schema.json'))
127
+ _load_schema(File.join(base, "schema.json"))
128
128
  _load_schema(File.join(base, "schema_#{name}.json")) unless name.nil?
129
129
  _load_schemas(File.join(base, dir), name) unless dir.nil?
130
130
  end
@@ -133,7 +133,7 @@ module PUNK
133
133
  @schema.each do |key, value|
134
134
  next unless value[:required]
135
135
  current_value = @values[key]
136
- raise InternalServerError, "Missing required configuration value: #{key.join('.')}" if current_value.nil?
136
+ raise InternalServerError, "Missing required configuration value: #{key.join(".")}" if current_value.nil?
137
137
  end
138
138
  end
139
139
 
@@ -212,16 +212,16 @@ module PUNK
212
212
  else
213
213
  raise InternalServerError, "Unknown validation: #{validation}"
214
214
  end
215
- raise InternalServerError, "#{value} is invalid for #{key.join('.')}: #{validation}" unless valid
215
+ raise InternalServerError, "#{value} is invalid for #{key.join(".")}: #{validation}" unless valid
216
216
  value
217
217
  end
218
218
 
219
219
  def _add_value(key, value)
220
220
  schema = @schema[key]
221
- raise InternalServerError, "Configuration not found in schema: #{key.join('.')}" if schema.nil?
221
+ raise InternalServerError, "Configuration not found in schema: #{key.join(".")}" if schema.nil?
222
222
  unless schema[:override]
223
223
  current_value = @values[key]
224
- raise InternalServerError, "Cannot override configuration value: #{key.join('.')}" unless current_value.nil?
224
+ raise InternalServerError, "Cannot override configuration value: #{key.join(".")}" unless current_value.nil?
225
225
  end
226
226
  @values[key] = _typecast(key, value, schema[:validate], schema[:required])
227
227
  end
@@ -238,9 +238,9 @@ module PUNK
238
238
  _add_config(ActiveSupport::JSON.decode(File.read(path)))
239
239
  end
240
240
 
241
- def _load_configs(base, name=nil, dir=nil)
241
+ def _load_configs(base, name = nil, dir = nil)
242
242
  base = File.expand_path(base)
243
- _load_config(File.join(base, 'defaults.json'))
243
+ _load_config(File.join(base, "defaults.json"))
244
244
  _load_config(File.join(base, "#{name}.json")) unless name.nil?
245
245
  _load_configs(File.join(base, dir), name) unless dir.nil?
246
246
  end
@@ -251,12 +251,12 @@ module PUNK
251
251
  Dotenv.load(path)
252
252
  end
253
253
 
254
- def _load_environment(base, name=nil, dir=nil)
254
+ def _load_environment(base, name = nil, dir = nil)
255
255
  base = File.expand_path(base)
256
256
  _load_environment(File.join(base, dir), name) unless dir.nil?
257
- _load_dotenv(File.join(base, 'locals.sh'))
257
+ _load_dotenv(File.join(base, "locals.sh"))
258
258
  _load_dotenv(File.join(base, "#{name}.sh"))
259
- _load_dotenv(File.join(base, 'defaults.sh'))
259
+ _load_dotenv(File.join(base, "defaults.sh"))
260
260
  end
261
261
 
262
262
  def _add_environment
@@ -264,7 +264,7 @@ module PUNK
264
264
  key = key.downcase
265
265
  match = /^punk_(.*)$/.match(key)
266
266
  next unless match
267
- key = match[1].split('_').reject(&:empty?).map(&:to_sym)
267
+ key = match[1].split("_").reject(&:empty?).map(&:to_sym)
268
268
  _add_value(key, value)
269
269
  end
270
270
  end
@@ -7,24 +7,24 @@ module PUNK
7
7
  if PUNK.get.app.reloadable?
8
8
  PUNK.loader.require(path)
9
9
  else
10
- Dir.glob(File.join(path, '**/*.rb')).sort.each { |file| require(file) }
10
+ Dir.glob(File.join(path, "**/*.rb")).sort.each { |file| require(file) }
11
11
  end
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
16
  PUNK::Interface.register(:loader) do
17
- require 'rack/unreloader'
17
+ require "rack/unreloader"
18
18
  raise PUNK::InternalServerError, "App is not reloadable" unless PUNK.get.app.reloadable?
19
19
  retval = Rack::Unreloader.new { PUNK::App }
20
- require_relative './monkey_unreloader'
20
+ require_relative "./monkey_unreloader"
21
21
  retval
22
22
  end
23
23
 
24
24
  PUNK::Interface.register(:app) do
25
- require_relative 'app'
26
- PUNK.require_all(File.join(__dir__, '..', 'routes'))
27
- PUNK.require_all(File.join(PUNK.get.app.path, 'routes'))
25
+ require_relative "app"
26
+ PUNK.require_all(File.join(__dir__, "..", "routes"))
27
+ PUNK.require_all(File.join(PUNK.get.app.path, "routes"))
28
28
  retval = PUNK.get.app.reloadable ? PUNK.loader : PUNK::App.freeze.app
29
29
  SemanticLogger.flush
30
30
  retval
@@ -32,8 +32,8 @@ end
32
32
 
33
33
  PUNK.inject :loader, :app
34
34
 
35
- ['actions', 'models', 'views', 'services', 'workers'].each do |dir|
36
- PUNK.require_all(File.join(__dir__, '..', dir))
35
+ ["actions", "models", "views", "services", "workers"].each do |dir|
36
+ PUNK.require_all(File.join(__dir__, "..", dir))
37
37
  PUNK.require_all(File.join(PUNK.get.app.path, dir))
38
38
  end
39
39
 
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/dependencies/autoload'
4
- require 'active_support/core_ext'
5
- require 'active_support/json'
3
+ require "active_support/dependencies/autoload"
4
+ require "active_support/core_ext"
5
+ require "active_support/json"
6
6
 
7
- require 'oj'
7
+ require "oj"
8
8
  Oj.optimize_rails
9
9
 
10
- require 'forwardable'
11
- require 'dim'
10
+ require "forwardable"
11
+ require "dim"
12
12
 
13
- require_relative 'version'
14
- require_relative 'error'
15
- require_relative 'monkey'
13
+ require_relative "version"
14
+ require_relative "error"
15
+ require_relative "monkey"
16
16
 
17
17
  module PUNK
18
18
  extend SingleForwardable
@@ -27,30 +27,30 @@ module PUNK
27
27
  end
28
28
 
29
29
  PUNK::Interface.register(:store) do
30
- require 'ostruct'
30
+ require "ostruct"
31
31
  store = OpenStruct.new
32
32
  store.state = :included
33
33
  Thread.current[:rr] = store
34
34
  end
35
35
 
36
36
  PUNK::Interface.register(:bootstrap) do
37
- raise PUNK::InternalServerError, 'Must call PUNK.init first!' if PUNK.state != :initialised
38
- require_relative 'settings'
39
- require_relative 'logger'
37
+ raise PUNK::InternalServerError, "Must call PUNK.init first!" if PUNK.state != :initialised
38
+ require_relative "settings"
39
+ require_relative "logger"
40
40
  end
41
41
 
42
42
  PUNK::Interface.register(:config) do |c|
43
43
  c.bootstrap
44
- PUNK.profile_trace('config') do
45
- require_relative 'env'
44
+ PUNK.profile_trace("config") do
45
+ require_relative "env"
46
46
  PUNK.get.load!
47
- require_relative 'commands'
47
+ require_relative "commands"
48
48
  end
49
49
  end
50
50
 
51
51
  PUNK::Interface.register(:boot) do |c|
52
52
  c.config
53
- retval = PUNK.profile_trace('boot') { require_relative 'boot' }
53
+ retval = PUNK.profile_trace("boot") { require_relative "boot" }
54
54
  PUNK.logger.info "Punk! v#{PUNK.version}"
55
55
  PUNK.db.fetch("SELECT version(), timeofday()") do |row|
56
56
  row.each_value { |value| PUNK.logger.info value }
@@ -60,12 +60,12 @@ end
60
60
 
61
61
  PUNK::Interface.register(:load) do |c|
62
62
  c.boot
63
- PUNK.profile_debug('load') { require_relative 'load' }
63
+ PUNK.profile_debug("load") { require_relative "load" }
64
64
  end
65
65
 
66
66
  PUNK::Interface.register(:exec) do |c|
67
67
  c.load
68
- retval = PUNK.profile_debug('exec') { require_relative 'exec' }
68
+ retval = PUNK.profile_debug("exec") { require_relative "exec" }
69
69
  PUNK.logger.tagged(PUNK.env, PUNK.task) do
70
70
  PUNK.logger.info PUNK.get.app.name
71
71
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  PUNK.db
4
4
 
5
- require_relative '../helpers/all'
6
- require_relative '../framework/all'
5
+ require_relative "../helpers/all"
6
+ require_relative "../framework/all"
7
7
 
8
8
  PUNK.store[:state] = :loaded
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'semantic_logger'
3
+ require "semantic_logger"
4
4
 
5
5
  module PUNK
6
6
  include SemanticLogger::Loggable
@@ -22,9 +22,9 @@ module PUNK
22
22
 
23
23
  SemanticLogger.default_level =
24
24
  case PUNK.store.args.task
25
- when 'console', 'script'
25
+ when "console", "script"
26
26
  :info
27
- when 'spec'
27
+ when "spec"
28
28
  :debug
29
29
  else
30
30
  :trace
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Hash
4
4
  def sanitize
5
- merge(slice(:password, :secret, 'password', 'secret').transform_values { "***" })
5
+ merge(slice(:password, :secret, "password", "secret").transform_values { "***" })
6
6
  end
7
7
  end
data/lib/punk/core/pry.rb CHANGED
@@ -22,9 +22,9 @@ ensure
22
22
  end
23
23
 
24
24
  def reload!
25
- ['actions', 'models', 'views', 'services', 'workers'].each do |dir|
25
+ ["actions", "models", "views", "services", "workers"].each do |dir|
26
26
  path = File.join(PUNK.get.app.path, dir)
27
- Dir.glob(File.join(path, '**/*.rb')).each { |file| load(file) }
27
+ Dir.glob(File.join(path, "**/*.rb")).each { |file| load(file) }
28
28
  end
29
29
  "Reloaded all actions, models, views, services and workers."
30
30
  ensure
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dot_hash'
3
+ require "dot_hash"
4
4
 
5
5
  module PUNK
6
6
  class Settings < DotHash::Settings
7
- alias key? has_key?
7
+ alias_method :key?, :has_key?
8
8
 
9
9
  delegate :inspect, to: :_inspect_hash
10
10
 
@@ -13,9 +13,9 @@ module PUNK
13
13
  if match && key?(match[1]) && !key?(key)
14
14
  value = execute(match[1], *args, &block)
15
15
  case match[2]
16
- when '?'
16
+ when "?"
17
17
  return value if value.is_a?(TrueClass) || value.is_a?(FalseClass)
18
- when '!'
18
+ when "!"
19
19
  raise InternalServerError, "Value is nil: #{key}" if value.nil?
20
20
  return value
21
21
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PUNK
4
4
  def self.version
5
- File.read(File.join(__dir__, '..', '..', '..', 'VERSION'))
5
+ File.read(File.join(__dir__, "..", "..", "..", "VERSION"))
6
6
  end
7
7
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../punk'
4
- require 'sidekiq'
5
- require 'sidekiq-cron'
3
+ require_relative "../../punk"
4
+ require "sidekiq"
5
+ require "sidekiq-cron"
6
6
 
7
- PUNK.init(task: 'worker', config: { app: { name: 'Roadie' } }).exec
7
+ PUNK.init(task: "worker", config: {app: {name: "Roadie"}}).exec
8
8
 
9
- Sidekiq.logger = SemanticLogger['PUNK::SKQ']
9
+ Sidekiq.logger = SemanticLogger["PUNK::SKQ"]
10
10
  Sidekiq.logger.class.alias_method(:with_context, :tagged)
11
11
 
12
- path = File.expand_path(File.join(PUNK.get.app.path, '..', 'config', 'schedule.yml'))
12
+ path = File.expand_path(File.join(PUNK.get.app.path, "..", "config", "schedule.yml"))
13
13
  Sidekiq::Cron::Job.load_from_hash(YAML.load_file(path))
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'plugins/all'
4
- require_relative 'model'
5
- require_relative 'runnable'
6
- require_relative 'service'
7
- require_relative 'worker'
8
- require_relative 'action'
9
- require_relative 'view'
10
- require_relative 'command'
3
+ require_relative "plugins/all"
4
+ require_relative "model"
5
+ require_relative "runnable"
6
+ require_relative "service"
7
+ require_relative "worker"
8
+ require_relative "action"
9
+ require_relative "view"
10
+ require_relative "command"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aasm'
3
+ require "aasm"
4
4
 
5
5
  AASM::Configuration.hide_warnings = true
6
6
 
@@ -22,17 +22,18 @@ module PUNK
22
22
 
23
23
  plugin PUNK::Plugins::Validation
24
24
 
25
- def validate; end
25
+ def validate
26
+ end
26
27
 
27
28
  def inspect
28
29
  id.present? ? "#{id}|#{self}" : to_s
29
30
  end
30
31
 
31
- def self.sample_dataset(count=1)
32
- order(Sequel.lit('random()')).limit(count)
32
+ def self.sample_dataset(count = 1)
33
+ order(Sequel.lit("random()")).limit(count)
33
34
  end
34
35
 
35
- def self.sample(count=1)
36
+ def self.sample(count = 1)
36
37
  query = sample_dataset(count)
37
38
  count == 1 ? query.first : query.all
38
39
  end