Skip to content

Commit

Permalink
liturgical law: don't depend on markly
Browse files Browse the repository at this point in the history
as it prevents the specs from running on Ruby < 2.5
and we're not ditching support of rubies down to 2.0 just for niceties
in the specs
ref #101
  • Loading branch information
igneus committed Jul 15, 2024
1 parent 3383c74 commit 53ca5e6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ group :test do
gem 'cucumber', '~> 2.99'
gem 'simplecov'
gem 'backports', '~> 3.18'
gem 'markly'
end
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ GEM
i18n (0.6.9)
jaro_winkler (1.5.4)
json (2.0.2)
markly (0.10.0)
multi_json (1.12.2)
multi_test (0.1.2)
parallel (1.19.2)
Expand Down Expand Up @@ -84,7 +83,6 @@ DEPENDENCIES
backports (~> 3.18)
cucumber (~> 2.99)
i18n
markly
rake
roman-numerals
rspec
Expand Down
26 changes: 6 additions & 20 deletions spec/liturgical_law_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'markly'

class LiturgicalLawExample
# make RSpec expectations available for the code example
Expand Down Expand Up @@ -29,26 +28,13 @@ def years_with(from: 1970, to: 2300)
describe path, slow: true do
document = File.read path

last_paragraph = ''
header_level = 0
Markly.parse(document).each do |node|
case node.type
when :header
last_paragraph = node.to_plaintext
when :paragraph
last_paragraph = node.to_plaintext
when :code_block
next if node.fence_info != 'ruby'
MarkdownDocument.new(document).each_ruby_example do |code, line, last_paragraph|
context = last_paragraph[0..50].gsub(/\s+/, ' ')
context = context[0..context.rindex(' ')]

line = node.source_position[:start_line]

context = last_paragraph[0..50].gsub(/\s+/, ' ')
context = context[0..context.rindex(' ')]

it context do
cls = Class.new(LiturgicalLawExample)
cls.class_eval(node.string_content, path, line)
end
it context do
cls = Class.new(LiturgicalLawExample)
cls.class_eval(code, path, line)
end
end
end
Expand Down
9 changes: 8 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,21 @@ def initialize(str)
def each_ruby_example
example = nil
line = nil
last_paragraph = ''
paragraph_beginning = false
@str.each_line.with_index(1) do |l, i|
if example.nil?
if example_beginning?(l)
example = ''
line = i + 1
elsif l.strip.empty?
paragraph_beginning = true
elsif paragraph_beginning
last_paragraph = l
paragraph_beginning = false
end
elsif example_end?(l)
yield example, line
yield example, line, last_paragraph
example = nil
else
example += l
Expand Down

0 comments on commit 53ca5e6

Please sign in to comment.