lightgraf 0.1.1.pre.beta.1 → 0.1.1.pre.beta.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 887b14c815b3b0891625506fd0c8a24853b93fb713f7446159f177d539ff182d
4
- data.tar.gz: e2212a9792924b7096ede20918a7299c53dd36b405b5403a5e35bfcf00a3dee6
3
+ metadata.gz: 585033e2ead222922515b406e6ee777684cb4fd44f811001320436f419d3568b
4
+ data.tar.gz: 75256a6bfb720e9c706dbd5282cd7caf04d693da034f5c25adaf952b79da0b90
5
5
  SHA512:
6
- metadata.gz: db9724f20aa5aa288a3dea179066e6f9a31fc84da8af9baa72ebc4bf35609ca8b3f2bd38bd2ae94a85f2eb5cbf8566e6079e8df76e43440eb52c889b88f9f435
7
- data.tar.gz: 5b0a64c0fd10d0a549ab7a5204bf3ac6718bb404ceff95f6918d0c6509676520ed6053a50bc7c1daafa513c7d2ea0d33b5e6f7e2d3dc0cc59bf4ab2963c9148f
6
+ metadata.gz: 1e1bd25f17998fbdf42a35ddde5b0725f816a6aa8221051d4220cc1bb06d979232b75b1adc0727ed9a36bd2af1057d372ccdb5c34dbb29e54ef473f357e44788
7
+ data.tar.gz: dbe73735849376e7a50d2a973a9cd2a926a46eb21328f89ce4bd077d2def2b6a8abe673b7a0939731ac4d4d0c8704dd65c40413f103155c031100ee444f0b094
@@ -0,0 +1,38 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ "dev", "master" ]
13
+ pull_request:
14
+ branches: [ "master" ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['2.6']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ # uses: ruby/setup-ruby@v1
33
+ uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
34
+ with:
35
+ ruby-version: ${{ matrix.ruby-version }}
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Run tests
38
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1 +1,2 @@
1
- ## Initial
1
+ ## In this update:
2
+ - Fixing complex whitespace cases
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lightgraf (0.1.1.pre.beta.1)
4
+ lightgraf (0.1.1.pre.beta.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Lightgraf
2
+ [![Gem Version](https://badge.fury.io/rb/lightgraf.svg)](https://badge.fury.io/rb/lightgraf)
2
3
 
3
4
  Lightweight typography tool for Rails. It handles for you:
4
5
  - __Quotes__:
@@ -18,6 +19,14 @@ Lightweight typography tool for Rails. It handles for you:
18
19
  А что я? А я ничего\
19
20
  `↓` \
20
21
  А(NBSP)что я?(NBSP)А(NBSP)я(NBSP)ничего
22
+
23
+ - __No-breakables__:
24
+
25
+ Call me: 232-12-34\
26
+ `↓` \
27
+ Call me: \<nobr\>232-12-34\</nobr\>
28
+
29
+ It is fast and efficient, handling complex text of ~5800 characters at 0.06 sec
21
30
 
22
31
  ## Installation
23
32
 
@@ -37,7 +46,10 @@ Or install it yourself as:
37
46
 
38
47
  ## Usage
39
48
 
40
- TODO: Write usage instructions here
49
+ ```ruby
50
+ require 'lightgraf'
51
+ fixed_text = Lightgraf.fix "My text"
52
+ ```
41
53
 
42
54
  ## Development
43
55
 
@@ -6,7 +6,7 @@ module Lightgraf
6
6
  module Fixtures
7
7
  INCORRECT_QUOTES = %w[' " `].freeze
8
8
  HYPHENS = %w[- – —].freeze
9
- SPACES = [' ', ' ', ' ', ' ', ' '].freeze
9
+ SPACES = [' ', ' ', ' ', ' ', ' ', '​', '‍', '‌', 'ㅤ', ' ', ' ', ' ', '⠀', '⁣', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '⁠'].freeze
10
10
  TAG_L = %(<)
11
11
  TAG_R = %(>)
12
12
  QUOT_RU_A_L = %(«)
@@ -47,6 +47,10 @@ module Lightgraf
47
47
  elsif [QUOT_RU_A_R, QUOT_EN_A_R].include?(char)
48
48
  inside.pop if inside.last == :quote_a
49
49
  elsif SPACES.include?(char)
50
+ if last_space == i - 1
51
+ last_space = i
52
+ next
53
+ end
50
54
  need_next = false
51
55
  if !disable_nbsp and (i < nbsp_max_length or (!last_space.nil? and last_hyphen != i - 1 and (i - last_space) <= nbsp_max_length) or HYPHENS.include?(text[i + 1]))
52
56
  fixed += NBSP
@@ -58,6 +62,8 @@ module Lightgraf
58
62
  end
59
63
  last_space = i
60
64
  next if need_next
65
+ fixed += SPACE
66
+ next
61
67
  elsif HYPHENS.include?(char)
62
68
  need_next = false
63
69
  if !disable_hyphens and (i.zero? or last_space == i - 1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lightgraf
4
- VERSION = '0.1.1-beta.1'
4
+ VERSION = '0.1.1-beta.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightgraf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.pre.beta.1
4
+ version: 0.1.1.pre.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aydar N.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-21 00:00:00.000000000 Z
11
+ date: 2023-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/ruby.yml"
90
91
  - ".gitignore"
91
92
  - ".rubocop.yml"
92
93
  - CHANGELOG.md