nvim 1.1.0 → 1.3.0
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 +4 -4
- data/INFO.yaml +1 -1
- data/README.md +4 -1
- data/lib/neovim/info.rb +2 -2
- data/lib/neovim/ruby_provider.rb +11 -51
- data/lib/neovim/tools/calculator.rb +114 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5191debebad5c3b62e615186a5d01bd768a0b1b5779e56a2f52e01f0c421773
|
4
|
+
data.tar.gz: 264e879be038d63211c76b1ad2bcffcf8cb28796212010850b6e733a5ad702f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0696bf812f39ad42982db2cb61242ba325dae1f94405c1ca537058617cac648a2e601215a8c2f02c40e27e238efc28a681a6a19e4abd55b9c11865318e77ecfc'
|
7
|
+
data.tar.gz: 9ead8707a4fc45cf519a92f7ad03bc78acac2a3b2e8a532e3f3a02e06cfe5963d69bb82817cf098f40293ce03f7384a3102d844d1becc1f252067301132b7601
|
data/INFO.yaml
CHANGED
data/README.md
CHANGED
@@ -150,9 +150,12 @@ Further, a simple number/cash summing tool is included.
|
|
150
150
|
```
|
151
151
|
Apples : 3.99
|
152
152
|
Bananas : 5 * 0.40 # multiplication
|
153
|
-
Oranges : 3.59
|
153
|
+
Oranges : 3.59 - 10% # percentage added (here subtracted)
|
154
154
|
Kiwi : 0,40 # comma is allowed
|
155
155
|
Coconut : 5,- # empty decimal places
|
156
|
+
# !dot # dot forced now
|
157
|
+
Tangerines: 4.44
|
158
|
+
# !comma # result with comma
|
156
159
|
~
|
157
160
|
~
|
158
161
|
:%ruby +
|
data/lib/neovim/info.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "neovim/meta.rb"
|
2
2
|
Neovim::INFO = Neovim::Meta.new "nvim",
|
3
|
-
version: "1.
|
3
|
+
version: "1.3.0",
|
4
4
|
license: "BSD-2-Clause+",
|
5
5
|
authors: ["Bertram Scharpf"],
|
6
6
|
email: "software@bertram-scharpf.de",
|
7
7
|
summary: "Yet another Ruby client for Neovim",
|
8
8
|
description: "A simple Ruby client for Neovim.\nClean code, minimal dependecies, no frills, no wokeness.",
|
9
9
|
homepage: "https://github.com/BertramScharpf/ruby-nvim",
|
10
|
-
commit: "
|
10
|
+
commit: "7dc787c"
|
data/lib/neovim/ruby_provider.rb
CHANGED
@@ -117,53 +117,6 @@ module Neovim
|
|
117
117
|
run_dsl DslProvider, &block
|
118
118
|
end
|
119
119
|
|
120
|
-
def build_sum lines
|
121
|
-
require "bigdecimal"
|
122
|
-
sum = BigDecimal 0
|
123
|
-
prev, decs = 0, 0
|
124
|
-
sep = "."
|
125
|
-
lines.each { |l|
|
126
|
-
l.slice! /^.*:/
|
127
|
-
l.slice! /#.*/
|
128
|
-
l = l.split /(?:\+\s+|\|)/
|
129
|
-
l.map! { |m|
|
130
|
-
m.strip!
|
131
|
-
if m =~ %r/ *%\z/ then
|
132
|
-
prev * (BigDecimal $`) / 100
|
133
|
-
else
|
134
|
-
m = m.split "*"
|
135
|
-
m.map! { |n|
|
136
|
-
n.sub! /,/ do sep = $& ; "." end
|
137
|
-
n.sub! /\.(?:-+|([0-9]+))/ do
|
138
|
-
if $1 then
|
139
|
-
d = $1.length
|
140
|
-
decs = d if decs < d
|
141
|
-
".#$1"
|
142
|
-
else
|
143
|
-
decs = 2
|
144
|
-
nil
|
145
|
-
end
|
146
|
-
end
|
147
|
-
BigDecimal n
|
148
|
-
}
|
149
|
-
prev = m.inject do |p,e| p*e end
|
150
|
-
end
|
151
|
-
}
|
152
|
-
sum = l.inject sum do |s,e| s+e end
|
153
|
-
}
|
154
|
-
sum = sum.round decs
|
155
|
-
case sum
|
156
|
-
when BigDecimal then
|
157
|
-
sum = sum.to_s "F"
|
158
|
-
sum.sub! /(?:\.([0-9]+))?\z/ do
|
159
|
-
sep + ($1.to_s.ljust decs, "0")
|
160
|
-
end
|
161
|
-
when Integer then
|
162
|
-
sum = sum.to_s
|
163
|
-
end
|
164
|
-
sum
|
165
|
-
end
|
166
|
-
|
167
120
|
end
|
168
121
|
|
169
122
|
plugin_provider do |dsl|
|
@@ -180,7 +133,7 @@ module Neovim
|
|
180
133
|
r.each do |l|
|
181
134
|
require l
|
182
135
|
rescue LoadError
|
183
|
-
client.
|
136
|
+
client.out_write "Warning: #$!"
|
184
137
|
end
|
185
138
|
end
|
186
139
|
end
|
@@ -226,9 +179,16 @@ module Neovim
|
|
226
179
|
client.command "#{lst}"
|
227
180
|
set_globals client, fst..lst do |lines|
|
228
181
|
WriteBuf.redirect client do
|
229
|
-
|
230
|
-
|
231
|
-
|
182
|
+
require "neovim/tools/calculator"
|
183
|
+
@calc ||= Calculator.new
|
184
|
+
@calc.reset!
|
185
|
+
w = 0
|
186
|
+
lines.each { |l|
|
187
|
+
l.length.tap { |g| w = g if g > w }
|
188
|
+
@calc.add l
|
189
|
+
}
|
190
|
+
puts "-"*w
|
191
|
+
puts @calc.result
|
232
192
|
rescue
|
233
193
|
puts "Error: #$! (#{$!.class})"
|
234
194
|
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
#
|
2
|
+
# neovim/tools/calculator.rb -- Simple calculator
|
3
|
+
#
|
4
|
+
|
5
|
+
require "supplement"
|
6
|
+
require "bigdecimal"
|
7
|
+
|
8
|
+
|
9
|
+
module Neovim
|
10
|
+
|
11
|
+
class Calculator
|
12
|
+
|
13
|
+
def result
|
14
|
+
@result or return
|
15
|
+
r = @result.round @decs
|
16
|
+
case r
|
17
|
+
when BigDecimal then
|
18
|
+
r = r.to_s "F"
|
19
|
+
r.sub! /(?:(\.)([0-9]+))?\z/ do
|
20
|
+
(@sep||$1) + ($2.to_s.ljust @decs, "0")
|
21
|
+
end
|
22
|
+
when Integer then
|
23
|
+
r = r.to_s
|
24
|
+
end
|
25
|
+
r
|
26
|
+
end
|
27
|
+
|
28
|
+
def reset!
|
29
|
+
@result = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def decs= d ; @decs = Integer d ; end
|
33
|
+
|
34
|
+
def dot! ; @sep = "." ; end
|
35
|
+
def dot? ; @sep == "." ; end
|
36
|
+
def comma! ; @sep = "," ; end
|
37
|
+
def comma? ; @sep == "," ; end
|
38
|
+
def auto! ; @sep = nil ; end
|
39
|
+
|
40
|
+
def add line
|
41
|
+
line = line.chomp
|
42
|
+
line.slice! /#.*/
|
43
|
+
if $& =~ /!(\w+)/ then
|
44
|
+
case $1
|
45
|
+
when "c", "comma", "k", "komma" then comma!
|
46
|
+
when "d", "dot", "p", "point" then dot!
|
47
|
+
when "a", "auto" then auto!
|
48
|
+
when /\A\d+\z/ then @decs = $1.to_i
|
49
|
+
end
|
50
|
+
end
|
51
|
+
line.slice! /^.*:/
|
52
|
+
line.strip!
|
53
|
+
line.notempty? or return
|
54
|
+
|
55
|
+
products = []
|
56
|
+
line.split /(?:[;|&]|\s+[,+-]\s+)/ do |p|
|
57
|
+
products.push [ (split_products p), $& =~ /-/]
|
58
|
+
end
|
59
|
+
|
60
|
+
minus = false
|
61
|
+
products.each { |p,nm|
|
62
|
+
if not @result then @result = p
|
63
|
+
elsif minus then @result -= p
|
64
|
+
else @result += p
|
65
|
+
end
|
66
|
+
minus = nm
|
67
|
+
}
|
68
|
+
@result
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def split_products p
|
74
|
+
nums = []
|
75
|
+
p.split /[*\/]/ do |n|
|
76
|
+
nums.push [ (parse_number n), $& == "/"]
|
77
|
+
end
|
78
|
+
|
79
|
+
inv = false
|
80
|
+
prod = nil
|
81
|
+
nums.each { |n,ni|
|
82
|
+
if not prod then prod = n
|
83
|
+
elsif inv then prod /= n
|
84
|
+
else prod *= n
|
85
|
+
end
|
86
|
+
inv = ni
|
87
|
+
}
|
88
|
+
@prev = prod
|
89
|
+
end
|
90
|
+
|
91
|
+
def parse_number n
|
92
|
+
n.strip!
|
93
|
+
if n =~ %r/ *%\z/ then
|
94
|
+
@prev * (BigDecimal $`) / 100
|
95
|
+
else
|
96
|
+
comma! if not @sep and n =~ /\d,(?:-|\d+\b(?:[^.]|$))/
|
97
|
+
if @sep == "," then n.gsub! ".", "_" ; n.sub! @sep, "."
|
98
|
+
else n.gsub! ",", "_"
|
99
|
+
end
|
100
|
+
if n =~ /\.-/ then
|
101
|
+
n = $`
|
102
|
+
@decs ||= 2
|
103
|
+
elsif n =~ /\.(\d*)/ then
|
104
|
+
d = $1.length
|
105
|
+
@decs = d if not @decs or @decs < d
|
106
|
+
end
|
107
|
+
@decs.nonzero? ? (BigDecimal n) : (Integer n)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nvim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: software@bertram-scharpf.de
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/neovim/remote.rb
|
40
40
|
- lib/neovim/remote_object.rb
|
41
41
|
- lib/neovim/ruby_provider.rb
|
42
|
+
- lib/neovim/tools/calculator.rb
|
42
43
|
- lib/neovim/tools/copy.rb
|
43
44
|
- lib/neovim/vimscript_provider.rb
|
44
45
|
homepage: https://github.com/BertramScharpf/ruby-nvim
|
@@ -60,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '0'
|
62
63
|
requirements: []
|
63
|
-
rubygems_version: 3.5.
|
64
|
+
rubygems_version: 3.5.19
|
64
65
|
signing_key:
|
65
66
|
specification_version: 4
|
66
67
|
summary: Yet another Ruby client for Neovim
|