bookshop-array-structures 1.4.6 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bookshop-array-structures.rb +50 -17
- data/lib/bookshop-array-structures/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c0a35b6a33b5ee4c41a6613b606215917ad4d8f96428e7a2c65a103cbd40bf5
|
4
|
+
data.tar.gz: 62fd2204b8c1686bc9ecc62b3854fbeb74503f1ebc81c64e832ba43ddadda1ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d4fa070d5331c027d10a54c444c5042d8cf5eebc91fac52a01e7af925213f13243e71f5942044a9a4ef3ca1ff82655f743ac5f90c7235155a32e3c9ee6436b
|
7
|
+
data.tar.gz: 27919b0a39c3495ef05121344c238a0e15a513f78bfdb60497f9744dc371771768f79fe71a5d38cec0e10d8208468109dae80cf915d8cdab404c62a52fd3be4d
|
@@ -4,8 +4,8 @@ require "toml-rb"
|
|
4
4
|
module Bookshop
|
5
5
|
class ArrayStructures
|
6
6
|
def self.get_story_name(path)
|
7
|
-
basename = path
|
8
|
-
return basename.split(
|
7
|
+
basename = get_component_type(path)
|
8
|
+
return basename.split(/-|\//).map(&:capitalize).join(" ")
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.get_component_type(path)
|
@@ -18,12 +18,9 @@ module Bookshop
|
|
18
18
|
return result
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
result['_component_type'] = get_component_type(path);
|
25
|
-
component.each_pair { |storyname, story|
|
26
|
-
story.each_pair {|key, value|
|
21
|
+
def self.handle_story(story, site)
|
22
|
+
result = {};
|
23
|
+
story.each_pair {|key, value|
|
27
24
|
if result.has_key?(key) && storyname != "defaults"
|
28
25
|
next
|
29
26
|
end
|
@@ -63,31 +60,67 @@ module Bookshop
|
|
63
60
|
end
|
64
61
|
site.config["_select_data"][new_key].push(option)
|
65
62
|
}
|
63
|
+
elsif key.include? "--"
|
64
|
+
new_key = key.split("--").first
|
65
|
+
result[new_key] = nil
|
66
66
|
else
|
67
67
|
result[key] = value
|
68
68
|
end
|
69
69
|
}
|
70
|
+
return result
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.transform_component(path, component, site)
|
74
|
+
result = { "value" => {} }
|
75
|
+
result["label"] = get_story_name(path)
|
76
|
+
result["value"]["_component_type"] = get_component_type(path)
|
77
|
+
component.each_pair { |storyname, story|
|
78
|
+
if storyname == "meta"
|
79
|
+
result.merge!(story)
|
80
|
+
else
|
81
|
+
result["value"].merge!(handle_story(story, site))
|
82
|
+
end
|
70
83
|
}
|
84
|
+
result["array_structures"] ||= [];
|
85
|
+
contains_component = result["array_structures"].select{|value| value == 'components'}.length > 0
|
86
|
+
if !contains_component && !result["_hidden"]
|
87
|
+
result["array_structures"].push("components")
|
88
|
+
end
|
89
|
+
result.delete("_hidden") unless result["_hidden"].nil?
|
71
90
|
return result
|
72
91
|
end
|
73
92
|
|
74
93
|
def self.build_array_structures(site)
|
75
|
-
base_path = ""
|
94
|
+
base_path = "_bookshop/components/"
|
76
95
|
if !site.theme.nil?
|
77
96
|
base_path = site.theme.root + "/_bookshop/components/"
|
78
97
|
end
|
79
98
|
site.config["_select_data"] ||= {}
|
80
99
|
site.config["_array_structures"] ||= {}
|
81
|
-
|
82
|
-
"values" => []
|
83
|
-
}
|
100
|
+
puts "📚 Parsing Stories..."
|
84
101
|
Dir.glob("**/*.stories.{toml,tml,tom,tm}", base: base_path).each do |f|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
"
|
89
|
-
|
102
|
+
begin
|
103
|
+
component = TomlRB.load_file(base_path + f)
|
104
|
+
rescue => exception
|
105
|
+
puts "❌ Error Parsing Story: " + f
|
106
|
+
puts exception
|
107
|
+
next
|
108
|
+
end
|
109
|
+
transformed_component = transform_component(f, component, site)
|
110
|
+
array_structures = transformed_component.delete("array_structures")
|
111
|
+
array_structures.each{|key|
|
112
|
+
begin
|
113
|
+
site.config["_array_structures"][key] ||= {}
|
114
|
+
site.config["_array_structures"][key]["values"] ||= []
|
115
|
+
site.config["_array_structures"][key]["values"].push(transformed_component)
|
116
|
+
rescue => exception
|
117
|
+
puts "❌ Error Adding Story to Array Structures: " + f
|
118
|
+
puts "🤔 Maybe your current _config.yml has conflicting array structures?"
|
119
|
+
end
|
120
|
+
}
|
90
121
|
end
|
122
|
+
puts "✅ Finshed Parsing Stories"
|
123
|
+
#puts site.config["_array_structures"].inspect
|
91
124
|
end
|
92
125
|
end
|
93
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookshop-array-structures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tate
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '3.0'
|
53
|
-
description:
|
53
|
+
description:
|
54
54
|
email:
|
55
55
|
- tate@cloudcannon.com
|
56
56
|
executables: []
|
@@ -64,7 +64,7 @@ homepage: https://github.com/cloudcannon/bookshop
|
|
64
64
|
licenses:
|
65
65
|
- MIT
|
66
66
|
metadata: {}
|
67
|
-
post_install_message:
|
67
|
+
post_install_message:
|
68
68
|
rdoc_options: []
|
69
69
|
require_paths:
|
70
70
|
- lib
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubygems_version: 3.0.3
|
83
|
-
signing_key:
|
83
|
+
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: A Jekyll plugin to generate array structures from bookshop
|
86
86
|
test_files: []
|