M .rubocop.yml => .rubocop.yml +7 -0
@@ 1,9 1,16 @@
AllCops:
+ TargetRubyVersion: 2.7.4
NewCops: enable
Layout/LineLength:
Max: 80
+Layout/MultilineMethodCallIndentation:
+ EnforcedStyle: indented
+
+Layout/SpaceBeforeBlockBraces:
+ EnforcedStyle: no_space
+
Style/MethodCallWithArgsParentheses:
Enabled: True
M lib/tilt/emacs_org.rb => lib/tilt/emacs_org.rb +6 -13
@@ 1,7 1,6 @@
# frozen_string_literal: true
require 'nokogiri'
-require 'open3'
require 'tempfile'
require 'tilt'
@@ 12,9 11,8 @@ module Tilt
metadata[:mime_type] = 'text/html'
def head
- @head ||= doc.at_css('head').css('script, link, style').inject do
- |elm, head| "#{head}#{elm}\n"
- end
+ @head ||= doc.at_css('head').css('script, link, style')
+ .map(&:to_s).inject(:+)
end
def body
@@ 50,15 48,10 @@ module Tilt
if options.include?(:setupfile)
f.write(@data)
f.rewind
- Open3.capture3(
- <<~SH
- emacs --batch --quick --load org --eval='
- (progn
- (find-file-literally "#{f.path}")
- (org-html-export-as-html)
- (message "%s" (buffer-string)))'
- SH
- )[1]
+ out = `emacs --batch --quick --load org --eval=' \
+ (progn (find-file-literally "#{f.path}") \
+ (princ (org-html-export-to-html)))'`
+ File.new("/tmp/#{out}").read
end
end
end
M test/emacs_org_test.rb => test/emacs_org_test.rb +5 -5
@@ 18,12 18,12 @@ module Tilt
end
def test_render__without_setupfile
- doc = render_and_inspect { '* anything' }
+ doc = render_and_inspect{ '* anything' }
assert_equal('Table of Contents', doc.at_css('h2').inner_html)
end
def test_render__body_only
- doc = render_and_inspect({ setupfile: setupfile }) { '* jelou' }
+ doc = render_and_inspect({ setupfile: setupfile }){ '* jelou' }
assert_equal('jelou', doc.at_css('h2').inner_html)
assert_nil(doc.at_css('head'))
end
@@ 69,12 69,12 @@ module Tilt
end
def test_title
- template = Tilt['org'].new { '#+TITLE: My title' }
+ template = Tilt['org'].new{ '#+TITLE: My title' }
assert_equal('My title', template.title)
end
def test_body
- template = Tilt['org'].new { 'My body' }
+ template = Tilt['org'].new{ 'My body' }
assert_includes(template.body, 'My body')
refute_includes(template.body, '<head>')
end
@@ 83,7 83,7 @@ module Tilt
def render_and_inspect(options = {}, &block)
Nokogiri::HTML(
- Tilt['org'].new(nil, 1, options) { block.call }.render
+ Tilt['org'].new(nil, 1, options){ block.call }.render
)
end
end
M tilt-emacs_org.gemspec => tilt-emacs_org.gemspec +8 -10
@@ 1,17 1,15 @@
# frozen_string_literal: true
-require_relative 'lib/tilt/emacs_org'
-
Gem::Specification.new do |spec|
spec.name = 'tilt-emacs_org'
- spec.version = '0.1.0'
+ spec.version = '0.1.1'
spec.authors = ['Felix Freeman']
spec.email = ['libsys@hacktivista.jrg']
spec.summary = 'Native Emacs Org templating engine for Tilt.'
spec.homepage = 'https://git.hacktivista.org/tilt-emacs_org'
spec.license = 'MIT'
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.4')
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
@@ 20,11 18,11 @@ Gem::Specification.new do |spec|
spec.files = Dir['lib/**/*.rb']
spec.require_paths = ['lib']
- spec.add_dependency('nokogiri')
- spec.add_dependency('tilt')
+ spec.add_runtime_dependency('nokogiri', '~> 1.13.7')
+ spec.add_runtime_dependency('tilt', '~> 2.0.10')
- spec.add_development_dependency('minitest')
- spec.add_development_dependency('rake')
- spec.add_development_dependency('rubocop')
- spec.add_development_dependency('rubocop-minitest')
+ spec.add_development_dependency('minitest', '~> 5.16.2')
+ spec.add_development_dependency('rake', '~> 13.0.6')
+ spec.add_development_dependency('rubocop', '~> 1.31.2')
+ spec.add_development_dependency('rubocop-minitest', '~> 0.20.1')
end