Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ OPENC3_SR_REDIS_PASSWORD=scriptrunnerpassword
OPENC3_SR_BUCKET_USERNAME=scriptrunnerminio
OPENC3_SR_BUCKET_PASSWORD=scriptrunnerminiopassword
# Build and repository settings
ALPINE_VERSION=3.17
ALPINE_BUILD=3
ALPINE_VERSION=3.18
ALPINE_BUILD=0
APK_URL=https://dl-cdn.alpinelinux.org
RUBYGEMS_URL=https://rubygems.org
NPM_URL=https://registry.npmjs.org
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0", "3.1"]
ruby-version: ["3.1", "3.2"]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0", "3.1"]
ruby-version: ["3.1", "3.2"]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clamav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 3.1
- name: Set up Ruby 3.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.2
bundler-cache: false # runs 'bundle install' and caches installed gems automatically
working-directory: openc3
- name: openc3.sh build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
environment: Release
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 3.1
- name: Set up Ruby 3.2
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.2
bundler-cache: false # runs 'bundle install' and caches installed gems automatically
working-directory: openc3
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruby_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.0", "3.1"]
ruby-version: ["3.1", "3.2"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ inherit_from:

AllCops:
NewCops: enable
TargetRubyVersion: 3.1
TargetRubyVersion: 3.2

# Layout
Layout/LineLength:
Expand Down
2 changes: 1 addition & 1 deletion openc3-cosmos-cmd-tlm-api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gem 'prometheus-client', '~> 4.0'
gem 'bootsnap', '>= 1.9.3', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors', '~> 1.1'
gem 'rack-cors', '~> 2.0'

group :development do
gem 'debase-ruby_core_source'
Expand Down
2 changes: 1 addition & 1 deletion openc3-cosmos-script-runner-api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ gem 'prometheus-client', '~> 4.0'
gem 'bootsnap', '>= 1.9.3', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors', '~> 1.1'
gem 'rack-cors', '~> 2.0'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
4 changes: 3 additions & 1 deletion openc3/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ gemspec :name => 'openc3'
# Include the rails gems for the convenience of custom microservice plugins
gem 'rails', '~> 7.0.0'
gem 'bootsnap', '>= 1.9.3', require: false
gem 'rack-cors', '~> 1.1'
gem 'rack-cors', '~> 2.0'
gem 'tzinfo-data'
# httpclient hasn't been released since 2016 so use Shopify's updated one
gem 'httpclient', git: 'https://github.com/Shopify/httpclient'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do this as it always requires an internet connection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to switch to Faraday.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

25 changes: 17 additions & 8 deletions openc3/lib/openc3/utilities/ruby_lex_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.

require 'irb'
require 'irb/ruby-lex'
require 'stringio'

Expand Down Expand Up @@ -80,6 +81,14 @@ class RubyLexUtils

# Create a new RubyLex and StringIO to hold the text to operate on
def initialize
# Taken from https://github.com/ruby/ruby/blob/master/test/irb/test_ruby_lex.rb#L827
IRB.init_config(nil)
# IRB.setup doesn't work because the command line options are passed
# and it doesn't recognize --warnings when we run rspec (see spec.rake)
# IRB.setup(__FILE__)
workspace = IRB::WorkSpace.new(binding)
@context = IRB::Context.new(nil, workspace)

@lex = RubyLex.new
@lex_io = StringIO.new('')
end
Expand All @@ -99,7 +108,7 @@ def ripper_lex_without_warning(code)
def contains_begin?(text)
@lex.reinitialize
@lex_io.string = text
@lex.set_input(@lex_io)
@lex.set_input(@lex_io, context: @context)
tokens = ripper_lex_without_warning(text)
tokens.each do |token|
if token[1] == :on_kw and token[2] == 'begin'
Expand All @@ -114,7 +123,7 @@ def contains_begin?(text)
def contains_end?(text)
@lex.reinitialize
@lex_io.string = text
@lex.set_input(@lex_io)
@lex.set_input(@lex_io, context: @context)
tokens = ripper_lex_without_warning(text)
tokens.each do |token|
if token[1] == :on_kw and token[2] == 'end'
Expand All @@ -129,7 +138,7 @@ def contains_end?(text)
def contains_keyword?(text)
@lex.reinitialize
@lex_io.string = text
@lex.set_input(@lex_io)
@lex.set_input(@lex_io, context: @context)
tokens = ripper_lex_without_warning(text)
tokens.each do |token|
if token[1] == :on_kw
Expand All @@ -149,7 +158,7 @@ def contains_keyword?(text)
def contains_block_beginning?(text)
@lex.reinitialize
@lex_io.string = text
@lex.set_input(@lex_io)
@lex.set_input(@lex_io, context: @context)
tokens = ripper_lex_without_warning(text)
tokens.each do |token|
if token[1] == :on_kw
Expand All @@ -166,7 +175,7 @@ def contains_block_beginning?(text)
def continue_block?(text)
@lex.reinitialize
@lex_io.string = text
@lex.set_input(@lex_io)
@lex.set_input(@lex_io, context: @context)
tokens = RubyLex.ripper_lex_without_warning(text)
index = tokens.length - 1
while index > 0
Expand All @@ -184,7 +193,7 @@ def continue_block?(text)
def remove_comments(text, progress_dialog = nil)
@lex.reinitialize
@lex_io.string = text
@lex.set_input(@lex_io)
@lex.set_input(@lex_io, context: @context)
comments_removed = ""
token_count = 0
progress = 0.0
Expand Down Expand Up @@ -218,14 +227,14 @@ def each_lexed_segment(text)
inside_begin = false
lex = RubyLex.new
lex_io = StringIO.new(text)
lex.set_input(lex_io)
lex.set_input(lex_io, context: @context)
lex.line = ''
line = ''
continue_indent = nil
begin_indent = nil
previous_indent = 0

while lexed = lex.lex
while lexed = lex.lex(@context)
#puts "lexed = #{lexed.chomp}, indent = #{lex.indent}, continue = #{lex.continue}"
lex.line_no += lexed.count("\n")
lex.line.concat lexed
Expand Down
7 changes: 3 additions & 4 deletions openc3/openc3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ spec = Gem::Specification.new do |s|
s.add_runtime_dependency 'snmp', '~> 1.3'
s.add_runtime_dependency 'rubyzip', '~> 2.3'
s.add_runtime_dependency 'nokogiri', '~> 1.13'
s.add_runtime_dependency 'puma', '~> 5.5'
# TODO: Bump rack to 3.x when puma also upgrades to incorporate rack 3
s.add_runtime_dependency 'puma', '~> 6.2'
# TODO: Bump rack to 3.x when rails 7.1 is released
s.add_runtime_dependency 'rack', '~> 2.2'
s.add_runtime_dependency 'redis', '~> 5.0'
s.add_runtime_dependency 'psych', '~> 4.0'
s.add_runtime_dependency 'psych', '~> 5.0'
s.add_runtime_dependency 'matrix', '~> 0.4' # bundled gem in Ruby 3.1
s.add_runtime_dependency 'httpclient', '~> 2.8'
s.add_runtime_dependency 'aws-sdk-s3', '~> 1.109'
s.add_runtime_dependency 'tzinfo-data', '~> 1.2021'
s.add_runtime_dependency 'ffi', '~> 1.15' # Required by childprocess on Windows
Expand Down