rails-pseudoloc 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6410c20d06c8f43c3ace177e8f3a9288fa8696bc
4
+ data.tar.gz: 9292ddcbf6b7ef8113694eb6505643de6b990068
5
+ SHA512:
6
+ metadata.gz: c21750da7aac874fafa401bbd2ac24aaa76af922661047e90993ed2c8c5109683f4871d9c5286ea51c9fe88d3e2bd5fd23d6d0ae7b0d3353cf0a874ce8d8feed
7
+ data.tar.gz: 74ef3f3503c42513d83b2bd75fd3178e53bf243372b96485a4025dbd4775f3858a521c67fa5967ab07e9ae601e28a7533df10695ca5f3e46db25794b3cee200b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format Fuubar
2
+ --color
3
+ -r spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ Encoding:
6
+ Enabled: false
7
+
8
+ LineLength:
9
+ Enabled: true
10
+ Max: 100
11
+
12
+ SignalException:
13
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'rubocop', git: 'git://github.com/bbatsov/rubocop.git'
5
+ end
6
+
7
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ guard :rubocop do
6
+ watch(%r{.+\.rb$})
7
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
8
+ end
9
+
10
+ guard :rspec do
11
+ watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Lee Dohm, Lifted Studios
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Rails::Pseudoloc
2
+
3
+ Provides automated pseudolocalization to Ruby on Rails applications.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rails-pseudoloc'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install rails-pseudoloc
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ require 'bundler/gem_tasks'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ require 'rails/pseudoloc/backend'
6
+ require 'rails/pseudoloc/codec'
7
+ require 'rails/pseudoloc/version'
@@ -0,0 +1,27 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ require 'delegate'
6
+
7
+ module Rails
8
+ module Pseudoloc
9
+ # An I18n::Backend that pseudolocalizes all translations requested of it and delegates to
10
+ # another backend for the actual translations and localizations.
11
+ class Backend < SimpleDelegator
12
+ # Creates a pseudolocalized backend that gets all its translations from `backend`.
13
+ def initialize(backend)
14
+ super(backend)
15
+
16
+ @codec = Codec.new
17
+ end
18
+
19
+ # Pseudolocalizes the translation returned from the actual backend.
20
+ def translate(locale, key, options = {})
21
+ value = __getobj__.translate(locale, key, options)
22
+
23
+ value.is_a?(String) ? @codec.encode(value) : value
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,66 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ module Rails
6
+ module Pseudoloc
7
+ # Encodes and decodes strings from the pseudolocalized character set.
8
+ class Codec
9
+ # rubocop:disable MethodLength
10
+
11
+ # @return Default pseudolocalization table.
12
+ def self.default_table
13
+ {
14
+ 'a' => 'àáâãäåāăąǻάαад',
15
+ 'b' => 'þьБъ',
16
+ 'c' => '¢çćĉċčсς',
17
+ 'd' => 'ďđ',
18
+ 'e' => 'èéêëēĕėęěέεеёє℮',
19
+ 'f' => 'ƒ',
20
+ 'g' => 'ĝğġģ',
21
+ 'h' => 'ĥħћђ',
22
+ 'i' => 'ìíîïĩīĭįίιϊіїΐ',
23
+ 'j' => 'ĵј',
24
+ 'k' => 'ķ',
25
+ 'l' => 'ĺļľŀłℓ',
26
+ 'm' => 'm',
27
+ 'n' => 'ήηńņňʼnŋñ',
28
+ 'o' => 'òóôõöøōŏőοσόо',
29
+ 'p' => 'þρр',
30
+ 'r' => 'ŕŗřѓґгř',
31
+ 's' => 'śŝşѕš',
32
+ 't' => 'ţť',
33
+ 'u' => 'µùúûüũūŭůűųΰυϋύ',
34
+ 'w' => 'ŵωώẁẃẅ',
35
+ 'x' => 'хж',
36
+ 'y' => 'ýÿŷўỳу',
37
+ 'z' => 'źżž'
38
+ }
39
+ end
40
+
41
+ # rubocop:enable MethodLength
42
+
43
+ # Constructs a codec for the given translation table.
44
+ #
45
+ # @param [Hash] table Mappings from input characters to arrays of possible output characters.
46
+ def initialize(table = Codec.default_table)
47
+ @table = table
48
+ end
49
+
50
+ # Encodes the given text using the translation table.
51
+ #
52
+ # @param [String] text Text to encode.
53
+ # @return [String] Encoded text.
54
+ def encode(text)
55
+ output = ''
56
+
57
+ text.each_char.each_with_index do |char, i|
58
+ alts = @table.fetch(char, [char])
59
+ output << alts[i % alts.length]
60
+ end
61
+
62
+ output
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,11 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ module Rails
6
+ # Provides automated pseudolocalization capabilites to Ruby on Rails applications.
7
+ module Pseudoloc
8
+ # Version number of the gem.
9
+ VERSION = '0.0.2'
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails/pseudoloc/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rails-pseudoloc'
8
+ spec.version = Rails::Pseudoloc::VERSION
9
+ spec.authors = ['Lee Dohm']
10
+ spec.email = ['lee@liftedstudios.com']
11
+ spec.description = %q{Provides automated pseudolocalization capabilities to Ruby on Rails applications.}
12
+ spec.summary = %q{Provides automated pseudolocalization capabilities to Rails applications.}
13
+ spec.homepage = 'https://github.com/lee-dohm/rails-pseudoloc'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'fuubar'
22
+ spec.add_development_dependency 'guard'
23
+ spec.add_development_dependency 'guard-rspec'
24
+ spec.add_development_dependency 'guard-rubocop'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'redcarpet'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'yard'
29
+ end
@@ -0,0 +1,10 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ describe Rails::Pseudoloc::Backend do
6
+ subject { Rails::Pseudoloc::Backend.new(backend_mock) }
7
+ let(:backend_mock) { double('backend') }
8
+
9
+ it { should respond_to(:translate) }
10
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ include Rails::Pseudoloc
6
+
7
+ describe Codec do
8
+ describe 'when supplied a definitions table' do
9
+ it 'translates a single character into the first character in the output array' do
10
+ codec = Codec.new('a' => 'zyxw'.chars)
11
+
12
+ expect(codec.encode('a')).to eq('z')
13
+ end
14
+
15
+ it 'translates multiple characters into each successive character in the output array' do
16
+ codec = Codec.new('a' => 'zyxw'.chars)
17
+
18
+ expect(codec.encode('aaaa')).to eq('zyxw')
19
+ end
20
+
21
+ it 'translates all given characters according to their mappings' do
22
+ codec = Codec.new('a' => 'zyxw', 'b' => 'yxwv', 'c' => 'xwvu')
23
+
24
+ expect(codec.encode('abc')).to eq('zxv')
25
+ end
26
+
27
+ it 'has a default mapping table' do
28
+ codec = Codec.new
29
+
30
+ expect(codec.encode('abc')).to eq('àьć')
31
+ end
32
+
33
+ it 'passes through characters it does not have a mapping for' do
34
+ codec = Codec.new('z' => 'abcdefg')
35
+
36
+ expect(codec.encode('abc')).to eq('abc')
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ #
2
+ # Copyright (c) 2013 by Lifted Studios. All Rights Reserved.
3
+ #
4
+
5
+ require 'spec_helper'
6
+
7
+ describe Rails::Pseudoloc do
8
+ it 'should have a version number' do
9
+ Rails::Pseudoloc::VERSION.should_not be_nil
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rails/pseudoloc'
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-pseudoloc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Lee Dohm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fuubar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
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
+ - !ruby/object:Gem::Dependency
98
+ name: redcarpet
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Provides automated pseudolocalization capabilities to Ruby on Rails applications.
140
+ email:
141
+ - lee@liftedstudios.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - .gitignore
147
+ - .rspec
148
+ - .rubocop.yml
149
+ - .travis.yml
150
+ - Gemfile
151
+ - Guardfile
152
+ - LICENSE.md
153
+ - README.md
154
+ - Rakefile
155
+ - lib/rails/pseudoloc.rb
156
+ - lib/rails/pseudoloc/backend.rb
157
+ - lib/rails/pseudoloc/codec.rb
158
+ - lib/rails/pseudoloc/version.rb
159
+ - rails-pseudoloc.gemspec
160
+ - spec/rails/pseudoloc/backend_spec.rb
161
+ - spec/rails/pseudoloc/codec_spec.rb
162
+ - spec/rails/pseudoloc_spec.rb
163
+ - spec/spec_helper.rb
164
+ homepage: https://github.com/lee-dohm/rails-pseudoloc
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.0.3
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Provides automated pseudolocalization capabilities to Rails applications.
188
+ test_files:
189
+ - spec/rails/pseudoloc/backend_spec.rb
190
+ - spec/rails/pseudoloc/codec_spec.rb
191
+ - spec/rails/pseudoloc_spec.rb
192
+ - spec/spec_helper.rb
193
+ has_rdoc: