unbabel 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4005346914d2c63457a1b5c7169bd58cee40aee5
4
- data.tar.gz: 3ed086012c74df6dcafe171638fc7f430fffc7d4
3
+ metadata.gz: 5dea7104dcb7b3d1c4d60bcf33aa261865be3b11
4
+ data.tar.gz: 5594de79f3d9a992e80a8f6effcfa80c23ee0519
5
5
  SHA512:
6
- metadata.gz: 6d7a90a752d671182df26361902d00975f3aaa6439d9ff27d060abd237f5199c8c79fb8b3534bfe52638f3340c4bd056ec4f8b09d25440c082129c859d746a21
7
- data.tar.gz: ad5da31135058fbf4d5cb64534e4fda5c2e1b5125501a6c99637a0d95102db192ceb01a9ca8226b2de73ab26b8dd01d823f6dfa3e3b49bbdcb27969bc6d35a6b
6
+ metadata.gz: f7403fee8ebc478568083b349af2ec80c00caf9ddd89682751eebad0c3cd29a0f92c871e2b6b84bdea0ab3809d35016269fcc5b9334bc8c54905f79b86cdf04c
7
+ data.tar.gz: cdbcf97279a18fcdcabd87b8f1a5c60a25d0f5ec0cc5612caf0cefff5a424f7cbe881bf949d0bf7cc5f5ed4dcc146454da7082db156684a780d97e8cfd8f9a2f
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  unbabel_api/
2
2
  *.DS_Store
3
3
  creds
4
+ *.swp
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # CHANGELOG
2
+
3
+ #### version 0.0.2
4
+
5
+ - better documentation
6
+ - changes #request to #request_translation for readability
7
+ - fixes bug on #translations, now you can correctly search by status
8
+
9
+ #### version 0.0.1
10
+
11
+ Initial release
data/README.md CHANGED
@@ -27,19 +27,50 @@ export UNBABEL_SANDBOX="true"
27
27
  ## Available methods
28
28
 
29
29
  ```ruby
30
- client.language_pairs # lists available language pairs
31
- client.topics # lists available topics
32
- client.tones # lists available tones
33
- client.translations # lists translations
34
- client.translations.find(uid) # finds a translation by unique id
35
- client.translations.request # requests a new translation
30
+ client.language_pairs # lists all available language pairs
31
+ client.topics # lists all available topics
32
+ client.tones # lists all available tones
33
+ client.find(uid) # finds a translation by unique id
34
+ client.translations # lists all translations
35
+ client.translations(status) # lists translations in a given status
36
+ client.request_translation(params) # requests a new translation
36
37
  ```
37
38
 
38
- ### Sample
39
+ ### Translation Statuses
39
40
 
40
41
  ```
41
- irb(main):009:0> client.topics
42
+ 'new' - The translation has been created and is being pre-processed
43
+ 'ready' - The translation is ready to be processed in the unbabel platform.
44
+ 'in_progress' - The translation is being executed
45
+ 'delivered' - The translation has already been returned to the client (either using the endpoint or query for a translation)
46
+ ```
47
+
48
+ ### Request Translation
49
+
50
+ You will need the following to perform a translation request
51
+
52
+ ```
53
+ text (required) - the text to be translated.
54
+ target_language (required) - the language to translate the text to.
55
+ source_language - the language of text. If not supplemented it will be auto detected from the text.
56
+ text_format - The format of the text to be translated [one of text,html].
57
+ target_text - initial version of the text to be post-edited.
58
+ uid - A unique identifier for the job. If one is not supplied the system will provide one.
59
+ callback_url - Once the job is done the result will be posted to this endpoint.
60
+ formality (optional) - The tone that should be used in the translation.
61
+ instructions (optional) - Client instructions for the translator.
62
+ topics (optional) - List of the topics of text.
63
+ ```
64
+
65
+ ### Usage samples
66
+
67
+ ```
68
+ irb> client.topics
42
69
  => [{"topic"=>{"name"=>"politics"}}, {"topic"=>{"name"=>"gossip"}}, {"topic"=>{"name"=>"sex & relationships"}}, {"topic"=>{"name"=>"crafts"}}, {"topic"=>{"name"=>"parenting"}}, {"topic"=>{"name"=>"startups"}}, {"topic"=>{"name"=>"tech"}}, {"topic"=>{"name"=>"sports"}}]
70
+
71
+ irb> params = {:text=>"unbabel rules!", :target_language=>"pt", :source_language=>"en"}
72
+ irb> client.request(params)
73
+ => {"balance"=>982.0, "client"=>"davidslv", "price"=>6.0, "source_language"=>"en", "status"=>"new", "target_language"=>"pt", "text"=>"unbabel rules!", "text_format"=>"text", "uid"=>"dbd3fea5b5"}
43
74
  ```
44
75
 
45
76
  ## Available soon
@@ -17,7 +17,7 @@ module Unbabel
17
17
  # formality (optional) - The tone that should be used in the translation.
18
18
  # instructions (optional) - Client instructions for the translator.
19
19
  # topics (optional) - List of the topics of text.
20
- def request(params = {})
20
+ def request_translation(params = {})
21
21
  response = Unirest.post("#{Unbabel::Client::ENDPOINT}/translation/",
22
22
  parameters: params.to_json)
23
23
  response.body
@@ -29,7 +29,7 @@ module Unbabel
29
29
  # 'in_progress' - The translation is being executed
30
30
  # 'delivered' - The translation has already been returned to the client (either using the endpoint or query for a translation)
31
31
  def translations(status = nil)
32
- status = "?#{status}" if status
32
+ status = "?status=#{status}" if status
33
33
 
34
34
  response = Unirest.get("#{Unbabel::Client::ENDPOINT}/translation/#{status}")
35
35
  response.body['objects']
@@ -1,3 +1,3 @@
1
1
  module Unbabel
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Unbabel::LanguangePair do
4
+ include Unbabel::LanguangePair
5
+
6
+ it 'returns an array of hashes' do
7
+ expected = [{
8
+ "lang_pair"=> {
9
+ "source_language"=>{"name"=>"Portuguese", "shortname"=>"pt"},
10
+ "target_language"=>{"name"=>"English", "shortname"=>"en"}}
11
+ }].to_json
12
+
13
+
14
+ stub_request(:get, "http://sandbox.unbabel.com/tapi/v2/language_pair")
15
+ .to_return(:body => {'objects' => expected } )
16
+
17
+ expect(language_pairs).to eq expected
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Unbabel::Tone do
4
+ include Unbabel::Tone
5
+
6
+ it 'returns an array of hashes' do
7
+ expected = [
8
+ {"tone"=> {"description"=>"Informal style", "name"=>"Informal"}},
9
+ {"tone"=> {"description"=>"Friendly style", "name"=>"Friendly"}}
10
+ ].to_json
11
+
12
+ stub_request(:get, "http://sandbox.unbabel.com/tapi/v2/tone")
13
+ .to_return(:body => {'objects' => expected } )
14
+
15
+ expect(tones).to eq expected
16
+ end
17
+ end
@@ -1,4 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Unbabel::Topic do
4
+ include Unbabel::Topic
5
+
6
+ it 'returns an array of hashes' do
7
+ expected = [{
8
+ 'topic' => {'name' => 'politics'},
9
+ 'topic' => {'name' => 'gossip'}
10
+ }].to_json
11
+
12
+ stub_request(:get, "http://sandbox.unbabel.com/tapi/v2/topic")
13
+ .to_return(:body => {'objects' => expected } )
14
+
15
+ expect(topics).to eq expected
16
+ end
4
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unbabel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-22 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ files:
89
89
  - ".gitignore"
90
90
  - ".rspec"
91
91
  - ".ruby-version"
92
+ - CHANGELOG.md
92
93
  - Gemfile
93
94
  - Gemfile.lock
94
95
  - LICENSE.txt
@@ -102,6 +103,8 @@ files:
102
103
  - lib/unbabel/translation.rb
103
104
  - lib/unbabel/version.rb
104
105
  - spec/lib/unbabel/client_spec.rb
106
+ - spec/lib/unbabel/language_pair_spec.rb
107
+ - spec/lib/unbabel/tone_spec.rb
105
108
  - spec/lib/unbabel/topic_spec.rb
106
109
  - spec/spec_helper.rb
107
110
  - unbabel.gemspec
@@ -131,6 +134,8 @@ specification_version: 4
131
134
  summary: A wrapper for Unbabel API.
132
135
  test_files:
133
136
  - spec/lib/unbabel/client_spec.rb
137
+ - spec/lib/unbabel/language_pair_spec.rb
138
+ - spec/lib/unbabel/tone_spec.rb
134
139
  - spec/lib/unbabel/topic_spec.rb
135
140
  - spec/spec_helper.rb
136
141
  has_rdoc: