keyboard_convertor 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/keyboard_convertor.rb +14 -12
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e3bfc02f5b0ad9f612d680cdb3eecdcb6818d57
|
4
|
+
data.tar.gz: 289b3a3ed468f8a08b635c3d44aaa95fb7deb060
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25b10d42824afa630a27e0d4f8336a440a57cd06d07ff760ff5d4953df3afe4244b33d6de0a66b9b36369969efdc2587c2ce5356a462c72c60c20256a6236138
|
7
|
+
data.tar.gz: b932765cc60f3981e7ddd879c6b56e8f2a68389f675e0b401f9463cec7fe87c93ae2f51341e4a506543c7b6197c5e872c13b9b5892f5fb71a8e7279213da0b1b
|
data/lib/keyboard_convertor.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
class String
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
def data(options)
|
7
|
-
if options && options[:from] && options[:to]
|
8
|
-
String.const_get("#{options[:from]}_#{options[:to]}".upcase)
|
9
|
-
else
|
10
|
-
RU_EN
|
11
|
-
end
|
12
|
-
end
|
4
|
+
RU_LAYOUT = %q/ёЁ"№;:?йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭ\/ЯЧСМИТЬБЮ,/
|
5
|
+
EN_LAYOUT = %q/`~@#$^&qwertyuiop[]asdfghjkl;'zxcvbnm,.\/QWERTYUIOP{}ASDFGHJKL:"|ZXCVBNM<>?/
|
13
6
|
|
14
7
|
def convert_keyboard(options = nil)
|
15
|
-
|
8
|
+
dir = ru_en?(options)
|
9
|
+
|
10
|
+
wrong_chars = dir ? RU_LAYOUT : EN_LAYOUT
|
11
|
+
right_chars = dir ? EN_LAYOUT : RU_LAYOUT
|
16
12
|
|
17
|
-
new_word = self.each_char.map { |char|
|
13
|
+
new_word = self.each_char.map { |char| (i = wrong_chars.index(char)).nil? ? char : right_chars[i] }
|
18
14
|
new_word.join('').force_encoding('UTF-8')
|
19
15
|
end
|
20
16
|
|
21
|
-
|
17
|
+
private
|
18
|
+
|
19
|
+
def ru_en?(options)
|
20
|
+
options && options[:from] == 'ru' && options[:to] == 'en'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keyboard_convertor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maksim Berjoza
|
8
|
+
- Alexey Zhuravlev
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Converting from/to keyboard
|
14
15
|
email: maksim.berjoza@gmail.com
|
@@ -18,7 +19,8 @@ extra_rdoc_files: []
|
|
18
19
|
files:
|
19
20
|
- lib/keyboard_convertor.rb
|
20
21
|
homepage: https://github.com/torbjon/keyboard_convertor
|
21
|
-
licenses:
|
22
|
+
licenses:
|
23
|
+
- MIT
|
22
24
|
metadata: {}
|
23
25
|
post_install_message:
|
24
26
|
rdoc_options: []
|
@@ -26,17 +28,17 @@ require_paths:
|
|
26
28
|
- lib
|
27
29
|
required_ruby_version: !ruby/object:Gem::Requirement
|
28
30
|
requirements:
|
29
|
-
- -
|
31
|
+
- - ">="
|
30
32
|
- !ruby/object:Gem::Version
|
31
33
|
version: '0'
|
32
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
35
|
requirements:
|
34
|
-
- -
|
36
|
+
- - ">="
|
35
37
|
- !ruby/object:Gem::Version
|
36
38
|
version: '0'
|
37
39
|
requirements: []
|
38
40
|
rubyforge_project:
|
39
|
-
rubygems_version: 2.
|
41
|
+
rubygems_version: 2.2.2
|
40
42
|
signing_key:
|
41
43
|
specification_version: 4
|
42
44
|
summary: KeyboardConvertor
|