web_translate_it 2.0.0.rc2 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/wti +11 -25
- data/history.md +7 -1
- data/lib/web_translate_it.rb +2 -1
- data/lib/web_translate_it/command_line.rb +31 -41
- data/lib/web_translate_it/configuration.rb +2 -1
- data/lib/web_translate_it/connection.rb +62 -0
- data/lib/web_translate_it/project.rb +14 -18
- data/lib/web_translate_it/string.rb +42 -58
- data/lib/web_translate_it/term.rb +41 -52
- data/lib/web_translate_it/term_translation.rb +14 -22
- data/lib/web_translate_it/translation.rb +9 -12
- data/lib/web_translate_it/util.rb +1 -39
- data/spec/web_translate_it/string_spec.rb +57 -58
- data/spec/web_translate_it/term_spec.rb +53 -54
- data/version +1 -1
- metadata +3 -2
@@ -6,8 +6,7 @@ describe WebTranslateIt::Term do
|
|
6
6
|
|
7
7
|
describe "#initialize" do
|
8
8
|
it "should assign api_key and many parameters" do
|
9
|
-
term = WebTranslateIt::Term.new(
|
10
|
-
term.api_key.should == api_key
|
9
|
+
term = WebTranslateIt::Term.new({ "id" => 1234, "text" => "bacon"})
|
11
10
|
term.id.should == 1234
|
12
11
|
term.text.should == "bacon"
|
13
12
|
end
|
@@ -15,78 +14,78 @@ describe WebTranslateIt::Term do
|
|
15
14
|
|
16
15
|
describe "#save" do
|
17
16
|
it "should create a new Term" do
|
18
|
-
WebTranslateIt::
|
19
|
-
term = WebTranslateIt::Term.new(
|
20
|
-
term.save
|
17
|
+
WebTranslateIt::Connection.new(api_key) do
|
18
|
+
term = WebTranslateIt::Term.new({ "text" => "Term", "description" => "A description" })
|
19
|
+
term.save
|
21
20
|
term.id.should_not be_nil
|
22
|
-
term_fetched = WebTranslateIt::Term.find(
|
21
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
23
22
|
term_fetched.should_not be_nil
|
24
23
|
term_fetched.should be_a(WebTranslateIt::Term)
|
25
24
|
term_fetched.id.should == term.id
|
26
|
-
term.delete
|
25
|
+
term.delete
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
it "should update an existing Term" do
|
31
|
-
WebTranslateIt::
|
32
|
-
term = WebTranslateIt::Term.new(
|
33
|
-
term.save
|
30
|
+
WebTranslateIt::Connection.new(api_key) do
|
31
|
+
term = WebTranslateIt::Term.new({ "text" => "Term", "description" => "A description" })
|
32
|
+
term.save
|
34
33
|
term.text = "A Term"
|
35
|
-
term.save
|
36
|
-
term_fetched = WebTranslateIt::Term.find(
|
34
|
+
term.save
|
35
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
37
36
|
term_fetched.text.should == "A Term"
|
38
|
-
term.delete
|
37
|
+
term.delete
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
41
|
it "should create a new Term with a TermTranslation" do
|
43
|
-
translation1 = WebTranslateIt::TermTranslation.new(
|
44
|
-
translation2 = WebTranslateIt::TermTranslation.new(
|
42
|
+
translation1 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Bonjour" })
|
43
|
+
translation2 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Salut" })
|
45
44
|
|
46
|
-
term = WebTranslateIt::Term.new(
|
47
|
-
WebTranslateIt::
|
48
|
-
term.save
|
49
|
-
term_fetched = WebTranslateIt::Term.find(
|
50
|
-
term_fetched.translation_for(
|
51
|
-
term_fetched.translation_for(
|
52
|
-
term_fetched.translation_for(
|
53
|
-
term_fetched.translation_for(
|
54
|
-
term.delete
|
45
|
+
term = WebTranslateIt::Term.new({ "text" => "Hello", "translations" => [translation1, translation2] })
|
46
|
+
WebTranslateIt::Connection.new(api_key) do
|
47
|
+
term.save
|
48
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
49
|
+
term_fetched.translation_for("fr").should_not be_nil
|
50
|
+
term_fetched.translation_for("fr")[0].text.should == "Bonjour"
|
51
|
+
term_fetched.translation_for("fr")[1].text.should == "Salut"
|
52
|
+
term_fetched.translation_for("es").should be_nil
|
53
|
+
term.delete
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
57
|
it "should update a Term and save its Translation" do
|
59
|
-
translation1 = WebTranslateIt::TermTranslation.new(
|
60
|
-
translation2 = WebTranslateIt::TermTranslation.new(
|
58
|
+
translation1 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Bonjour" })
|
59
|
+
translation2 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Salut" })
|
61
60
|
|
62
|
-
term = WebTranslateIt::Term.new(
|
63
|
-
WebTranslateIt::
|
64
|
-
term.save
|
65
|
-
term_fetched = WebTranslateIt::Term.find(
|
66
|
-
term_fetched.translation_for(
|
61
|
+
term = WebTranslateIt::Term.new({ "text" => "Hi!" })
|
62
|
+
WebTranslateIt::Connection.new(api_key) do
|
63
|
+
term.save
|
64
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
65
|
+
term_fetched.translation_for("fr").should be_nil
|
67
66
|
|
68
67
|
term_fetched.translations = [translation1, translation2]
|
69
|
-
term_fetched.save
|
68
|
+
term_fetched.save
|
70
69
|
|
71
|
-
term_fetched = WebTranslateIt::Term.find(
|
72
|
-
term_fetched.translation_for(
|
73
|
-
term_fetched.translation_for(
|
74
|
-
term_fetched.translation_for(
|
75
|
-
term.delete
|
70
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
71
|
+
term_fetched.translation_for("fr").should_not be_nil
|
72
|
+
term_fetched.translation_for("fr")[0].text.should == "Bonjour"
|
73
|
+
term_fetched.translation_for("fr")[1].text.should == "Salut"
|
74
|
+
term.delete
|
76
75
|
end
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
80
79
|
describe "#delete" do
|
81
80
|
it "should delete a Term" do
|
82
|
-
term = WebTranslateIt::Term.new(
|
83
|
-
WebTranslateIt::
|
84
|
-
term.save
|
85
|
-
term_fetched = WebTranslateIt::Term.find(
|
81
|
+
term = WebTranslateIt::Term.new({ "text" => "bacon" })
|
82
|
+
WebTranslateIt::Connection.new(api_key) do
|
83
|
+
term.save
|
84
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
86
85
|
term_fetched.should_not be_nil
|
87
86
|
|
88
|
-
term_fetched.delete
|
89
|
-
term_fetched = WebTranslateIt::Term.find(
|
87
|
+
term_fetched.delete
|
88
|
+
term_fetched = WebTranslateIt::Term.find(term.id)
|
90
89
|
term_fetched.should be_nil
|
91
90
|
end
|
92
91
|
end
|
@@ -94,20 +93,20 @@ describe WebTranslateIt::Term do
|
|
94
93
|
|
95
94
|
describe "#find_all" do
|
96
95
|
it "should fetch many terms" do
|
97
|
-
WebTranslateIt::
|
98
|
-
term1 = WebTranslateIt::Term.new(
|
99
|
-
term1.save
|
100
|
-
term2 = WebTranslateIt::Term.new(
|
101
|
-
term2.save
|
102
|
-
term3 = WebTranslateIt::Term.new(
|
103
|
-
term3.save
|
96
|
+
WebTranslateIt::Connection.new(api_key) do
|
97
|
+
term1 = WebTranslateIt::Term.new({ "text" => "bacon" })
|
98
|
+
term1.save
|
99
|
+
term2 = WebTranslateIt::Term.new({ "text" => "tart" })
|
100
|
+
term2.save
|
101
|
+
term3 = WebTranslateIt::Term.new({ "text" => "bacon tart" })
|
102
|
+
term3.save
|
104
103
|
|
105
|
-
terms = WebTranslateIt::Term.find_all
|
104
|
+
terms = WebTranslateIt::Term.find_all
|
106
105
|
terms.count.should == 3
|
107
106
|
|
108
|
-
term1.delete
|
109
|
-
term2.delete
|
110
|
-
term3.delete
|
107
|
+
term1.delete
|
108
|
+
term2.delete
|
109
|
+
term3.delete
|
111
110
|
end
|
112
111
|
end
|
113
112
|
end
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.rc3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web_translate_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multipart-post
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/web_translate_it/cacert.pem
|
111
111
|
- lib/web_translate_it/command_line.rb
|
112
112
|
- lib/web_translate_it/configuration.rb
|
113
|
+
- lib/web_translate_it/connection.rb
|
113
114
|
- lib/web_translate_it/project.rb
|
114
115
|
- lib/web_translate_it/string.rb
|
115
116
|
- lib/web_translate_it/term.rb
|