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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/keyboard_convertor.rb +14 -12
  3. metadata +8 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 445fdc63bbdac9cb32fab739a500a74c4d21a893
4
- data.tar.gz: 7eff1cba72ca7074ef6a027cda3461fc47c8de53
3
+ metadata.gz: 9e3bfc02f5b0ad9f612d680cdb3eecdcb6818d57
4
+ data.tar.gz: 289b3a3ed468f8a08b635c3d44aaa95fb7deb060
5
5
  SHA512:
6
- metadata.gz: d7d7ccee7768e340440ccb286fa3a7bd7508bc5b44aca1645d0172c387f055b5bf4f393935d4a3335791e6a3284073c55365a23f71f201ce61759d0a58a52ae3
7
- data.tar.gz: b2868f72168c8ab9ce2bfeebc275cc4af52f1e43f5d92a11313632f9c4f017efc1a505e1fafd6de07594d933a93b2bb88c68d7210e314c220797730ebeda12d5
6
+ metadata.gz: 25b10d42824afa630a27e0d4f8336a440a57cd06d07ff760ff5d4953df3afe4244b33d6de0a66b9b36369969efdc2587c2ce5356a462c72c60c20256a6236138
7
+ data.tar.gz: b932765cc60f3981e7ddd879c6b56e8f2a68389f675e0b401f9463cec7fe87c93ae2f51341e4a506543c7b6197c5e872c13b9b5892f5fb71a8e7279213da0b1b
@@ -1,21 +1,23 @@
1
1
  # coding: utf-8
2
2
  class String
3
3
 
4
- RU_EN = { 'q' => 'й', 'w' => 'ц', 'e' => 'у', 'r' => 'к', 't' => 'е', 'y' => 'н', 'u' => 'г', 'i' => 'ш', 'o' => 'щ', 'p' => 'з', '[' => 'х', ']' => 'ъ', 'a' => 'ф', 's' => 'ы', 'd' => 'в', 'f' => 'а', 'g' => 'п', 'h' => 'р', 'j' => 'о', 'k' => 'л', 'l' => 'д', ';' => 'ж', '\'' => 'э', '\\' => 'ё', 'z' => 'я', 'x' => 'ч', 'c' => 'с', 'v' => 'м', 'b' => 'и', 'n' => 'т', 'm' => 'ь', ',' => 'б', '.' => 'ю', 'Q' => 'Й', 'W' => 'Ц', 'E' => 'У', 'R' => 'К', 'T' => 'Е', 'Y' => 'Н', 'I' => 'Ш', 'O' => 'Щ', 'P' => 'З', '{' => 'Х', '}' => 'Ъ', 'A' => 'Ф', 'S' => 'Ы', 'D' => 'В', 'F' => 'А', 'G' => 'П', 'H' => 'Р', 'J' => 'О', 'K' => 'Л', 'L' => 'Д', ':' => 'Ж', '"' => 'Э', '|' => 'Ё', 'Z' => 'Я', 'X' => 'Ч', 'C' => 'С', 'V' => 'М', 'B' => 'И', 'N' => 'Т', 'M' => 'Ь', '<' => 'Б', '>' => 'Ю' }
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
- data = self.data(options)
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| data[char].nil? ? char : data[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
- end
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.1.1
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: 2013-05-30 00:00:00.000000000 Z
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.0.3
41
+ rubygems_version: 2.2.2
40
42
  signing_key:
41
43
  specification_version: 4
42
44
  summary: KeyboardConvertor