diff --git a/.gitignore b/.gitignore index 96a0d9db..c5b42d45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ coverage tmp +build diff --git a/Gemfile b/Gemfile index d5345979..cc6e0eef 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ source "https://rubygems.org" ruby File.read(File.join(__dir__, ".ruby-version")).strip gem "json-schema" +gem "rake" group :test do gem "rspec" diff --git a/Gemfile.lock b/Gemfile.lock index 8aad434b..0e1fa1bd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -105,6 +105,7 @@ DEPENDENCIES guard-rubocop json-schema overcommit + rake rspec rubocop rubocop-rspec diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..a0288bae --- /dev/null +++ b/Rakefile @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +task :environment do + require File.join(__dir__, "lib/catalog") +end + +desc "Generates and exports the catalog to the default location" +task export: :environment do + Catalog.new.export +end diff --git a/build/index.md b/build/index.md new file mode 100644 index 00000000..a4efa17a --- /dev/null +++ b/build/index.md @@ -0,0 +1,2 @@ +# The Ruby Toolbox Catalog Export + diff --git a/lib/catalog.rb b/lib/catalog.rb index c6debb4f..d35c1c79 100644 --- a/lib/catalog.rb +++ b/lib/catalog.rb @@ -21,6 +21,12 @@ def as_json } end + def export(path: File.join(__dir__, "../build/catalog.json")) + File.open(path, "w+") do |f| + f.puts JSON.pretty_generate(as_json) + end + end + private def category_groups