Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gem 'html2rss', github: 'html2rss/html2rss', branch: :master

group :development do
# gem 'html2rss-generator', path: '../generator'
gem 'html2rss-generator', github: 'html2rss/generator', branch: :main

gem 'nokogiri'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GIT

GIT
remote: https://github.com/html2rss/html2rss
revision: 762a09c15e5def5897b2d08f0e3c11c023cc9b35
revision: e0dca5bf74b17c1e2a0618fc0a4af27c16da1883
branch: master
specs:
html2rss (0.17.0)
Expand Down Expand Up @@ -224,7 +224,7 @@ GEM
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.0)
rubocop-ast (1.49.1)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-performance (1.26.1)
Expand Down
2 changes: 1 addition & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bundle install

echo
echo "==> Installing Node dependencies (required for make lint)..."
npm install --ignore-scripts --no-fund --no-audit
npm ci --ignore-scripts --no-fund --no-audit

echo
echo "==> Checking system tools..."
Expand Down
10 changes: 7 additions & 3 deletions bin/validate_configs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

require 'bundler/setup'
require 'html2rss'
require 'yaml'

unless Html2rss::Config.respond_to?(:validate_yaml)
warn 'Error: installed html2rss gem does not support Config.validate_yaml.'
warn 'Run: bundle update html2rss'
exit 1
end

files = Dir['lib/html2rss/configs/**/*.yml']
failed = []

files.each do |file|
config = YAML.safe_load_file(file, symbolize_names: true)
result = Html2rss::Config.validate(config)
result = Html2rss::Config.validate_yaml(file)

if result.success?
puts "ok #{file}"
Expand Down
56 changes: 56 additions & 0 deletions spec/bin/validate_configs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

require 'fileutils'
require 'tmpdir'

RSpec.describe 'bin/validate_configs' do # rubocop:disable RSpec/DescribeClass
let(:script_path) { File.expand_path('../../bin/validate_configs', __dir__) }
let(:config_path) { File.join('lib', 'html2rss', 'configs', 'example.com', 'search.yml') }
let(:success_output) do
a_string_including(
"ok #{config_path}",
'1 configs validated successfully.'
)
end

it 'passes validation for parameterized configs when defaults are present' do
with_temp_config do |dir|
expect { run_script(dir) }.to output(success_output).to_stdout
.and output('').to_stderr
end
end

def with_temp_config
Dir.mktmpdir do |dir|
write_config(dir)
yield dir
end
end

def write_config(dir)
FileUtils.mkdir_p(File.join(dir, File.dirname(config_path)))
File.write(File.join(dir, config_path), valid_config)
end

def run_script(dir)
Dir.chdir(dir) { load script_path }
end

def valid_config
<<~YAML
parameters:
query:
type: string
default: ruby
headers:
X-Query: "%<query>s"
channel:
url: "https://example.com/search?q=%<query>s"
selectors:
items:
selector: ".item"
title:
selector: "h2"
YAML
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'bundler/setup'
require 'tzinfo'

require 'html2rss'
require 'html2rss/configs'

Expand Down
Loading