termit 2.0.9 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +10 -6
- data/lib/termit/data_fetcher.rb +6 -0
- data/lib/termit/output_manager.rb +6 -1
- data/lib/termit/version.rb +1 -1
- data/spec/termit/modules/delegation_spec.rb +31 -0
- data/spec/termit/text_translator_spec.rb +1 -2
- metadata +23 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 005678038c55280a62f53d5a73272f896800d977
|
4
|
+
data.tar.gz: 66dfcce80fabdb602f4db12053beff952e44edbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2956bec8dc28c166a2d27fe67b12e1416cd6b94046577b67fc05a234c9c92e25cb2801420c41a76d8c00991d85ca07c96a766e7cd146f2123cd68b53f608adc7
|
7
|
+
data.tar.gz: 7973388099b78d418660859b0ef17a6a7db50a7b11574e40251289ab36ef8212b0f59497a3f42de178d660f0ccf1ba76c53d1ed2c74b01ce970cd82e4833a26c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#Termit [![Build Status](https://travis-ci.org/pawurb/termit.png)](https://travis-ci.org/pawurb/termit) [![Gem Version](https://badge.fury.io/rb/termit.png)](http://badge.fury.io/rb/termit) [![Coverage Status](https://coveralls.io/repos/pawurb/termit/badge.png)](https://coveralls.io/r/pawurb/termit)
|
2
2
|
|
3
3
|
|
4
|
-
Termit is an easy way to use Google Translate in your terminal.
|
4
|
+
Termit is an easy way to use Google Translate in your terminal. You can check out its node.js npm version [normit](https://github.com/pawurb/normit)
|
5
|
+
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
```ruby
|
@@ -52,6 +53,14 @@ termit es en muchacho -s
|
|
52
53
|
=> Synonyms: boy, lad, youngster, laddie, cully
|
53
54
|
```
|
54
55
|
|
56
|
+
#### Learning language when committing to git (zsh only)
|
57
|
+
Idea by [Nedomas](https://news.ycombinator.com/item?id=7545747) . See and hear your messages translated to target lang every time you commit:
|
58
|
+
|
59
|
+
In **~/.zshrc**
|
60
|
+
```bash
|
61
|
+
export LANG=es
|
62
|
+
git(){[[ "$@" = commit\ -m* ]]&&termit en $LANG ${${@:$#}//./} -t;command git $@}
|
63
|
+
```
|
55
64
|
|
56
65
|
|
57
66
|
## Language codes:
|
@@ -80,11 +89,6 @@ For MacOSX:
|
|
80
89
|
|
81
90
|
brew install mpg123
|
82
91
|
|
83
|
-
## Status
|
84
|
-
|
85
|
-
This is my first open-source project for people to use. Any feedback will be appreciated.
|
86
|
-
|
87
|
-
You can contact me on: p.urbanek89@gmail.com
|
88
92
|
|
89
93
|
|
90
94
|
|
data/lib/termit/data_fetcher.rb
CHANGED
@@ -4,6 +4,10 @@ require 'uri'
|
|
4
4
|
|
5
5
|
module Termit
|
6
6
|
class DataFetcher
|
7
|
+
extend ::Delegation
|
8
|
+
@output_manager = Termit::OutputManager.new
|
9
|
+
delegate :display_no_internet_msg, to: @output_manager
|
10
|
+
|
7
11
|
def initialize url, text
|
8
12
|
@url = url
|
9
13
|
@text = text
|
@@ -21,6 +25,8 @@ module Termit
|
|
21
25
|
request = Net::HTTP::Post.new(uri.request_uri)
|
22
26
|
request.set_form_data(text: @text)
|
23
27
|
http.request(request)
|
28
|
+
rescue SocketError
|
29
|
+
display_no_internet_msg
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -7,7 +7,7 @@ module Termit
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def display_player_error_and_quit
|
10
|
-
message = "
|
10
|
+
message = "TERMIT: speech synthesis requires mpg123 installed."
|
11
11
|
case Gem::Platform.local.os
|
12
12
|
when "darwin"
|
13
13
|
message << "\nPlease run 'brew install mpg123'"
|
@@ -51,5 +51,10 @@ EOS
|
|
51
51
|
print '=> Synonyms: '
|
52
52
|
puts synonyms
|
53
53
|
end
|
54
|
+
|
55
|
+
def display_no_internet_msg
|
56
|
+
puts "TERMIT: There seems to be a problem with your internet connection"
|
57
|
+
exit
|
58
|
+
end
|
54
59
|
end
|
55
60
|
end
|
data/lib/termit/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class DummyDelegate
|
4
|
+
def hello
|
5
|
+
'Hello there'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class DummyDelegator
|
10
|
+
extend ::Delegation
|
11
|
+
@delegate = ::DummyDelegate.new
|
12
|
+
|
13
|
+
delegate :hello, to: @delegate
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
describe "Delegation module" do
|
18
|
+
describe "functionality" do
|
19
|
+
subject do
|
20
|
+
DummyDelegator.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "enables delegating to target objects" do
|
24
|
+
expect(subject.hello).to eq 'Hello there'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "still raises error if method is not defined" do
|
28
|
+
expect { subject.goodbye }.to raise_error(NoMethodError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -10,6 +10,7 @@ describe Termit::TextTranslator do
|
|
10
10
|
expect(translator.text).to eq 'hey cowboy gdzie jest twój koń'
|
11
11
|
end
|
12
12
|
end
|
13
|
+
end
|
13
14
|
|
14
15
|
describe "translated_text" do
|
15
16
|
it "translates text correctly" do
|
@@ -20,6 +21,4 @@ describe Termit::TextTranslator do
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
|
-
end
|
25
24
|
end
|
metadata
CHANGED
@@ -1,101 +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.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-24 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
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: nyan-cat-formatter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description:
|
98
|
-
from your terminal.
|
97
|
+
description: ' Termit is an easy way to use all the Google Translate goodies straight
|
98
|
+
from your terminal. '
|
99
99
|
email:
|
100
100
|
- p.urbanek89@gmail.com
|
101
101
|
executables:
|
@@ -103,9 +103,9 @@ executables:
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
106
|
+
- .gitignore
|
107
|
+
- .rspec
|
108
|
+
- .travis.yml
|
109
109
|
- Gemfile
|
110
110
|
- LICENSE.txt
|
111
111
|
- README.md
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- spec/spec_helper.rb
|
131
131
|
- spec/termit/data_fetcher_spec.rb
|
132
132
|
- spec/termit/main_spec.rb
|
133
|
+
- spec/termit/modules/delegation_spec.rb
|
133
134
|
- spec/termit/output_manager_spec.rb
|
134
135
|
- spec/termit/sound_response_handler_spec.rb
|
135
136
|
- spec/termit/speech_synthesizer_spec.rb
|
@@ -148,12 +149,12 @@ require_paths:
|
|
148
149
|
- lib
|
149
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
150
151
|
requirements:
|
151
|
-
- -
|
152
|
+
- - '>='
|
152
153
|
- !ruby/object:Gem::Version
|
153
154
|
version: '0'
|
154
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
156
|
requirements:
|
156
|
-
- -
|
157
|
+
- - '>='
|
157
158
|
- !ruby/object:Gem::Version
|
158
159
|
version: '0'
|
159
160
|
requirements: []
|
@@ -170,6 +171,7 @@ test_files:
|
|
170
171
|
- spec/spec_helper.rb
|
171
172
|
- spec/termit/data_fetcher_spec.rb
|
172
173
|
- spec/termit/main_spec.rb
|
174
|
+
- spec/termit/modules/delegation_spec.rb
|
173
175
|
- spec/termit/output_manager_spec.rb
|
174
176
|
- spec/termit/sound_response_handler_spec.rb
|
175
177
|
- spec/termit/speech_synthesizer_spec.rb
|