rfbeam 0.5.0 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.pre-commit-config.yaml +8 -0
- data/.streerc +1 -0
- data/.tool-versions +1 -1
- data/CHANGELOG.md +48 -47
- data/Gemfile +10 -7
- data/Gemfile.lock +48 -44
- data/README.md +71 -113
- data/Rakefile +3 -2
- data/cliff.toml +74 -0
- data/cog.toml +28 -0
- data/exe/rfbeam +0 -1
- data/lib/rfbeam/cli.rb +93 -36
- data/lib/rfbeam/kld7/constants.rb +66 -138
- data/lib/rfbeam/kld7/detection_params.rb +149 -0
- data/lib/rfbeam/kld7/module_params.rb +96 -0
- data/lib/rfbeam/kld7/operation_params.rb +162 -0
- data/lib/rfbeam/kld7/radar_messages.rb +18 -17
- data/lib/rfbeam/kld7/serial_connection.rb +13 -14
- data/lib/rfbeam/kld7/streamer.rb +83 -0
- data/lib/rfbeam/version.rb +1 -1
- data/lib/rfbeam.rb +8 -7
- data/output.csv +257 -0
- data/rfbeam.gemspec +6 -11
- data/streamer2.rb +55 -0
- data/streaming.rb +71 -0
- data/yarn.lock +221 -12
- metadata +23 -173
- data/.rubocop.yml +0 -25
- data/.streerc +0 -2
- data/lib/rfbeam/kld7/cli_formatter.rb +0 -61
- data/lib/rfbeam/kld7/cli_output.rb +0 -141
- data/lib/rfbeam/kld7/radar_parameters.rb +0 -397
- data/node_modules/.bin/prettier +0 -1
- data/node_modules/.yarn-integrity +0 -19
- data/node_modules/@prettier/plugin-ruby/CHANGELOG.md +0 -1351
- data/node_modules/@prettier/plugin-ruby/CODE_OF_CONDUCT.md +0 -76
- data/node_modules/@prettier/plugin-ruby/CONTRIBUTING.md +0 -185
- data/node_modules/@prettier/plugin-ruby/LICENSE +0 -21
- data/node_modules/@prettier/plugin-ruby/README.md +0 -226
- data/node_modules/@prettier/plugin-ruby/docs/logo.png +0 -0
- data/node_modules/@prettier/plugin-ruby/node_modules/.bin/prettier +0 -1
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/LICENSE +0 -5945
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/README.md +0 -109
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/bin-prettier.js +0 -62
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/cli.js +0 -15136
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/doc.js +0 -1473
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-angular.mjs +0 -2
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-babel.mjs +0 -29
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-espree.mjs +0 -26
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-flow.mjs +0 -35
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-glimmer.mjs +0 -27
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-graphql.mjs +0 -15
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-html.mjs +0 -36
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-markdown.mjs +0 -76
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-meriyah.mjs +0 -19
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-postcss.mjs +0 -76
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-typescript.mjs +0 -257
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-yaml.mjs +0 -150
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/standalone.mjs +0 -116
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/index.js +0 -37885
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/package.json +0 -21
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-angular.js +0 -2
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-babel.js +0 -29
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-espree.js +0 -26
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-flow.js +0 -35
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-glimmer.js +0 -27
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-graphql.js +0 -15
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-html.js +0 -36
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-markdown.js +0 -76
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-meriyah.js +0 -19
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-postcss.js +0 -76
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-typescript.js +0 -257
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-yaml.js +0 -150
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/standalone.js +0 -116
- data/node_modules/@prettier/plugin-ruby/node_modules/prettier/third-party.js +0 -8978
- data/node_modules/@prettier/plugin-ruby/package.json +0 -64
- data/node_modules/@prettier/plugin-ruby/prettier.gemspec +0 -36
- data/node_modules/@prettier/plugin-ruby/rubocop.yml +0 -64
- data/node_modules/@prettier/plugin-ruby/src/getInfo.js +0 -23
- data/node_modules/@prettier/plugin-ruby/src/netcat.js +0 -13
- data/node_modules/@prettier/plugin-ruby/src/parseSync.js +0 -236
- data/node_modules/@prettier/plugin-ruby/src/plugin.js +0 -172
- data/node_modules/@prettier/plugin-ruby/src/server.rb +0 -199
- data/node_modules/prettier/LICENSE +0 -5970
- data/node_modules/prettier/README.md +0 -109
- data/node_modules/prettier/bin-prettier.js +0 -64
- data/node_modules/prettier/cli.js +0 -15364
- data/node_modules/prettier/doc.js +0 -1473
- data/node_modules/prettier/esm/parser-angular.mjs +0 -2
- data/node_modules/prettier/esm/parser-babel.mjs +0 -29
- data/node_modules/prettier/esm/parser-espree.mjs +0 -26
- data/node_modules/prettier/esm/parser-flow.mjs +0 -35
- data/node_modules/prettier/esm/parser-glimmer.mjs +0 -27
- data/node_modules/prettier/esm/parser-graphql.mjs +0 -15
- data/node_modules/prettier/esm/parser-html.mjs +0 -36
- data/node_modules/prettier/esm/parser-markdown.mjs +0 -76
- data/node_modules/prettier/esm/parser-meriyah.mjs +0 -19
- data/node_modules/prettier/esm/parser-postcss.mjs +0 -76
- data/node_modules/prettier/esm/parser-typescript.mjs +0 -49
- data/node_modules/prettier/esm/parser-yaml.mjs +0 -150
- data/node_modules/prettier/esm/standalone.mjs +0 -116
- data/node_modules/prettier/index.js +0 -38236
- data/node_modules/prettier/package.json +0 -21
- data/node_modules/prettier/parser-angular.js +0 -2
- data/node_modules/prettier/parser-babel.js +0 -29
- data/node_modules/prettier/parser-espree.js +0 -26
- data/node_modules/prettier/parser-flow.js +0 -35
- data/node_modules/prettier/parser-glimmer.js +0 -27
- data/node_modules/prettier/parser-graphql.js +0 -15
- data/node_modules/prettier/parser-html.js +0 -36
- data/node_modules/prettier/parser-markdown.js +0 -76
- data/node_modules/prettier/parser-meriyah.js +0 -19
- data/node_modules/prettier/parser-postcss.js +0 -76
- data/node_modules/prettier/parser-typescript.js +0 -49
- data/node_modules/prettier/parser-yaml.js +0 -150
- data/node_modules/prettier/standalone.js +0 -116
- data/node_modules/prettier/third-party.js +0 -8978
- data/package.json +0 -6
@@ -1,199 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "socket"
|
5
|
-
require "json"
|
6
|
-
require "fileutils"
|
7
|
-
require "open3"
|
8
|
-
|
9
|
-
require "prettier_print"
|
10
|
-
require "syntax_tree"
|
11
|
-
require "syntax_tree/haml"
|
12
|
-
require "syntax_tree/rbs"
|
13
|
-
|
14
|
-
# First, require all of the plugins that the user specified.
|
15
|
-
ARGV.shift[/^--plugins=(.*)$/, 1]
|
16
|
-
.split(",")
|
17
|
-
.each { |plugin| require "syntax_tree/#{plugin}" }
|
18
|
-
|
19
|
-
# Make sure we trap these signals to be sure we get the quit command coming from
|
20
|
-
# the parent node process
|
21
|
-
quit = false
|
22
|
-
trap(:INT) { quit = true }
|
23
|
-
trap(:TERM) { quit = true }
|
24
|
-
|
25
|
-
if Signal.list.key?("QUIT") && RUBY_ENGINE != "jruby"
|
26
|
-
trap(:QUIT) { quit = true }
|
27
|
-
end
|
28
|
-
|
29
|
-
# The information variable stores the actual connection information, which will
|
30
|
-
# either be an IP address and port or a path to a unix socket file.
|
31
|
-
information = ""
|
32
|
-
|
33
|
-
# The candidates array is a list of potential programs that could be used to
|
34
|
-
# connect to our server. We'll run through them after the server starts to find
|
35
|
-
# the best one to use.
|
36
|
-
candidates = []
|
37
|
-
|
38
|
-
if Gem.win_platform?
|
39
|
-
# If we're on windows, we're going to start up a TCP server. The 0 here means
|
40
|
-
# to bind to some available port.
|
41
|
-
server = TCPServer.new("127.0.0.1", 0)
|
42
|
-
address = server.local_address
|
43
|
-
|
44
|
-
# Ensure that we close the server when this process exits.
|
45
|
-
at_exit { server.close }
|
46
|
-
|
47
|
-
information = "#{address.ip_address} #{address.ip_port}"
|
48
|
-
candidates = %w[nc telnet]
|
49
|
-
else
|
50
|
-
# If we're not on windows, then we're going to assume we can use unix socket
|
51
|
-
# files (since they're faster than a TCP server).
|
52
|
-
filepath = "/tmp/prettier-ruby-parser-#{Process.pid}.sock"
|
53
|
-
server = UNIXServer.new(filepath)
|
54
|
-
|
55
|
-
# Ensure that we close the server and delete the socket file when this
|
56
|
-
# process exits.
|
57
|
-
at_exit do
|
58
|
-
server.close
|
59
|
-
File.unlink(filepath)
|
60
|
-
end
|
61
|
-
|
62
|
-
information = server.local_address.unix_path
|
63
|
-
candidates = ["nc -w 3 -U", "ncat -w 3 -U"]
|
64
|
-
end
|
65
|
-
|
66
|
-
# This is the actual listening thread that will be acting as our server. We have
|
67
|
-
# to start it in another thread to begin with so that we can run through our
|
68
|
-
# candidate connection programs. Eventually we'll just join into this thread
|
69
|
-
# though and it will act as a daemon.
|
70
|
-
listener =
|
71
|
-
Thread.new do
|
72
|
-
loop do
|
73
|
-
break if quit
|
74
|
-
|
75
|
-
# Start up a new thread that will handle each successive connection.
|
76
|
-
Thread.new(server.accept_nonblock) do |socket|
|
77
|
-
parser, maxwidth_string, tabwidth_string, source =
|
78
|
-
socket.read.force_encoding("UTF-8").split("|", 4)
|
79
|
-
|
80
|
-
source.each_line do |line|
|
81
|
-
case line
|
82
|
-
when /^\s*#.+?coding/
|
83
|
-
# If we've found an encoding comment, then we're going to take that
|
84
|
-
# into account and reclassify the encoding for the source.
|
85
|
-
encoding = Ripper.new(line).tap(&:parse).encoding
|
86
|
-
source = source.force_encoding(encoding)
|
87
|
-
break
|
88
|
-
when /^\s*#/
|
89
|
-
# continue
|
90
|
-
else
|
91
|
-
break
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# At the moment, we're not going to support odd tabwidths. It's going to
|
96
|
-
# have to be a multiple of 2, because of the way that the prettyprint
|
97
|
-
# gem functions. So we're going to just use integer division here.
|
98
|
-
scalar = tabwidth_string.to_i / 2
|
99
|
-
genspace = ->(n) { " " * n * scalar }
|
100
|
-
|
101
|
-
maxwidth = maxwidth_string.to_i
|
102
|
-
response =
|
103
|
-
case parser
|
104
|
-
when "ping"
|
105
|
-
"pong"
|
106
|
-
when "ruby"
|
107
|
-
formatter =
|
108
|
-
SyntaxTree::Formatter.new(source, [], maxwidth, "\n", &genspace)
|
109
|
-
SyntaxTree.parse(source).format(formatter)
|
110
|
-
formatter.flush
|
111
|
-
formatter.output.join
|
112
|
-
when "rbs"
|
113
|
-
formatter =
|
114
|
-
SyntaxTree::RBS::Formatter.new(
|
115
|
-
source,
|
116
|
-
[],
|
117
|
-
maxwidth,
|
118
|
-
"\n",
|
119
|
-
&genspace
|
120
|
-
)
|
121
|
-
SyntaxTree::RBS.parse(source).format(formatter)
|
122
|
-
formatter.flush
|
123
|
-
formatter.output.join
|
124
|
-
when "haml"
|
125
|
-
formatter_class =
|
126
|
-
if defined?(SyntaxTree::Haml::Format::Formatter)
|
127
|
-
SyntaxTree::Haml::Format::Formatter
|
128
|
-
else
|
129
|
-
PrettierPrint
|
130
|
-
end
|
131
|
-
|
132
|
-
formatter =
|
133
|
-
formatter_class.new(source, +"", maxwidth, "\n", &genspace)
|
134
|
-
|
135
|
-
SyntaxTree::Haml.parse(source).format(formatter)
|
136
|
-
formatter.flush
|
137
|
-
formatter.output
|
138
|
-
end
|
139
|
-
|
140
|
-
if response
|
141
|
-
socket.write(JSON.fast_generate(response.force_encoding("UTF-8")))
|
142
|
-
else
|
143
|
-
socket.write("{ \"error\": true }")
|
144
|
-
end
|
145
|
-
rescue SyntaxTree::Parser::ParseError => error
|
146
|
-
loc = { start: { line: error.lineno, column: error.column } }
|
147
|
-
socket.write(JSON.fast_generate(error: error.message, loc: loc))
|
148
|
-
rescue StandardError => error
|
149
|
-
begin
|
150
|
-
socket.write(JSON.fast_generate(error: error.message))
|
151
|
-
rescue Errno::EPIPE
|
152
|
-
# Do nothing, the pipe has been closed by the parent process so we don't
|
153
|
-
# actually care about writing to it anymore.
|
154
|
-
end
|
155
|
-
ensure
|
156
|
-
socket.close
|
157
|
-
end
|
158
|
-
rescue IO::WaitReadable, Errno::EINTR
|
159
|
-
# Wait for select(2) to give us a connection that has content for 1
|
160
|
-
# second. Otherwise timeout and continue on (so that we hit our
|
161
|
-
# "break if quit" pretty often).
|
162
|
-
IO.select([server], nil, nil, 1)
|
163
|
-
|
164
|
-
retry unless quit
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
# Map each candidate connection method to a thread that will check if it works.
|
169
|
-
candidates.map! do |candidate|
|
170
|
-
Thread.new do
|
171
|
-
Thread.current.report_on_exception = false
|
172
|
-
|
173
|
-
# We do not care about stderr here, so throw it away
|
174
|
-
stdout, _stderr, status =
|
175
|
-
Open3.capture3("#{candidate} #{information}", stdin_data: "ping")
|
176
|
-
|
177
|
-
candidate if JSON.parse(stdout) == "pong" && status.exitstatus == 0
|
178
|
-
rescue StandardError
|
179
|
-
# We don't actually care if this fails, because we'll just skip that
|
180
|
-
# connection option.
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
# Find the first one prefix that successfully returned the correct value.
|
185
|
-
prefix =
|
186
|
-
candidates.detect do |candidate|
|
187
|
-
value = candidate.value
|
188
|
-
break value if value
|
189
|
-
end
|
190
|
-
|
191
|
-
# Default to running the netcat.js script that we ship with the plugin. It's a
|
192
|
-
# good fallback as it will always work, but it is slower than the other options.
|
193
|
-
prefix ||= "node #{File.expand_path("netcat.js", __dir__)}"
|
194
|
-
|
195
|
-
# Write out our connection information to the file given as the first argument
|
196
|
-
# to this script.
|
197
|
-
File.write(ARGV[0], "#{prefix} #{information}")
|
198
|
-
|
199
|
-
listener.join
|