vrowser 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,8 +6,8 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |gem|
8
8
  gem.name = "vrowser"
9
- gem.summary = %Q{TODO: one-line summary of your gem}
10
- gem.description = %Q{TODO: longer description of your gem}
9
+ gem.summary = %Q{Server browser and Crawler for many games (L4D2, TF2, CS:S, KZMOD, The Ship)}
10
+ gem.description = %Q{Server browser and Crawler for many games (L4D2, TF2, CS:S, KZMOD, The Ship)}
11
11
  gem.email = "sub+peerler@gmail.com"
12
12
  gem.homepage = "http://github.com/kimoto/vrowser"
13
13
  gem.authors = ["kimoto"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/app.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'sinatra'
2
+ require './lib/vrowser'
3
+
4
+ def get_active_servers
5
+ Vrowser.load_file("/home/kimoto/config.yml") do |vrowser|
6
+ greped = vrowser.active_servers.select(:name, :host, :ping, :num_players, :type, :map, :players)
7
+ ordered = greped.order(:host)
8
+ return ordered.map(&:values)
9
+ end
10
+ end
11
+
12
+ def get_active_servers_nary
13
+ get_active_servers.map(&:values)
14
+ end
15
+
16
+ get '/api/connected/json' do
17
+ content_type :json
18
+ return get_active_servers.to_json
19
+ end
20
+
21
+ get '/api/updated/json' do
22
+ content_type :json
23
+ return get_active_servers_nary.to_json
24
+ end
25
+
26
+ get '/' do
27
+ redirect "index.html"
28
+ end
29
+
data/bin/vrowser CHANGED
@@ -49,6 +49,9 @@ hoge
49
49
  when "json"
50
50
  opt :config_file, "config file path", :short => "-f", :type => String, :required => true
51
51
  when "server", "daemon"
52
+ opt :config_file, "config file path", :short => "-f", :type => String, :required => true
53
+ opt :log_path, "log file path", :short => "-l", :type => String
54
+ when "httpd"
52
55
  opt :config_file, "config file path", :short => "-f", :type => String, :required => true
53
56
  opt :port, "port number", :short => "-p", :type => String, :default => '3000'
54
57
  opt :host, "host or ip address", :short => "-h", :type => String, :default => 'localhost'
@@ -120,8 +123,24 @@ hoge
120
123
  execute_as_server(options.merge({:daemonize => true}))
121
124
  end
122
125
 
126
+ def command_httpd_daemon(options)
127
+ execute_as_httpd_server(options.merge({:daemonize => true}))
128
+ end
129
+
123
130
  private
124
131
  def execute_as_server(options)
132
+ Vrowser.logger = Logger.new(options[:log_path]) if options[:log_path]
133
+ Vrowser::Daemon.new(:config_path => Pathname.new(options[:config_file]).realpath) do |vrowser|
134
+ if options[:daemonize]
135
+ vrowser.daemonize!
136
+ vrowser.start
137
+ else
138
+ vrowser.start
139
+ end
140
+ end
141
+ end
142
+
143
+ def execute_as_httpd_server(options)
125
144
  Vrowser::HTTPDaemon.new(
126
145
  :config_path => Pathname.new(options[:config_file]).realpath,
127
146
  :BindAddress => options[:host],
data/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require 'sinatra'
2
+ require './app'
3
+ run Sinatra::Application
@@ -3,6 +3,55 @@
3
3
  require 'vrowser'
4
4
  require 'webrick'
5
5
 
6
+ class Vrowser::Daemon
7
+ def self.start(options={})
8
+ self.new(options) do |instance|
9
+ instance.start
10
+ end
11
+ end
12
+
13
+ public
14
+ def initialize(options={})
15
+ @config_path = options[:config_path] or raise ArgumentError("config_path")
16
+ yield(self) if block_given?
17
+ self
18
+ end
19
+
20
+ def start
21
+ fetch_and_update @config_path
22
+ regist_stop
23
+ end
24
+
25
+ def daemonize!
26
+ Process.daemon
27
+ end
28
+
29
+ def stop
30
+ end
31
+
32
+ private
33
+ def regist_stop
34
+ trap("INT") do
35
+ stop
36
+ end
37
+ end
38
+
39
+ def fetch_and_update(config_path)
40
+ Vrowser.load_file(config_path) do |vrowser|
41
+ while true
42
+ puts "update server list"
43
+ vrowser.fetch
44
+
45
+ (60 / 5).times do
46
+ puts "try update"
47
+ vrowser.update
48
+ sleep (30 * 5)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
6
55
  class Vrowser::HTTPDaemon
7
56
  def self.start(options={})
8
57
  self.new(options) do |instance|
@@ -61,7 +110,7 @@ class Vrowser::HTTPDaemon
61
110
  (60 / 5).times do
62
111
  puts "try update"
63
112
  vrowser.update
64
- sleep (60 * 5)
113
+ sleep (30 * 5)
65
114
  end
66
115
  end
67
116
  end
@@ -12,42 +12,44 @@
12
12
  <link rel="StyleSheet" href="./css/demo_table.css" />
13
13
  <link rel="StyleSheet" href="./css/demo_table_jui.css" />
14
14
  <title>Vrowser</title>
15
- </head>
15
+ </head>
16
16
 
17
- <body>
18
- <section>
19
- <h1 id="subject">Vrowser <a href="https://github.com/kimoto/vrowser/">(source)</a></h1>
20
- <ul>
21
- <li>サーバーの行でダブルクリックでログインできます</li>
22
- <li>プレイヤー名で検索できます</li>
23
- </ul>
17
+ <body>
18
+ <div class="container">
19
+ <section>
20
+ <h1 id="subject">Vrowser <a href="https://github.com/kimoto/vrowser/">(source)</a></h1>
21
+ <ul>
22
+ <li>サーバーの行でダブルクリックでログインできます</li>
23
+ <li>プレイヤー名で検索できます</li>
24
+ </ul>
24
25
 
25
- <table id="servers" class="display">
26
- <thead>
27
- <tr>
28
- <th>サーバー名</th>
29
- <th>ホスト</th>
30
- <th>Ping</th>
31
- <th>人数</th>
32
- <th>タイプ</th>
33
- <th>マップ</th>
34
- <th>プレイヤー</th>
35
- </tr>
36
- </thead>
37
- <tbody>
38
- <script id="myTemplate" type="text/x-jquery-tmpl">
39
- <tr>
40
- <td>${name}</td>
41
- <td>${host}</td>
42
- <td>${ping}</td>
43
- <td>${num_players}</td>
44
- <td>${type}</td>
45
- <td>${map}</td>
46
- <td>${players}</td>
47
- </tr>
48
- </script>
49
- </tbody>
50
- </table>
51
- </section>
52
- </body>
53
- </html>
26
+ <table id="servers" class="table-striped zebra-striped">
27
+ <thead>
28
+ <tr>
29
+ <th>サーバー名</th>
30
+ <th>ホスト</th>
31
+ <th>Ping</th>
32
+ <th>人数</th>
33
+ <th>タイプ</th>
34
+ <th>マップ</th>
35
+ <th>プレイヤー</th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <script id="myTemplate" type="text/x-jquery-tmpl">
40
+ <tr>
41
+ <td>${name}</td>
42
+ <td>${host}</td>
43
+ <td>${ping}</td>
44
+ <td>${num_players}</td>
45
+ <td>${type}</td>
46
+ <td>${map}</td>
47
+ <td>${players}</td>
48
+ </tr>
49
+ </script>
50
+ </tbody>
51
+ </table>
52
+ </section>
53
+ </div>
54
+ </body>
55
+ </html>
data/vrowser.gemspec ADDED
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "vrowser"
8
+ s.version = "0.1.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["kimoto"]
12
+ s.date = "2012-03-12"
13
+ s.description = "Server browser and Crawler for many games (L4D2, TF2, CS:S, KZMOD, The Ship)"
14
+ s.email = "sub+peerler@gmail.com"
15
+ s.executables = ["vrowser"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "app.rb",
27
+ "bin/vrowser",
28
+ "config.ru",
29
+ "examples/config.yml",
30
+ "lib/plugins/l4d2.rb",
31
+ "lib/vrowser.rb",
32
+ "lib/vrowser/http_daemon.rb",
33
+ "public_html/css/demo_page.css",
34
+ "public_html/css/demo_table.css",
35
+ "public_html/css/demo_table_jui.css",
36
+ "public_html/css/demo_validation.css",
37
+ "public_html/css/main.css",
38
+ "public_html/css/site_jui.ccss.css",
39
+ "public_html/index.html",
40
+ "public_html/js/jquery-ui-1.8.16.custom.min.js",
41
+ "public_html/js/jquery.dataTables.columnFilter.js",
42
+ "public_html/js/jquery.dataTables.js",
43
+ "public_html/js/jquery.dataTables.min.js",
44
+ "public_html/js/jquery.dataTables.nightly.min.js",
45
+ "public_html/js/jquery.min.js",
46
+ "public_html/js/jquery.tmpl.min.js",
47
+ "public_html/js/vrowser.js",
48
+ "test/helper.rb",
49
+ "test/test_vrowser.rb",
50
+ "vrowser.gemspec"
51
+ ]
52
+ s.homepage = "http://github.com/kimoto/vrowser"
53
+ s.require_paths = ["lib"]
54
+ s.rubygems_version = "1.8.11"
55
+ s.summary = "Server browser and Crawler for many games (L4D2, TF2, CS:S, KZMOD, The Ship)"
56
+
57
+ if s.respond_to? :specification_version then
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
67
+ end
68
+ end
69
+
metadata CHANGED
@@ -1,183 +1,89 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vrowser
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - kimoto
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-02-06 00:00:00 +09:00
18
- default_executable: vrowser
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: ruby-qstat
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
31
- type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: sequel
35
- prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
44
- type: :runtime
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: retry-handler
48
- prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
57
- type: :runtime
58
- version_requirements: *id003
59
- - !ruby/object:Gem::Dependency
60
- name: i18n
61
- prerelease: false
62
- requirement: &id004 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
70
- type: :runtime
71
- version_requirements: *id004
72
- - !ruby/object:Gem::Dependency
73
- name: sqlite3
74
- prerelease: false
75
- requirement: &id005 !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
- version: "0"
83
- type: :runtime
84
- version_requirements: *id005
85
- - !ruby/object:Gem::Dependency
86
- name: mysql
87
- prerelease: false
88
- requirement: &id006 !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- segments:
94
- - 0
95
- version: "0"
96
- type: :runtime
97
- version_requirements: *id006
98
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
99
15
  name: thoughtbot-shoulda
100
- prerelease: false
101
- requirement: &id007 !ruby/object:Gem::Requirement
16
+ requirement: &96717520 !ruby/object:Gem::Requirement
102
17
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- segments:
107
- - 0
108
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
109
22
  type: :development
110
- version_requirements: *id007
111
- description: Server browser for many games (Left4Dead2, TeamFortress2, etc)
23
+ prerelease: false
24
+ version_requirements: *96717520
25
+ description: Server browser and Crawler for many games (L4D2, TF2, CS:S, KZMOD, The
26
+ Ship)
112
27
  email: sub+peerler@gmail.com
113
- executables:
28
+ executables:
114
29
  - vrowser
115
30
  extensions: []
116
-
117
- extra_rdoc_files:
31
+ extra_rdoc_files:
118
32
  - LICENSE.txt
119
33
  - README.rdoc
120
- files:
34
+ files:
121
35
  - .document
122
- - .gitignore
123
36
  - LICENSE.txt
124
37
  - README.rdoc
125
38
  - Rakefile
126
39
  - VERSION
40
+ - app.rb
127
41
  - bin/vrowser
42
+ - config.ru
128
43
  - examples/config.yml
129
44
  - lib/plugins/l4d2.rb
130
- - lib/vrowser/http_daemon.rb
131
45
  - lib/vrowser.rb
46
+ - lib/vrowser/http_daemon.rb
47
+ - public_html/css/demo_page.css
48
+ - public_html/css/demo_table.css
49
+ - public_html/css/demo_table_jui.css
50
+ - public_html/css/demo_validation.css
51
+ - public_html/css/main.css
52
+ - public_html/css/site_jui.ccss.css
53
+ - public_html/index.html
54
+ - public_html/js/jquery-ui-1.8.16.custom.min.js
55
+ - public_html/js/jquery.dataTables.columnFilter.js
56
+ - public_html/js/jquery.dataTables.js
57
+ - public_html/js/jquery.dataTables.min.js
58
+ - public_html/js/jquery.dataTables.nightly.min.js
59
+ - public_html/js/jquery.min.js
60
+ - public_html/js/jquery.tmpl.min.js
61
+ - public_html/js/vrowser.js
132
62
  - test/helper.rb
133
63
  - test/test_vrowser.rb
134
- - ./public_html/css/demo_page.css
135
- - ./public_html/css/demo_table.css
136
- - ./public_html/css/demo_table_jui.css
137
- - ./public_html/css/demo_validation.css
138
- - ./public_html/css/main.css
139
- - ./public_html/css/site_jui.ccss.css
140
- - ./public_html/index.html
141
- - ./public_html/js/jquery-ui-1.8.16.custom.min.js
142
- - ./public_html/js/jquery.dataTables.columnFilter.js
143
- - ./public_html/js/jquery.dataTables.js
144
- - ./public_html/js/jquery.dataTables.min.js
145
- - ./public_html/js/jquery.dataTables.nightly.min.js
146
- - ./public_html/js/jquery.min.js
147
- - ./public_html/js/jquery.tmpl.min.js
148
- - ./public_html/js/vrowser.js
149
- has_rdoc: true
64
+ - vrowser.gemspec
150
65
  homepage: http://github.com/kimoto/vrowser
151
66
  licenses: []
152
-
153
67
  post_install_message:
154
- rdoc_options:
155
- - --charset=UTF-8
156
- require_paths:
68
+ rdoc_options: []
69
+ require_paths:
157
70
  - lib
158
- required_ruby_version: !ruby/object:Gem::Requirement
71
+ required_ruby_version: !ruby/object:Gem::Requirement
159
72
  none: false
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- segments:
164
- - 0
165
- version: "0"
166
- required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
78
  none: false
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- segments:
172
- - 0
173
- version: "0"
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
174
83
  requirements: []
175
-
176
84
  rubyforge_project:
177
- rubygems_version: 1.3.7
85
+ rubygems_version: 1.8.11
178
86
  signing_key:
179
87
  specification_version: 3
180
- summary: Server browser for many games
181
- test_files:
182
- - test/helper.rb
183
- - test/test_vrowser.rb
88
+ summary: Server browser and Crawler for many games (L4D2, TF2, CS:S, KZMOD, The Ship)
89
+ test_files: []
data/.gitignore DELETED
@@ -1,49 +0,0 @@
1
- # rcov generated
2
- coverage
3
- coverage.data
4
-
5
- # rdoc generated
6
- rdoc
7
-
8
- # yard generated
9
- doc
10
- .yardoc
11
-
12
- # bundler
13
- .bundle
14
-
15
- # jeweler generated
16
- pkg
17
-
18
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
- #
20
- # * Create a file at ~/.gitignore
21
- # * Include files you want ignored
22
- # * Run: git config --global core.excludesfile ~/.gitignore
23
- #
24
- # After doing this, these files will be ignored in all your git projects,
25
- # saving you from having to 'pollute' every project you touch with them
26
- #
27
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
- #
29
- # For MacOS:
30
- #
31
- #.DS_Store
32
-
33
- # For TextMate
34
- #*.tmproj
35
- #tmtags
36
-
37
- # For emacs:
38
- #*~
39
- #\#*
40
- #.\#*
41
-
42
- # For vim:
43
- #*.swp
44
-
45
- # For redcar:
46
- #.redcar
47
-
48
- # For rubinius:
49
- #*.rbc