lotus-controller 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,6 @@ module Lotus
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '0.2.0'
6
+ VERSION = '0.3.0'.freeze
7
7
  end
8
8
  end
@@ -14,6 +14,9 @@ module Lotus
14
14
  ALL = ::Rack::Utils::HTTP_STATUS_CODES.dup.merge({
15
15
  103 => 'Checkpoint',
16
16
  122 => 'Request-URI too long',
17
+ 413 => 'Payload Too Large', # Rack 1.5 compat
18
+ 414 => 'URI Too Long', # Rack 1.5 compat
19
+ 416 => 'Range Not Satisfiable', # Rack 1.5 compat
17
20
  418 => 'I\'m a teapot',
18
21
  420 => 'Enhance Your Calm',
19
22
  444 => 'No Response',
@@ -21,6 +24,7 @@ module Lotus
21
24
  450 => 'Blocked by Windows Parental Controls',
22
25
  451 => 'Wrong Exchange server',
23
26
  499 => 'Client Closed Request',
27
+ 506 => 'Variant Also Negotiates', # Rack 1.5 compat
24
28
  598 => 'Network read timeout error',
25
29
  599 => 'Network connect timeout error'
26
30
  }).freeze
@@ -37,7 +41,7 @@ module Lotus
37
41
  # @example
38
42
  # require 'lotus/http/status'
39
43
  #
40
- # Lotus::Http::Status.for_code(418) # => [418, "I'm a teapot (RFC 2324)"]
44
+ # Lotus::Http::Status.for_code(418) # => [418, "I'm a teapot"]
41
45
  def self.for_code(code)
42
46
  ALL.assoc(code)
43
47
  end
data/lib/rack-patch.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # see https://github.com/rack/rack/pull/659
2
2
  require 'rack'
3
+ require 'lotus/utils'
3
4
 
4
5
  if Rack.release <= '1.5'
5
6
  require 'rack/utils'
@@ -8,11 +9,16 @@ if Rack.release <= '1.5'
8
9
  def self.best_q_match(q_value_header, available_mimes)
9
10
  values = q_values(q_value_header)
10
11
 
11
- value = values.map do |req_mime, quality|
12
+ values = values.map do |req_mime, quality|
12
13
  match = available_mimes.find { |am| Rack::Mime.match?(am, req_mime) }
13
14
  next unless match
14
15
  [match, quality]
15
- end.compact.sort_by do |match, quality|
16
+ end.compact
17
+
18
+ # See https://github.com/lotus/controller/issues/59
19
+ values = values.reverse if RUBY_VERSION >= '2.2.0' || Lotus::Utils.rubinius?
20
+
21
+ value = values.sort_by do |match, quality|
16
22
  (match.split('/', 2).count('*') * -10) + quality
17
23
  end.last
18
24
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Lotus::Controller::VERSION
9
9
  spec.authors = ['Luca Guidi']
10
10
  spec.email = ['me@lucaguidi.com']
11
- spec.description = %q{Controller layer for Lotus}
12
- spec.summary = %q{Controller layer for Lotus, compatible with Rack}
11
+ spec.description = %q{Complete, fast and testable actions for Rack}
12
+ spec.summary = %q{Complete, fast and testable actions for Rack and Lotus}
13
13
  spec.homepage = 'http://lotusrb.org'
14
14
  spec.license = 'MIT'
15
15
 
@@ -17,9 +17,11 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = []
18
18
  spec.test_files = spec.files.grep(%r{^(test)/})
19
19
  spec.require_paths = ['lib']
20
+ spec.required_ruby_version = '>= 2.0.0'
20
21
 
21
- spec.add_dependency 'rack', '~> 1.5'
22
- spec.add_dependency 'lotus-utils', '~> 0.2'
22
+ spec.add_dependency 'rack', '~> 1.5'
23
+ spec.add_dependency 'lotus-utils', '~> 0.3', '>= 0.3.2'
24
+ spec.add_dependency 'lotus-validations', '~> 0.2', '>= 0.2.1'
23
25
 
24
26
  spec.add_development_dependency 'bundler', '~> 1.6'
25
27
  spec.add_development_dependency 'minitest', '~> 5'
metadata CHANGED
@@ -1,100 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lotus-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-23 00:00:00.000000000 Z
11
+ date: 2014-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lotus-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.3.2
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.3'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.3.2
47
+ - !ruby/object:Gem::Dependency
48
+ name: lotus-validations
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
32
52
  - !ruby/object:Gem::Version
33
53
  version: '0.2'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.2.1
34
57
  type: :runtime
35
58
  prerelease: false
36
59
  version_requirements: !ruby/object:Gem::Requirement
37
60
  requirements:
38
- - - ~>
61
+ - - "~>"
39
62
  - !ruby/object:Gem::Version
40
63
  version: '0.2'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.2.1
41
67
  - !ruby/object:Gem::Dependency
42
68
  name: bundler
43
69
  requirement: !ruby/object:Gem::Requirement
44
70
  requirements:
45
- - - ~>
71
+ - - "~>"
46
72
  - !ruby/object:Gem::Version
47
73
  version: '1.6'
48
74
  type: :development
49
75
  prerelease: false
50
76
  version_requirements: !ruby/object:Gem::Requirement
51
77
  requirements:
52
- - - ~>
78
+ - - "~>"
53
79
  - !ruby/object:Gem::Version
54
80
  version: '1.6'
55
81
  - !ruby/object:Gem::Dependency
56
82
  name: minitest
57
83
  requirement: !ruby/object:Gem::Requirement
58
84
  requirements:
59
- - - ~>
85
+ - - "~>"
60
86
  - !ruby/object:Gem::Version
61
87
  version: '5'
62
88
  type: :development
63
89
  prerelease: false
64
90
  version_requirements: !ruby/object:Gem::Requirement
65
91
  requirements:
66
- - - ~>
92
+ - - "~>"
67
93
  - !ruby/object:Gem::Version
68
94
  version: '5'
69
95
  - !ruby/object:Gem::Dependency
70
96
  name: rack-test
71
97
  requirement: !ruby/object:Gem::Requirement
72
98
  requirements:
73
- - - ~>
99
+ - - "~>"
74
100
  - !ruby/object:Gem::Version
75
101
  version: '0.6'
76
102
  type: :development
77
103
  prerelease: false
78
104
  version_requirements: !ruby/object:Gem::Requirement
79
105
  requirements:
80
- - - ~>
106
+ - - "~>"
81
107
  - !ruby/object:Gem::Version
82
108
  version: '0.6'
83
109
  - !ruby/object:Gem::Dependency
84
110
  name: rake
85
111
  requirement: !ruby/object:Gem::Requirement
86
112
  requirements:
87
- - - ~>
113
+ - - "~>"
88
114
  - !ruby/object:Gem::Version
89
115
  version: '10'
90
116
  type: :development
91
117
  prerelease: false
92
118
  version_requirements: !ruby/object:Gem::Requirement
93
119
  requirements:
94
- - - ~>
120
+ - - "~>"
95
121
  - !ruby/object:Gem::Version
96
122
  version: '10'
97
- description: Controller layer for Lotus
123
+ description: Complete, fast and testable actions for Rack
98
124
  email:
99
125
  - me@lucaguidi.com
100
126
  executables: []
@@ -106,21 +132,28 @@ files:
106
132
  - README.md
107
133
  - lib/lotus-controller.rb
108
134
  - lib/lotus/action.rb
135
+ - lib/lotus/action/cache.rb
136
+ - lib/lotus/action/cache/cache_control.rb
137
+ - lib/lotus/action/cache/conditional_get.rb
138
+ - lib/lotus/action/cache/directives.rb
139
+ - lib/lotus/action/cache/expires.rb
109
140
  - lib/lotus/action/callable.rb
110
141
  - lib/lotus/action/callbacks.rb
111
142
  - lib/lotus/action/configurable.rb
112
143
  - lib/lotus/action/cookie_jar.rb
113
144
  - lib/lotus/action/cookies.rb
114
145
  - lib/lotus/action/exposable.rb
146
+ - lib/lotus/action/flash.rb
147
+ - lib/lotus/action/glue.rb
115
148
  - lib/lotus/action/mime.rb
116
149
  - lib/lotus/action/params.rb
117
150
  - lib/lotus/action/rack.rb
118
151
  - lib/lotus/action/redirect.rb
119
152
  - lib/lotus/action/session.rb
120
153
  - lib/lotus/action/throwable.rb
154
+ - lib/lotus/action/validatable.rb
121
155
  - lib/lotus/controller.rb
122
156
  - lib/lotus/controller/configuration.rb
123
- - lib/lotus/controller/dsl.rb
124
157
  - lib/lotus/controller/version.rb
125
158
  - lib/lotus/http/status.rb
126
159
  - lib/rack-patch.rb
@@ -135,19 +168,19 @@ require_paths:
135
168
  - lib
136
169
  required_ruby_version: !ruby/object:Gem::Requirement
137
170
  requirements:
138
- - - '>='
171
+ - - ">="
139
172
  - !ruby/object:Gem::Version
140
- version: '0'
173
+ version: 2.0.0
141
174
  required_rubygems_version: !ruby/object:Gem::Requirement
142
175
  requirements:
143
- - - '>='
176
+ - - ">="
144
177
  - !ruby/object:Gem::Version
145
178
  version: '0'
146
179
  requirements: []
147
180
  rubyforge_project:
148
- rubygems_version: 2.0.14
181
+ rubygems_version: 2.2.2
149
182
  signing_key:
150
183
  specification_version: 4
151
- summary: Controller layer for Lotus, compatible with Rack
184
+ summary: Complete, fast and testable actions for Rack and Lotus
152
185
  test_files: []
153
186
  has_rdoc:
@@ -1,56 +0,0 @@
1
- module Lotus
2
- module Controller
3
- # Public DSL
4
- #
5
- # @since 0.1.0
6
- module Dsl
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- module ClassMethods
12
- # Define an action for the given name.
13
- # It generates a concrete class for the action, for this reason the name
14
- # MUST be a valid name for Ruby.
15
- #
16
- # @param name [String] the name of the action
17
- # @param blk [Proc] the code of the action
18
- #
19
- # @raise TypeError when the name isn't a valid Ruby name
20
- #
21
- # @since 0.1.0
22
- #
23
- # @see Lotus::Controller::Configuration#action_module
24
- #
25
- # @example
26
- # require 'lotus/controller'
27
- #
28
- # class ArticlesController
29
- # include Lotus::Controller
30
- #
31
- # action 'Index' do
32
- # def call(params)
33
- # # ...
34
- # end
35
- # end
36
- #
37
- # action 'Show' do
38
- # def call(params)
39
- # # ...
40
- # end
41
- # end
42
- # end
43
- def action(name, &blk)
44
- config = configuration.duplicate
45
- const_set(name, Class.new)
46
-
47
- const_get(name).tap do |klass|
48
- klass.class_eval { include config.action_module }
49
- klass.configuration = config
50
- klass.class_eval(&blk)
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end