uk_translator 0.1.5

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a3a7cf0d7fba60d0ad67766ec5c9f8a4b226d3d
4
+ data.tar.gz: e875b09cfbb9beff5523f9bbaaab4f2275490404
5
+ SHA512:
6
+ metadata.gz: 1acede3bd588c8876608a698099f4a118e7595e3d40cd384b4273728d2df2e70d92a3b803fe6eaae166eaa04e24871337eb9825060163cbb6fe750eb6d117bcb
7
+ data.tar.gz: d92abe15c638de7b370308e7da3a2c95f94b28adee9397a021cd4e71eb8a99f80ea9f8d5f5b273b221eb5b6ba8234b52515660cf7a9282681824732799aa21b8
@@ -0,0 +1,31 @@
1
+
2
+ require 'yaml'
3
+
4
+ module UkTranslator
5
+
6
+ def self.data
7
+ @@data ||= YAML.load_file(File.join(File.dirname(__FILE__), '..', 'share',
8
+ 'uk_to_us.yml'))
9
+ end
10
+
11
+ def self.us_to_uk(us_string)
12
+ uk_string = us_string
13
+ self.data.each do |us_word, uk_word|
14
+ uk_string.gsub!(/#{'\b'+us_word+'\b'}/, uk_word)
15
+ uk_string.gsub!(/#{'\b'+us_word.capitalize+'\b'}/, uk_word.capitalize)
16
+ uk_string.gsub!(/#{'\b'+us_word.upcase+'\b'}/, uk_word.upcase)
17
+ end
18
+ uk_string
19
+ end
20
+
21
+ def self.uk_to_us(uk_string)
22
+ us_string = uk_string
23
+ self.data.each do |us_word, uk_word|
24
+ us_string.gsub!(/#{'\b'+uk_word+'\b'}/, us_word)
25
+ us_string.gsub!(/#{'\b'+uk_word.capitalize+'\b'}/, us_word.capitalize)
26
+ us_string.gsub!(/#{'\b'+uk_word.upcase+'\b'}/, us_word.upcase)
27
+ end
28
+ us_string
29
+ end
30
+
31
+ end
@@ -0,0 +1,14 @@
1
+ require 'test/unit'
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'uk_translator')
3
+
4
+ class TestUkTranslator < Test::Unit::TestCase
5
+ def test_us_to_uk
6
+ assert_equal "Prioritise colour CUSTOMISATIONS",
7
+ UkTranslator.us_to_uk("Prioritize color CUSTOMIZATIONS")
8
+ end
9
+
10
+ def test_uk_to_us
11
+ assert_equal "Prioritize color CUSTOMIZATIONS",
12
+ UkTranslator.uk_to_us("Prioritise colour CUSTOMISATIONS")
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uk_translator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Andy Parkinson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Translate strings in US english to UK spelling using a dictionary of
14
+ almost 1800 words.
15
+ email: andy.g.parkinson@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/uk_translator.rb
21
+ - test/test_uk_translator.rb
22
+ homepage: https://github.com/envisialearning/uk_translator
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Translate strings in US english to UK spelling.
46
+ test_files:
47
+ - test/test_uk_translator.rb