bwkfanboy 1.4.1 → 2.0.0

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.
Files changed (81) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +51 -0
  4. data/Procfile +1 -0
  5. data/README.rdoc +40 -77
  6. data/Rakefile +13 -48
  7. data/bin/bwkfanboy +47 -166
  8. data/bin/bwkfanboy_generate +7 -19
  9. data/bin/bwkfanboy_parse +21 -17
  10. data/bwkfanboy.gemspec +40 -0
  11. data/config.ru +3 -0
  12. data/doc/NEWS.rdoc +21 -79
  13. data/doc/plugin.rdoc +63 -79
  14. data/etc/bwkfanboy.yaml +2 -0
  15. data/etc/sinatra.rb +34 -0
  16. data/lib/bwkfanboy/cliconfig.rb +141 -0
  17. data/lib/bwkfanboy/cliutils.rb +114 -0
  18. data/lib/bwkfanboy/fetch.rb +22 -24
  19. data/lib/bwkfanboy/generator.rb +78 -0
  20. data/lib/bwkfanboy/home.rb +53 -0
  21. data/lib/bwkfanboy/meta.rb +5 -2
  22. data/lib/bwkfanboy/plugin.rb +247 -0
  23. data/lib/bwkfanboy/plugin_skeleton.erb +19 -23
  24. data/lib/bwkfanboy/server.rb +73 -0
  25. data/lib/bwkfanboy/utils.rb +39 -129
  26. data/plugins/bwk.rb +25 -0
  27. data/plugins/econlib.rb +22 -0
  28. data/plugins/freebsd-ports-update.rb +73 -0
  29. data/plugins/inc.rb +29 -0
  30. data/plugins/test.rb +29 -0
  31. data/public/.gitattributes +1 -0
  32. data/public/favicon.ico +0 -0
  33. data/public/jquery-1.7.2.min.js +0 -0
  34. data/public/list.js +111 -0
  35. data/public/loading.gif +0 -0
  36. data/public/style.css +54 -0
  37. data/shotgun.rb +20 -0
  38. data/test/example/.gitattributes +1 -0
  39. data/test/example/.gitignore +1 -0
  40. data/test/example/02/plugins/bwk.html +0 -0
  41. data/test/{plugins → example/02/plugins}/empty.rb +0 -0
  42. data/test/example/02/plugins/garbage.rb +1 -0
  43. data/test/example/02/plugins/inc.html +0 -0
  44. data/test/helper.rb +30 -27
  45. data/test/helper_cliutils.rb +34 -0
  46. data/test/test_cli.rb +86 -0
  47. data/test/test_fetch.rb +49 -18
  48. data/test/test_generate.rb +43 -16
  49. data/test/test_home.rb +33 -0
  50. data/test/test_plugin.rb +141 -0
  51. data/test/test_server.rb +21 -32
  52. data/views/list.haml +38 -0
  53. metadata +223 -110
  54. data/bin/bwkfanboy_fetch +0 -13
  55. data/bin/bwkfanboy_server +0 -126
  56. data/doc/README.erb +0 -114
  57. data/doc/README.rdoc +0 -141
  58. data/doc/TODO +0 -7
  59. data/doc/bwkfanboy_fetch.rdoc +0 -4
  60. data/doc/bwkfanboy_generate.rdoc +0 -7
  61. data/doc/bwkfanboy_parse.rdoc +0 -7
  62. data/doc/bwkfanboy_server.rdoc +0 -35
  63. data/doc/rakefile.rb +0 -59
  64. data/lib/bwkfanboy/generate.rb +0 -63
  65. data/lib/bwkfanboy/parser.rb +0 -156
  66. data/lib/bwkfanboy/plugins/bwk.rb +0 -33
  67. data/lib/bwkfanboy/plugins/econlib.rb +0 -34
  68. data/lib/bwkfanboy/plugins/freebsd-ports-update.rb +0 -76
  69. data/lib/bwkfanboy/plugins/inc.rb +0 -37
  70. data/lib/bwkfanboy/schema.js +0 -39
  71. data/test/popen4.sh +0 -4
  72. data/test/rake_git.rb +0 -36
  73. data/test/semis/Rakefile +0 -35
  74. data/test/semis/bwk.html +0 -393
  75. data/test/semis/bwk.json +0 -82
  76. data/test/semis/econlib.html +0 -21
  77. data/test/semis/inc.html +0 -1067
  78. data/test/semis/links.txt +0 -4
  79. data/test/test_parse.rb +0 -27
  80. data/test/xml-clean.sh +0 -8
  81. data/web/bwkfanboy.cgi +0 -36
@@ -0,0 +1,38 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title #{meta::NAME} :: Plugins List
5
+ %link(rel="stylesheet" href="/style.css")
6
+ %script(type='text/javascript' src='/jquery-1.7.2.min.js')
7
+ %script(type='text/javascript' src='/list.js')
8
+
9
+ %body
10
+ #header
11
+ %h1 Plugins List
12
+
13
+ #list
14
+ - list.each do |idx|
15
+ %b #{idx.keys.first}:
16
+ %ul
17
+ - idx[idx.keys.first].each do |file|
18
+ %li
19
+ %span= file
20
+
21
+ #plugin
22
+ %h2 Plugin Info
23
+ %form
24
+ %p
25
+ Additional options:
26
+ %input(type='text' name='opts')
27
+
28
+ #info
29
+ (Click on any link from the left.)
30
+
31
+ #footer
32
+ %hr/
33
+ .footer
34
+ %a{href: url("#{meta::HOMEPAGE}")} #{meta::NAME}
35
+ \#{meta::VERSION}
36
+ - if ENV["COMMIT_HASH"]
37
+ %br/
38
+ Commit hash: #{ENV["COMMIT_HASH"]}
metadata CHANGED
@@ -1,168 +1,281 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bwkfanboy
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
4
5
  prerelease:
5
- version: 1.4.1
6
6
  platform: ruby
7
- authors:
8
- - Alexander Gromnitsky
7
+ authors:
8
+ - bwkfanboy
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-04-20 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: open4
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.0
22
+ type: :runtime
17
23
  prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: msgpack
32
+ requirement: !ruby/object:Gem::Requirement
19
33
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.0.1
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.4.6
24
38
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: activesupport
28
39
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
30
41
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 3.0.5
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.4.6
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2.2
35
54
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2.2
62
+ - !ruby/object:Gem::Dependency
38
63
  name: nokogiri
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.5.2
70
+ type: :runtime
39
71
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
41
73
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: 1.4.4
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.5.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: sinatra
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.3.2
46
86
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: jsonschema
50
87
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.2
94
+ - !ruby/object:Gem::Dependency
95
+ name: haml
96
+ requirement: !ruby/object:Gem::Requirement
52
97
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 2.0.1
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 3.1.4
57
102
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: git
61
103
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 3.1.4
110
+ - !ruby/object:Gem::Dependency
111
+ name: rdoc
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '3.12'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '3.12'
126
+ - !ruby/object:Gem::Dependency
127
+ name: minitest
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 2.12.1
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 2.12.1
142
+ - !ruby/object:Gem::Dependency
143
+ name: fakefs
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.4.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
63
153
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 1.2.5
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.4.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: rack-test
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 0.6.1
68
166
  type: :development
69
- version_requirements: *id005
70
- description: bwkfanboy is a converter from a raw HTML to an Atom feed. You can use it to watch sites that do not provide its own feed.
71
- email: alexander.gromnitsky@gmail.com
72
- executables:
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 0.6.1
174
+ description: A converter from a raw HTML to an Atom feed. You can use it to watch
175
+ sites that do not provide its own feed
176
+ email:
177
+ - alexander.gromnitsky@gmail.com
178
+ executables:
179
+ - bwkfanboy
73
180
  - bwkfanboy_generate
74
181
  - bwkfanboy_parse
75
- - bwkfanboy
76
- - bwkfanboy_server
77
- - bwkfanboy_fetch
78
182
  extensions: []
79
-
80
- extra_rdoc_files:
183
+ extra_rdoc_files:
184
+ - doc/LICENSE
81
185
  - doc/NEWS.rdoc
82
186
  - doc/plugin.rdoc
83
- - doc/bwkfanboy_fetch.rdoc
84
- - doc/bwkfanboy_generate.rdoc
85
- - doc/bwkfanboy_parse.rdoc
86
- - doc/bwkfanboy_server.rdoc
87
- - doc/README.rdoc
88
- files:
187
+ files:
188
+ - .gitignore
189
+ - Gemfile
190
+ - Gemfile.lock
191
+ - Procfile
89
192
  - README.rdoc
90
193
  - Rakefile
91
194
  - bin/bwkfanboy
92
- - bin/bwkfanboy_fetch
93
195
  - bin/bwkfanboy_generate
94
196
  - bin/bwkfanboy_parse
95
- - bin/bwkfanboy_server
197
+ - bwkfanboy.gemspec
198
+ - config.ru
96
199
  - doc/LICENSE
97
200
  - doc/NEWS.rdoc
98
- - doc/README.erb
99
- - doc/README.rdoc
100
- - doc/TODO
101
- - doc/bwkfanboy_fetch.rdoc
102
- - doc/bwkfanboy_generate.rdoc
103
- - doc/bwkfanboy_parse.rdoc
104
- - doc/bwkfanboy_server.rdoc
105
201
  - doc/plugin.rdoc
106
- - doc/rakefile.rb
202
+ - etc/bwkfanboy.yaml
203
+ - etc/sinatra.rb
204
+ - lib/bwkfanboy/cliconfig.rb
205
+ - lib/bwkfanboy/cliutils.rb
107
206
  - lib/bwkfanboy/fetch.rb
108
- - lib/bwkfanboy/generate.rb
207
+ - lib/bwkfanboy/generator.rb
208
+ - lib/bwkfanboy/home.rb
109
209
  - lib/bwkfanboy/meta.rb
110
- - lib/bwkfanboy/parser.rb
210
+ - lib/bwkfanboy/plugin.rb
111
211
  - lib/bwkfanboy/plugin_skeleton.erb
112
- - lib/bwkfanboy/plugins/bwk.rb
113
- - lib/bwkfanboy/plugins/econlib.rb
114
- - lib/bwkfanboy/plugins/freebsd-ports-update.rb
115
- - lib/bwkfanboy/plugins/inc.rb
116
- - lib/bwkfanboy/schema.js
212
+ - lib/bwkfanboy/server.rb
117
213
  - lib/bwkfanboy/utils.rb
214
+ - plugins/bwk.rb
215
+ - plugins/econlib.rb
216
+ - plugins/freebsd-ports-update.rb
217
+ - plugins/inc.rb
218
+ - plugins/test.rb
219
+ - public/.gitattributes
220
+ - public/favicon.ico
221
+ - public/jquery-1.7.2.min.js
222
+ - public/list.js
223
+ - public/loading.gif
224
+ - public/style.css
225
+ - shotgun.rb
226
+ - test/example/.gitattributes
227
+ - test/example/.gitignore
228
+ - test/example/02/plugins/bwk.html
229
+ - test/example/02/plugins/empty.rb
230
+ - test/example/02/plugins/garbage.rb
231
+ - test/example/02/plugins/inc.html
118
232
  - test/helper.rb
119
- - test/plugins/empty.rb
120
- - test/popen4.sh
121
- - test/rake_git.rb
122
- - test/semis/Rakefile
123
- - test/semis/bwk.html
124
- - test/semis/bwk.json
125
- - test/semis/econlib.html
126
- - test/semis/inc.html
127
- - test/semis/links.txt
233
+ - test/helper_cliutils.rb
234
+ - test/test_cli.rb
128
235
  - test/test_fetch.rb
129
236
  - test/test_generate.rb
130
- - test/test_parse.rb
237
+ - test/test_home.rb
238
+ - test/test_plugin.rb
131
239
  - test/test_server.rb
132
- - test/xml-clean.sh
133
- - web/bwkfanboy.cgi
240
+ - views/list.haml
134
241
  homepage: http://github.com/gromnitsky/bwkfanboy
135
242
  licenses: []
243
+ post_install_message: ! 'This version was rewritten from scratch.
244
+
245
+ Plugins from & for previous versions (0.x & 1.x) WILL NOT WORK.
246
+
247
+
248
+ See also doc/NEWS.rdoc file.
136
249
 
137
- post_install_message:
138
- rdoc_options:
250
+ '
251
+ rdoc_options:
139
252
  - -m
140
- - doc/README.rdoc
141
- - -x
142
- - plugins
143
- require_paths:
253
+ - README.rdoc
254
+ require_paths:
144
255
  - lib
145
- required_ruby_version: !ruby/object:Gem::Requirement
256
+ required_ruby_version: !ruby/object:Gem::Requirement
146
257
  none: false
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
150
261
  version: 1.9.2
151
- required_rubygems_version: !ruby/object:Gem::Requirement
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
263
  none: false
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- version: "0"
264
+ requirements:
265
+ - - ! '>='
266
+ - !ruby/object:Gem::Version
267
+ version: '0'
157
268
  requirements: []
158
-
159
269
  rubyforge_project:
160
- rubygems_version: 1.7.2
270
+ rubygems_version: 1.8.23
161
271
  signing_key:
162
272
  specification_version: 3
163
- summary: bwkfanboy is a converter from a raw HTML to an Atom feed. You can use it to watch sites that do not provide its own feed.
164
- test_files:
273
+ summary: A converter from a raw HTML to an Atom feed. You can use it to watch sites
274
+ that do not provide its own feed.
275
+ test_files:
276
+ - test/test_cli.rb
165
277
  - test/test_fetch.rb
166
- - test/test_parse.rb
167
- - test/test_server.rb
168
278
  - test/test_generate.rb
279
+ - test/test_home.rb
280
+ - test/test_plugin.rb
281
+ - test/test_server.rb
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*-ruby-*-
3
-
4
- require_relative '../lib/bwkfanboy/fetch'
5
-
6
- $conf = { banner: "Usage: #{File.basename($0)} [options] < uri" }
7
-
8
- Bwkfanboy::Utils.cl_parse(ARGV, $conf[:banner], nil, true)
9
-
10
- uri = gets
11
- Bwkfanboy::Fetch.cat(uri) {|f|
12
- f.each_line {|line| puts line }
13
- }
@@ -1,126 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*-ruby-*-
3
-
4
- require 'shellwords'
5
- require 'webrick'
6
- require 'date'
7
- require_relative '../lib/bwkfanboy/utils'
8
-
9
- $conf = {
10
- addr: '127.0.0.1',
11
- port: 9042,
12
- converter: "./#{Bwkfanboy::Meta::NAME}",
13
- banner: "Usage: #{File.basename($0)} [options]",
14
- server_type: WEBrick::SimpleServer,
15
- workdir: File.dirname(File.expand_path($0)),
16
- pidfile: "#{Bwkfanboy::Meta::DIR_TMP}/#{File.basename($0)}.pid",
17
- log: "#{Bwkfanboy::Meta::DIR_LOG}/#{File.basename($0)}.log",
18
- alog: "#{Bwkfanboy::Meta::DIR_LOG}/#{File.basename($0)}-access.log",
19
- mode: 'pipe'
20
- }
21
-
22
- o = Bwkfanboy::Utils.cl_parse(ARGV, $conf[:banner]) # create OptionParser object
23
- o.on('-b VAL', 'BindAddress') { |i| $conf[:addr] = i }
24
- o.on('-p VAL', 'A port number') { |i| $conf[:port] = i }
25
- o.on('-c VAL', "A path to main #{Bwkfanboy::Meta::NAME} executable") { |i| $conf[:converter] = i }
26
- o.on('-d', 'Detach from a terminal') {|i| $conf[:server_type] = WEBrick::Daemon }
27
- o.on('-D', '(ignore this) Use URI_DEBUG const instead URI in plugins') { |i| $conf[:mode] = 'debug' }
28
- Bwkfanboy::Utils.cl_parse(ARGV, $conf[:banner], o) # run cl parser
29
-
30
- Bwkfanboy::Utils.dir_tmp_create()
31
-
32
- class FeedServlet < WEBrick::HTTPServlet::AbstractServlet # :nodoc: all
33
- def do_GET(req, res)
34
- if req.query['p'] && req.query['p'] =~ Bwkfanboy::Meta::PLUGIN_NAME
35
- res['Content-Type'] = 'application/atom+xml; charset=UTF-8'
36
- res['Content-Disposition'] = "inline; filename=\"#{Bwkfanboy::Meta::NAME}-#{req.query['p']}.xml"
37
-
38
- # possible options for the plugin
39
- if req.query['o'] && req.query['o'] !~ Bwkfanboy::Meta::PLUGIN_OPTS
40
- raise WEBrick::HTTPStatus::InternalServerError.new("'o' is too harsh")
41
- end
42
-
43
- cmd = "#{$conf[:converter]} #{$conf[:mode] == 'debug' ? '-D' : ''} '#{req.query['p']}' #{req.query['o']}"
44
- r = Bwkfanboy::Utils.cmd_run(cmd)
45
- if r[0] != 0 then
46
- raise WEBrick::HTTPStatus::InternalServerError.new("Errors in the pipeline:\n\n #{r[1]}")
47
- end
48
-
49
- res.body = r[2]
50
-
51
- # search for <updated> tag and set Last-Modified header
52
- if (m = r[2].match('<updated>(.+?)</updated>'))
53
- res['Last-Modified'] = DateTime.parse(m.to_s).httpdate
54
- end
55
-
56
- else
57
- raise WEBrick::HTTPStatus::InternalServerError.new("Parameter 'p' required")
58
- end
59
- end
60
- end
61
-
62
- class FeedListServlet < WEBrick::HTTPServlet::AbstractServlet # :nodoc: all
63
- def do_GET(req, res)
64
- cmd = "#{$conf[:converter]} -l"
65
- r = Bwkfanboy::Utils.cmd_run(cmd)
66
- if r[0] != 0 then
67
- raise WEBrick::HTTPStatus::InternalServerError.new("Errors:\n\n #{r[1]}")
68
- end
69
-
70
- res.body = r[2]
71
- end
72
- end
73
-
74
- # create temporally files
75
- def start_callback()
76
- Dir.chdir($conf[:workdir])
77
- if ! File.executable?($conf[:converter]) then
78
- Bwkfanboy::Utils.errx(1, "Missing executable file '#{$conf[:converter]}'")
79
- end
80
-
81
- begin
82
- File.open($conf[:pidfile], "w+") {|i| i.puts $$ }
83
- rescue
84
- Bwkfanboy::Utils.warnx("unable to create a pidfile " + $conf[:pidfile])
85
- end
86
- end
87
-
88
- # remove temporally files
89
- def stop_callback()
90
- begin
91
- File.unlink $conf[:pidfile]
92
- rescue
93
- # ignore errors
94
- end
95
- end
96
-
97
- def log_create(f)
98
- begin
99
- log = Logger.new(f, 2, Bwkfanboy::Meta::LOG_MAXSIZE)
100
- rescue
101
- Bwkfanboy::Utils.warnx("cannot open log #{f}");
102
- return nil
103
- end
104
- log.datetime_format = "%H:%M:%S"
105
- log
106
- end
107
-
108
- # ----------------------------------------------------------------------
109
-
110
- server_log = log_create($conf[:log])
111
- access_log = [[ log_create($conf[:alog]), WEBrick::AccessLog::COMBINED_LOG_FORMAT ]]
112
-
113
- s = WEBrick::HTTPServer.new(Port: $conf[:port],
114
- BindAddress: $conf[:addr],
115
- ServerType: $conf[:server_type],
116
- StartCallback: -> {start_callback},
117
- StopCallback: -> {stop_callback},
118
- Logger: server_log,
119
- AccessLog: access_log
120
- )
121
- s.mount("/", FeedServlet)
122
- s.mount("/list", FeedListServlet)
123
- ['TERM', 'INT'].each {|i|
124
- trap(i) { s.shutdown }
125
- }
126
- s.start