Skip to content

Commit

Permalink
Merge pull request #27 from jlong/github-actions
Browse files Browse the repository at this point in the history
Add GitHub Action CI
  • Loading branch information
saturnflyer authored Dec 20, 2024
2 parents 6f3c648 + e81a52d commit 2e05273
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 171 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
types: [opened, synchronize, reopened]
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- ruby-version: '2.7.8'
bundler-version: '2.4.22'
- ruby-version: '3.0.7'
bundler-version: '2.5.23'
- ruby-version: '3.1.6'
bundler-version: '2.6.1'
- ruby-version: '3.3.6'
bundler-version: '2.6.1'
- ruby-version: '3.4.0-rc1'
bundler-version: '2.6.1'
- ruby-version: 'jruby'
bundler-version: '2.6.1'

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler: ${{ matrix.bundler-version }}
bundler-cache: true
- name: Run tests
env:
COVERALLS: ${{ matrix.ruby-version != 'jruby' }}
JRUBY_OPTS: ${{ matrix.ruby-version == 'jruby' && '--debug' || '' }}
run: bundle exec rake
9 changes: 7 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ group :test do
gem 'rake'
gem 'kramdown'
gem "simplecov"
gem 'coveralls-ruby', :require => false
gem 'coveralls_reborn', :require => false
gem 'minitest'
end


platforms :rbx do
gem 'racc' # if using gems like ruby_parser or parser
# gem 'rubysl', '~> 2.0'
gem 'psych'
# gem 'psych'
gem 'rubinius-developer_tools'
end

platforms :jruby do
gem 'jar-dependencies', '~> 0.4.1'
gem 'ruby-maven', '~> 3.3.11'
end
1 change: 1 addition & 0 deletions lib/radius/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def render_tag(name, attributes = {}, &block)
else
tag_definition_block = @definitions[qualified_tag_name(name.to_s)]
if tag_definition_block
# puts name: name, attributes: attributes
stack(name, attributes, block) do |tag|
tag_definition_block.call(tag).to_s
end
Expand Down
6 changes: 5 additions & 1 deletion lib/radius/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ def stack_up

def default_scanner
if RUBY_PLATFORM == 'java'
require 'java'
if Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('9.3')
require 'jruby'
else
require 'java'
end
require 'radius/parser/java_scanner.jar'
::Radius.send(:include_package, 'radius.parser')
Radius::JavaScanner.new(JRuby.runtime)
Expand Down
Binary file modified lib/radius/parser/JavaScanner.class
Binary file not shown.
372 changes: 211 additions & 161 deletions lib/radius/parser/JavaScanner.java

Large diffs are not rendered by default.

43 changes: 36 additions & 7 deletions lib/radius/parser/JavaScanner.rl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,37 @@

action _prefix { mark_pfx = p; }
action prefix {
prefix = input.substring(mark_pfx, p);
prefix = String.valueOf(input.substring(mark_pfx, p));
}
action _check_prefix {
if ( !prefix.equals(tag_prefix) ) {
// have to manually add ':' / Sep
// pass the text through & reset state
pass_through(input.substring(tagstart, p) + ":");
// Pass through the entire tag markup as text
pass_through(input.substring(tagstart, p + 1));
// Reset all state
prefix = "";
name = "";
attributes = RubyHash.newHash(runtime);
flavor = RubySymbol.newSymbol(runtime, "tasteless".intern());
tagstart = p + 1;
fgoto main;
}
}

action _starttag { mark_stg = p; }
action starttag { name = input.substring(mark_stg, p); }
action starttag {
name = String.valueOf(input.substring(mark_stg, p));
if (name == null || name.trim().isEmpty()) {
// Pass through the entire tag markup as text
pass_through(input.substring(tagstart, p + 1));
// Reset all state
prefix = "";
name = "";
attributes = RubyHash.newHash(runtime);
flavor = RubySymbol.newSymbol(runtime, "tasteless".intern());
tagstart = p + 1;
fgoto main;
}
}
action _attr { mark_attr = p; }
action attr {
attributes.op_aset(
Expand All @@ -40,7 +57,7 @@
# words
PrefixChar = [\-A-Za-z0-9._?] ;
NameChar = [\-A-Za-z0-9._:?] ;
TagName = NameChar+ >_starttag %starttag;
TagName = ([\-A-Za-z0-9._?]+ (':' [\-A-Za-z0-9._?]+)*) >_starttag %starttag;
Prefix = PrefixChar+ >_prefix %prefix;
Open = "<";
Sep = ":" >_check_prefix;
Expand Down Expand Up @@ -111,11 +128,23 @@ public class JavaScanner {
}

void tag(String prefix, String name, RubyHash attr, RubySymbol flavor) {
// Validate both prefix and name
if ((prefix == null || prefix.trim().isEmpty()) &&
(name == null || name.trim().isEmpty())) {
pass_through("<");
return;
}

if (name == null || name.trim().isEmpty()) {
pass_through("<" + prefix + ":");
return;
}

RubyHash tag = RubyHash.newHash(runtime);
tag.op_aset(
runtime.getCurrentContext(),
RubySymbol.newSymbol(runtime, "prefix"),
RubyString.newString(runtime, prefix)
RubyString.newString(runtime, prefix != null ? prefix : "")
);
tag.op_aset(
runtime.getCurrentContext(),
Expand Down

0 comments on commit 2e05273

Please sign in to comment.