rtl 0.1.0

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: df2a044c0ebc80f6ff0b8763d52827e529567aef
4
+ data.tar.gz: 0958f273ac491d0875fe34af4977ee6656ed7823
5
+ SHA512:
6
+ metadata.gz: 3c6c90a696f41b2c58ef2e30ad749237a90a5aeb10bc0aec31ecd3e23ae39259ebd3738aa842eb6702d620ca8ea30ae8e9a2b2385d14a83e353b062de392b4df
7
+ data.tar.gz: fc173904a30a2c44d6490d37ad58b4501613da920736ace9dae69a12b03719f5dc0c6299d1fbc0f1570953ff020f7bcf42a42f13072c1d7952931c43383e6a99
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /.idea
12
+ /.idea/*
13
+
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.0
5
+ cache: bundler
6
+ before_install: gem install bundler -v 1.13.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rtl.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 abarrak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Rtl
2
+ This gem helps you in checking whether a language is written from right-to-left (RTL) or vise versa.
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'rtl'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ ```sh
15
+ $ bundle
16
+ ```
17
+
18
+ Or install it yourself as:
19
+
20
+ ```sh
21
+ $ gem install rtl
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ...
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are very much appreciated at [Github](https://github.com/abarrak/rtl).
31
+
32
+
33
+ ## License
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
35
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/lib/rtl.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "rtl/core"
2
+ require "rtl/version"
data/lib/rtl/core.rb ADDED
@@ -0,0 +1,99 @@
1
+ module Rtl
2
+ # Formal full names for RTL languages.
3
+ FULL_NAMES = ["Adlam", "Arabic", "Arabic (Nastaliq variant)", "Imperial Aramaic", "Avestan",
4
+ "Cypriot", "Egyptian demotic", "Egyptian hieratic", "Hatran", "Hebrew",
5
+ "Old Hungarian (Hungarian Runic)", "Indus (Harappan)", "Kharoshthi", "Lydian",
6
+ "Mandaic, Mandaean", "Manichaean", "Mende Kikakui", "Meroitic Cursive",
7
+ "Meroitic Hieroglyphs", "Old North Arabian (Ancient North Arabian)",
8
+ "Nabataean", "N’Ko", "Old Turkic, Orkhon Runic", "Palmyrene",
9
+ "Inscriptional Pahlavi", "Psalter Pahlavi", "Book Pahlavi", "Phoenician",
10
+ "Inscriptional Parthian", "Samaritan", "Old South Arabian", "Syriac",
11
+ "Syriac (Estrangelo variant)", "Syriac (Western variant)",
12
+ "Syriac (Eastern variant)", "Thaana", "Woleai"]
13
+
14
+ # ISO 639 codes for RTL languages.
15
+ # If a language has 639-1 and 639-2 codes, both are included.
16
+ ISO_CODES = ["ar", "ara", "arc", "ae", "ave", "egy", "he", "heb", "nqo", "pal", "phn", "sam",
17
+ "syc", "syr"]
18
+
19
+ # ISO 15924 codes for RTL languages.
20
+ ISO_LONG_CODES = ['Adlm', 'Arab', 'Aran', 'Armi', 'Avst', 'Cprt', 'Egyd', 'Egyh', 'Hatr',
21
+ 'Hebr', 'Hung', 'Inds', 'Khar', 'Lydi', 'Mand', 'Mani', 'Mend', 'Merc',
22
+ 'Mero', 'Narb', 'Nbat', 'Nkoo', 'Orkh', 'Palm', 'Phli', 'Phlp', 'Phlv',
23
+ 'Phnx', 'Prti', 'Samr', 'Sarb', 'Syrc', 'Syre', 'Syrj', 'Syrn', 'Thaa',
24
+ 'Wole']
25
+
26
+ # ISO 15924 numbers for RTL languages.
27
+ ISO_NUMBERS = ['166', '160', '161', '124', '134', '403', '070', '060', '127', '125', '176',
28
+ '610', '305', '116', '140', '139', '438', '101', '100', '106', '159', '165',
29
+ '175', '126', '131', '132', '133', '115', '130', '123', '105', '135', '138',
30
+ '137', '136', '170', '480']
31
+
32
+ # Unicode alias names for RTL languages.
33
+ # Not all ISO languages has this alias.
34
+ UNICODE_ALIASES = ["Adlam", "Arabic", "Imperial Aramaic", "Avestan", "Cypriot",
35
+ "Hatran", "Hebrew", "Old Hungarian", "Kharoshthi", "Lydian", "Mandaic",
36
+ "Manichaean", "Mende Kikakui", "Meroitic Cursive", "Meroitic Hieroglyphs",
37
+ "Old North Arabian", "Nabataean", "NKo", "Old Turkic", "Palmyrene",
38
+ "Inscriptional Pahlavi", "Psalter Pahlavi", "Phoenician",
39
+ "Inscriptional Parthian", "Samaritan", "Old South Arabian", "Syriac",
40
+ "Thaana"]
41
+
42
+ # Query whether a language is rtl or not.
43
+ def self.rtl? language, scheme = :iso_code
44
+ sch = scheme.to_sym
45
+ l = language.to_s.strip
46
+
47
+ case sch
48
+ when :iso_code
49
+ self.iso_codes l
50
+ when :iso_long_code
51
+ self.iso_long_codes l
52
+ when :iso_number
53
+ self.iso_numbers l
54
+ when :unicode_alias
55
+ self.unicode_aliases l
56
+ when :full_name
57
+ self.full_names l
58
+ when :all
59
+ all l
60
+ else
61
+ raise ArgumentError.new "Unknown base value #{base}."
62
+ end
63
+ end
64
+
65
+ # Get a list of languages by scheme
66
+ def self.rtl_languages scheme = :iso_code
67
+ sch = scheme.to_s
68
+ s = sch.end_with?('s') ? 'ES' : 'S'
69
+ member = "#{sch.to_s.upcase}#{s}".to_sym
70
+ self.const_get member
71
+ end
72
+
73
+ private
74
+
75
+ def self.iso_codes lang
76
+ ISO_CODES.include? lang.downcase
77
+ end
78
+
79
+ def self.iso_long_codes lang
80
+ ISO_LONG_CODES.include? lang.capitalize
81
+ end
82
+
83
+ def self.iso_numbers lang
84
+ ISO_NUMBERS.include? lang
85
+ end
86
+
87
+ def self.full_names lang
88
+ FULL_NAMES.map(&:capitalize).include? lang.capitalize
89
+ end
90
+
91
+ def self.unicode_aliases lang
92
+ UNICODE_ALIASES.map(&:downcase).include? lang.downcase
93
+ end
94
+
95
+ def self.all lang
96
+ iso_codes(lang) || iso_long_codes(lang) || iso_numbers(lang) ||
97
+ full_names(lang) || unicode_aliases(lang)
98
+ end
99
+ end
@@ -0,0 +1,3 @@
1
+ module Rtl
2
+ VERSION = "0.1.0"
3
+ end
data/rtl.gemspec ADDED
@@ -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 'rtl/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rtl"
8
+ spec.version = Rtl::VERSION
9
+ spec.date = '2016-10-01'
10
+ spec.authors = ["Abdullah Barrak (abarrak)"]
11
+ spec.email = ["a@abarrak.com"]
12
+
13
+ spec.summary = "A gem for checking RTL direction of languages."
14
+ spec.description = "RTL helps you to check whether a language direction is right-to-left (RTL)
15
+ or left-to-right (LTR) implicitly, by supplying its full name, iso code,
16
+ or others options."
17
+ spec.homepage = "https://github.com/abarrak/rtl"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.13"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "minitest", "~> 5.0"
29
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Abdullah Barrak (abarrak)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-01 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: |-
56
+ RTL helps you to check whether a language direction is right-to-left (RTL)
57
+ or left-to-right (LTR) implicitly, by supplying its full name, iso code,
58
+ or others options.
59
+ email:
60
+ - a@abarrak.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".gitignore"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - lib/rtl.rb
72
+ - lib/rtl/core.rb
73
+ - lib/rtl/version.rb
74
+ - rtl.gemspec
75
+ homepage: https://github.com/abarrak/rtl
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.8
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: A gem for checking RTL direction of languages.
99
+ test_files: []