Skip to content

Commit

Permalink
Add export of catalog as json to build directory
Browse files Browse the repository at this point in the history
  • Loading branch information
colszowka committed Oct 18, 2017
1 parent 96356f4 commit 2405bd7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coverage
tmp
build
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ DEPENDENCIES
guard-rubocop
json-schema
overcommit
rake
rspec
rubocop
rubocop-rspec
Expand Down
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions build/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The Ruby Toolbox Catalog Export

6 changes: 6 additions & 0 deletions lib/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2405bd7

Please sign in to comment.