hanami-controller 0.0.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +155 -0
  3. data/LICENSE.md +22 -0
  4. data/README.md +1180 -9
  5. data/hanami-controller.gemspec +19 -12
  6. data/lib/hanami-controller.rb +1 -0
  7. data/lib/hanami/action.rb +85 -0
  8. data/lib/hanami/action/cache.rb +174 -0
  9. data/lib/hanami/action/cache/cache_control.rb +70 -0
  10. data/lib/hanami/action/cache/conditional_get.rb +93 -0
  11. data/lib/hanami/action/cache/directives.rb +99 -0
  12. data/lib/hanami/action/cache/expires.rb +73 -0
  13. data/lib/hanami/action/callable.rb +94 -0
  14. data/lib/hanami/action/callbacks.rb +210 -0
  15. data/lib/hanami/action/configurable.rb +49 -0
  16. data/lib/hanami/action/cookie_jar.rb +181 -0
  17. data/lib/hanami/action/cookies.rb +85 -0
  18. data/lib/hanami/action/exposable.rb +115 -0
  19. data/lib/hanami/action/flash.rb +182 -0
  20. data/lib/hanami/action/glue.rb +66 -0
  21. data/lib/hanami/action/head.rb +122 -0
  22. data/lib/hanami/action/mime.rb +493 -0
  23. data/lib/hanami/action/params.rb +285 -0
  24. data/lib/hanami/action/rack.rb +270 -0
  25. data/lib/hanami/action/rack/callable.rb +47 -0
  26. data/lib/hanami/action/rack/file.rb +33 -0
  27. data/lib/hanami/action/redirect.rb +59 -0
  28. data/lib/hanami/action/request.rb +86 -0
  29. data/lib/hanami/action/session.rb +154 -0
  30. data/lib/hanami/action/throwable.rb +194 -0
  31. data/lib/hanami/action/validatable.rb +128 -0
  32. data/lib/hanami/controller.rb +250 -2
  33. data/lib/hanami/controller/configuration.rb +705 -0
  34. data/lib/hanami/controller/error.rb +7 -0
  35. data/lib/hanami/controller/version.rb +4 -1
  36. data/lib/hanami/http/status.rb +62 -0
  37. metadata +124 -16
  38. data/.gitignore +0 -9
  39. data/Gemfile +0 -4
  40. data/Rakefile +0 -2
  41. data/bin/console +0 -14
  42. data/bin/setup +0 -8
@@ -0,0 +1,7 @@
1
+ module Hanami
2
+ module Controller
3
+ # @since 0.5.0
4
+ class Error < ::StandardError
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,8 @@
1
1
  module Hanami
2
2
  module Controller
3
- VERSION = "0.0.0"
3
+ # Defines the version
4
+ #
5
+ # @since 0.1.0
6
+ VERSION = '0.6.0'.freeze
4
7
  end
5
8
  end
@@ -0,0 +1,62 @@
1
+ require 'rack/utils'
2
+
3
+ module Hanami
4
+ module Http
5
+ # An HTTP status
6
+ #
7
+ # @since 0.1.0
8
+ # @api private
9
+ class Status
10
+ # A set of standard codes and messages for HTTP statuses
11
+ #
12
+ # @since 0.1.0
13
+ # @api private
14
+ ALL = ::Rack::Utils::HTTP_STATUS_CODES.dup.merge({
15
+ 103 => 'Checkpoint',
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
20
+ 418 => 'I\'m a teapot',
21
+ 420 => 'Enhance Your Calm',
22
+ 444 => 'No Response',
23
+ 449 => 'Retry With',
24
+ 450 => 'Blocked by Windows Parental Controls',
25
+ 451 => 'Wrong Exchange server',
26
+ 499 => 'Client Closed Request',
27
+ 506 => 'Variant Also Negotiates', # Rack 1.5 compat
28
+ 598 => 'Network read timeout error',
29
+ 599 => 'Network connect timeout error'
30
+ }).freeze
31
+
32
+ # Return a status for the given code
33
+ #
34
+ # @param code [Fixnum] a valid HTTP code
35
+ #
36
+ # @return [Array] a pair of code and message for an HTTP status
37
+ #
38
+ # @since 0.1.0
39
+ # @api private
40
+ #
41
+ # @example
42
+ # require 'hanami/http/status'
43
+ #
44
+ # Hanami::Http::Status.for_code(418) # => [418, "I'm a teapot"]
45
+ def self.for_code(code)
46
+ ALL.assoc(code)
47
+ end
48
+
49
+ # Return a message for the given status code
50
+ #
51
+ # @param code [Fixnum] a valid HTTP code
52
+ #
53
+ # @return [String] a message for the given status code
54
+ #
55
+ # @since 0.3.2
56
+ # @api private
57
+ def self.message_for(code)
58
+ for_code(code)[1]
59
+ end
60
+ end
61
+ end
62
+ end
metadata CHANGED
@@ -1,61 +1,168 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
+ - Trung Lê
9
+ - Alfonso Uceda
8
10
  autorequire:
9
- bindir: exe
11
+ bindir: bin
10
12
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
13
+ date: 2016-01-22 00:00:00.000000000 Z
12
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.6.2
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - "~>"
30
+ - !ruby/object:Gem::Version
31
+ version: '1.6'
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.6.2
35
+ - !ruby/object:Gem::Dependency
36
+ name: hanami-utils
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.7'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.7'
49
+ - !ruby/object:Gem::Dependency
50
+ name: hanami-validations
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.5'
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.5'
13
63
  - !ruby/object:Gem::Dependency
14
64
  name: bundler
15
65
  requirement: !ruby/object:Gem::Requirement
16
66
  requirements:
17
67
  - - "~>"
18
68
  - !ruby/object:Gem::Version
19
- version: '1.11'
69
+ version: '1.6'
20
70
  type: :development
21
71
  prerelease: false
22
72
  version_requirements: !ruby/object:Gem::Requirement
23
73
  requirements:
24
74
  - - "~>"
25
75
  - !ruby/object:Gem::Version
26
- version: '1.11'
76
+ version: '1.6'
77
+ - !ruby/object:Gem::Dependency
78
+ name: minitest
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '5'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '5'
91
+ - !ruby/object:Gem::Dependency
92
+ name: rack-test
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.6'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.6'
27
105
  - !ruby/object:Gem::Dependency
28
106
  name: rake
29
107
  requirement: !ruby/object:Gem::Requirement
30
108
  requirements:
31
109
  - - "~>"
32
110
  - !ruby/object:Gem::Version
33
- version: '10.0'
111
+ version: '10'
34
112
  type: :development
35
113
  prerelease: false
36
114
  version_requirements: !ruby/object:Gem::Requirement
37
115
  requirements:
38
116
  - - "~>"
39
117
  - !ruby/object:Gem::Version
40
- version: '10.0'
41
- description: Hanami is a web framework for Ruby
118
+ version: '10'
119
+ description: Complete, fast and testable actions for Rack
42
120
  email:
43
121
  - me@lucaguidi.com
122
+ - trung.le@ruby-journal.com
123
+ - uceda73@gmail.com
44
124
  executables: []
45
125
  extensions: []
46
126
  extra_rdoc_files: []
47
127
  files:
48
- - ".gitignore"
49
- - Gemfile
128
+ - CHANGELOG.md
129
+ - LICENSE.md
50
130
  - README.md
51
- - Rakefile
52
- - bin/console
53
- - bin/setup
54
131
  - hanami-controller.gemspec
132
+ - lib/hanami-controller.rb
133
+ - lib/hanami/action.rb
134
+ - lib/hanami/action/cache.rb
135
+ - lib/hanami/action/cache/cache_control.rb
136
+ - lib/hanami/action/cache/conditional_get.rb
137
+ - lib/hanami/action/cache/directives.rb
138
+ - lib/hanami/action/cache/expires.rb
139
+ - lib/hanami/action/callable.rb
140
+ - lib/hanami/action/callbacks.rb
141
+ - lib/hanami/action/configurable.rb
142
+ - lib/hanami/action/cookie_jar.rb
143
+ - lib/hanami/action/cookies.rb
144
+ - lib/hanami/action/exposable.rb
145
+ - lib/hanami/action/flash.rb
146
+ - lib/hanami/action/glue.rb
147
+ - lib/hanami/action/head.rb
148
+ - lib/hanami/action/mime.rb
149
+ - lib/hanami/action/params.rb
150
+ - lib/hanami/action/rack.rb
151
+ - lib/hanami/action/rack/callable.rb
152
+ - lib/hanami/action/rack/file.rb
153
+ - lib/hanami/action/redirect.rb
154
+ - lib/hanami/action/request.rb
155
+ - lib/hanami/action/session.rb
156
+ - lib/hanami/action/throwable.rb
157
+ - lib/hanami/action/validatable.rb
55
158
  - lib/hanami/controller.rb
159
+ - lib/hanami/controller/configuration.rb
160
+ - lib/hanami/controller/error.rb
56
161
  - lib/hanami/controller/version.rb
162
+ - lib/hanami/http/status.rb
57
163
  homepage: http://hanamirb.org
58
- licenses: []
164
+ licenses:
165
+ - MIT
59
166
  metadata: {}
60
167
  post_install_message:
61
168
  rdoc_options: []
@@ -65,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
172
  requirements:
66
173
  - - ">="
67
174
  - !ruby/object:Gem::Version
68
- version: '0'
175
+ version: 2.0.0
69
176
  required_rubygems_version: !ruby/object:Gem::Requirement
70
177
  requirements:
71
178
  - - ">="
@@ -76,5 +183,6 @@ rubyforge_project:
76
183
  rubygems_version: 2.5.1
77
184
  signing_key:
78
185
  specification_version: 4
79
- summary: The web, with simplicity
186
+ summary: Complete, fast and testable actions for Rack and Hanami
80
187
  test_files: []
188
+ has_rdoc:
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in hanami-controller.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "hanami/controller"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here