# Generated from mdtoc-0.1.5.gem by gem2rpm -*- rpm-spec -*- %global gem_name mdtoc Name: rubygem-%{gem_name} Version: 0.1.5 Release: 1%{?dist} Summary: Read Markdown files and output a table of contents License: MIT URL: https://github.com/andornaut/mdtoc Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby >= 2.7.2 # BuildRequires: rubygem(minitest) >= 5 # BuildRequires: rubygem(minitest) < 6 # BuildRequires: rubygem(sorbet) # BuildRequires: rubygem(rubocop) >= 0.86 # BuildRequires: rubygem(rubocop) < 1 # BuildRequires: rubygem(rubocop-shopify) >= 1.0.4 # BuildRequires: rubygem(rubocop-sorbet) >= 0.5 # BuildRequires: rubygem(rubocop-sorbet) < 1 # BuildRequires: rubygem(unparser) >= 0.4.9 # BuildRequires: rubygem(unparser) < 0.5 BuildArch: noarch %description # mdtoc - Markdown Table of Contents Read Markdown files and output a table of contents. ## Installation Requirements: * [Ruby](https://www.ruby-lang.org/en/) (see [.ruby-version](./.ruby-version)) ``` $ gem install mdtoc ``` ## Usage ``` $ mdtoc --help Usage: mdtoc [options] files or directories... -h, --help Show this message -o, --output PATH Update a table of contents in the file at PATH -a, --[no-]append Append to the --output file if a tag isn't found -c, --[no-]create Create the --output file if it does not exist ``` 1. Add a `` tag to a Markdown file. ``` $ echo '` >> README.md ``` 2. Run `mdtoc` and specify input files or directories (eg. the "test/samples" directory) and an output file (eg. "README.md"). ``` $ mdtoc -aco README.md test/samples ``` ## Example Rakefile Create a `Rakefile` with the contents below, then run [`rake`](https://github.com/ruby/rake) to: * `git pull` * `git add` any *.md files * Run `mdtoc` to update the generated table of contents in the ./README.md file * Git commit and push any changes ``` task default: %w[mdtoc] desc 'Update Markdown table of contents and push changes to the git repository' task :mdtoc do |t| command = <<~END set -e git pull if [ -n "$(git diff --name-only --diff-filter=U)" ]; then echo 'Error: conflicts exist' >&2 exit 1 fi mdtoc --append --create --output README.md docs/ git add *.md **/*.md git commit -m 'Update TOC' git push END %x|#{command}| end ``` See [andornaut/til](https://github.com/andornaut/til/blob/master/Rakefile) for an example. ## Development ### Installation Requirements: * [Bundler](https://bundler.io/) ``` # Install dependencies $ bundle ``` ### Usage ``` # List rake tasks $ rake -T rake build # Build mdtoc-0.0.2.gem into the pkg directory rake default # Run the build, rubocop:auto_correct, sorbet and test tasks rake install # Build and install mdtoc-0.0.2.gem into system gems rake install:local # Build and install mdtoc-0.0.2.gem into system gems without... rake release[remote] # Create tag v0.0.2 and build and push mdtoc-0.0.2.gem to ru... rake rubocop # Run RuboCop rake rubocop:auto_correct # Auto-correct RuboCop offenses rake sorbet # Run the Sorbet type checker rake test # Run tests # Run mdtoc with test inputs $ ruby -Ilib bin/mdtoc test/samples # Run mdtoc with test inputs, and write to a newly created output file $ f=$(mktemp) && ruby -Ilib bin/mdtoc -aco ${f} test/samples ; cat ${f} ```. %package doc Summary: Documentation for %{name} Requires: %{name} = %{version}-%{release} BuildArch: noarch %description doc Documentation for %{name}. %prep %setup -q -n %{gem_name}-%{version} %build # Create the gem as gem install only works on a gem file gem build ../%{gem_name}-%{version}.gemspec # %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir # by default, so that we can move it into the buildroot in %%install %gem_install %install mkdir -p %{buildroot}%{gem_dir} cp -a .%{gem_dir}/* \ %{buildroot}%{gem_dir}/ mkdir -p %{buildroot}%{_bindir} cp -a .%{_bindir}/* \ %{buildroot}%{_bindir}/ find %{buildroot}%{gem_instdir}/bin -type f | xargs chmod a+x %check pushd .%{gem_instdir} # ruby -e 'Dir.glob "./test/**/*_test.rb", &method(:require)' popd %files %dir %{gem_instdir} %{_bindir}/mdtoc %{gem_instdir}/bin %{gem_libdir} %exclude %{gem_cache} %{gem_spec} %files doc %doc %{gem_docdir} %changelog * Tue Aug 24 2021 mockbuilder - 0.1.5-1 - Initial package