rtl_that_string 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/lib/rtl_that_string/rtl_that_string.rb +7 -3
- data/lib/rtl_that_string/version.rb +1 -1
- data/rtl_that_string.gemspec +2 -8
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0432dad5681cc92edf64cc49eeb328115d4a66f7
|
4
|
+
data.tar.gz: cc759e882e9e2f2e680b860a0043847bc30c1058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb9a9515d892822ebb53fe3ac595b2ab3c2da74a33f34af86f0c0946e98c91570042d463813647c0b9a99ee2c333d73701ba549401888cb0a10b11695baf4c3
|
7
|
+
data.tar.gz: 541b2f7504f5fb4413e28d135d9efca3cdca27b3376b28f7c57414d0e18136685cc608336a7a3b30d287351cd91200944e011482e4c30b4684756bc73785486e
|
data/Gemfile
CHANGED
@@ -1,6 +1,3 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in rtl_that_string.gemspec
|
4
3
|
gemspec
|
5
|
-
|
6
|
-
gem 'string-direction', '~> 0.0.4', :git => 'git@github.com:craig-day/string-direction.git', :branch => 'craig-day/cleanup' # https://github.com/waiting-for-dev/string-direction/pull/1
|
@@ -17,6 +17,10 @@ module RtlThatString
|
|
17
17
|
|
18
18
|
STRIP_TAGS_REGEX = /<.*?>/.freeze # Strip any html tag, with or without attributes
|
19
19
|
|
20
|
+
def self.included(base)
|
21
|
+
@@direction_detector ||= StringDirection::Detector.new
|
22
|
+
end
|
23
|
+
|
20
24
|
# Wrap plain text or html in direction control unicode characters or tags
|
21
25
|
#
|
22
26
|
# If the string is detected as all RTL characters it will be bordered with
|
@@ -28,7 +32,7 @@ module RtlThatString
|
|
28
32
|
def with_rtl(options = {})
|
29
33
|
return with_rtl_html(options) if options.delete(:html)
|
30
34
|
|
31
|
-
case direction
|
35
|
+
case @@direction_detector.direction(self)
|
32
36
|
when StringDirection::RTL
|
33
37
|
rtl_string_borders
|
34
38
|
when StringDirection::BIDI
|
@@ -48,7 +52,7 @@ module RtlThatString
|
|
48
52
|
def with_rtl_html(options = {})
|
49
53
|
plain_text = self.gsub(STRIP_TAGS_REGEX, '')
|
50
54
|
|
51
|
-
case
|
55
|
+
case @@direction_detector.direction(plain_text)
|
52
56
|
when StringDirection::RTL
|
53
57
|
rtl_html_borders
|
54
58
|
when StringDirection::BIDI
|
@@ -62,7 +66,7 @@ module RtlThatString
|
|
62
66
|
|
63
67
|
def majority_rtl?
|
64
68
|
dir_counts = split(' ').each_with_object({}) do |token, h|
|
65
|
-
dir =
|
69
|
+
dir = @@direction_detector.direction(token)
|
66
70
|
h[dir] ||= 1
|
67
71
|
h[dir] += 1
|
68
72
|
end
|
data/rtl_that_string.gemspec
CHANGED
@@ -14,19 +14,13 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/craig-day/"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
-
# delete this section to allow pushing this gem to any host.
|
19
|
-
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
# else
|
22
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
-
# end
|
24
|
-
|
25
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
18
|
spec.bindir = "exe"
|
27
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
20
|
spec.require_paths = ["lib"]
|
29
21
|
|
22
|
+
spec.add_dependency "string-direction", "~> 1.0"
|
23
|
+
|
30
24
|
spec.add_development_dependency "bundler", "~> 1.10"
|
31
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
26
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtl_that_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Day
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: string-direction
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|