diff --git a/README.md b/README.md new file mode 100644 index 0000000..362d811 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# Jocasta +![Gem](https://img.shields.io/gem/v/jocasta.svg) + + +Utility to extract a section of a Markdown file and write it into a separate file. + +## Installation + +`gem install jocasta` + +## Usage + +`jocasta [input] [output] [level] [section] [...options]` + +* __input__ - input markdown file. +* __output__ - Markdown file that will be written. +* __level__ - Level of the section to be extracted (`# Level1` `## Level2` `### Level3`) +* __section__ - Section to be extracted. It will also extract sub-sections inside this section. + +Options: +* __--title__ - Title that will replace the section title in the output file. If none, it will use the same title. + +Named after [Jocasta Nu](https://starwars.fandom.com/wiki/Jocasta_Nu) from Star Wars. +Based on script made by [ReSwift](https://github.com/ReSwift/ReSwift/blob/master/.scripts/doc-preprocessor) diff --git a/bin/jocasta b/bin/jocasta index 2b71ceb..422233a 100755 --- a/bin/jocasta +++ b/bin/jocasta @@ -33,7 +33,7 @@ end def require_args(args, count) return unless args.length != count - puts 'usage: docgen [input] [output] [level] [section] [...options]' + puts 'usage: jocasta [input] [output] [level] [section] [...options]' exit 1 end @@ -80,7 +80,11 @@ level_hash = '' (1..level).each do level_hash += '#' end -result = "#{level_hash} #{options[:title]}\n" + result if options[:title] +result = if options[:title] + "#{level_hash} #{options[:title]}\n" + result + else + "#{level_hash} #{section_name}\n" + result + end # ----- diff --git a/jocasta.gemspec b/jocasta.gemspec index c49130c..5395d65 100644 --- a/jocasta.gemspec +++ b/jocasta.gemspec @@ -2,12 +2,14 @@ Gem::Specification.new do |s| s.name = 'jocasta' s.version = '0.0.1' s.date = '2019-07-24' - s.summary = "Ruby gem to extract sections of a Markdown file into a separate file." - s.description = "Ruby gem to extract sections of a Markdown file into a separate file." + s.summary = "Utility to extract a section of a Markdown file and write it into a separate file." s.authors = ["Duarte Pinto"] s.email = 'duartemr.pinto@gmail.com' s.executables << 'jocasta' - s.homepage = - 'https://rubygems.org/gems/jocasta' - s.license = 'Apache-2.0' + s.homepage = 'https://rubygems.org/gems/jocasta' + s.license = 'Apache-2.0' + s.metadata = { + "source_code_uri" => "https://github.com/duartepinto/jocasta", + "bug_tracker_uri" => "https://github.com/duartepinto/jocasta/issues" + } end