-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
015d013
commit 632c9e6
Showing
8 changed files
with
417 additions
and
481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/_site | ||
/docs/_data/unstable | ||
/docs/.jekyll-metadata | ||
node_modules | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Docs | ||
class Mappings | ||
def reverse_shopify_mapping_rules(mappings) | ||
mappings.each do |mapping| | ||
if shopify_mapping?(mapping) | ||
reverse_mapping_rules(mapping) | ||
end | ||
end | ||
end | ||
|
||
def reverse_mapping_rules(mapping) | ||
mapping["rules"].each do |rule| | ||
rule["output"]["category"].each_with_index do |output, index| | ||
if index == 0 | ||
rule["input"], rule["output"] = { "category" => output }, {"category" => [rule["input"]["category"]]} | ||
else | ||
mapping.push = build_rule(input: output, output: rule["input"]["category"]) | ||
end | ||
end | ||
end | ||
end | ||
|
||
def shopify_mapping?(mapping) | ||
mapping["output_taxonomy"].include?("shopify") | ||
end | ||
|
||
def build_rule(input:, output:) | ||
{ | ||
"input" => {"category" => input}, | ||
"output" => {"category" => [output]} | ||
} | ||
end | ||
end | ||
end |
Oops, something went wrong.