runit-man 2.2.7 → 2.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/i18n/en.yml CHANGED
@@ -4,8 +4,6 @@ en:
4
4
  title: "%{p1} - %{p2}"
5
5
  header: "%{p1}: %{p2}"
6
6
  error: Error encountered while accessing resource
7
- errors:
8
- invalid_encoding: "File contains octets that cannot be parsed as UTF-8 character sequences."
9
7
  loading: "Please wait while loading…"
10
8
  footer: "State of services updated automatically every %{sec} seconds."
11
9
  services:
data/i18n/ru.yml CHANGED
@@ -4,8 +4,6 @@ ru:
4
4
  title: "%{p1} - %{p2}"
5
5
  header: "%{p1}: %{p2}"
6
6
  error: Ошибка обращения к ресурсу
7
- errors:
8
- invalid_encoding: "Файл содержит октеты, которые не получается распознать как символьные последовательности UTF-8."
9
7
  loading: "Идёт загрузка…"
10
8
  footer: "Состояние сервисов обновляется автоматически каждые %{sec} секунд."
11
9
  services:
data/lib/runit-man/app.rb CHANGED
@@ -9,6 +9,11 @@ require 'file/tail'
9
9
  require 'runit-man/helpers'
10
10
  require 'runit-man/version'
11
11
 
12
+ if RUBY_VERSION >= '1.9'
13
+ Encoding.default_external = "utf-8"
14
+ Encoding.default_internal = "utf-8"
15
+ end
16
+
12
17
  class RunitMan < Sinatra::Base
13
18
  VERSION = RunitManVersion::VERSION
14
19
  MIN_TAIL = 100
@@ -123,20 +128,10 @@ class RunitMan < Sinatra::Base
123
128
  srv = ServiceInfo[name]
124
129
  return nil if srv.nil? || !srv.logged?
125
130
  text = ''
126
- begin
127
- text.force_encoding('utf-8') if text.respond_to?(:force_encoding)
128
- File::Tail::Logfile.open(srv.log_file_location, :backward => count, :return_if_eof => true) do |log|
129
- log.tail do |line|
130
- if line.respond_to?(:force_encoding)
131
- line.force_encoding('utf-8')
132
- raise ArgumentError.new('wrong encoding') unless line.valid_encoding?
133
- end
134
- line.force_encoding('utf-8') if line.respond_to?(:force_encoding)
135
- text += line
136
- end
131
+ File::Tail::Logfile.open(srv.log_file_location, :backward => count, :return_if_eof => true) do |log|
132
+ log.tail do |line|
133
+ text += line
137
134
  end
138
- rescue ArgumentError
139
- text = I18n.t('runit.errors.invalid_encoding')
140
135
  end
141
136
 
142
137
  {
@@ -154,12 +149,6 @@ class RunitMan < Sinatra::Base
154
149
  file_path = request.GET['file']
155
150
  return nil unless all_files_to_view.include?(file_path)
156
151
  text = IO.read(file_path)
157
- begin
158
- text.force_encoding('utf-8') if text.respond_to?(:force_encoding)
159
- raise ArgumentError.new('wrong encoding') unless text.valid_encoding?
160
- rescue ArgumentError
161
- text = I18n.t('runit.errors.invalid_encoding')
162
- end
163
152
  {
164
153
  :name => file_path,
165
154
  :text => text
@@ -294,7 +294,11 @@ private
294
294
 
295
295
  def real_data_from_file(file_name)
296
296
  return nil unless File.readable?(file_name)
297
- data = IO.read(file_name)
297
+ if RUBY_VERSION >= '1.9'
298
+ data = IO.read(file_name, :external_encoding => 'ASCII-8BIT')
299
+ else
300
+ data = IO.read(file_name)
301
+ end
298
302
  data.chomp! unless data.nil?
299
303
  data.empty? ? nil : data
300
304
  end
@@ -1,4 +1,4 @@
1
1
  module RunitManVersion
2
- VERSION = '2.2.7'.freeze
2
+ VERSION = '2.2.8'.freeze
3
3
  end
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runit-man
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
- - 7
10
- version: 2.2.7
9
+ - 8
10
+ version: 2.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akzhan Abdulin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-06 00:00:00 +04:00
18
+ date: 2011-05-19 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency