localeapp 0.0.11 → 0.1.1
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.
- data/CHANGELOG.md +19 -0
- data/{README.textile → README.md} +38 -56
- data/bin/localeapp +111 -36
- data/features/localeapp_binary.feature +5 -5
- data/lib/localeapp/configuration.rb +52 -5
- data/lib/localeapp/updater.rb +8 -2
- data/lib/localeapp/version.rb +1 -1
- data/localeapp.gemspec +1 -0
- data/spec/localeapp/configuration_spec.rb +159 -40
- data/spec/localeapp/rails/controller_spec.rb +5 -8
- metadata +33 -18
data/CHANGELOG.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Version 0.1.1
|
2
|
+
|
3
|
+
* Gem compiled with 1.8.7
|
4
|
+
|
5
|
+
# Version 0.1.0
|
6
|
+
|
7
|
+
* Added support for Heroku's Cedar stack
|
8
|
+
* Added a safer configuration style where enabled environments are explicitly
|
9
|
+
defined
|
10
|
+
* Removed some unnecessary default options from config files generated with
|
11
|
+
`localeapp install`
|
12
|
+
* Fixed `localeapp push` with no arguments
|
13
|
+
|
14
|
+
## NOTICE
|
15
|
+
|
16
|
+
If you've added disabled_polling_environments,
|
17
|
+
disabled_reloading_environments or disabled_sending_environments to your
|
18
|
+
initializer you should change these to polling_environments,
|
19
|
+
reloading_environments and sending_environments and configure as per the README
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# Locale
|
2
|
+
|
3
|
+
[](http://travis-ci.org/Locale/localeapp)
|
2
4
|
|
3
5
|
The localeapp gem connects your rails app to the Locale service on
|
4
|
-
|
5
|
-
|
6
|
+
http://www.localeapp.com. Locale makes hand editing translation files something
|
7
|
+
you don't have to do.
|
6
8
|
|
7
9
|
The gem hooks into the i18n exception mechanism to send missing translations to
|
8
10
|
the app. When translated content has been added it's automatically pulled down
|
@@ -12,54 +14,42 @@ We're still in private beta but if you think Locale would be useful to you and
|
|
12
14
|
are willing to provide feedback then please get in touch at info@localeapp.com
|
13
15
|
and we'll see what we can do.
|
14
16
|
|
15
|
-
|
17
|
+
## Installation
|
16
18
|
|
17
|
-
|
19
|
+
### Rails 3
|
18
20
|
|
19
|
-
Add the localeapp gem to your Gemfile and install it:
|
21
|
+
Add the localeapp gem to your `Gemfile` and install it:
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
bundle install
|
24
|
-
</pre>
|
23
|
+
echo "gem 'localeapp'" >> Gemfile
|
24
|
+
bundle install
|
25
25
|
|
26
26
|
Create a project on localeapp.com and get the api key. Then run:
|
27
27
|
|
28
|
-
<
|
29
|
-
bundle exec localeapp install <YOUR_API_KEY>
|
30
|
-
</pre>
|
28
|
+
bundle exec localeapp install <YOUR_API_KEY>
|
31
29
|
|
32
30
|
This will check everything looks good and create
|
33
|
-
config/initializers/localeapp.rb for you.
|
31
|
+
`config/initializers/localeapp.rb` for you.
|
34
32
|
|
35
|
-
|
33
|
+
### Rails 2.3
|
36
34
|
|
37
|
-
Define localeapp in config/environment.rb
|
35
|
+
Define localeapp in `config/environment.rb`:
|
38
36
|
|
39
|
-
|
40
|
-
config.gem 'localeapp'
|
41
|
-
</pre>
|
37
|
+
config.gem 'localeapp'
|
42
38
|
|
43
39
|
Install the gem:
|
44
40
|
|
45
|
-
|
46
|
-
rake gems:install
|
47
|
-
</pre>
|
41
|
+
rake gems:install
|
48
42
|
|
49
43
|
Create a project on localeapp.com and get the api key. Then run:
|
50
44
|
|
51
|
-
<
|
52
|
-
localeapp install <YOUR_API_KEY>
|
53
|
-
</pre>
|
45
|
+
localeapp install <YOUR_API_KEY>
|
54
46
|
|
55
|
-
|
47
|
+
## Importing existing content
|
56
48
|
|
57
49
|
You can import via localeapp.com or with the command line tool. To import
|
58
50
|
existing translations do:
|
59
51
|
|
60
|
-
|
61
|
-
localeapp import config/locales/en.yml
|
62
|
-
</pre>
|
52
|
+
localeapp import config/locales/en.yml
|
63
53
|
|
64
54
|
This will queue importing the file. The projects pages on localeapp.com will
|
65
55
|
automatically refresh so you can see the import progress.
|
@@ -67,81 +57,73 @@ automatically refresh so you can see the import progress.
|
|
67
57
|
If you've more than one locale to import you can zip up the yml files. Both
|
68
58
|
localeapp.com and the localeapp import command accept zip files.
|
69
59
|
|
70
|
-
|
60
|
+
## Automatically sending missing translations
|
71
61
|
|
72
62
|
Missing translations are automatically sent only in the development environment
|
73
63
|
by default. When a page is refreshed any missing translations will be sent to
|
74
64
|
localeapp.com.
|
75
65
|
|
76
66
|
If you want to disable sending missing translations in the development
|
77
|
-
environment then edit config/initializers/localeapp.rb to include:
|
67
|
+
environment then edit `config/initializers/localeapp.rb` to include:
|
78
68
|
|
79
|
-
|
80
|
-
config.disabled_sending_environments << 'development'
|
81
|
-
</pre>
|
69
|
+
config.sending_environments = []
|
82
70
|
|
83
|
-
This is just an array, so you can configure it to match any environment
|
84
|
-
wish.
|
71
|
+
This is just an array, so you can configure it to match send in any environment
|
72
|
+
you wish.
|
85
73
|
|
86
|
-
|
74
|
+
## Automatically pulling translations
|
87
75
|
|
88
76
|
There are two ways to do this, one that suits a single developer working the
|
89
77
|
code locally and one where the translations are being pulled down to a staging
|
90
78
|
(or live) server.
|
91
79
|
|
92
|
-
|
80
|
+
### Single developer
|
93
81
|
|
94
82
|
In this mode the gem pulls any updated translations from localeapp.com at the
|
95
83
|
beginning of each request. This is the default setting so you don't need to do
|
96
84
|
anything special.
|
97
85
|
|
98
|
-
|
86
|
+
### Staging server
|
99
87
|
|
100
88
|
In this mode you configure the individual listeners to not poll every request
|
101
89
|
and instead run localeapp in daemon mode to fetch updated translations. This is
|
102
90
|
useful when you have more than one listener and don't want them to race to
|
103
91
|
update the translations.
|
104
92
|
|
105
|
-
|
93
|
+
#### Disabling polling
|
106
94
|
|
107
95
|
Edit config/initializers/localeapp.rb to include:
|
108
96
|
|
109
|
-
|
110
|
-
config.disabled_polling_environments << 'development'
|
111
|
-
</pre>
|
97
|
+
config.polling_environments = []
|
112
98
|
|
113
99
|
Run the daemon with:
|
114
100
|
|
115
|
-
|
116
|
-
localeapp daemon
|
117
|
-
</pre>
|
101
|
+
localeapp daemon
|
118
102
|
|
119
103
|
The listeners will automatically reload translations when they see there are
|
120
104
|
new ones.
|
121
105
|
|
122
|
-
|
106
|
+
### Disabling Reloading
|
123
107
|
|
124
|
-
Automatic reloading is
|
125
|
-
can be disabled
|
108
|
+
Automatic reloading is only enabled in the development environment by default and
|
109
|
+
can be disabled in a similar way to polling and sending:
|
126
110
|
|
127
|
-
|
128
|
-
config.disabled_reloading_environments << 'development'
|
129
|
-
</pre>
|
111
|
+
config.reloading_environments = []
|
130
112
|
|
131
|
-
|
113
|
+
### Inviting other developers and translators
|
132
114
|
|
133
115
|
You can invite other developers and translators via localeapp.com. Developers
|
134
116
|
have access to all the content and all the locales. Translators are restricted
|
135
117
|
to editing only the locales you give them access too.
|
136
118
|
|
137
|
-
|
119
|
+
### Adding a locale
|
138
120
|
|
139
121
|
If we find an unknown locale during an import we'll add it to your project.
|
140
122
|
You can also add a new locale to a project via localeapp.com. This will create
|
141
123
|
missing translations for every translation key. You will need to restart any
|
142
124
|
listeners completely to pick up the new locale.
|
143
125
|
|
144
|
-
|
126
|
+
### Support and feedback
|
145
127
|
|
146
128
|
You can contact us via the support link at the bottom of the page, emailing
|
147
|
-
info@localeapp.com, or on campfire at https://localeapp.campfirenow.com/d77b5
|
129
|
+
info@localeapp.com, or on campfire at https://localeapp.campfirenow.com/d77b5
|
data/bin/localeapp
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
3
|
|
4
|
+
require 'slop'
|
4
5
|
require 'localeapp'
|
5
6
|
|
6
7
|
# Don't connect to the net if we're running under cucumber for testing
|
@@ -14,48 +15,122 @@ if ENV['FAKE_WEB_DURING_CUCUMBER_RUN'] && fake_data_as_json = ENV['FAKE_WEB_FAKE
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
command = args.shift.strip rescue nil
|
20
|
-
|
21
|
-
unless %w{help install}.include?(command)
|
18
|
+
def include_config_file
|
22
19
|
unless Localeapp.include_config_file
|
23
20
|
puts "Could not load config file"
|
24
|
-
exit
|
21
|
+
exit 1
|
25
22
|
end
|
26
23
|
end
|
24
|
+
slop = Slop.new(ARGV, :help => true, :strict => true) do
|
25
|
+
banner "Usage: localeapp COMMAND [options]"
|
26
|
+
description <<-COMMANDS
|
27
|
+
COMMAND:
|
28
|
+
install <api_key> - Creates new configuration files and confirms key works
|
29
|
+
pull - Pulls all translations from localeapp.com
|
30
|
+
push <file> - Pushes a translation file to localeapp.com
|
31
|
+
update - Gets any changes since the last poll and updates the yml
|
32
|
+
daemon - Simple daemon (checks every 5 seconds for new translations)
|
33
|
+
COMMANDS
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
on_empty { puts self.to_s }
|
36
|
+
end
|
37
|
+
|
38
|
+
slop.command :install do
|
39
|
+
execute do |opts, args|
|
40
|
+
key = args.first
|
41
|
+
installer = Localeapp::CLI::Install.new
|
42
|
+
if installer.execute(key)
|
43
|
+
exit 0
|
44
|
+
else
|
45
|
+
exit 1
|
46
|
+
end
|
36
47
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
slop.command :pull do
|
51
|
+
execute do |opts, args|
|
52
|
+
include_config_file
|
53
|
+
Localeapp::CLI::Pull.new.execute
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
slop.command :push do
|
58
|
+
on_empty { puts "localeapp push requires an file to push" }
|
59
|
+
|
60
|
+
execute do |opts, args|
|
61
|
+
file = args.first
|
62
|
+
exit 1 if file.nil?
|
63
|
+
include_config_file
|
64
|
+
pusher = Localeapp::CLI::Push.new
|
65
|
+
pusher.execute(file)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
slop.command :update do
|
70
|
+
execute do |opts, args|
|
71
|
+
include_config_file
|
47
72
|
Localeapp::CLI::Update.new.execute
|
48
|
-
sleep 5
|
49
73
|
end
|
50
|
-
else
|
51
|
-
puts <<-HELP
|
52
|
-
Usage: localeapp COMMAND [ARGS]
|
53
|
-
|
54
|
-
Commands:
|
55
|
-
install <api_key> - Creates new configuration files and confirms key works
|
56
|
-
pull - Pulls all translations from localeapp.com
|
57
|
-
push <file> - Pushes a translation file to localeapp.com
|
58
|
-
update - Gets any changes since the last poll and updates the yml files
|
59
|
-
daemon - Simple daemon that checks every 5 seconds for new translations
|
60
|
-
HELP
|
61
74
|
end
|
75
|
+
|
76
|
+
slop.command :daemon do
|
77
|
+
execute do |opts, args|
|
78
|
+
include_config_file
|
79
|
+
while true do
|
80
|
+
Localeapp::CLI::Update.new.execute
|
81
|
+
sleep 5
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
begin
|
87
|
+
slop.parse
|
88
|
+
rescue Slop::InvalidOptionError
|
89
|
+
puts slop
|
90
|
+
end
|
91
|
+
|
92
|
+
# args = ARGV.dup
|
93
|
+
#
|
94
|
+
# command = args.shift.strip rescue nil
|
95
|
+
#
|
96
|
+
# unless %w{help install}.include?(command)
|
97
|
+
# unless Localeapp.include_config_file
|
98
|
+
# puts "Could not load config file"
|
99
|
+
# exit
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
# case command
|
104
|
+
# when 'install'
|
105
|
+
# key = args.shift.strip rescue nil
|
106
|
+
# installer = Localeapp::CLI::Install.new
|
107
|
+
# if installer.execute(key)
|
108
|
+
# exit 0
|
109
|
+
# else
|
110
|
+
# exit 1
|
111
|
+
# end
|
112
|
+
# when 'pull'
|
113
|
+
# Localeapp::CLI::Pull.new.execute
|
114
|
+
# when 'push'
|
115
|
+
# file = args.shift.strip rescue nil
|
116
|
+
# pusher = Localeapp::CLI::Push.new
|
117
|
+
# pusher.execute(file)
|
118
|
+
# when 'update'
|
119
|
+
# Localeapp::CLI::Update.new.execute
|
120
|
+
# when 'daemon'
|
121
|
+
# while true do
|
122
|
+
# Localeapp::CLI::Update.new.execute
|
123
|
+
# sleep 5
|
124
|
+
# end
|
125
|
+
# else
|
126
|
+
# puts <<-HELP
|
127
|
+
# Usage: localeapp COMMAND [ARGS]
|
128
|
+
#
|
129
|
+
# Commands:
|
130
|
+
# install <api_key> - Creates new configuration files and confirms key works
|
131
|
+
# pull - Pulls all translations from localeapp.com
|
132
|
+
# push <file> - Pushes a translation file to localeapp.com
|
133
|
+
# update - Gets any changes since the last poll and updates the yml files
|
134
|
+
# daemon - Simple daemon that checks every 5 seconds for new translations
|
135
|
+
# HELP
|
136
|
+
# end
|
@@ -2,14 +2,14 @@ Feature: localeapp executable
|
|
2
2
|
|
3
3
|
Scenario: Viewing help
|
4
4
|
In order to see what options I have
|
5
|
-
When I run `localeapp help`
|
5
|
+
When I run `localeapp --help`
|
6
6
|
Then the output should contain:
|
7
7
|
"""
|
8
|
-
Usage: localeapp COMMAND [
|
8
|
+
Usage: localeapp COMMAND [options]
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
COMMAND:
|
11
|
+
install <api_key> - Creates new configuration files and confirms key works
|
12
|
+
pull - Pulls all translations from localeapp.com
|
13
13
|
"""
|
14
14
|
|
15
15
|
Scenario: Running install
|
@@ -20,17 +20,44 @@ module Localeapp
|
|
20
20
|
# RAILS_ROOT
|
21
21
|
attr_accessor :project_root
|
22
22
|
|
23
|
+
# The names of environments where notifications are sent
|
24
|
+
# (defaults to 'development')
|
25
|
+
attr_accessor :sending_environments
|
26
|
+
|
27
|
+
# The names of environments where I18n.reload is called for each request
|
28
|
+
# (defaults to 'development')
|
29
|
+
attr_accessor :reloading_environments
|
30
|
+
|
31
|
+
# The names of environments where updates aren't pulled
|
32
|
+
# (defaults to 'development')
|
33
|
+
attr_accessor :polling_environments
|
34
|
+
|
35
|
+
# @deprecated Use {#sending_environments} instead. This is safer but make sure to reverse your logic if you've changed the defaults
|
23
36
|
# The names of environments where notifications aren't sent (defaults to
|
24
37
|
# 'test', 'cucumber', 'production')
|
25
38
|
attr_accessor :disabled_sending_environments
|
39
|
+
def disabled_sending_environments=(value)
|
40
|
+
@deprecated_environment_config_used = true
|
41
|
+
@disabled_sending_environments = value
|
42
|
+
end
|
26
43
|
|
44
|
+
# @deprecated Use {#reloading_environments} instead. This is safer but make sure to reverse your logic if you've changed the defaults
|
27
45
|
# The names of environments where I18n.reload isn't called for each request
|
28
46
|
# (defaults to 'test', 'cucumber', 'production')
|
29
47
|
attr_accessor :disabled_reloading_environments
|
48
|
+
def disabled_reloading_environments=(value)
|
49
|
+
@deprecated_environment_config_used = true
|
50
|
+
@disabled_reloading_environments = value
|
51
|
+
end
|
30
52
|
|
53
|
+
# @deprecated Use {#polling_environments} instead. This is safer but make sure to reverse your logic if you've changed the defaults
|
31
54
|
# The names of environments where updates aren't pulled (defaults to
|
32
55
|
# 'test', 'cucumber', 'production')
|
33
56
|
attr_accessor :disabled_polling_environments
|
57
|
+
def disabled_polling_environments=(value)
|
58
|
+
@deprecated_environment_config_used = true
|
59
|
+
@disabled_polling_environments = value
|
60
|
+
end
|
34
61
|
|
35
62
|
# The logger used by Localeapp
|
36
63
|
attr_accessor :logger
|
@@ -47,12 +74,19 @@ module Localeapp
|
|
47
74
|
# The complete path to the directory where translations are stored
|
48
75
|
attr_accessor :translation_data_directory
|
49
76
|
|
77
|
+
def deprecated_environment_config_used?
|
78
|
+
@deprecated_environment_config_used
|
79
|
+
end
|
80
|
+
|
50
81
|
def initialize
|
51
82
|
@host = 'api.localeapp.com'
|
52
83
|
@port = 80
|
53
84
|
@disabled_sending_environments = %w(test cucumber production)
|
54
85
|
@disabled_reloading_environments = %w(test cucumber production)
|
55
86
|
@disabled_polling_environments = %w(test cucumber production)
|
87
|
+
@sending_environments = %w(development)
|
88
|
+
@reloading_environments = %w(development)
|
89
|
+
@polling_environments = %w(development)
|
56
90
|
@poll_interval = 0
|
57
91
|
@synchronization_data_file = File.join('log', 'localeapp.yml')
|
58
92
|
@translation_data_directory = File.join('config', 'locales')
|
@@ -63,15 +97,30 @@ module Localeapp
|
|
63
97
|
end
|
64
98
|
|
65
99
|
def polling_disabled?
|
66
|
-
|
100
|
+
if deprecated_environment_config_used?
|
101
|
+
::Localeapp.log "DEPRECATION: disabled_polling_environments is deprecated and will be removed. Use polling_environments instead and reverse the logic if you've changed the defaults"
|
102
|
+
disabled_polling_environments.include?(environment_name)
|
103
|
+
else
|
104
|
+
!polling_environments.include?(environment_name)
|
105
|
+
end
|
67
106
|
end
|
68
107
|
|
69
108
|
def reloading_disabled?
|
70
|
-
|
109
|
+
if deprecated_environment_config_used?
|
110
|
+
::Localeapp.log "DEPRECATION: disabled_reloading_environments is deprecated and will be removed. Use reloading_environments instead and reverse the logic if you've changed the defaults"
|
111
|
+
disabled_reloading_environments.include?(environment_name)
|
112
|
+
else
|
113
|
+
!reloading_environments.include?(environment_name)
|
114
|
+
end
|
71
115
|
end
|
72
116
|
|
73
117
|
def sending_disabled?
|
74
|
-
|
118
|
+
if deprecated_environment_config_used?
|
119
|
+
::Localeapp.log "DEPRECATION: disabled_sending_environments is deprecated and will be removed. Use sending_environments instead and reverse the logic if you've changed the defaults"
|
120
|
+
disabled_sending_environments.include?(environment_name)
|
121
|
+
else
|
122
|
+
!sending_environments.include?(environment_name)
|
123
|
+
end
|
75
124
|
end
|
76
125
|
|
77
126
|
def write_initial(path)
|
@@ -83,8 +132,6 @@ require 'localeapp/rails'
|
|
83
132
|
|
84
133
|
Localeapp.configure do |config|
|
85
134
|
config.api_key = '#{@api_key}'
|
86
|
-
config.host = '#{@host}'
|
87
|
-
config.port = #{@port}
|
88
135
|
end
|
89
136
|
CONTENT
|
90
137
|
end
|
data/lib/localeapp/updater.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Localeapp
|
2
4
|
class Updater
|
3
5
|
|
@@ -53,12 +55,16 @@ module Localeapp
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
# from ActiveSupport
|
58
|
+
# originally from ActiveSupport
|
57
59
|
def atomic_write(file_name, temp_dir = Dir.tmpdir)
|
58
60
|
temp_file = Tempfile.new(File.basename(file_name), temp_dir)
|
59
61
|
yield temp_file
|
60
62
|
temp_file.close
|
61
|
-
|
63
|
+
# heroku has /tmp on a different fs
|
64
|
+
# so move first to sure they're on the same fs
|
65
|
+
# so rename will work
|
66
|
+
FileUtils.mv(temp_file.path, "#{file_name}.tmp")
|
67
|
+
File.rename("#{file_name}.tmp", file_name)
|
62
68
|
end
|
63
69
|
end
|
64
70
|
end
|
data/lib/localeapp/version.rb
CHANGED
data/localeapp.gemspec
CHANGED
@@ -1,99 +1,220 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Localeapp::Configuration do
|
4
|
-
|
5
|
-
@configuration = Localeapp::Configuration.new
|
6
|
-
end
|
4
|
+
let(:configuration) { Localeapp::Configuration.new }
|
7
5
|
|
8
6
|
it "sets the host by default" do
|
9
|
-
|
7
|
+
configuration.host.should == 'api.localeapp.com'
|
10
8
|
end
|
11
9
|
|
12
10
|
it "allows the host to be overwritten" do
|
13
|
-
expect {
|
11
|
+
expect { configuration.host = 'test.host' }.to change(configuration, :host).to('test.host')
|
14
12
|
end
|
15
13
|
|
16
14
|
it "includes http_auth_username defaulting to nil" do
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
configuration.http_auth_username.should == nil
|
16
|
+
configuration.http_auth_username = "test"
|
17
|
+
configuration.http_auth_username.should == "test"
|
20
18
|
end
|
21
19
|
|
22
20
|
it "includes http_auth_password defaulting to nil" do
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
configuration.http_auth_password.should == nil
|
22
|
+
configuration.http_auth_password = "test"
|
23
|
+
configuration.http_auth_password.should == "test"
|
26
24
|
end
|
27
25
|
|
28
26
|
it "includes translation_data_directory defaulting to config/locales" do
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
configuration.translation_data_directory.should == File.join("config", "locales")
|
28
|
+
configuration.translation_data_directory = "test"
|
29
|
+
configuration.translation_data_directory.should == "test"
|
30
|
+
end
|
31
|
+
|
32
|
+
context "enabled_sending_environments" do
|
33
|
+
it "is only development by default" do
|
34
|
+
configuration.sending_environments.should == ['development']
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "enabled_reloading_environments" do
|
39
|
+
it "is only development by default" do
|
40
|
+
configuration.reloading_environments.should == ['development']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "enabled_polling_environments" do
|
45
|
+
it "is only development by default" do
|
46
|
+
configuration.polling_environments.should == ['development']
|
47
|
+
end
|
32
48
|
end
|
33
49
|
|
34
50
|
context "disabled_sending_environments" do
|
51
|
+
it "sets deprecated_environment_config_used flag to true" do
|
52
|
+
configuration.disabled_sending_environments = %(foo bar)
|
53
|
+
configuration.deprecated_environment_config_used?.should be_true
|
54
|
+
end
|
55
|
+
|
35
56
|
it "does not include development by default" do
|
36
|
-
|
37
|
-
|
57
|
+
configuration.environment_name = 'development'
|
58
|
+
configuration.sending_disabled?.should be_false
|
38
59
|
end
|
39
60
|
|
40
61
|
it "include cucumber by default" do
|
41
|
-
|
42
|
-
|
62
|
+
configuration.environment_name = 'cucumber'
|
63
|
+
configuration.sending_disabled?.should be_true
|
43
64
|
end
|
44
65
|
|
45
66
|
it "include test by default" do
|
46
|
-
|
47
|
-
|
67
|
+
configuration.environment_name = 'test'
|
68
|
+
configuration.sending_disabled?.should be_true
|
48
69
|
end
|
49
70
|
|
50
71
|
it "include production by default" do
|
51
|
-
|
52
|
-
|
72
|
+
configuration.environment_name = 'production'
|
73
|
+
configuration.sending_disabled?.should be_true
|
53
74
|
end
|
54
75
|
end
|
55
76
|
|
56
77
|
context "disabled_reloading_environments" do
|
78
|
+
it "sets deprecated_environment_config_used flag to true" do
|
79
|
+
configuration.disabled_reloading_environments = %(foo bar)
|
80
|
+
configuration.deprecated_environment_config_used?.should be_true
|
81
|
+
end
|
82
|
+
|
57
83
|
it "does not include development by default" do
|
58
|
-
|
59
|
-
|
84
|
+
configuration.environment_name = 'development'
|
85
|
+
configuration.reloading_disabled?.should be_false
|
60
86
|
end
|
61
87
|
|
62
88
|
it "include cucumber by default" do
|
63
|
-
|
64
|
-
|
89
|
+
configuration.environment_name = 'cucumber'
|
90
|
+
configuration.reloading_disabled?.should be_true
|
65
91
|
end
|
66
92
|
|
67
93
|
it "include test by default" do
|
68
|
-
|
69
|
-
|
94
|
+
configuration.environment_name = 'test'
|
95
|
+
configuration.reloading_disabled?.should be_true
|
70
96
|
end
|
71
97
|
|
72
98
|
it "include production by default" do
|
73
|
-
|
74
|
-
|
99
|
+
configuration.environment_name = 'production'
|
100
|
+
configuration.reloading_disabled?.should be_true
|
75
101
|
end
|
76
102
|
end
|
77
103
|
|
78
104
|
context "disabled_polling_environments" do
|
105
|
+
it "sets deprecated_environment_config_used flag to true" do
|
106
|
+
configuration.disabled_polling_environments = %(foo bar)
|
107
|
+
configuration.deprecated_environment_config_used?.should be_true
|
108
|
+
end
|
109
|
+
|
79
110
|
it "does not include development by default" do
|
80
|
-
|
81
|
-
|
111
|
+
configuration.environment_name = 'development'
|
112
|
+
configuration.polling_disabled?.should be_false
|
82
113
|
end
|
83
114
|
|
84
115
|
it "include cucumber by default" do
|
85
|
-
|
86
|
-
|
116
|
+
configuration.environment_name = 'cucumber'
|
117
|
+
configuration.polling_disabled?.should be_true
|
87
118
|
end
|
88
119
|
|
89
120
|
it "include test by default" do
|
90
|
-
|
91
|
-
|
121
|
+
configuration.environment_name = 'test'
|
122
|
+
configuration.polling_disabled?.should be_true
|
92
123
|
end
|
93
124
|
|
94
125
|
it "include production by default" do
|
95
|
-
|
96
|
-
|
126
|
+
configuration.environment_name = 'production'
|
127
|
+
configuration.polling_disabled?.should be_true
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "polling_disabled?" do
|
132
|
+
context "deprecated syntax used" do
|
133
|
+
it "is true when environment is disabled" do
|
134
|
+
configuration.disabled_polling_environments = %(foo)
|
135
|
+
configuration.environment_name = 'foo'
|
136
|
+
configuration.should be_polling_disabled
|
137
|
+
end
|
138
|
+
|
139
|
+
it "is false when environment is not disabled" do
|
140
|
+
configuration.disabled_polling_environments = %(foo)
|
141
|
+
configuration.environment_name = 'bar'
|
142
|
+
configuration.should_not be_polling_disabled
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "new syntax used" do
|
147
|
+
it "is true when environment is not enabled" do
|
148
|
+
configuration.polling_environments = %(foo)
|
149
|
+
configuration.environment_name = 'bar'
|
150
|
+
configuration.should be_polling_disabled
|
151
|
+
end
|
152
|
+
|
153
|
+
it "is false when environment is enabled" do
|
154
|
+
configuration.polling_environments = %(foo)
|
155
|
+
configuration.environment_name = 'foo'
|
156
|
+
configuration.should_not be_polling_disabled
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "reloading_disabled?" do
|
162
|
+
context "deprecated syntax used" do
|
163
|
+
it "is true when environment is disabled" do
|
164
|
+
configuration.disabled_reloading_environments = %(foo)
|
165
|
+
configuration.environment_name = 'foo'
|
166
|
+
configuration.should be_reloading_disabled
|
167
|
+
end
|
168
|
+
|
169
|
+
it "is false when environment is not disabled" do
|
170
|
+
configuration.disabled_reloading_environments = %(foo)
|
171
|
+
configuration.environment_name = 'bar'
|
172
|
+
configuration.should_not be_reloading_disabled
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "new syntax used" do
|
177
|
+
it "is true when environment is not enabled" do
|
178
|
+
configuration.reloading_environments = %(foo)
|
179
|
+
configuration.environment_name = 'bar'
|
180
|
+
configuration.should be_reloading_disabled
|
181
|
+
end
|
182
|
+
|
183
|
+
it "is false when environment is enabled" do
|
184
|
+
configuration.reloading_environments = %(foo)
|
185
|
+
configuration.environment_name = 'foo'
|
186
|
+
configuration.should_not be_reloading_disabled
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "sending_disabled?" do
|
192
|
+
context "deprecated syntax used" do
|
193
|
+
it "is true when environment is disabled" do
|
194
|
+
configuration.disabled_sending_environments = %(foo)
|
195
|
+
configuration.environment_name = 'foo'
|
196
|
+
configuration.should be_sending_disabled
|
197
|
+
end
|
198
|
+
|
199
|
+
it "is false when environment is not disabled" do
|
200
|
+
configuration.disabled_sending_environments = %(foo)
|
201
|
+
configuration.environment_name = 'bar'
|
202
|
+
configuration.should_not be_sending_disabled
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
context "new syntax used" do
|
207
|
+
it "is true when environment is not enabled" do
|
208
|
+
configuration.sending_environments = %(foo)
|
209
|
+
configuration.environment_name = 'bar'
|
210
|
+
configuration.should be_sending_disabled
|
211
|
+
end
|
212
|
+
|
213
|
+
it "is false when environment is enabled" do
|
214
|
+
configuration.sending_environments = %(foo)
|
215
|
+
configuration.environment_name = 'foo'
|
216
|
+
configuration.should_not be_sending_disabled
|
217
|
+
end
|
97
218
|
end
|
98
219
|
end
|
99
220
|
end
|
@@ -109,8 +230,6 @@ require 'localeapp/rails'
|
|
109
230
|
|
110
231
|
Localeapp.configure do |config|
|
111
232
|
config.api_key = 'APIKEY'
|
112
|
-
config.host = 'api.localeapp.com'
|
113
|
-
config.port = 80
|
114
233
|
end
|
115
234
|
CONTENT
|
116
235
|
File.should_receive(:open).with(path, 'w+').and_yield(file)
|
@@ -23,8 +23,7 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
23
23
|
|
24
24
|
context "when polling is enabled" do
|
25
25
|
before do
|
26
|
-
Localeapp.configuration.environment_name = 'development'
|
27
|
-
Localeapp.configuration.disabled_reloading_environments << 'development'
|
26
|
+
Localeapp.configuration.environment_name = 'development'
|
28
27
|
end
|
29
28
|
|
30
29
|
it "calls poller.poll! when the synchronization file's polled_at has changed" do
|
@@ -41,8 +40,7 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
41
40
|
|
42
41
|
context "when polling is disabled" do
|
43
42
|
before do
|
44
|
-
Localeapp.configuration.environment_name = 'production'
|
45
|
-
Localeapp.configuration.disabled_reloading_environments << 'production'
|
43
|
+
Localeapp.configuration.environment_name = 'production'
|
46
44
|
end
|
47
45
|
|
48
46
|
it "doesn't poller.poll! when the synchronization file's polled_at has changed" do
|
@@ -59,8 +57,8 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
59
57
|
|
60
58
|
context "when reloading is enabled" do
|
61
59
|
before do
|
62
|
-
Localeapp.configuration.environment_name = 'development'
|
63
|
-
Localeapp.
|
60
|
+
Localeapp.configuration.environment_name = 'development'
|
61
|
+
Localeapp.poller.stub!(:poll!)
|
64
62
|
end
|
65
63
|
|
66
64
|
it "calls I18n.reload! when the synchronization file's updated_at has changed" do
|
@@ -77,8 +75,7 @@ describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
|
77
75
|
|
78
76
|
context "when reloading is disabled" do
|
79
77
|
before do
|
80
|
-
Localeapp.configuration.environment_name = 'production'
|
81
|
-
Localeapp.configuration.disabled_polling_environments << 'production'
|
78
|
+
Localeapp.configuration.environment_name = 'production'
|
82
79
|
end
|
83
80
|
|
84
81
|
it "doesn't call I18n.reload! when the synchronization file's updated_at has changed" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localeapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Dell
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-09-07 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: i18n
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
type: :runtime
|
76
76
|
version_requirements: *id004
|
77
77
|
- !ruby/object:Gem::Dependency
|
78
|
-
name:
|
78
|
+
name: slop
|
79
79
|
prerelease: false
|
80
80
|
requirement: &id005 !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
@@ -86,12 +86,26 @@ dependencies:
|
|
86
86
|
segments:
|
87
87
|
- 0
|
88
88
|
version: "0"
|
89
|
-
type: :
|
89
|
+
type: :runtime
|
90
90
|
version_requirements: *id005
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
|
-
name:
|
92
|
+
name: rake
|
93
93
|
prerelease: false
|
94
94
|
requirement: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
type: :development
|
104
|
+
version_requirements: *id006
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rspec
|
107
|
+
prerelease: false
|
108
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
95
109
|
none: false
|
96
110
|
requirements:
|
97
111
|
- - "="
|
@@ -103,11 +117,11 @@ dependencies:
|
|
103
117
|
- 0
|
104
118
|
version: 2.5.0
|
105
119
|
type: :development
|
106
|
-
version_requirements: *
|
120
|
+
version_requirements: *id007
|
107
121
|
- !ruby/object:Gem::Dependency
|
108
122
|
name: yard
|
109
123
|
prerelease: false
|
110
|
-
requirement: &
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
111
125
|
none: false
|
112
126
|
requirements:
|
113
127
|
- - "="
|
@@ -119,11 +133,11 @@ dependencies:
|
|
119
133
|
- 7
|
120
134
|
version: 0.6.7
|
121
135
|
type: :development
|
122
|
-
version_requirements: *
|
136
|
+
version_requirements: *id008
|
123
137
|
- !ruby/object:Gem::Dependency
|
124
138
|
name: RedCloth
|
125
139
|
prerelease: false
|
126
|
-
requirement: &
|
140
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
127
141
|
none: false
|
128
142
|
requirements:
|
129
143
|
- - "="
|
@@ -135,11 +149,11 @@ dependencies:
|
|
135
149
|
- 7
|
136
150
|
version: 4.2.7
|
137
151
|
type: :development
|
138
|
-
version_requirements: *
|
152
|
+
version_requirements: *id009
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: aruba
|
141
155
|
prerelease: false
|
142
|
-
requirement: &
|
156
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
143
157
|
none: false
|
144
158
|
requirements:
|
145
159
|
- - "="
|
@@ -151,11 +165,11 @@ dependencies:
|
|
151
165
|
- 6
|
152
166
|
version: 0.3.6
|
153
167
|
type: :development
|
154
|
-
version_requirements: *
|
168
|
+
version_requirements: *id010
|
155
169
|
- !ruby/object:Gem::Dependency
|
156
170
|
name: fakeweb
|
157
171
|
prerelease: false
|
158
|
-
requirement: &
|
172
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
159
173
|
none: false
|
160
174
|
requirements:
|
161
175
|
- - "="
|
@@ -167,7 +181,7 @@ dependencies:
|
|
167
181
|
- 0
|
168
182
|
version: 1.3.0
|
169
183
|
type: :development
|
170
|
-
version_requirements: *
|
184
|
+
version_requirements: *id011
|
171
185
|
description: Post any unfound translation keys to the Locale SaaS
|
172
186
|
email:
|
173
187
|
- chris@tigrish.com
|
@@ -184,11 +198,12 @@ files:
|
|
184
198
|
- .rspec
|
185
199
|
- .rvmrc
|
186
200
|
- .travis.yml
|
201
|
+
- CHANGELOG.md
|
187
202
|
- Gemfile
|
188
203
|
- Gemfile.i18n_037
|
189
204
|
- Gemfile.i18n_050
|
190
205
|
- Gemfile.i18n_060
|
191
|
-
- README.
|
206
|
+
- README.md
|
192
207
|
- Rakefile
|
193
208
|
- bin/localeapp
|
194
209
|
- cucumber.yml
|