pakyow-core 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80c64e0fbe8b4edcb3b10b4ac4cd640fbd4e4fb501108798f418cf0829289d50
4
- data.tar.gz: ce5ebf0caebc91cbfd1c0c1463a9bcd9312fff947f1fef05aeec07df1833c486
3
+ metadata.gz: 12e96f8e6d8402b05a724cf25346153e3dd6e983a781553b048f5f22ee5f9658
4
+ data.tar.gz: 34981bf9cb7538249e849bdf3974ab610e11beb47a780b51deb16663478cd926
5
5
  SHA512:
6
- metadata.gz: 9edb7dd91ee759baada1e3176644f9c7f409fce6f052f0dbe87dcdd7220ef946d22f90eb87add99a33ae5edfa0ed409e6104781fbf78fb8888b003a7c4fa27dc
7
- data.tar.gz: bfe086b797fbf4501b7a549caffe0797949421e9a71eb04d243a7c44041ff05ef7f55c75db134ff9b25731f5fec174695db8dba4af8a56117b773d09c65c18d0
6
+ metadata.gz: d681b76e4c741396812704e3af8b548f6e6d400985cd27c8bafbd59ae3597c5aa799981a2b99ed65f1bc161d41e8bfbe15c0dc1dab4c9e96e818bfbe25621efb
7
+ data.tar.gz: 8596bc0d9d783cf15af6178b0f4acaf681c1decf56ecfffd1da1a8b209a4a4c704d9050f165d2de7c7534f1a4b7e0af36c7bff525533c487e744bd1949f183ed
data/lib/pakyow/app.rb CHANGED
@@ -188,8 +188,8 @@ module Pakyow
188
188
  app_connection = isolated(:Connection).new(self, connection)
189
189
  super(app_connection)
190
190
  rescue => error
191
- if respond_to?(:controller_for_connection)
192
- controller_for_connection(app_connection).handle_error(error)
191
+ if respond_to?(:controller_for_connection) && controller = controller_for_connection(app_connection)
192
+ controller.handle_error(error)
193
193
  else
194
194
  raise error
195
195
  end
@@ -32,12 +32,16 @@ module Pakyow
32
32
  private
33
33
 
34
34
  def load_aspect(aspect, path: File.join(config.src, aspect.to_s), target: self.class)
35
+ __load_aspect(aspect, path: path, target: target)
36
+ end
37
+
38
+ def __load_aspect(aspect, path: File.join(config.src, aspect.to_s), target: self.class)
35
39
  Dir.glob(File.join(path, "*.rb")) do |file_path|
36
40
  Loader.new(file_path).call(target)
37
41
  end
38
42
 
39
43
  Dir.glob(File.join(path, "*")).select { |sub_path| File.directory?(sub_path) }.each do |directory|
40
- load_aspect(aspect, path: directory, target: target)
44
+ __load_aspect(aspect, path: directory, target: target)
41
45
  end
42
46
  end
43
47
  end
@@ -79,14 +79,6 @@ module Pakyow
79
79
  end
80
80
  end
81
81
 
82
- def included_helper_context(object)
83
- @__included_helpers.each_pair do |object_with_helpers, context|
84
- return context if object.is_a?(object_with_helpers)
85
- end
86
-
87
- nil
88
- end
89
-
90
82
  def helpers(context)
91
83
  case context.to_sym
92
84
  when :global
@@ -101,6 +93,15 @@ module Pakyow
101
93
  )
102
94
  end
103
95
  end
96
+
97
+ # @api private
98
+ def included_helper_context(object)
99
+ @__included_helpers.each_pair do |object_with_helpers, context|
100
+ return context if object.is_a?(object_with_helpers)
101
+ end
102
+
103
+ nil
104
+ end
104
105
  end
105
106
  end
106
107
  end
@@ -35,6 +35,7 @@ module Pakyow
35
35
  class_methods do
36
36
  # Define operations as stateful when an app is defined.
37
37
  #
38
+ # @api private
38
39
  def make(*)
39
40
  super.tap do |new_class|
40
41
  new_class.stateful :operation, Operation
@@ -25,12 +25,12 @@ module Pakyow
25
25
 
26
26
  def load_pipeline_defaults(pipeline)
27
27
  if self.class.includes_framework?(:assets)
28
- pipeline.action(Assets::Actions::Public, self)
29
- pipeline.action(Assets::Actions::Process)
28
+ pipeline.action(Actions::Assets::Public, self)
29
+ pipeline.action(Actions::Assets::Process)
30
30
  end
31
31
 
32
32
  if self.class.includes_framework?(:realtime) && Pakyow.config.realtime.server && !is_a?(Plugin)
33
- pipeline.action(Realtime::Actions::Upgrader)
33
+ pipeline.action(Actions::Realtime::Upgrader)
34
34
  end
35
35
 
36
36
  if self.class.includes_framework?(:routing) && !Pakyow.env?(:prototype)
@@ -46,11 +46,11 @@ module Pakyow
46
46
  end
47
47
 
48
48
  if self.class.includes_framework?(:presenter)
49
- pipeline.action(Presenter::Actions::AutoRender)
49
+ pipeline.action(Actions::Presenter::AutoRender)
50
50
  end
51
51
 
52
52
  if self.class.includes_framework?(:routing) && !Pakyow.env?(:prototype) && !is_a?(Plugin)
53
- pipeline.action(Routing::Actions::RespondMissing)
53
+ pipeline.action(Actions::Routing::RespondMissing)
54
54
  end
55
55
  end
56
56
  end
@@ -43,6 +43,8 @@ module Pakyow
43
43
  end
44
44
  end
45
45
 
46
+ private
47
+
46
48
  def setup_for_restarting
47
49
  if config.process.restartable
48
50
  config.process.watched_paths << File.join(config.src, "**/*.rb")
data/lib/pakyow/cli.rb CHANGED
@@ -19,12 +19,12 @@ module Pakyow
19
19
  app: {
20
20
  description: "The app to run the command on",
21
21
  global: true
22
- },
22
+ }.freeze,
23
23
  env: {
24
24
  description: "What environment to use",
25
25
  global: true
26
- }
27
- }
26
+ }.freeze
27
+ }.freeze
28
28
 
29
29
  def initialize(argv = ARGV.dup)
30
30
  @argv = argv
@@ -6,6 +6,8 @@ require "securerandom"
6
6
  require "async/http"
7
7
  require "async/http/protocol/response"
8
8
 
9
+ require "protocol/http/body/rewindable"
10
+
9
11
  require "mini_mime"
10
12
 
11
13
  require "pakyow/support/deep_dup"
@@ -109,8 +111,8 @@ module Pakyow
109
111
  #
110
112
  def method
111
113
  unless instance_variable_defined?(:@method)
112
- @method = if request_method == "POST" && params.include?(:_method)
113
- params[:_method].downcase.to_sym
114
+ @method = if request_method == "POST" && params.include?(:"pw-http-method")
115
+ params[:"pw-http-method"].downcase.to_sym
114
116
  else
115
117
  request_method.downcase.to_sym
116
118
  end
@@ -494,8 +496,14 @@ module Pakyow
494
496
 
495
497
  def parse_input
496
498
  if instance_variable_defined?(:@input_parser) && input
497
- @input_parser.call(input, self).tap do
498
- input.rewind if input.respond_to?(:rewind)
499
+ if @input_parser[:rewindable]
500
+ request.body = Async::HTTP::Body::Rewindable.new(request.body)
501
+ end
502
+
503
+ @input_parser[:block].call(input, self).tap do
504
+ if input.respond_to?(:rewind)
505
+ input.rewind
506
+ end
499
507
  end
500
508
  else
501
509
  nil
@@ -29,7 +29,7 @@ module Pakyow
29
29
  ).parse(input)
30
30
  end
31
31
 
32
- Pakyow.parse_input "application/json" do |input, connection|
32
+ Pakyow.parse_input "application/json", rewindable: true do |input, connection|
33
33
  values = JSON.parse(input.read)
34
34
 
35
35
  if values.is_a?(Hash)
@@ -44,8 +44,11 @@ module Pakyow
44
44
  end
45
45
 
46
46
  class_methods do
47
- def parse_input(type, &block)
48
- @input_parsers[type] = block
47
+ def parse_input(type, rewindable: true, &block)
48
+ @input_parsers[type] = {
49
+ block: block,
50
+ rewindable: rewindable
51
+ }
49
52
  end
50
53
  end
51
54
  end
@@ -12,7 +12,6 @@ require "pakyow/support/configurable"
12
12
  require "pakyow/support/class_state"
13
13
  require "pakyow/support/deep_dup"
14
14
  require "pakyow/support/deep_freeze"
15
- require "pakyow/support/logging"
16
15
  require "pakyow/support/pipeline"
17
16
  require "pakyow/support/inflector"
18
17
 
@@ -371,13 +370,23 @@ module Pakyow
371
370
  def handle_boot_failure(error)
372
371
  @error = error
373
372
 
374
- Support::Logging.safe do |logger|
375
- logger.houston(error)
373
+ safe_logger do |logger|
374
+ if logger.respond_to?(:houston)
375
+ logger.houston(error)
376
+ else
377
+ logger.error(error)
378
+ end
376
379
  end
377
380
 
378
381
  if config.exit_on_boot_failure
379
382
  exit(false)
380
383
  end
381
384
  end
385
+
386
+ require "logger"
387
+
388
+ def safe_logger
389
+ yield logger || ::Logger.new($stdout)
390
+ end
382
391
  end
383
392
  end
@@ -9,3 +9,7 @@
9
9
  # Ignore local databases.
10
10
  #
11
11
  database/*.db*
12
+
13
+ # Ignore tmp files.
14
+ #
15
+ tmp
@@ -13,7 +13,7 @@ gem "pakyow", "~> <%= Pakyow::VERSION %>", require: "pakyow/all"
13
13
  #
14
14
  gem "dotenv"
15
15
 
16
- group :development, :prototype do
16
+ group :development do
17
17
  # Speed up project boot time.
18
18
  #
19
19
  gem "bootsnap", require: false
@@ -9,6 +9,6 @@ You can access your project at [`localhost:3000`](http://localhost:3000) from yo
9
9
  ## Learn more
10
10
 
11
11
  * Website: https://pakyow.com
12
- * Community: https://pakyow.com/talk
12
+ * Community: https://pakyow.com/community
13
13
  * Documentation: https://pakyow.com/docs/hello
14
14
  * View Source: https://github.com/pakyow/pakyow
@@ -6,6 +6,10 @@ Pakyow.configure :development do
6
6
  config.data.connections.sql[:default] = "sqlite://database/development.db"
7
7
  end
8
8
 
9
+ Pakyow.configure :prototype do
10
+ config.data.connections.sql[:default] = "sqlite://database/prototype.db"
11
+ end
12
+
9
13
  Pakyow.configure :production do
10
14
  config.data.connections.sql[:default] = ENV["DATABASE_URL"]
11
15
  end
@@ -3,5 +3,5 @@
3
3
  # Requires the bundle.
4
4
  #
5
5
  if defined?(Bundler)
6
- Bundler.require :default, Pakyow.env
6
+ Bundler.require :default, Pakyow.env?(:prototype) ? :development : Pakyow.env
7
7
  end
@@ -39,8 +39,6 @@ module Pakyow
39
39
  serialize(entry)
40
40
  end
41
41
 
42
- private
43
-
44
42
  def format_logger_message(logger_message, entry)
45
43
  logger = logger_message["logger"]
46
44
  message = logger_message["message"]
@@ -54,7 +54,6 @@ module Pakyow
54
54
  #
55
55
  # @see Pakyow::Verifier
56
56
  #
57
- # @api public
58
57
  def verify(&block)
59
58
  define_method :__verify do
60
59
  verify(&block)
@@ -4,7 +4,6 @@ require "forwardable"
4
4
 
5
5
  module Pakyow
6
6
  class Plugin
7
- # @api private
8
7
  class Lookup
9
8
  include Enumerable
10
9
 
@@ -45,7 +45,7 @@ module Pakyow
45
45
  if app_info = app_templates.info(path)
46
46
  # Define the plugin view as the `plug` partial so that it can be included.
47
47
  #
48
- plugin_info[:partials][:plug] = Presenter::Partial.from_object(
48
+ plugin_info[:partials][:plug] = Presenter::Views::Partial.from_object(
49
49
  :plug, plugin_info[:page].object
50
50
  )
51
51
 
data/lib/pakyow/plugin.rb CHANGED
@@ -140,6 +140,7 @@ module Pakyow
140
140
  @helper_class.new(self, connection)
141
141
  end
142
142
 
143
+ # @api private
143
144
  def __object_name
144
145
  self.class.__object_name
145
146
  end
@@ -172,6 +173,7 @@ module Pakyow
172
173
  :"__#{prefix}.#{name}"
173
174
  end
174
175
 
176
+ # @api private
175
177
  def _dump(_)
176
178
  Marshal.dump(
177
179
  {
@@ -186,6 +188,7 @@ module Pakyow
186
188
  )
187
189
  end
188
190
 
191
+ # @api private
189
192
  def self._load(state)
190
193
  state = Marshal.load(state)
191
194
  Pakyow.app(state[:parent][:name]).plugs.find { |plug|
@@ -215,7 +218,7 @@ module Pakyow
215
218
  end
216
219
  end
217
220
 
218
- def load_aspect(aspect)
221
+ def load_aspect(aspect, **)
219
222
  @state.each do |state|
220
223
  super(aspect, path: state.backend_path(aspect), target: self)
221
224
  end
@@ -15,8 +15,6 @@ module Pakyow
15
15
  #
16
16
  # @api public
17
17
  module Presence
18
- WHITESPACE_ONLY = /^\s*$/
19
-
20
18
  def self.name
21
19
  :presence
22
20
  end
@@ -27,7 +25,7 @@ module Pakyow
27
25
 
28
26
  def self.valid?(value, **)
29
27
  if value.is_a?(String)
30
- !value.match?(WHITESPACE_ONLY)
28
+ !value.strip.empty?
31
29
  elsif value.respond_to?(:empty?)
32
30
  !value.empty?
33
31
  else
@@ -34,6 +34,7 @@ module Pakyow
34
34
  @validation_objects[validation_object.name] = validation_object
35
35
  end
36
36
 
37
+ # @api private
37
38
  def validation_object_for(validation)
38
39
  @validation_objects[validation] || raise(
39
40
  UnknownValidationError.new_with_message(validation: validation)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: commands
11
11
  cert_chain: []
12
- date: 2019-07-04 00:00:00.000000000 Z
12
+ date: 2019-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pakyow-support
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.0.0.rc2
20
+ version: 1.0.0.rc3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.0.rc2
27
+ version: 1.0.0.rc3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: async
30
30
  requirement: !ruby/object:Gem::Requirement