i18n-export 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/i18n_export.rb +3 -0
- data/lib/i18n_export/railtie.rb +5 -6
- data/lib/i18n_export/version.rb +1 -1
- data/lib/tasks/i18n_export.rake +0 -2
- data/test/helper.rb +9 -3
- data/test/test_export.rb +8 -0
- metadata +4 -4
data/lib/i18n_export.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require File.expand_path("i18n_export/config", File.dirname(__FILE__))
|
2
2
|
require "active_support"
|
3
|
+
require "fileutils"
|
3
4
|
|
4
5
|
module I18nExport
|
5
6
|
|
@@ -21,6 +22,8 @@ module I18nExport
|
|
21
22
|
|
22
23
|
private
|
23
24
|
def self.export_file(definition)
|
25
|
+
FileUtils.mkdir_p File.dirname(definition.filename)
|
26
|
+
|
24
27
|
open(definition.filename, "w+") do |f|
|
25
28
|
f.print "var I18n = I18n || {};\n"
|
26
29
|
f.print "I18n.translations = "
|
data/lib/i18n_export/railtie.rb
CHANGED
@@ -8,12 +8,11 @@ module I18nExport
|
|
8
8
|
|
9
9
|
# Used for development
|
10
10
|
config.to_prepare do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
I18nExport.export!
|
11
|
+
is_running_rake = (File.basename($0) == "rake")
|
12
|
+
|
13
|
+
unless is_running_rake
|
14
|
+
I18nExport.export!
|
15
|
+
end
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
data/lib/i18n_export/version.rb
CHANGED
data/lib/tasks/i18n_export.rake
CHANGED
data/test/helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "test/unit"
|
3
|
+
require "fileutils"
|
3
4
|
|
4
5
|
require File.expand_path("../lib/i18n_export.rb", File.dirname(__FILE__))
|
5
6
|
|
@@ -8,13 +9,18 @@ class Test::Unit::TestCase
|
|
8
9
|
def setup
|
9
10
|
# assign the configuration file
|
10
11
|
I18nExport.config_file = fixture_filename("config.yml")
|
12
|
+
|
13
|
+
# create the temporary directory
|
14
|
+
temporary_directory = File.dirname(tempfile "foo")
|
15
|
+
|
16
|
+
FileUtils.mkdir(temporary_directory)
|
11
17
|
end
|
12
18
|
|
13
19
|
def teardown
|
14
20
|
# remove temp files from the test/tmp directory
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
temporary_directory = File.dirname(tempfile "foo")
|
22
|
+
|
23
|
+
FileUtils.rm_r(temporary_directory)
|
18
24
|
end
|
19
25
|
|
20
26
|
protected
|
data/test/test_export.rb
CHANGED
@@ -32,6 +32,14 @@ class TestExport < Test::Unit::TestCase
|
|
32
32
|
assert_equal true, File.file?(tempfile("app.js"))
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_nested_directory
|
36
|
+
I18nExport.config_file = fixture_filename("config-with-nested-directory.yml")
|
37
|
+
|
38
|
+
assert_nothing_thrown do
|
39
|
+
I18nExport.export!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
35
43
|
def test_full_export
|
36
44
|
I18nExport.export!
|
37
45
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- William Howard
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-13 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|