ttyhue 0.1.0 → 0.1.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: cb7345390820acfae134f75dc1981a94237f2f928923e69b811b054beefbdeca
4
- data.tar.gz: e538fbdd297be620d19b00734fa45e32997d6a41908536135b040e1816ab2abe
3
+ metadata.gz: a87fe9928772a8b47f04fd044edf1ffd9ddc412c6d844480dc195b3d4b8c9840
4
+ data.tar.gz: 3d697a8759a4028b70136d25bd76d9f84821a20287e97d4201dc78a33cc59802
5
5
  SHA512:
6
- metadata.gz: 172e42263db78b3eaa8ed2560a2f175868d3ef15022f95de19912302398086cd21cc62d3bb305cdfbfbfa2846d3111d62887cfaee88125c41f4bba533fcf180c
7
- data.tar.gz: a7cf357df077c92732886b0909e7741283688592c9830c6ecb3f0331ec18d03eb11a1e6343edd779ffaa4eeea9f585dc4d7dbf050888fcd3eb773d973434db29
6
+ metadata.gz: 2df7735cadaa236596343b9efc7e0cc23d8b1f39a69766ef5badf3ddbdad8f15e72511964883c310c1c9506455d6b7961e9d6a69f3a8b25bf37d86a77f89a373
7
+ data.tar.gz: 5524e9b1ef604e7d610e909e42e952e0d077a252ac881a7dd22386998b12d4687c7393ecb841cd29f7649794c8fab7c657d084c1323482b4689b817b89a85f95
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2022-10-05
4
+
5
+ - Enable passing styles directly to TTYHue.c method
6
+
7
+ ## [0.1.1] - 2022-10-05
8
+
9
+ - Fixed parser bug, where row of color tags as well as unclosed tags were not handled gracefully
10
+
3
11
  ## [0.1.0] - 2022-10-04
4
12
 
5
13
  - Initial release
@@ -3,8 +3,8 @@ module TTYHue
3
3
 
4
4
  class << self
5
5
 
6
- def colorize(str)
7
- Parser.new(str).parse.map do |parsed_section|
6
+ def colorize(str, styles)
7
+ Parser.new(str, styles).parse.map do |parsed_section|
8
8
  colorized_section(parsed_section)
9
9
  end.join
10
10
  end
@@ -6,8 +6,6 @@ module TTYHue
6
6
  /{(?<closing>\/?)(?<bg>b?)(?<name>#{TermColor.defs.map(&:tag_name).join("|")})}/
7
7
  end
8
8
 
9
- attr_reader :color_name, :bg
10
-
11
9
  def bg
12
10
  @match_data[:bg] != ""
13
11
  end
data/lib/ttyhue/parser.rb CHANGED
@@ -7,7 +7,8 @@ module TTYHue
7
7
 
8
8
  TOKENS = {
9
9
  tag: /{[^{}]+}/,
10
- content: /[^{]+/
10
+ content: /[^{]+/,
11
+ unclosed_tag: /{[^{]*/
11
12
  }
12
13
 
13
14
  class ParseError < StandardError; end
@@ -23,7 +24,10 @@ module TTYHue
23
24
  scanner = StringScanner.new(@string)
24
25
  until scanner.eos?
25
26
  next if handle_content!(scanner.scan(TOKENS[:content]))
26
- next if handle_tag!(scanner.scan(TOKENS[:tag]))
27
+ while str = scanner.scan(TOKENS[:tag])
28
+ handle_tag!(str)
29
+ end
30
+ next if handle_content!(scanner.scan(TOKENS[:unclosed_tag]))
27
31
  end
28
32
  flattened_result
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module TTYHue
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/ttyhue.rb CHANGED
@@ -17,8 +17,8 @@ module TTYHue
17
17
  @@styles = hash.to_h
18
18
  end
19
19
 
20
- def self.c(str)
21
- TTYHue::Colorizer.colorize(str)
20
+ def self.c(str, styles = {})
21
+ TTYHue::Colorizer.colorize(str, styles)
22
22
  end
23
23
 
24
24
  def self.preview_termcolors
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttyhue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Sito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-04 00:00:00.000000000 Z
11
+ date: 2022-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest