ghost_reader 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +51 -27
- data/lib/ghost_reader/backend.rb +5 -5
- data/lib/ghost_reader/version.rb +1 -1
- data/spec/ghost_reader/backend_spec.rb +13 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -1,35 +1,59 @@
|
|
1
1
|
GhostReader
|
2
2
|
===========
|
3
3
|
|
4
|
-
|
4
|
+
GhostReader is an alternative I18n backend which makes use of the
|
5
|
+
GhostWriter service.
|
5
6
|
|
6
7
|
## Usage
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
9
|
+
### Gemfile
|
10
|
+
|
11
|
+
gem 'ghost_reader', '~> 1.1.1'
|
12
|
+
|
13
|
+
### config/initializers/ghost_reader.rb
|
14
|
+
|
15
|
+
unless Rails.env.test?
|
16
|
+
config = {
|
17
|
+
:report_interval => 42, # secs
|
18
|
+
:retrieval_interval => 23, # secs
|
19
|
+
:fallback => I18n.backend,
|
20
|
+
:logfile => File.join(Rails.root, %w(log ghostwriter.log)),
|
21
|
+
:service => {
|
22
|
+
:api_key => '<here_goes_your_api_key>'
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
I18n.backend = GhostReader::Backend.new(config)
|
27
|
+
end
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
* 'report interval' is the delay in seconds between subsequent POST
|
32
|
+
requests (reporting requests), which report missing translations.
|
33
|
+
* 'retrieval_interval' is the delay in seconds between subsequent GET
|
34
|
+
requests (incremental requests), which retrieve updated translations.
|
35
|
+
* 'fallback' point to the I18n backend wich should be used as a
|
36
|
+
fallback.
|
37
|
+
* 'logfile' is the path to a optional, separate logfile. If this is
|
38
|
+
omitted, log messages go to standard out.
|
39
|
+
* 'service' holds a hash with connection details.
|
40
|
+
- 'api_key' is a GhostWriter API key.
|
41
|
+
- 'host' is the hostname, optionally with port.
|
42
|
+
- 'protocol' is either 'http' or 'https'
|
43
|
+
- 'uri' is the complete uri with the folling keys, which will be
|
44
|
+
replaced: :protocol, :host, :api_key
|
45
|
+
|
46
|
+
## TODO
|
47
|
+
|
48
|
+
* implement counting, for statistics
|
49
|
+
* document all config options
|
50
|
+
|
51
|
+
## THANKS
|
52
|
+
|
53
|
+
All work on GhostReader is supported by Panter LLC, Zurich,
|
54
|
+
Switzerland. http://panter.ch
|
55
|
+
|
56
|
+
Special thanks go to Andreas Koenig, for his inital version of
|
57
|
+
GhostReader, and Peco Danajlovski for helping with the rewrite.
|
34
58
|
|
35
59
|
|
data/lib/ghost_reader/backend.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'logger'
|
2
2
|
require 'ostruct'
|
3
3
|
require 'i18n'
|
4
|
-
#require 'i18n/backend/transliterator' # i18n/backend/base fails to require this
|
5
|
-
#require 'i18n/backend/base'
|
6
|
-
#require 'i18n/backend/memoize'
|
7
|
-
#require 'i18n/backend/flatten'
|
8
4
|
|
9
5
|
module GhostReader
|
10
6
|
class Backend
|
@@ -30,6 +26,10 @@ module GhostReader
|
|
30
26
|
config.logger.info "Initialized GhostReader backend."
|
31
27
|
end
|
32
28
|
|
29
|
+
def available_locales
|
30
|
+
( memoized_lookup.keys + config.fallback.available_locales ).uniq
|
31
|
+
end
|
32
|
+
|
33
33
|
protected
|
34
34
|
|
35
35
|
# this won't be called if memoize kicks in
|
@@ -147,7 +147,7 @@ module GhostReader
|
|
147
147
|
|
148
148
|
include I18n::Backend::Base
|
149
149
|
include Implementation
|
150
|
-
include I18n::Backend::Memoize # provides
|
150
|
+
include I18n::Backend::Memoize # provides #memoized_lookup
|
151
151
|
include I18n::Backend::Flatten # provides #flatten_translations
|
152
152
|
end
|
153
153
|
end
|
data/lib/ghost_reader/version.rb
CHANGED
@@ -40,6 +40,19 @@ describe GhostReader::Backend do
|
|
40
40
|
result.has_key?(:one).should be_true
|
41
41
|
end
|
42
42
|
|
43
|
+
it 'should nicely respond to available_locales' do
|
44
|
+
@backend.should respond_to(:available_locales)
|
45
|
+
|
46
|
+
expected = [:en, :de]
|
47
|
+
@fallback.stub!(:available_locales).and_return(expected)
|
48
|
+
@backend.available_locales.should eq(expected)
|
49
|
+
|
50
|
+
# FIXME
|
51
|
+
# @backend.send(:memoize_merge!, :it => {'dummay' => 'Dummy'})
|
52
|
+
# @backend.translate(:it, 'this.is.a.test')
|
53
|
+
# @backend.available_locales.should eq([:it, :en, :de])
|
54
|
+
end
|
55
|
+
|
43
56
|
context 'nicely merge data into memoized_hash' do
|
44
57
|
|
45
58
|
it 'should work with valid data' do
|
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Phil Hofmann
|