i18n_sync 0.0.2 → 0.0.4

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/.gitignore CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ spec/work/*
data/Rakefile CHANGED
@@ -18,21 +18,21 @@ rescue LoadError
18
18
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
19
  end
20
20
 
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
21
+ # require 'spec/rake/spectask'
22
+ # Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ # spec.libs << 'lib' << 'spec'
24
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ # end
26
26
 
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
27
+ # Spec::Rake::SpecTask.new(:rcov) do |spec|
28
+ # spec.libs << 'lib' << 'spec'
29
+ # spec.pattern = 'spec/**/*_spec.rb'
30
+ # spec.rcov = true
31
+ # end
32
32
 
33
- task :spec => :check_dependencies
33
+ # task :spec => :check_dependencies
34
34
 
35
- task :default => :spec
35
+ # task :default => :spec
36
36
 
37
37
  require 'rake/rdoctask'
38
38
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.4
data/bin/i18s CHANGED
@@ -24,12 +24,14 @@ Usage: #{File.basename($0)} <path/to/master.yml> [args]
24
24
 
25
25
  Options are:
26
26
 
27
- -O --no-order - Order by name
28
- -t --trace - Be more verbose
27
+ -o --order - Order by name
28
+ -t --trace - Be more verbose
29
29
 
30
30
  Common usage:
31
31
 
32
- i18s ./en-US.yml
32
+ i18s ./en-US.yml - Will sync all files with en-US
33
+ i18s ./en-US.yml pt - Creates a new translate file pt.yml
34
+
33
35
 
34
36
  BANNER
35
37
  opts.on("-O", "--no-order", "Table order" ) { Options[:order] = false }
data/i18n_sync.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{i18n_sync}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcos Piccinini"]
12
- s.date = %q{2010-05-17}
12
+ s.date = %q{2010-07-16}
13
13
  s.default_executable = %q{i18s}
14
14
  s.description = %q{Gem to sync all locale yml/rb files based on a "master" one.}
15
15
  s.email = %q{x@nofxx.com}
@@ -29,6 +29,10 @@ Gem::Specification.new do |s|
29
29
  "i18n_sync.gemspec",
30
30
  "lib/i18n_sync.rb",
31
31
  "spec/fixtures/en.yml",
32
+ "spec/fixtures/named.en.yml",
33
+ "spec/fixtures/named.pt.yml",
34
+ "spec/fixtures/order.en.yml",
35
+ "spec/fixtures/order.pt.yml",
32
36
  "spec/fixtures/pt.yml",
33
37
  "spec/i18n_sync_spec.rb",
34
38
  "spec/spec_helper.rb"
@@ -36,7 +40,7 @@ Gem::Specification.new do |s|
36
40
  s.homepage = %q{http://github.com/nofxx/i18n_sync}
37
41
  s.rdoc_options = ["--charset=UTF-8"]
38
42
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.6}
43
+ s.rubygems_version = %q{1.3.7}
40
44
  s.summary = %q{Syncs all locale yml/rb files based on a "master" one.}
41
45
  s.test_files = [
42
46
  "spec/spec_helper.rb",
@@ -47,7 +51,7 @@ Gem::Specification.new do |s|
47
51
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
52
  s.specification_version = 3
49
53
 
50
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
55
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
52
56
  else
53
57
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
data/lib/i18n_sync.rb CHANGED
@@ -8,7 +8,10 @@ class I18S
8
8
  @fullpath, *new_ones = argv
9
9
  @file, *path = @fullpath.split("/").reverse # hm.. hack,,, in 1.9
10
10
  @path = path.reverse.join("/") # can splat the first
11
- @lang = @file.split(".")[0]
11
+ @path ||= "."
12
+ s = @file.split(".")
13
+ @namespace = s.length > 2 ? s[0] : false
14
+ @lang = s[-2]
12
15
  @debug = opts[:trace]
13
16
  @order = opts[:order]
14
17
  puts "Start work on #{@file} (#{@lang})"
@@ -27,6 +30,10 @@ class I18S
27
30
  Dir["#{@path}/*.{yml,rb}"].each do |filename|
28
31
  #next if filename.match('_rails')
29
32
  basename = File.basename(filename, '.yml')
33
+ if basename =~ /\./
34
+ n, basename = basename.split(".")
35
+ next unless @namespace && @namespace == n
36
+ end
30
37
  puts "Writing #{filename} -> #{basename}"
31
38
  (comments, other) = read_file(filename, basename)
32
39
  @words.each { |k,v| other[k] ||= @words[k] } #Initializing hash variable as empty if it does not exist
@@ -36,7 +43,7 @@ class I18S
36
43
  end
37
44
 
38
45
  def create(file)
39
- fullpath = "#{@path}/#{file}.yml"
46
+ fullpath = file =~ /\// ? file : "#{@path}/#{file}.yml"
40
47
  return puts("File exists.") if File.exists?(fullpath)
41
48
  write_file(fullpath, file, "", @words)
42
49
  end
data/spec/fixtures/en.yml CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- en:
2
+ en:
3
3
  sync: To Sync It!
4
4
  test: Test
@@ -0,0 +1,4 @@
1
+
2
+ en:
3
+ something: Something
4
+ another: Another
@@ -0,0 +1,3 @@
1
+
2
+ pt:
3
+ something: Algo
@@ -0,0 +1,3 @@
1
+ en:
2
+ blue: Blue
3
+ alpha: Alpha
@@ -0,0 +1,4 @@
1
+ pt:
2
+ zebra: Zebra
3
+ blue: Azul
4
+ alpha: Alfa
data/spec/fixtures/pt.yml CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
- pt:
2
+ pt:
3
3
  sync: To Sync It!
4
4
  test: Teste
5
+ new: "Uau, isso é novo"
@@ -1,7 +1,39 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
3
 
4
+ EN = "spec/work/en.yml"
5
+
3
6
  describe "I18nSync" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
7
+ before do
8
+ `rm -rf spec/work`
9
+ `cp -rf spec/fixtures spec/work`
10
+ end
11
+
12
+ it "should create a new one" do
13
+ newfile = "spec/work/fo.yml"
14
+ `rm #{newfile}` if File.exists?(newfile)
15
+ `bin/i18s #{EN} fo`
16
+ File.read(newfile).should eql("\nfo: \n sync: To Sync It!\n test: Test\n")
17
+ end
18
+
19
+ it "should sync files nicely" do
20
+ `bin/i18s spec/work/pt.yml`
21
+ File.read(EN).should eql("\nen: \n new: \"Uau, isso é novo\"\n sync: To Sync It!\n test: Test\n")
22
+ end
23
+
24
+ it "should respect namespaces" do
25
+ `bin/i18s spec/work/pt.yml`
26
+ File.read("spec/work/named.pt.yml").should eql("\npt:\n something: Algo\n")
27
+ end
28
+
29
+ it "should respect namespaces" do
30
+ `bin/i18s spec/work/named.en.yml`
31
+ File.read("spec/work/named.pt.yml").should eql("\npt: \n another: Another\n something: Algo\n")
32
+ end
33
+
34
+ it "should order alphabeticaly namespaces" do
35
+ `bin/i18s spec/work/order.pt.yml`
36
+ File.read("spec/work/order.en.yml").should eql("\nen: \n alpha: Alpha\n blue: Blue\n zebra: Zebra\n")
37
+ File.read("spec/work/named.pt.yml").should eql("\npt:\n something: Algo\n")
6
38
  end
7
39
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,14 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ TEST = true
3
4
  require 'i18n_sync'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
5
+ begin
6
+ require 'spec'
7
+ require 'spec/autorun'
8
+ rescue LoadError
9
+ require 'rspec'
9
10
  end
11
+
12
+ # Spec::Runner.configure do |config|
13
+
14
+ # end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marcos Piccinini
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-17 00:00:00 -03:00
17
+ date: 2010-07-16 00:00:00 -03:00
18
18
  default_executable: i18s
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -51,6 +52,10 @@ files:
51
52
  - i18n_sync.gemspec
52
53
  - lib/i18n_sync.rb
53
54
  - spec/fixtures/en.yml
55
+ - spec/fixtures/named.en.yml
56
+ - spec/fixtures/named.pt.yml
57
+ - spec/fixtures/order.en.yml
58
+ - spec/fixtures/order.pt.yml
54
59
  - spec/fixtures/pt.yml
55
60
  - spec/i18n_sync_spec.rb
56
61
  - spec/spec_helper.rb
@@ -64,6 +69,7 @@ rdoc_options:
64
69
  require_paths:
65
70
  - lib
66
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
67
73
  requirements:
68
74
  - - ">="
69
75
  - !ruby/object:Gem::Version
@@ -71,6 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
77
  - 0
72
78
  version: "0"
73
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
74
81
  requirements:
75
82
  - - ">="
76
83
  - !ruby/object:Gem::Version
@@ -80,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
87
  requirements: []
81
88
 
82
89
  rubyforge_project:
83
- rubygems_version: 1.3.6
90
+ rubygems_version: 1.3.7
84
91
  signing_key:
85
92
  specification_version: 3
86
93
  summary: Syncs all locale yml/rb files based on a "master" one.