termit 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/README.md +7 -3
- data/bin/termit +1 -1
- data/lib/termit/text_response_handler.rb +7 -3
- data/lib/termit/url_constructor.rb +1 -5
- data/lib/termit/user_input_parser.rb +2 -2
- data/lib/termit/version.rb +1 -1
- data/spec/fixtures/{text_response → text_response_with_synonyms} +0 -0
- data/spec/fixtures/text_response_without_synonyms +1 -0
- data/spec/spec_helper.rb +22 -1
- data/spec/termit/output_manager_spec.rb +6 -22
- data/spec/termit/text_response_handler_spec.rb +19 -6
- data/spec/termit/url_constructor_spec.rb +2 -2
- data/termit.gemspec +1 -0
- metadata +38 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef57028577912b0a81d3f578039562f7376164af
|
4
|
+
data.tar.gz: 3dcd645b6eedc75f3a8902510fc24e077b1014ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1518115ddfd9efb3afdeb12244aac7f740f7a4d8c59a25acdeb3b602d9ab8f4962425f0be423e7d7b6dae053f9a28ae29e90c5862598cb303b1291090e7ec400
|
7
|
+
data.tar.gz: 9bf6aadcafb4184a70a9e27e9345d41776334beb2a16849280e9d26aa17480c866eaceb99aac626cbcc6fed922ea2498938f49ebb330ab8244a87f1f3cc3b9a1
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--color
|
2
|
-
--format
|
2
|
+
--format NyanCatWideFormatter
|
data/README.md
CHANGED
@@ -34,7 +34,13 @@ termit fr ru qui est votre papa?
|
|
34
34
|
Specify a **-t** (talk) flag to use speech synthesis (requires mpg123):
|
35
35
|
``` ruby
|
36
36
|
termit en zh "hey cowboy where is your horse?" -t
|
37
|
-
=> "嘿,牛仔是你的马在哪里?" #and a chinese voice says something about a horse
|
37
|
+
=> "嘿,牛仔是你的马在哪里?" # and a chinese voice says something about a horse
|
38
|
+
```
|
39
|
+
|
40
|
+
You can use termit as a speech synthesizer of any supported language without having to translate anything:
|
41
|
+
``` ruby
|
42
|
+
termit en en "hold your horses cowboy !" -t
|
43
|
+
=> "hold your horses cowboy !" # and an english voice asks you to hold on
|
38
44
|
```
|
39
45
|
|
40
46
|
#### Synonyms
|
@@ -78,8 +84,6 @@ For MacOSX:
|
|
78
84
|
|
79
85
|
This is my first open-source project for people to use. Any feedback will be appreciated.
|
80
86
|
|
81
|
-
Currently I am available for hire as a rails developer and willing to relocate.
|
82
|
-
|
83
87
|
You can contact me on: p.urbanek89@gmail.com
|
84
88
|
|
85
89
|
|
data/bin/termit
CHANGED
@@ -26,10 +26,10 @@ module Termit
|
|
26
26
|
def extract_synonyms
|
27
27
|
synonyms_data = @text.split("[[")[2].split("[")[1]
|
28
28
|
length = synonyms_data.length
|
29
|
-
if synonyms_data
|
30
|
-
" ---"
|
31
|
-
else
|
29
|
+
if synonyms_available synonyms_data
|
32
30
|
synonyms_data[0..(length-3)].delete("\"").gsub(/(,)/, ", ")
|
31
|
+
else
|
32
|
+
" ---"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,5 +38,9 @@ module Termit
|
|
38
38
|
text.gsub!(/(\\x26#39;)/, "'")
|
39
39
|
text.force_encoding(encoding).encode(encoding)
|
40
40
|
end
|
41
|
+
|
42
|
+
def synonyms_available synonyms_data
|
43
|
+
!synonyms_data.include?('true,false')
|
44
|
+
end
|
41
45
|
end
|
42
46
|
end
|
@@ -38,8 +38,8 @@ module Termit
|
|
38
38
|
def validate_user_input
|
39
39
|
raise ArgumentError unless @user_input.is_a? Array
|
40
40
|
raise ArgumentError unless @user_input.length > 1
|
41
|
-
|
42
|
-
raise ArgumentError unless [2, 4].include?
|
41
|
+
@user_input.first(2).each do |language_code|
|
42
|
+
raise ArgumentError unless [2, 4].include? language_code.length
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
data/lib/termit/version.rb
CHANGED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
[[[\"będzie tam iść",\"will go there\",\"\",\"\"]],,\"en\",,[[\"będzie\",[1],true,false,996,0,1,0],[\"tam\",[2],true,false,996,1,2,0],[\"iść\",[3],true,false,995,2,3,0]],[[\"will\",1,[[\"będzie\",996,true,false],[\"będą\",3,true,false],[\"zostanie\",0,true,false],[\"zostaną\",0,true,false],[\"się\",0,true,false]],[[0,4]],\"will go there\"],[\"there\",2,[[\"tam\",996,true,false],[\"nie\",0,true,false],[\"istnieje\",0,true,false],[\"jest\",0,true,false],[\"Istnieją\",0,true,false]],[[8,13]],\"\"],[\"go\",3,[[\"iść\",995,true,false],[\"pójść\",0,true,false],[\"pojechać\",0,true,false],[\"przejść\",0,true,false],[\"udać\",0,true,false]],[[5,7]],\"\"]],,,[[\"en\"]],1]
|
data/spec/spec_helper.rb
CHANGED
@@ -8,10 +8,31 @@ Coveralls.wear!
|
|
8
8
|
require_relative '../lib/termit'
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
|
-
|
11
|
+
original_stderr = $stderr
|
12
|
+
original_stdout = $stdout
|
13
|
+
|
14
|
+
# redirect output to file
|
15
|
+
config.before(:suite) do
|
16
|
+
$stderr = File.new(File.join(File.dirname(__FILE__), 'output.txt'), 'w')
|
17
|
+
$stdout = File.new(File.join(File.dirname(__FILE__), 'output.txt'), 'w')
|
18
|
+
end
|
19
|
+
|
20
|
+
config.after(:suite) do
|
21
|
+
$stderr = original_stderr
|
22
|
+
$stdout = original_stdout
|
23
|
+
system "echo '=======Specs output:======='"
|
24
|
+
system "cat spec/output.txt"
|
25
|
+
File.delete(File.join(File.dirname(__FILE__), 'output.txt'))
|
26
|
+
end
|
27
|
+
|
28
|
+
#for nyan cat formatter
|
29
|
+
config.before(:each) do
|
30
|
+
sleep(0.10)
|
31
|
+
end
|
12
32
|
end
|
13
33
|
|
14
34
|
VCR.configure do |c|
|
15
35
|
c.cassette_library_dir = 'spec/fixtures/'
|
16
36
|
c.hook_into :webmock
|
37
|
+
c.allow_http_connections_when_no_cassette = true
|
17
38
|
end
|
@@ -2,30 +2,14 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Termit::OutputManager do
|
5
|
+
METHOD_NAMES = [:display_error_info_and_quit, :display_help_and_quit, :display_version_and_quit, :display_player_error_and_quit]
|
5
6
|
subject { Termit::OutputManager.new }
|
6
|
-
describe "instance_methods" do
|
7
|
-
describe "display_error_info_and_quit" do
|
8
|
-
it "does what is says" do
|
9
|
-
expect { subject.display_error_info_and_quit }.to raise_error SystemExit
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "display_help_and_quit" do
|
14
|
-
it "does what is says" do
|
15
|
-
expect { subject.display_help_and_quit }.to raise_error SystemExit
|
16
|
-
end
|
17
|
-
end
|
18
7
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "display_player_error_and_quit" do
|
26
|
-
it "does what is says" do
|
27
|
-
expect { subject.display_player_error_and_quit }.to raise_error SystemExit
|
8
|
+
describe "instance_methods" do
|
9
|
+
it "does what it says" do
|
10
|
+
METHOD_NAMES.each do |m|
|
11
|
+
expect { subject.send(m) }.to raise_error SystemExit
|
28
12
|
end
|
29
13
|
end
|
30
14
|
end
|
31
|
-
end
|
15
|
+
end
|
@@ -5,25 +5,38 @@ describe Termit::TextResponseHandler do
|
|
5
5
|
describe "call method" do
|
6
6
|
context "no synonyms wanted" do
|
7
7
|
let(:handler) do
|
8
|
-
response_body = File.open('spec/fixtures/
|
8
|
+
response_body = File.open('spec/fixtures/text_response_with_synonyms').read
|
9
9
|
Termit::TextResponseHandler.new(response_body, false)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "extracts data from HTTP response body" do
|
13
|
-
expect(
|
13
|
+
expect($stdout).to receive(:puts).with("tyłek")
|
14
14
|
handler.call
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
context "synonyms wanted" do
|
18
|
+
context "synonyms wanted and available" do
|
19
19
|
let(:handler) do
|
20
|
-
response_body = File.open('spec/fixtures/
|
20
|
+
response_body = File.open('spec/fixtures/text_response_with_synonyms').read
|
21
21
|
Termit::TextResponseHandler.new(response_body, true)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "extracts data from HTTP response body" do
|
25
|
-
expect(
|
26
|
-
expect(
|
25
|
+
expect($stdout).to receive(:puts).with("tyłek")
|
26
|
+
expect($stdout).to receive(:puts).with("osioł, tyłek, dupa, zadek")
|
27
|
+
handler.call
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "synonyms wanted and unavailable" do
|
32
|
+
let(:handler) do
|
33
|
+
response_body = File.open('spec/fixtures/text_response_without_synonyms').read
|
34
|
+
Termit::TextResponseHandler.new(response_body, true)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "extracts data from HTTP response body" do
|
38
|
+
expect($stdout).to receive(:puts).with("będzie tam iść")
|
39
|
+
expect($stdout).to receive(:puts).with(" ---")
|
27
40
|
handler.call
|
28
41
|
end
|
29
42
|
end
|
@@ -12,7 +12,7 @@ describe Termit::UrlConstructor do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
context "when talk flag is set to
|
15
|
+
context "when talk flag is set to true" do
|
16
16
|
it "returns correctly formatted url" do
|
17
17
|
url_formatter = Termit::UrlConstructor.new target_lang: :fr, text: 'your mother', talk: true
|
18
18
|
url = "http://translate.google.com/translate_tts?tl=fr&ie=UTF-8&oe=UTF-8"
|
@@ -20,4 +20,4 @@ describe Termit::UrlConstructor do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
data/termit.gemspec
CHANGED
metadata
CHANGED
@@ -1,87 +1,101 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.14.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.14.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: vcr
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.5.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webmock
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 1.12.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.12.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coveralls
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
|
84
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nyan-cat-formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: " Termit is an easy way to use all the Google Translate goodies straight
|
98
|
+
from your terminal. "
|
85
99
|
email:
|
86
100
|
- p.urbanek89@gmail.com
|
87
101
|
executables:
|
@@ -89,9 +103,9 @@ executables:
|
|
89
103
|
extensions: []
|
90
104
|
extra_rdoc_files: []
|
91
105
|
files:
|
92
|
-
- .gitignore
|
93
|
-
- .rspec
|
94
|
-
- .travis.yml
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
95
109
|
- Gemfile
|
96
110
|
- LICENSE.txt
|
97
111
|
- README.md
|
@@ -111,7 +125,8 @@ files:
|
|
111
125
|
- lib/termit/version.rb
|
112
126
|
- spec/fixtures/google_1.yml
|
113
127
|
- spec/fixtures/google_2.yml
|
114
|
-
- spec/fixtures/
|
128
|
+
- spec/fixtures/text_response_with_synonyms
|
129
|
+
- spec/fixtures/text_response_without_synonyms
|
115
130
|
- spec/spec_helper.rb
|
116
131
|
- spec/termit/data_fetcher_spec.rb
|
117
132
|
- spec/termit/main_spec.rb
|
@@ -133,24 +148,25 @@ require_paths:
|
|
133
148
|
- lib
|
134
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
150
|
requirements:
|
136
|
-
- -
|
151
|
+
- - ">="
|
137
152
|
- !ruby/object:Gem::Version
|
138
153
|
version: '0'
|
139
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
155
|
requirements:
|
141
|
-
- -
|
156
|
+
- - ">="
|
142
157
|
- !ruby/object:Gem::Version
|
143
158
|
version: '0'
|
144
159
|
requirements: []
|
145
160
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.1.
|
161
|
+
rubygems_version: 2.1.11
|
147
162
|
signing_key:
|
148
163
|
specification_version: 4
|
149
164
|
summary: Google Translate in your terminal
|
150
165
|
test_files:
|
151
166
|
- spec/fixtures/google_1.yml
|
152
167
|
- spec/fixtures/google_2.yml
|
153
|
-
- spec/fixtures/
|
168
|
+
- spec/fixtures/text_response_with_synonyms
|
169
|
+
- spec/fixtures/text_response_without_synonyms
|
154
170
|
- spec/spec_helper.rb
|
155
171
|
- spec/termit/data_fetcher_spec.rb
|
156
172
|
- spec/termit/main_spec.rb
|