wti_gettext_i18n_rails 1.0.0
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/MIT-LICENSE +22 -0
- data/README.md +106 -0
- data/bin/wti +5 -0
- data/examples/locale.rb +12 -0
- data/examples/translation.yml +18 -0
- data/generators/webtranslateit/lib/insert_commands.rb +34 -0
- data/generators/webtranslateit/templates/translation.yml +17 -0
- data/generators/webtranslateit/webtranslateit_generator.rb +26 -0
- data/history.md +99 -0
- data/lib/web_translate_it/auto_fetch.rb +22 -0
- data/lib/web_translate_it/command_line.rb +167 -0
- data/lib/web_translate_it/configuration.rb +54 -0
- data/lib/web_translate_it/project.rb +38 -0
- data/lib/web_translate_it/tasks.rb +59 -0
- data/lib/web_translate_it/translation_file.rb +97 -0
- data/lib/web_translate_it/util.rb +35 -0
- data/lib/web_translate_it.rb +20 -0
- data/man/wti.1 +90 -0
- data/man/wti.1.html +157 -0
- data/man/wti.1.ron +81 -0
- data/spec/examples/config/translation.yml +15 -0
- data/spec/examples/en.yml +38 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/web_translate_it/configuration_spec.rb +31 -0
- data/spec/web_translate_it/translation_file_spec.rb +68 -0
- data/spec/web_translate_it/util_spec.rb +10 -0
- data/spec/web_translate_it_spec.rb +27 -0
- data/version.yml +4 -0
- metadata +132 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe WebTranslateIt::TranslationFile do
|
4
|
+
before(:each) do
|
5
|
+
@translation_file = WebTranslateIt::TranslationFile.new(1174, "/config/locales/[locale].yml", "04b254da22a6eb301b103f848e469ad494eea47d")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#initialize" do
|
9
|
+
it "should assign id, file_path and api_key" do
|
10
|
+
tr_file = WebTranslateIt::TranslationFile.new(1174, "/config/locales/[locale].yml", "04b254da22a6eb301b103f848e469ad494eea47d")
|
11
|
+
tr_file.id.should == 1174
|
12
|
+
tr_file.file_path.should == "/config/locales/[locale].yml"
|
13
|
+
tr_file.api_key.should == "04b254da22a6eb301b103f848e469ad494eea47d"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#fetch" do
|
18
|
+
it "should prepare a HTTP request and get a 200 OK if the language file is stale" do
|
19
|
+
file = mock(File)
|
20
|
+
file.stub(:puts => true, :close => true)
|
21
|
+
File.stub(:exist? => true, :mtime => Time.at(0), :new => file)
|
22
|
+
@translation_file.fetch('fr_FR').should == 200
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should prepare a HTTP request and get a 200 OK if the language file is stale using the force download parameter" do
|
26
|
+
file = mock(File)
|
27
|
+
file.stub(:puts => true, :close => true)
|
28
|
+
File.stub(:exist? => true, :mtime => Time.at(0), :new => file)
|
29
|
+
@translation_file.fetch('fr_FR', true).should == 200
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should prepare a HTTP request and get a 304 OK if the language file is fresh" do
|
33
|
+
file = mock(File)
|
34
|
+
file.stub(:puts => true, :close => true)
|
35
|
+
File.stub(:exist? => true, :mtime => Time.now, :new => file)
|
36
|
+
@translation_file.fetch('fr_FR').should == 304
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should prepare a HTTP request and get a 200 OK if the language file is fresh using the force download parameter" do
|
40
|
+
file = mock(File)
|
41
|
+
file.stub(:puts => true, :close => true)
|
42
|
+
File.stub(:exist? => true, :mtime => Time.now, :new => file)
|
43
|
+
@translation_file.fetch('fr_FR', true).should == 200
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#upload" do
|
48
|
+
it "should prepare a HTTP request and get a 200 OK" do
|
49
|
+
@translation_file.stub(:file_path => File.join(File.dirname(__FILE__), '..', 'examples', 'en.yml'))
|
50
|
+
@translation_file.upload('en')
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should fail if the file does not exist" do
|
54
|
+
@translation_file.stub(:file_path => File.join('something', 'that', 'does', 'not', 'exist'))
|
55
|
+
lambda { @translation_file.upload('en') }.should raise_error
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#file_path_for_locale" do
|
60
|
+
it "should replace [locale] by the locale passed as a parameter" do
|
61
|
+
@translation_file.file_path_for_locale('fr').should == "/config/locales/fr.yml"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should fail if no parameter is given" do
|
65
|
+
lambda { @translation_file.file_path_for_locale }.should raise_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
|
3
|
+
module WebTranslateIt
|
4
|
+
class I18n
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
describe WebTranslateIt do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
WebTranslateIt::I18n.stub(:locale => 'en')
|
12
|
+
WebTranslateIt::Configuration.const_set("RAILS_ROOT", File.dirname(__FILE__) + '/examples')
|
13
|
+
@configuration = WebTranslateIt::Configuration.new
|
14
|
+
@file = mock(WebTranslateIt::TranslationFile)
|
15
|
+
@file.stub(:fetch => true)
|
16
|
+
@configuration.stub(:files => [@file])
|
17
|
+
WebTranslateIt::Configuration.stub(:new => @configuration)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "WebTranslateIt.fetch_translations" do
|
22
|
+
it "should fetch the configuration" do
|
23
|
+
WebTranslateIt::Configuration.should_receive(:new)
|
24
|
+
WebTranslateIt.fetch_translations
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/version.yml
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wti_gettext_i18n_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- "\xC3\x89douard Bri\xC3\xA8re"
|
13
|
+
- "Romain Semp\xC3\xA9"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-03-31 00:00:00 +02:00
|
19
|
+
default_executable: wti
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: multipart-post
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
version: "1.0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rspec
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 2
|
44
|
+
- 0
|
45
|
+
version: 1.2.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: mg
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
- 0
|
58
|
+
- 7
|
59
|
+
version: 0.0.7
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
description: A rack middleware and a handful of rake tasks to sync your translations between webtranslateit.com and your rails applications.
|
63
|
+
email:
|
64
|
+
executables:
|
65
|
+
- wti
|
66
|
+
extensions: []
|
67
|
+
|
68
|
+
extra_rdoc_files:
|
69
|
+
- history.md
|
70
|
+
- README.md
|
71
|
+
files:
|
72
|
+
- history.md
|
73
|
+
- MIT-LICENSE
|
74
|
+
- README.md
|
75
|
+
- version.yml
|
76
|
+
- examples/locale.rb
|
77
|
+
- examples/translation.yml
|
78
|
+
- lib/web_translate_it/auto_fetch.rb
|
79
|
+
- lib/web_translate_it/command_line.rb
|
80
|
+
- lib/web_translate_it/configuration.rb
|
81
|
+
- lib/web_translate_it/project.rb
|
82
|
+
- lib/web_translate_it/tasks.rb
|
83
|
+
- lib/web_translate_it/translation_file.rb
|
84
|
+
- lib/web_translate_it/util.rb
|
85
|
+
- lib/web_translate_it.rb
|
86
|
+
- generators/webtranslateit/lib/insert_commands.rb
|
87
|
+
- generators/webtranslateit/templates/translation.yml
|
88
|
+
- generators/webtranslateit/webtranslateit_generator.rb
|
89
|
+
- bin/wti
|
90
|
+
- man/wti.1
|
91
|
+
- man/wti.1.html
|
92
|
+
- man/wti.1.ron
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: https://webtranslateit.com
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options:
|
99
|
+
- --main
|
100
|
+
- README.md
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
requirements: []
|
118
|
+
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.3.6
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: Sync your translations between your Rails app and Web Translate It, adaptate for gettext_i18n_rails
|
124
|
+
test_files:
|
125
|
+
- spec/examples/config/translation.yml
|
126
|
+
- spec/examples/en.yml
|
127
|
+
- spec/spec.opts
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- spec/web_translate_it/configuration_spec.rb
|
130
|
+
- spec/web_translate_it/translation_file_spec.rb
|
131
|
+
- spec/web_translate_it/util_spec.rb
|
132
|
+
- spec/web_translate_it_spec.rb
|