nvim 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +112 -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: ba92c6fed4951efb4f5e19baeb500fa284eb4ff74bdc2c583024633e193c3678
|
4
|
+
data.tar.gz: 5642a68aef2c9310c7ee42dc2ce52dc20c5ba45413a69fc17897fbdcde7f8702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8d2c4fd3b66d4dba74c446f65ae08820dd5feb026e0ab14f8f97af54b495ef421220614473867e3e71039221d471f1da2976240f47fc8f5c96ce3738973320
|
7
|
+
data.tar.gz: d33e37d115531e00811714e86de6902be1db2a40748676200e7ee9590556d31f3edfe85ba3078ee3879831536f947222983f17d36a70db4b3b6b7af8b78fa2a8
|
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.2.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: "2f15f07"
|
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,112 @@
|
|
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
|
+
r = @result.round @decs
|
15
|
+
case r
|
16
|
+
when BigDecimal then
|
17
|
+
r = r.to_s "F"
|
18
|
+
r.sub! /(?:(\.)([0-9]+))?\z/ do
|
19
|
+
(@sep||$1) + ($2.to_s.ljust @decs, "0")
|
20
|
+
end
|
21
|
+
when Integer then
|
22
|
+
r = r.to_s
|
23
|
+
end
|
24
|
+
r
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset!
|
28
|
+
@result = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def decs= d ; @decs = Integer d ; end
|
32
|
+
|
33
|
+
def dot! ; @sep, @grp = ".", "," ; end
|
34
|
+
def comma! ; @sep, @grp = ",", "." ; end
|
35
|
+
def dot? ; @sep == "." ; end
|
36
|
+
def comma? ; @sep == "," ; end
|
37
|
+
|
38
|
+
def add line
|
39
|
+
line = line.chomp
|
40
|
+
line.slice! /#.*/
|
41
|
+
if $& =~ /!(\w+)/ then
|
42
|
+
case $1
|
43
|
+
when "c", "comma", "k", "komma" then comma!
|
44
|
+
when "d", "dot", "p", "point" then dot!
|
45
|
+
when /\A\d+\z/ then @decs = $1.to_i
|
46
|
+
end
|
47
|
+
end
|
48
|
+
line.slice! /^.*:/
|
49
|
+
line.strip!
|
50
|
+
line.notempty? or return
|
51
|
+
|
52
|
+
products = []
|
53
|
+
line.split /(?<![,.])[+-]/ do |p|
|
54
|
+
products.push [ (split_products p), $& == "-"]
|
55
|
+
end
|
56
|
+
|
57
|
+
minus = false
|
58
|
+
products.each { |p,nm|
|
59
|
+
if not @result then @result = p
|
60
|
+
elsif minus then @result -= p
|
61
|
+
else @result += p
|
62
|
+
end
|
63
|
+
minus = nm
|
64
|
+
}
|
65
|
+
@result
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def split_products p
|
71
|
+
nums = []
|
72
|
+
p.split /[*\/]/ do |n|
|
73
|
+
nums.push [ (parse_number n), $& == "/"]
|
74
|
+
end
|
75
|
+
|
76
|
+
inv = false
|
77
|
+
prod = nil
|
78
|
+
nums.each { |n,ni|
|
79
|
+
if not prod then prod = n
|
80
|
+
elsif inv then prod /= n
|
81
|
+
else prod *= n
|
82
|
+
end
|
83
|
+
inv = ni
|
84
|
+
}
|
85
|
+
@prev = prod
|
86
|
+
end
|
87
|
+
|
88
|
+
def parse_number n
|
89
|
+
n.strip!
|
90
|
+
if n =~ %r/ *%\z/ then
|
91
|
+
@prev * (BigDecimal $`) / 100
|
92
|
+
else
|
93
|
+
comma! if not @sep and n =~ /\d,\d/
|
94
|
+
case @sep
|
95
|
+
when "," then n.gsub! @grp, "_" ; n.sub! @sep, "."
|
96
|
+
when "." then n.gsub! @grp, "_"
|
97
|
+
end
|
98
|
+
if n =~ /\.-/ then
|
99
|
+
n = $`
|
100
|
+
@decs ||= 2
|
101
|
+
elsif n =~ /\.(\d*)/ then
|
102
|
+
d = $1.length
|
103
|
+
@decs = d if not @decs or @decs < d
|
104
|
+
end
|
105
|
+
@decs.nonzero? ? (BigDecimal n) : (Integer n)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
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.2.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-09-11 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.18
|
64
65
|
signing_key:
|
65
66
|
specification_version: 4
|
66
67
|
summary: Yet another Ruby client for Neovim
|