fishwife 1.1.1-java

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.
@@ -0,0 +1,33 @@
1
+ #--
2
+ # Copyright (c) 2011 David Kellum
3
+ # Copyright (c) 2010-2011 Don Werve
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
6
+ # may not use this file except in compliance with the License. You may
7
+ # obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
+ # implied. See the License for the specific language governing
15
+ # permissions and limitations under the License.
16
+ #++
17
+
18
+ # Load our local copy of Fishwife before anything else.
19
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
+
21
+ # Setup logging
22
+ require 'rjack-logback'
23
+ RJack::Logback.config_console( :stderr => true, :thread => true )
24
+ RJack::Logback.root.level = RJack::Logback::DEBUG if ENV['DEBUG_LOG']
25
+
26
+ # All dependencies for testing.
27
+ require 'yaml'
28
+ require 'net/http'
29
+ require 'rack/urlmap'
30
+ require 'rack/lint'
31
+ require 'fishwife'
32
+
33
+ Thread.abort_on_exception = true
@@ -0,0 +1,120 @@
1
+ #--
2
+ # Copyright (c) 2011 David Kellum
3
+ # Copyright (c) 2010-2011 Don Werve
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
6
+ # may not use this file except in compliance with the License. You may
7
+ # obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
+ # implied. See the License for the specific language governing
15
+ # permissions and limitations under the License.
16
+ #++
17
+
18
+ # A tiny Rack application for testing the Fishwife webserver. Each of
19
+ # the following paths can be used to test webserver behavior:
20
+ #
21
+ # /ping:: Always returns 200 OK.
22
+ #
23
+ # /error/:number:: Returns the HTTP status code specified in the path.
24
+ #
25
+ # /echo:: Returns a plaintext rendering of the original request.
26
+ #
27
+ # /file:: Returns a file for downloading.
28
+ #
29
+ # /push:: Publishes a message to async listeners.
30
+ #
31
+ # /pull:: Recieves messages sent via /push using async.
32
+ #
33
+ # A request to any endpoint not listed above will return a 404 error.
34
+ class TestApp
35
+ def initialize
36
+ @subscribers = Array.new
37
+ end
38
+
39
+ def call(env)
40
+ begin
41
+ request = Rack::Request.new(env)
42
+ method = request.path[/^\/(\w+)/, 1]
43
+ return(error(request, 404)) if (method.nil? or method.empty?)
44
+ return(error(request, 404)) unless respond_to?(method.to_sym)
45
+ send(method.to_sym, request)
46
+ rescue => error
47
+ puts error
48
+ puts error.backtrace
49
+ error(nil, 500)
50
+ end
51
+ end
52
+
53
+ def ping(request)
54
+ [ 200, { "Content-Type" => "text/plain",
55
+ "Content-Length" => "2" }, [ "OK" ] ]
56
+ end
57
+
58
+ def error(request, code = nil)
59
+ code ||= (request.path[/^\/\w+\/(\d+)/, 1] or "500")
60
+ [ code.to_i,
61
+ { "Content-Type" => "text/plain",
62
+ "Content-Length" => "5" },
63
+ [ "ERROR" ] ]
64
+ end
65
+
66
+ def echo(request)
67
+ response = Rack::Response.new
68
+ env = request.env.merge('request.params' => request.params)
69
+ response.write(env.to_yaml)
70
+ response.finish
71
+ end
72
+
73
+ def multi_headers(request)
74
+ [ 204, { "Warning" => %w[ warn-1 warn-2 ].join( "\n" ) }, [] ]
75
+ end
76
+
77
+ def push(request)
78
+ message = request.params['message']
79
+
80
+ @subscribers.reject! do |subscriber|
81
+ begin
82
+ response = Rack::Response.new
83
+ if(message.empty?)
84
+ subscriber.call(response.finish)
85
+ next(true)
86
+ else
87
+ response.write(message)
88
+ subscriber.call(response.finish)
89
+ next(false)
90
+ end
91
+ rescue java.io.IOException => error
92
+ next(true)
93
+ end
94
+ end
95
+
96
+ ping(request)
97
+ end
98
+
99
+ def pull(request)
100
+ @subscribers << request.env['async.callback']
101
+ throw(:async)
102
+ end
103
+
104
+ def download(request)
105
+ file = File.new('spec/data/reddit-icon.png', 'r')
106
+ response = Rack::Response.new(file)
107
+ response['Content-Type'] = 'image/png'
108
+ response['Content-Disposition'] =
109
+ 'attachment; filename=reddit-icon.png'
110
+ response.finish
111
+ end
112
+
113
+ def upload(request)
114
+ data = request.params['file'][:tempfile].read
115
+ checksum = Digest::MD5.hexdigest(Base64.decode64(data))
116
+ response = Rack::Response.new
117
+ response.write(checksum)
118
+ response.finish
119
+ end
120
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fishwife
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.1.1
6
+ platform: java
7
+ authors:
8
+ - David Kellum
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-11-06 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.3.2
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rjack-jetty
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 7.5.0
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rjack-slf4j
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.1
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rjack-logback
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.2.0
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rspec
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 2.6.0
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: rjack-tarpit
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.4.0
79
+ type: :development
80
+ version_requirements: *id006
81
+ description: |-
82
+ Researching fishing and salting process is supposed to increase the
83
+ fishing jetties output. That is, jetties rack holds 9 fish, with
84
+ Fishing (10%) and Salting Process (30%), their rack should hold 12
85
+ fish.
86
+
87
+ They will go through the motion of placing more fish in the rack, but
88
+ the program doesn't count more than 9. So, Fishing and Salting Process
89
+ is a waste of research.
90
+
91
+ Note: One fishing jetty with one fish monger can feed 33% more people
92
+ than one goat farm and one butcher.
93
+
94
+ -- {tomnobles}[http://www.civcityforums.com/index.php?topic=1672.20;wap2], 2009-10-23
95
+ email:
96
+ - dek-oss@gravitext.com
97
+ executables:
98
+ - fishwife
99
+ extensions: []
100
+
101
+ extra_rdoc_files:
102
+ - Manifest.txt
103
+ - History.rdoc
104
+ - README.rdoc
105
+ files:
106
+ - History.rdoc
107
+ - LICENSE
108
+ - Manifest.txt
109
+ - README.rdoc
110
+ - Rakefile
111
+ - bin/fishwife
112
+ - example/config.ru
113
+ - lib/fishwife/base.rb
114
+ - lib/fishwife.rb
115
+ - lib/fishwife/http_server.rb
116
+ - lib/fishwife/rack_servlet.rb
117
+ - lib/rack/handler/fishwife.rb
118
+ - spec/fishwife_spec.rb
119
+ - spec/spec_helper.rb
120
+ - spec/test_app.rb
121
+ - spec/data/hello.txt
122
+ - spec/data/reddit-icon.png
123
+ - .gemtest
124
+ homepage: http://github.com/dekellum/fishwife
125
+ licenses: []
126
+
127
+ post_install_message:
128
+ rdoc_options:
129
+ - --main
130
+ - README.rdoc
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: "0"
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: "0"
145
+ requirements: []
146
+
147
+ rubyforge_project: fishwife
148
+ rubygems_version: 1.8.9
149
+ signing_key:
150
+ specification_version: 3
151
+ summary: A hard working Jetty 7 based rack handler.
152
+ test_files: []
153
+