Skip to content

Commit 568ad46

Browse files
committed
standardrb --fix
1 parent ffc59c8 commit 568ad46

File tree

6 files changed

+49
-51
lines changed

6 files changed

+49
-51
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ task default: :deploy
99
# Standard set of tasks, which you can customize if you wish:
1010
#
1111
desc "Build the Bridgetown site for deployment"
12-
task :deploy => [:clean, "frontend:build"] do
12+
task deploy: [:clean, "frontend:build"] do
1313
Bridgetown::Commands::Build.start
1414
end
1515

plugins/curriculum_parser.rb

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class CurriculumParser
22
class ParsingError < StandardError; end
33

4-
DEFAULT_CONFIG = { ignore_incomplete?: true }
4+
DEFAULT_CONFIG = {ignore_incomplete?: true}
55

66
private attr_reader :markdown_string, :config
77

@@ -16,8 +16,8 @@ def initialize(markdown_string, custom_config: {})
1616
def parse
1717
markdown_string.gsub(/^\s*<!--.+?-->+/m, "")
1818
.gsub(" #TODO", "")
19-
.then { extract_title_and_intro(_1) }
20-
.then { extract_content(_1) }
19+
.then { extract_title_and_intro(it) }
20+
.then { extract_content(it) }
2121
end
2222

2323
private
@@ -35,7 +35,7 @@ def extract_title_and_intro(markdown_string)
3535
{
3636
title:,
3737
intro:,
38-
content:,
38+
content:
3939
}
4040
}
4141
end
@@ -47,18 +47,17 @@ def extract_content(title_intro_content_hash)
4747
title_intro_content_hash[:content] = {}
4848
return {
4949
**title_intro_content_hash,
50-
content: {},
50+
content: {}
5151
}
5252
end
5353

5454
heading_strings_and_procs = [
5555
["## ", ->(heading) { heading.delete_prefix("## ") }],
5656
["### ", ->(heading) { heading.delete_prefix("### ") }],
5757
["- **", ->(heading) {
58-
h4 = heading.match(/- \*\*(.+)\*\*/).captures.first
59-
h4.delete_suffix(":").delete_suffix(".")
60-
}
61-
],
58+
h4 = heading.match(/- \*\*(.+)\*\*/).captures.first
59+
h4.delete_suffix(":").delete_suffix(".")
60+
}]
6261
]
6362

6463
content =
@@ -70,7 +69,7 @@ def extract_content(title_intro_content_hash)
7069

7170
{
7271
**title_intro_content_hash,
73-
content:,
72+
content:
7473
}
7574
end
7675

@@ -88,7 +87,7 @@ def recursive_parse(content, heading_strings_and_procs:, exclude_sections: [])
8887

8988
content
9089
.split(/\n(?=#{Regexp.escape(next_heading_string)})/)
91-
.reject { !_1.start_with?(next_heading_string) }
90+
.reject { !it.start_with?(next_heading_string) }
9291
.map { |heading_and_content|
9392
heading_and_content.strip.split("\n", 2)
9493
}
@@ -103,14 +102,14 @@ def recursive_parse(content, heading_strings_and_procs:, exclude_sections: [])
103102
next_heading_proc.call(formatted_heading)
104103
}
105104
.reject { |k, v| exclude_sections.include?(k.downcase) }
106-
.transform_values { _1&.strip&.presence }
105+
.transform_values { it&.strip&.presence }
107106
.each { |heading, content_under|
108107
raise "No content under \"#{heading}\"" if content_under.nil?
109108
}
110109
.transform_values { |content_under|
111110
heading_strings_and_procs_under = heading_strings_and_procs
112111
.filter {
113-
heading_string = _1.first
112+
heading_string = it.first
114113
content_under.match?(/^#{Regexp.escape(heading_string)}/)
115114
}
116115

@@ -182,10 +181,10 @@ def parse_list(markdown_string)
182181
\z}x
183182
)
184183
&.named_captures
185-
&.transform_values { _1&.strip&.presence }
184+
&.transform_values { it&.strip&.presence }
186185
&.transform_keys(&:to_sym) ||
187-
(raise(ParsingError, "Could not parse: #{line}") \
188-
if line.strip.start_with?("- "))
186+
(raise(ParsingError, "Could not parse: #{line}") \
187+
if line.strip.start_with?("- "))
189188
}
190189
.compact
191190
.each { |item|
@@ -199,4 +198,4 @@ def parse_list(markdown_string)
199198
item.slice(:name, :url, :description, :image, :free)
200199
}
201200
end
202-
end
201+
end

plugins/site_builder.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
class SiteBuilder < Bridgetown::Builder
22
# write builders which subclass SiteBuilder in plugins/builders
33
end
4-

test/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Test
1616
Minitest::Reporters.use! [
1717
Minitest::Reporters::DefaultReporter.new(
1818
color: true
19-
),
19+
)
2020
]
2121

2222
Minitest::Test.class_eval do

test/test_curriculum_parser.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative "./helper"
1+
require_relative "helper"
22

33
class TestCurriculumParser < Minitest::Test
44
def self.title = "My Ruby road map"
@@ -20,15 +20,15 @@ def self.prev_parsed
2020

2121
example "blank file",
2222
markdown: "\n",
23-
parsed: { title: nil, intro: nil, content: {} }
23+
parsed: {title: nil, intro: nil, content: {}}
2424

2525
example "title",
2626
markdown: "# #{title}\n",
27-
parsed: { title:, intro: nil, content: {} }
27+
parsed: {title:, intro: nil, content: {}}
2828

2929
example "intro",
3030
markdown: "# #{title}\n#{intro}",
31-
parsed: { title:, intro:, content: {} }
31+
parsed: {title:, intro:, content: {}}
3232

3333
example "empty sections",
3434
markdown: <<~MD,
@@ -43,7 +43,7 @@ def self.prev_parsed
4343
parsed: {
4444
title:,
4545
intro: nil,
46-
content: { "Preface" => nil, "Basics" => nil },
46+
content: {"Preface" => nil, "Basics" => nil}
4747
}
4848

4949
example "empty sections with minimal line breaks",
@@ -103,10 +103,10 @@ def self.prev_parsed
103103
content: {
104104
"Advanced" => {
105105
"Quantum computing" => nil,
106-
"The meaning of life" => nil,
106+
"The meaning of life" => nil
107107
},
108-
"Galaxy brain" => nil,
109-
},
108+
"Galaxy brain" => nil
109+
}
110110
}
111111

112112
example "empty subsections with minimal line breaks",
@@ -152,11 +152,11 @@ def self.prev_parsed
152152
"Advanced" => {
153153
"Quantum computing" => {
154154
"Basics" => nil,
155-
"Experimental tech" => nil,
155+
"Experimental tech" => nil
156156
},
157-
"The meaning of life" => nil,
158-
},
159-
},
157+
"The meaning of life" => nil
158+
}
159+
}
160160
}
161161

162162
example "empty subsubsections with minimal line breaks",
@@ -200,26 +200,26 @@ def self.prev_parsed
200200
url: "https://www.theodinproject.com/paths/full-stack-ruby-on-rails/courses/ruby",
201201
description: "[Ruby track](https://www.theodinproject.com/paths/full-stack-ruby-on-rails/courses/ruby)",
202202
image: "https://example.com/top.png",
203-
free: true,
203+
free: true
204204
},
205205
{
206206
name: "GoRails - Ruby for Beginners",
207207
url: "https://gorails.com/series/ruby-for-beginners",
208208
description: "Great if you prefer videos.",
209209
image: "https://example.com/gorails.png",
210-
free: true,
211-
},
210+
free: true
211+
}
212212
],
213213
"Intermediate" => [
214214
{
215215
name: "Something",
216216
url: "http://somethingsomethingsomething.com",
217217
description: nil,
218218
image: "https://example.com/something.png",
219-
free: false,
220-
},
221-
],
222-
},
219+
free: false
220+
}
221+
]
222+
}
223223
}
224224

225225
example "content under subsections",
@@ -249,11 +249,11 @@ def self.prev_parsed
249249
url: "https://www.abcbootcamp.com/tracks/quantum",
250250
description: nil,
251251
image: "https://example.com/quantum.png",
252-
free: true,
253-
},
254-
],
255-
},
256-
},
252+
free: true
253+
}
254+
]
255+
}
256+
}
257257
}
258258

259259
example "content under subsubsections",
@@ -283,12 +283,12 @@ def self.prev_parsed
283283
url: "https://www.abcbootcamp.com/tracks/quantum",
284284
description: nil,
285285
image: "https://example.com/quantum.png",
286-
free: true,
287-
},
288-
],
289-
},
290-
},
291-
},
286+
free: true
287+
}
288+
]
289+
}
290+
}
291+
}
292292
}
293293

294294
# Test cases generated from the data above.

test/test_homepage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative "./helper"
1+
require_relative "helper"
22

33
class TestHomepage < Minitest::Test
44
context "homepage" do

0 commit comments

Comments
 (0)