ghost_reader 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
data/lib/ghost_reader.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
%w(backend client
|
1
|
+
%w( backend client ).each do |f|
|
2
2
|
require File.expand_path(File.join(%w(.. ghost_reader), f), __FILE__)
|
3
3
|
end
|
4
4
|
|
5
|
+
if defined?(::Rails)
|
6
|
+
%w( util engine ).each do |f|
|
7
|
+
require File.expand_path(File.join(%w(.. ghost_reader), f), __FILE__)
|
8
|
+
end
|
9
|
+
end
|
data/lib/ghost_reader/backend.rb
CHANGED
@@ -32,7 +32,7 @@ module GhostReader
|
|
32
32
|
raise 'no fallback given' if config.fallback.nil?
|
33
33
|
log "lookup: #{locale} #{key} #{scope.inspect} #{options.inspect}"
|
34
34
|
|
35
|
-
result = config.fallback.lookup
|
35
|
+
result = config.fallback.send(:lookup, locale, key, scope, options)
|
36
36
|
log "fallback result: #{result.inspect}"
|
37
37
|
rescue Exception => ex
|
38
38
|
log "fallback.lookup raised exception: #{ex}"
|
data/lib/ghost_reader/engine.rb
CHANGED
data/lib/ghost_reader/util.rb
CHANGED
@@ -6,33 +6,29 @@ module GhostReader
|
|
6
6
|
class << self
|
7
7
|
|
8
8
|
def poll(headers={})
|
9
|
-
p config_file
|
10
9
|
return unless File.exist?(config_file)
|
11
10
|
headers['If-Modified-Since'] = File.mtime(translation_file) if File.exist?(translation_file)
|
12
11
|
headers.reverse_merge! :method => :get
|
13
|
-
p headers
|
14
|
-
p config
|
15
12
|
excon = Excon.new(config['static'])
|
16
13
|
response = excon.request(headers)
|
17
|
-
p response
|
18
14
|
if response.status == 200
|
19
15
|
translation_file response.body
|
20
|
-
|
16
|
+
passenger_restart!
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
24
20
|
def translation_file(content=nil)
|
25
|
-
path = File.join(Rails.root, 'config', 'locales', 'ghost_reader.yml')
|
21
|
+
path = File.join(::Rails.root, 'config', 'locales', 'ghost_reader.yml')
|
26
22
|
return path if content.nil?
|
27
23
|
File.open(path, 'w') { |f| f.puts content }
|
28
24
|
end
|
29
25
|
|
30
26
|
def config_file
|
31
|
-
File.join(Rails.root, 'config', 'ghost_reader.yml')
|
27
|
+
File.join(::Rails.root, 'config', 'ghost_reader.yml')
|
32
28
|
end
|
33
29
|
|
34
|
-
def
|
35
|
-
FileUtils.touch(File.join(Rails.root, 'tmp', 'restart.txt'))
|
30
|
+
def passenger_restart!
|
31
|
+
FileUtils.touch(File.join(::Rails.root, 'tmp', 'restart.txt'))
|
36
32
|
end
|
37
33
|
|
38
34
|
def config
|
data/lib/ghost_reader/version.rb
CHANGED
data/lib/tasks/ghost_reader.rake
CHANGED
@@ -19,7 +19,7 @@ namespace :ghost_reader do
|
|
19
19
|
# end
|
20
20
|
#
|
21
21
|
# yaml_data.each_pair do |key,value|
|
22
|
-
# outfile = Rails.root.join("config", "locales",
|
22
|
+
# outfile = ::Rails.root.join("config", "locales",
|
23
23
|
# "#{key.to_s}.yml")
|
24
24
|
# begin
|
25
25
|
# puts "Deleting old translations: #{outfile}"
|
@@ -57,7 +57,7 @@ namespace :ghost_reader do
|
|
57
57
|
#
|
58
58
|
# # TODO: this should work only when the ghost_reader is introduced as gem
|
59
59
|
# infile = 'templates/ghost_reader.rb'
|
60
|
-
# outdir = Rails.root.join("config", "initializers")
|
60
|
+
# outdir = ::Rails.root.join("config", "initializers")
|
61
61
|
#
|
62
62
|
# puts "Installing ghost_reader.rb initializer..."
|
63
63
|
# FileUtils.copy_file(infile, outdir)
|
@@ -5,7 +5,7 @@ config = {
|
|
5
5
|
:report_interval => 5, # secs
|
6
6
|
:retrieval_interval => 10, # secs
|
7
7
|
:fallback => I18n.backend,
|
8
|
-
:logfile => File.join(Rails.root, %w(log ghostwriter.log)),
|
8
|
+
:logfile => File.join(::Rails.root, %w(log ghostwriter.log)),
|
9
9
|
:service => {
|
10
10
|
:api_key => '9d07cf6d805ea2951383c9ed76db762e' # Ghost Dummy Project
|
11
11
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghost_reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 3
|
10
|
+
version: 1.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phil Hofmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-24 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|