flame 4.7.2 → 4.7.4
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 +4 -4
- data/bin/flame +2 -2
- data/lib/flame/controller.rb +12 -2
- data/lib/flame/dispatcher.rb +3 -3
- data/lib/flame/render.rb +4 -3
- data/lib/flame/router.rb +6 -11
- data/lib/flame/static.rb +3 -3
- data/lib/flame/validators.rb +2 -6
- data/lib/flame/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db65a3c8ddcc20b17eba7c861d4e3312c50c4de3
|
4
|
+
data.tar.gz: 0dedc0d40dd716a783d7f8902f72b7850de4413c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67a398ed323183b5d49750ed8f7220993b2dd607e6ce6a2d3004716eb1928b71a7cb18256d3f7dee063913447d1f8df3397751c85293934bd487302fc2090510
|
7
|
+
data.tar.gz: c357eeb4004523028079a6ef602449e0d92751fd408b83e5b9c3bc04ad6679e3b0cadd4744911dc5a4c5d85c02a501129a9e493ff0d9576ac3f77b7e50c6fc02
|
data/bin/flame
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'thor'
|
4
4
|
require 'fileutils'
|
5
|
-
require 'gorilla-patch/
|
5
|
+
require 'gorilla-patch/inflections'
|
6
6
|
require 'erb'
|
7
7
|
|
8
8
|
## CLI Application
|
@@ -25,7 +25,7 @@ class FlameCLI < Thor
|
|
25
25
|
module New
|
26
26
|
module_function
|
27
27
|
|
28
|
-
using GorillaPatch::
|
28
|
+
using GorillaPatch::Inflections
|
29
29
|
|
30
30
|
def build(app_name)
|
31
31
|
@app_name = app_name
|
data/lib/flame/controller.rb
CHANGED
@@ -6,6 +6,11 @@ module Flame
|
|
6
6
|
## Class initialize when Dispatcher found route with it
|
7
7
|
## For new request and response
|
8
8
|
class Controller
|
9
|
+
## Shortcut for not-inherited public methods: actions
|
10
|
+
def self.actions
|
11
|
+
public_instance_methods(false)
|
12
|
+
end
|
13
|
+
|
9
14
|
## Initialize the controller for request execution
|
10
15
|
## @param dispatcher [Flame::Dispatcher] dispatcher object
|
11
16
|
def initialize(dispatcher)
|
@@ -91,6 +96,11 @@ module Flame
|
|
91
96
|
@dispatcher.send(m, *args, &block)
|
92
97
|
end
|
93
98
|
|
99
|
+
## Respond to Dispatcher methods
|
100
|
+
def respond_to_missing?(m, *)
|
101
|
+
@dispatcher.respond_to?(m) || super
|
102
|
+
end
|
103
|
+
|
94
104
|
private
|
95
105
|
|
96
106
|
def add_controller_class(args)
|
@@ -99,7 +109,7 @@ module Flame
|
|
99
109
|
end
|
100
110
|
|
101
111
|
class << self
|
102
|
-
using GorillaPatch::
|
112
|
+
using GorillaPatch::Inflections
|
103
113
|
|
104
114
|
## Default root path of the controller for requests
|
105
115
|
def default_path
|
@@ -133,7 +143,7 @@ module Flame
|
|
133
143
|
end
|
134
144
|
|
135
145
|
def define_parent_actions
|
136
|
-
superclass.
|
146
|
+
superclass.actions.each do |public_method|
|
137
147
|
um = superclass.public_instance_method(public_method)
|
138
148
|
define_method public_method, um
|
139
149
|
end
|
data/lib/flame/dispatcher.rb
CHANGED
@@ -26,9 +26,9 @@ module Flame
|
|
26
26
|
def run!
|
27
27
|
catch :halt do
|
28
28
|
try_route ||
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
try_static ||
|
30
|
+
try_static(File.join(__dir__, '..', '..', 'public')) ||
|
31
|
+
halt(404)
|
32
32
|
end
|
33
33
|
response.write body
|
34
34
|
response.finish
|
data/lib/flame/render.rb
CHANGED
@@ -4,7 +4,7 @@ require 'tilt'
|
|
4
4
|
require 'tilt/plain'
|
5
5
|
require 'tilt/erb'
|
6
6
|
|
7
|
-
require 'gorilla-patch/
|
7
|
+
require 'gorilla-patch/inflections'
|
8
8
|
|
9
9
|
module Flame
|
10
10
|
## Helper for render functionality
|
@@ -79,11 +79,12 @@ module Flame
|
|
79
79
|
|
80
80
|
## Find layout-files by path
|
81
81
|
def find_layouts(path)
|
82
|
-
find_files(path, layout_dirs)
|
82
|
+
find_files(path, layout_dirs)
|
83
|
+
.select { |file| Tilt[file] }
|
83
84
|
.sort! { |a, b| b.split('/').size <=> a.split('/').size }
|
84
85
|
end
|
85
86
|
|
86
|
-
using GorillaPatch::
|
87
|
+
using GorillaPatch::Inflections
|
87
88
|
|
88
89
|
## Find possible directories for the controller
|
89
90
|
def controller_dirs
|
data/lib/flame/router.rb
CHANGED
@@ -20,9 +20,8 @@ module Flame
|
|
20
20
|
|
21
21
|
## Add routes from controller to glob array
|
22
22
|
route_refine = RouteRefine.new(self, ctrl, path, block)
|
23
|
-
|
24
|
-
|
25
|
-
end
|
23
|
+
return unless Validators::ActionsValidator.new(route_refine).valid?
|
24
|
+
concat_routes(route_refine)
|
26
25
|
end
|
27
26
|
|
28
27
|
## Find route by any attributes
|
@@ -58,10 +57,6 @@ module Flame
|
|
58
57
|
attr_accessor :rest_routes
|
59
58
|
attr_reader :ctrl, :routes
|
60
59
|
|
61
|
-
def self.http_methods
|
62
|
-
[:GET, :POST, :PUT, :PATCH, :DELETE]
|
63
|
-
end
|
64
|
-
|
65
60
|
## Defaults REST routes (methods, pathes, controllers actions)
|
66
61
|
def rest_routes
|
67
62
|
@rest_routes ||= [
|
@@ -81,7 +76,7 @@ module Flame
|
|
81
76
|
execute(&block)
|
82
77
|
end
|
83
78
|
|
84
|
-
|
79
|
+
%i(GET POST PUT PATCH DELETE).each do |request_method|
|
85
80
|
## Define refine methods for all HTTP methods
|
86
81
|
## @overload post(path, action)
|
87
82
|
## Execute action on requested path and HTTP method
|
@@ -115,7 +110,7 @@ module Flame
|
|
115
110
|
## to defaults pathes and HTTP methods
|
116
111
|
def defaults
|
117
112
|
rest
|
118
|
-
@ctrl.
|
113
|
+
@ctrl.actions.each do |action|
|
119
114
|
next if find_route_index(action: action)
|
120
115
|
send(:GET.downcase, action)
|
121
116
|
end
|
@@ -125,8 +120,8 @@ module Flame
|
|
125
120
|
def rest
|
126
121
|
rest_routes.each do |rest_route|
|
127
122
|
action = rest_route[:action]
|
128
|
-
next
|
129
|
-
|
123
|
+
next if !@ctrl.actions.include?(action) ||
|
124
|
+
find_route_index(action: action)
|
130
125
|
send(*rest_route.values.map(&:downcase), prefix: true)
|
131
126
|
end
|
132
127
|
end
|
data/lib/flame/static.rb
CHANGED
@@ -19,9 +19,9 @@ module Flame
|
|
19
19
|
halt 304 if static_cached?(file_time)
|
20
20
|
content_type File.extname(file)
|
21
21
|
response['Last-Modified'] = file_time.httpdate
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
# 'Content-Disposition' => 'attachment;' \
|
23
|
+
# "filename=\"#{File.basename(static_file)}\"",
|
24
|
+
# 'Content-Length' => File.size?(static_file).to_s
|
25
25
|
halt 200, File.read(file)
|
26
26
|
end
|
27
27
|
end
|
data/lib/flame/validators.rb
CHANGED
@@ -65,10 +65,6 @@ module Flame
|
|
65
65
|
def initialize(route_refine)
|
66
66
|
@routes_actions = route_refine.routes.map(&:action)
|
67
67
|
@ctrl = route_refine.ctrl
|
68
|
-
@ctrl_actions = {
|
69
|
-
public: @ctrl.public_instance_methods(false),
|
70
|
-
all: @ctrl.instance_methods + @ctrl.private_instance_methods
|
71
|
-
}
|
72
68
|
end
|
73
69
|
|
74
70
|
def valid?
|
@@ -78,7 +74,7 @@ module Flame
|
|
78
74
|
private
|
79
75
|
|
80
76
|
def no_extra_routes_actions?
|
81
|
-
extra_routes_actions = @routes_actions - @
|
77
|
+
extra_routes_actions = @routes_actions - @ctrl.actions
|
82
78
|
return true if extra_routes_actions.empty?
|
83
79
|
raise Errors::RouterError::ExtraRoutesActionsError.new(
|
84
80
|
@ctrl, extra_routes_actions
|
@@ -86,7 +82,7 @@ module Flame
|
|
86
82
|
end
|
87
83
|
|
88
84
|
def no_extra_controller_actions?
|
89
|
-
extra_ctrl_actions = @
|
85
|
+
extra_ctrl_actions = @ctrl.actions - @routes_actions
|
90
86
|
return true if extra_ctrl_actions.empty?
|
91
87
|
raise Errors::RouterError::ExtraControllerActionsError.new(
|
92
88
|
@ctrl, extra_ctrl_actions
|
data/lib/flame/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -50,20 +50,20 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2'
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 2.0.0
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '2'
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 2.0.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: thor
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +78,20 @@ dependencies:
|
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rubocop
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
81
95
|
description: Use controller's classes with instance methods as routing actions, mounting
|
82
96
|
its in application class.
|
83
97
|
email:
|
@@ -141,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
155
|
version: '0'
|
142
156
|
requirements: []
|
143
157
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.6.8
|
145
159
|
signing_key:
|
146
160
|
specification_version: 4
|
147
161
|
summary: Web-framework, based on MVC-pattern
|