Skip to content

Commit 4638461

Browse files
committed
move constants to webmachine namespace
1 parent c3e2101 commit 4638461

17 files changed

Lines changed: 52 additions & 73 deletions

File tree

lib/webmachine/adapters/httpkit.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
module Webmachine
1111
module Adapters
1212
class HTTPkit < Adapter
13-
include Constants
14-
1513
VERSION_STRING = "#{Webmachine::SERVER_STRING} HTTPkit/#{::HTTPkit::VERSION}".freeze
1614

1715
def options

lib/webmachine/adapters/rack.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module Adapters
3434
# MyApplication.run
3535
#
3636
class Rack < Adapter
37-
include Constants
3837
# Used to override default Rack server options (useful in testing)
3938
DEFAULT_OPTIONS = {}
4039

@@ -97,7 +96,6 @@ def call(env)
9796
end
9897

9998
class RackResponse
100-
include Webmachine::Constants
10199
ONE_FIVE = '1.5'.freeze
102100

103101
def initialize(body, status, headers)

lib/webmachine/adapters/reel.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
module Webmachine
1010
module Adapters
1111
class Reel < Adapter
12-
include Constants
1312
# Used to override default Reel server options (useful in testing)
1413
DEFAULT_OPTIONS = {}
1514

lib/webmachine/adapters/webrick.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def run
2727

2828
# WEBRick::HTTPServer that is run by the WEBrick adapter.
2929
class Server < ::WEBrick::HTTPServer
30-
include Webmachine::Constants
3130

3231
def initialize(options)
3332
@application = options[:application]

lib/webmachine/chunked_body.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ module Webmachine
1515
#
1616
# This is needed for Ruby webservers which don't do the chunking themselves.
1717
class ChunkedBody
18-
include Constants
19-
2018
# Final chunk in any chunked-encoding response
2119
FINAL_CHUNK = "0#{CRLF}#{CRLF}".freeze
2220

lib/webmachine/constants.rb

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,74 @@
11
module Webmachine
2-
module Constants
3-
# Default HTTP linebreak
4-
CRLF = "\r\n".freeze
2+
# Universal HTTP delimiter
3+
CRLF = "\r\n".freeze
54

6-
# HTTP Content-Type
7-
CONTENT_TYPE = 'Content-Type'.freeze
5+
# HTTP Content-Type
6+
CONTENT_TYPE = 'Content-Type'.freeze
87

9-
# Default Content-Type
10-
TEXT_HTML = 'text/html'.freeze
8+
# Default Content-Type
9+
TEXT_HTML = 'text/html'.freeze
1110

12-
# HTTP Date
13-
DATE = 'Date'.freeze
11+
# HTTP Date
12+
DATE = 'Date'.freeze
1413

15-
# HTTP Transfer-Encoding
16-
TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
14+
# HTTP Transfer-Encoding
15+
TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
1716

18-
# HTTP Content-Length
19-
CONTENT_LENGTH = 'Content-Length'.freeze
17+
# HTTP Content-Length
18+
CONTENT_LENGTH = 'Content-Length'.freeze
2019

21-
# A underscore
22-
UNDERSCORE = '_'.freeze
20+
# A underscore
21+
UNDERSCORE = '_'.freeze
2322

24-
# A dash
25-
DASH = '-'.freeze
23+
# A dash
24+
DASH = '-'.freeze
2625

27-
# A Slash
28-
SLASH = '/'.freeze
26+
# A Slash
27+
SLASH = '/'.freeze
2928

30-
MATCHES_ALL = '*/*'.freeze
29+
MATCHES_ALL = '*/*'.freeze
3130

32-
GET_METHOD = "GET".freeze
33-
HEAD_METHOD = "HEAD".freeze
34-
POST_METHOD = "POST".freeze
35-
PUT_METHOD = "PUT".freeze
36-
DELETE_METHOD = "DELETE".freeze
37-
OPTIONS_METHOD = "OPTIONS".freeze
38-
TRACE_METHOD = "TRACE".freeze
39-
CONNECT_METHOD = "CONNECT".freeze
31+
GET_METHOD = "GET".freeze
32+
HEAD_METHOD = "HEAD".freeze
33+
POST_METHOD = "POST".freeze
34+
PUT_METHOD = "PUT".freeze
35+
DELETE_METHOD = "DELETE".freeze
36+
OPTIONS_METHOD = "OPTIONS".freeze
37+
TRACE_METHOD = "TRACE".freeze
38+
CONNECT_METHOD = "CONNECT".freeze
4039

41-
STANDARD_HTTP_METHODS = [
42-
GET_METHOD, HEAD_METHOD, POST_METHOD,
43-
PUT_METHOD, DELETE_METHOD, TRACE_METHOD,
44-
CONNECT_METHOD, OPTIONS_METHOD
45-
].map!(&:freeze)
40+
STANDARD_HTTP_METHODS = [
41+
GET_METHOD, HEAD_METHOD, POST_METHOD,
42+
PUT_METHOD, DELETE_METHOD, TRACE_METHOD,
43+
CONNECT_METHOD, OPTIONS_METHOD
44+
].map!(&:freeze)
4645

47-
# A colon
48-
COLON = ':'.freeze
46+
# A colon
47+
COLON = ':'.freeze
4948

50-
# http string
51-
HTTP = 'http'.freeze
49+
# http string
50+
HTTP = 'http'.freeze
5251

53-
# Host string
54-
HOST = 'Host'.freeze
52+
# Host string
53+
HOST = 'Host'.freeze
5554

56-
# HTTP Content-Encoding
57-
CONTENT_ENCODING = 'Content-Encoding'.freeze
55+
# HTTP Content-Encoding
56+
CONTENT_ENCODING = 'Content-Encoding'.freeze
5857

59-
# Charset string
60-
CHARSET = 'Charset'.freeze
58+
# Charset string
59+
CHARSET = 'Charset'.freeze
6160

62-
# Semicolon split match
63-
SPLIT_SEMI = /\s*,\s*/.freeze
61+
# Semicolon split match
62+
SPLIT_SEMI = /\s*,\s*/.freeze
6463

65-
# Star Character
66-
STAR = '*'.freeze
64+
# Star Character
65+
STAR = '*'.freeze
6766

68-
# HTTP Location
69-
LOCATION = 'Location'.freeze
67+
# HTTP Location
68+
LOCATION = 'Location'.freeze
7069

71-
# identity Encoding
72-
IDENTITY = 'identity'.freeze
70+
# identity Encoding
71+
IDENTITY = 'identity'.freeze
7372

74-
SERVER = 'Server'.freeze
75-
end
73+
SERVER = 'Server'.freeze
7674
end

lib/webmachine/decision/conneg.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Decision
88
# specifically, choosing media types, encodings, character sets
99
# and languages.
1010
module Conneg
11-
include Constants
1211
HAS_ENCODING = defined?(::Encoding) # Ruby 1.9 compat
1312

1413
# Given the 'Accept' header and provided types, chooses an

lib/webmachine/decision/flow.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Decision
1919
# @see https://raw.github.com/wiki/basho/webmachine/images/http-headers-status-v3.png
2020
module Flow
2121
include Base64
22-
include Constants
2322

2423
# Version of the flow diagram
2524
VERSION = 3

lib/webmachine/decision/fsm.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class FSM
1212
include Helpers
1313
include Trace::FSM
1414
include Translation
15-
include Constants
1615

1716
attr_reader :resource, :request, :response, :metadata
1817

lib/webmachine/decision/helpers.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Helpers
1414
include QuotedString
1515
include Streaming
1616
include HeaderNegotiation
17-
include Constants
1817

1918
# Determines if the response has a body/entity set.
2019
def has_response_body?

0 commit comments

Comments
 (0)