flame 5.0.0.rc10 → 5.0.0.rc11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9f5ed6826ce10190699edca72f191a08887d3acf0bf4f8b563457d6c13c3287
4
- data.tar.gz: e6f1cb17ebfe5edefad9c7f692e07f1394e94cf869219872201068703177a970
3
+ metadata.gz: 89e36471cb9755dd5cec82cd27a11a38dad419ad731fed6764534b996175117b
4
+ data.tar.gz: 0bbfd34f7b9424d3c519825a0302255980859d9591f97d1a466f0ec4f217321b
5
5
  SHA512:
6
- metadata.gz: caeabdc659c818aab2ad4b9e50f204ef4eae3e6ef398e4a1c38ef4b0e0d7c632dcc2956e490e68c2fd6ddd9c7521ce6f2ed9dd5bf5b524c44a37c1a4b53e9968
7
- data.tar.gz: d06cecef3a6a12e154e9f8b24ecff2eeda41f0fe9ee48a2eddbc4e051ea6da6faa4a50dd2ff11618792ceab4edb208b283c8c2ba22938e76c378f25dae484775
6
+ metadata.gz: 4152b8a1cf18f168aee8af8e839da19f579bd6a25cf63739c3ecbef15af83b21f37ecdfa96b0c94c007efbe8968052d53c51d1fe7cb7fd6b5cf1b2e49830c01c
7
+ data.tar.gz: de60d571c4f6fba4f89462c8895365615d730142bb94baf2f052e7f4a735b6afbe949972535cd1b79f2987eaa05c5974c3a02b56f9fbd9b6cf2b60a4512d73ad
data/CHANGELOG.md CHANGED
@@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file.
11
11
  But you can disable it with `nested: false` option for `mount`,
12
12
  for example, for conditional umbrella application.
13
13
  * Allow to mount anonymous controllers
14
- * Add support for Ruby 3.0 ­– 3.4
14
+ * Add support for Ruby 3.0 ­– 4.0
15
15
  * Add support of `OPTIONS` HTTP-method
16
16
  * Add `Application.require_dirs` method
17
17
  * Add `Controller#path_to_back` method
@@ -81,18 +81,22 @@ All notable changes to this project will be documented in this file.
81
81
  * Don't assign results of `execute` (after-hooks) as `body`
82
82
  * Require directories starting with `_` first
83
83
  * Allow to redefine controller path with `PATH` constant inside
84
+ * Resolve Ruby warnings
84
85
  * Update Rack and GorillaPatch
85
86
  * Update RuboCop to a new version, resolve new offenses
86
87
  * Improve version locks for dependencies
87
88
  * Use Depfu instead of closed Gemnasium
89
+ * Improve CI config
88
90
 
89
91
  ### Removed
90
92
 
91
93
  * Remove `Application#config` and `Application#router` methods
92
94
  * Remove Ruby < 2.7 support
95
+ * Remove integration with `better_errors`.
93
96
  * Remove HTML tags (`<h1>`) from default body \
94
97
  There is no `Content-Type` HTTP header, also there is no reason to return exactly HTML content \
95
98
  (Flame can be used only for API or something else).
99
+ * Remove `bundler` as development dependency.
96
100
 
97
101
  ### Fixed
98
102
 
@@ -111,10 +111,10 @@ module Flame
111
111
  ## mount :cabinet do # Cabinet::IndexController
112
112
  ## mount :articles # Cabinet::ArticlesController
113
113
  ## end
114
- def mount(controller, path = nil, nested: true, &block)
114
+ def mount(controller, path = nil, nested: true, &)
115
115
  ## Add routes from controller to glob array
116
116
  router.add Router::RoutesRefine.new(
117
- namespace_name, controller, path, nested: nested, &block
117
+ namespace_name, controller, path, nested: nested, &
118
118
  )
119
119
  end
120
120
 
data/lib/flame/config.rb CHANGED
@@ -25,7 +25,7 @@ module Flame
25
25
  ## @param key [Symbol] config key
26
26
  ## @return [Object] config value
27
27
  def [](key)
28
- result = super(key)
28
+ result = super
29
29
  result = instance_exec(&result) if result.class <= Proc && result.parameters.empty?
30
30
  result
31
31
  end
@@ -7,6 +7,7 @@ module Flame
7
7
  ## Module for work with actions
8
8
  module Actions
9
9
  include Memery
10
+
10
11
  using GorillaPatch::Slice
11
12
 
12
13
  ## Shortcut for not-inherited public methods: actions
@@ -14,8 +14,8 @@ module Flame
14
14
  end
15
15
 
16
16
  ## Build a URI to the given controller and action, or path
17
- def url_to(*args, **options)
18
- path = build_path_for_url(*args, **options)
17
+ def url_to(*, **)
18
+ path = build_path_for_url(*, **)
19
19
  Addressable::URI.join(request.base_url, path).to_s
20
20
  end
21
21
 
@@ -16,9 +16,18 @@ module Flame
16
16
  ## Class initialize when Dispatcher found route with it
17
17
  ## For new request and response
18
18
  class Controller
19
- extend Actions
20
19
  include Memery
21
20
 
21
+ extend Forwardable
22
+
23
+ extend Actions
24
+
25
+ def_delegators(
26
+ :@dispatcher,
27
+ :config, :request, :params, :halt, :session, :response, :status, :body,
28
+ :default_body, :cached_tilts, :find_static
29
+ )
30
+
22
31
  class << self
23
32
  attr_accessor :path_arguments
24
33
 
@@ -43,14 +52,6 @@ module Flame
43
52
  end
44
53
  end
45
54
 
46
- extend Forwardable
47
-
48
- def_delegators(
49
- :@dispatcher,
50
- :config, :request, :params, :halt, :session, :response, :status, :body,
51
- :default_body, :cached_tilts, :find_static
52
- )
53
-
54
55
  ## Initialize the controller for request execution
55
56
  ## @param dispatcher [Flame::Dispatcher] host dispatcher
56
57
  def initialize(dispatcher)
@@ -116,7 +117,7 @@ module Flame
116
117
  response[content_dis] = disposition.to_s
117
118
  return unless filename
118
119
 
119
- response[content_dis] << "; filename=\"#{File.basename(filename)}\""
120
+ response[content_dis] += "; filename=\"#{File.basename(filename)}\""
120
121
  ext = File.extname(filename)
121
122
  response.content_type = ext unless ext.empty?
122
123
  end
@@ -125,15 +126,15 @@ module Flame
125
126
  ## @param path [Symbol, nil] path to the template file
126
127
  ## @param options [Hash] options for the `Flame::Render` rendering
127
128
  ## @return [String] rendered template
128
- def view(path = nil, options = {}, &block)
129
+ def view(path = nil, options = {}, &)
129
130
  cache = options.delete(:cache)
130
131
  cache = config[:environment] == 'production' if cache.nil?
131
132
  template = Flame::Render.new(
132
133
  self,
133
- (path || caller_locations(1, 1)[0].base_label.to_sym),
134
+ path || caller_locations(1, 1)[0].base_label.to_sym,
134
135
  options
135
136
  )
136
- template.render(cache: cache, &block)
137
+ template.render(cache: cache, &)
137
138
  end
138
139
  alias render view
139
140
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'cgi'
3
+ require 'cgi/escape'
4
4
 
5
5
  module Flame
6
6
  class Dispatcher
@@ -18,8 +18,8 @@ module Flame
18
18
  private
19
19
 
20
20
  ## Find static files and try return it
21
- def try_static(*args, **kwargs)
22
- file = find_static(*args, **kwargs)
21
+ def try_static(*, **)
22
+ file = find_static(*, **)
23
23
  return nil unless file.exist?
24
24
 
25
25
  halt 400 unless file.within_directory
@@ -16,16 +16,17 @@ module Flame
16
16
  class Dispatcher
17
17
  include Memery
18
18
 
19
- GEM_STATIC_FILES = File.join(__dir__, '../../public').freeze
20
-
21
19
  extend Forwardable
22
- def_delegators :@app_class, :router, :path_to
23
-
24
- attr_reader :request, :response
25
20
 
26
21
  include Flame::Dispatcher::Static
27
22
  include Flame::Dispatcher::Routes
28
23
 
24
+ GEM_STATIC_FILES = File.join(__dir__, '../../public').freeze
25
+
26
+ attr_reader :request, :response
27
+
28
+ def_delegators :@app_class, :router, :path_to
29
+
29
30
  ## Initialize Dispatcher from Application#call
30
31
  ## @param app_class [Class] application class
31
32
  ## @param env Rack-environment object
data/lib/flame/path.rb CHANGED
@@ -11,6 +11,7 @@ module Flame
11
11
  include Memery
12
12
 
13
13
  extend Forwardable
14
+
14
15
  def_delegators :to_s, :include?
15
16
 
16
17
  ## Merge parts of path to one path
@@ -196,11 +197,11 @@ module Flame
196
197
  class Part
197
198
  extend Forwardable
198
199
 
199
- def_delegators :to_s, :[], :hash, :size, :empty?, :b, :inspect
200
-
201
200
  ARG_CHAR = ':'
202
201
  ARG_CHAR_OPT = '?'
203
202
 
203
+ def_delegators :to_s, :[], :hash, :size, :empty?, :b, :inspect
204
+
204
205
  ## Create new instance from String
205
206
  ## @param part [String] path part as String
206
207
  ## @param arg [Boolean] is this part an argument
data/lib/flame/render.rb CHANGED
@@ -46,14 +46,14 @@ module Flame
46
46
  ## Render template with layout
47
47
  ## @param cache [Boolean] cache compiles or not
48
48
  ## @return [String] compiled template
49
- def render(cache: true, &block)
49
+ def render(cache: true, &)
50
50
  @cache = cache
51
51
  ## Compile Tilt to instance hash
52
52
  return unless @filename
53
53
 
54
54
  tilt = compile_file
55
55
  ## Render Tilt from instance hash with new options
56
- layout_render tilt.render(@scope, @locals, &block)
56
+ layout_render tilt.render(@scope, @locals, &)
57
57
  end
58
58
 
59
59
  private
@@ -93,7 +93,7 @@ module Flame
93
93
 
94
94
  ## Find template-file by path
95
95
  def find_file(path)
96
- caller_path = caller_locations(4..4).first.path
96
+ caller_path = find_caller_path
97
97
 
98
98
  ## It now never causes `LoadError`, but returning `nil`, as I want
99
99
  ## https://github.com/jeremyevans/tilt/issues/2
@@ -103,6 +103,11 @@ module Flame
103
103
  .find { |file| Tilt[file] }
104
104
  end
105
105
 
106
+ ## Find caller path
107
+ def find_caller_path
108
+ caller_locations.find { |location| !location.path.include?(__dir__) }.path
109
+ end
110
+
106
111
  ## Find layout-files by path
107
112
  def find_layouts(path)
108
113
  find_files(path, layout_dirs)
@@ -39,6 +39,8 @@ module Flame
39
39
 
40
40
  TRASNFORMATION_METHODS = %i[camelize upcase].freeze
41
41
 
42
+ private_constant :TRASNFORMATION_METHODS
43
+
42
44
  def controller_name_variations
43
45
  TRASNFORMATION_METHODS.each_with_object([]) do |method, result|
44
46
  transformed = @controller_name.to_s.send(method)
@@ -9,10 +9,10 @@ module Flame
9
9
  class Route
10
10
  extend Forwardable
11
11
 
12
- def_delegators :to_s, :inspect
13
-
14
12
  attr_reader :controller, :action
15
13
 
14
+ def_delegators :to_s, :inspect
15
+
16
16
  ## Create a new instance
17
17
  ## @param controller [Flame::Controller] controller
18
18
  ## @param action [Symbol] action
@@ -13,9 +13,9 @@ module Flame
13
13
  ## @param controller [Flame::Controller] class of mounting controller
14
14
  ## @param path [String, nil] root path for mounting controller
15
15
  ## @yield Block of code for routes refine
16
- def mount(controller_name, path = nil, &block)
16
+ def mount(controller_name, path = nil, &)
17
17
  routes_refine = self.class.new(
18
- @namespace_name, controller_name, path, &block
18
+ @namespace_name, controller_name, path, &
19
19
  )
20
20
 
21
21
  @endpoint.deep_merge! routes_refine.routes
@@ -25,18 +25,15 @@ module Flame
25
25
 
26
26
  using GorillaPatch::Namespace
27
27
 
28
- def initialize(
29
- namespace_name, controller_or_name, path, nested: true, &block
30
- )
31
- @controller =
32
- ControllerFinder.new(namespace_name, controller_or_name).controller
28
+ def initialize(namespace_name, controller_or_name, path, nested: true, &)
29
+ @controller = ControllerFinder.new(namespace_name, controller_or_name).controller
33
30
  @namespace_name = @controller.deconstantize
34
31
  @path = Flame::Path.new(path || @controller.path)
35
32
  @controller.path_arguments = @path.parts.select(&:arg?).map(&:to_sym)
36
33
  @routes, @endpoint = @path.to_routes_with_endpoint
37
34
  @reverse_routes = {}
38
35
  @mount_nested = nested
39
- execute(&block)
36
+ execute(&)
40
37
  end
41
38
 
42
39
  private
@@ -85,10 +82,11 @@ module Flame
85
82
  get action unless find_reverse_route(action)
86
83
  end
87
84
 
88
- mount_nested_controllers if @mount_nested && (
89
- @controller.demodulize == 'IndexController' &&
90
- !@namespace_name.empty?
91
- )
85
+ if @mount_nested &&
86
+ @controller.demodulize == 'IndexController' &&
87
+ !@namespace_name.empty?
88
+ mount_nested_controllers
89
+ end
92
90
  end
93
91
 
94
92
  ## Assign methods of the controller to REST architecture
@@ -120,7 +118,7 @@ module Flame
120
118
  def validate_action_path(action, action_path)
121
119
  Validators::RouteArgumentsValidator
122
120
  .new(@controller, action_path, action)
123
- .valid?
121
+ .validate!
124
122
  end
125
123
 
126
124
  def remove_old_routes(action, new_route)
data/lib/flame/router.rb CHANGED
@@ -10,17 +10,18 @@ require_relative 'errors/controller_not_found_error'
10
10
  module Flame
11
11
  ## Router class for routing
12
12
  class Router
13
+ extend Forwardable
14
+
13
15
  HTTP_METHODS = %i[GET POST PUT PATCH DELETE].freeze
14
16
 
15
17
  require_relative 'router/route'
16
18
  require_relative 'router/routes'
17
19
  require_relative 'router/routes_refine'
18
20
 
19
- extend Forwardable
20
- def_delegators :routes, :navigate
21
-
22
21
  attr_reader :app, :routes, :reverse_routes
23
22
 
23
+ def_delegators :routes, :navigate
24
+
24
25
  ## @param app [Flame::Application] host application
25
26
  def initialize(app)
26
27
  @app = app
@@ -20,14 +20,14 @@ module Flame
20
20
  end
21
21
 
22
22
  ## Validate
23
- ## @return [true, false] valid or not
24
- def valid?
25
- extra_valid? && order_valid?
23
+ ## @return [true, false] valid or raise an error
24
+ def validate!
25
+ extra_validate! && order_validate!
26
26
  end
27
27
 
28
28
  private
29
29
 
30
- def extra_valid?
30
+ def extra_validate!
31
31
  extra_arguments = first_extra_arguments
32
32
  ## Raise error if extra arguments
33
33
  return true unless extra_arguments
@@ -37,7 +37,7 @@ module Flame
37
37
  )
38
38
  end
39
39
 
40
- def order_valid?
40
+ def order_validate!
41
41
  wrong_ordered_arguments = first_wrong_ordered_arguments
42
42
  return true unless wrong_ordered_arguments
43
43
 
data/lib/flame/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flame
4
- VERSION = '5.0.0.rc10'
4
+ VERSION = '5.0.0.rc11'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flame
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.rc10
4
+ version: 5.0.0.rc11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: addressable
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.0'
32
+ version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.0'
39
+ version: '3.0'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: gorilla_patch
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '3.0'
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: '6'
49
+ version: '7'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '3.0'
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
- version: '6'
59
+ version: '7'
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: psych
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -147,8 +147,8 @@ licenses:
147
147
  metadata:
148
148
  rubygems_mfa_required: 'true'
149
149
  bug_tracker_uri: https://github.com/AlexWayfer/flame/issues
150
- changelog_uri: https://github.com/AlexWayfer/flame/blob/v5.0.0.rc10/CHANGELOG.md
151
- documentation_uri: http://www.rubydoc.info/gems/flame/5.0.0.rc10
150
+ changelog_uri: https://github.com/AlexWayfer/flame/blob/v5.0.0.rc11/CHANGELOG.md
151
+ documentation_uri: http://www.rubydoc.info/gems/flame/5.0.0.rc11
152
152
  homepage_uri: https://github.com/AlexWayfer/flame
153
153
  source_code_uri: https://github.com/AlexWayfer/flame
154
154
  wiki_uri: https://github.com/AlexWayfer/flame/wiki
@@ -159,17 +159,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
- version: '3.0'
162
+ version: '3.2'
163
163
  - - "<"
164
164
  - !ruby/object:Gem::Version
165
- version: '3.5'
165
+ version: '5'
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
168
  - - ">="
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.6.2
172
+ rubygems_version: 4.0.3
173
173
  specification_version: 4
174
174
  summary: Web-framework, based on MVC-pattern
175
175
  test_files: []