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 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 = "
@@ -8,12 +8,11 @@ module I18nExport
8
8
 
9
9
  # Used for development
10
10
  config.to_prepare do
11
- I18nExport.export!
12
- end
13
-
14
- # Used for production
15
- config.after_initialize do
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
@@ -3,7 +3,7 @@ module I18nExport
3
3
  module Version
4
4
  MAJOR = 1
5
5
  MINOR = 0
6
- PATCH = 0
6
+ PATCH = 1
7
7
  BUILD = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -1,5 +1,3 @@
1
- puts "rake task loading!!!!"
2
-
3
1
  namespace :i18n do
4
2
  desc "exports all i18n translations according to configuration"
5
3
  task :export do
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
- Dir.glob(tempfile("*")).each do |filename|
16
- File.delete(filename)
17
- end
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.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-04 00:00:00 -04:00
18
+ date: 2011-07-13 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency