aoc_generator 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c2e50281fb4c3f191cbe11ca0417cb2ca969178f87a124572a5b34e07e01b17
4
- data.tar.gz: b00f142cd08f4ca55e651974c7d923f2c62515a49a4f07c4d3443f5584f24e4d
3
+ metadata.gz: 224ddd170a1b90b1f49ec1b74ae9f866469dfe4613f7e79c74fe21bc7e50df6e
4
+ data.tar.gz: ce15c6c8269ce2fbfcbb9a13c435c2ff05f3f87595ab073eec0452fbd261ec4c
5
5
  SHA512:
6
- metadata.gz: ce6d572095bf2acc47c429e5ece1fee0c335ed0403c94c47f33063a996193d0848deacf49a981fa18546b418d05c2425a553317f1677c5fb714d3de9163caf18
7
- data.tar.gz: 93ccfd82a61cb9ea1eb8b096cfa1c0a922a002abb923c93f06c25796a5af6d4356be28e06a88d9b62d4e489f04328e15d37569c24a7480cec366c57560bdd0ab
6
+ metadata.gz: 39b6cb3425c18ce2f88628e4d44a603481578e3cdb49096e252c10ff2edc1994c748ba859be5f67c6b6f3360331dd0caf4bbaad608e573939b13f1875fb018fb
7
+ data.tar.gz: 29e5215ba788af0c801933c96167f1872bd1c54f722257c9118fa981cd5a9b49b3821cc7f5f64a2bb1592121bd9a2c1cebc2ab651d7a79e0c840d4f409045767
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.4] - 2024-11-28
3
+ ## [0.1.6] - 2024-11-29
4
+
5
+ - Handle <ul> and <ol> HTML elements
6
+
7
+ ## [0.1.5] - 2024-11-28
8
+
9
+ - Generate main file with class methods, rather than instance methods
10
+
11
+ ## [0.1.4]
4
12
 
5
13
  - Add test data to spec file
6
14
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aoc_generator (0.1.4)
4
+ aoc_generator (0.1.6)
5
5
  fileutils (~> 1.7)
6
6
  nokogiri (~> 1.16)
7
7
  thor (~> 1.3)
@@ -65,15 +65,11 @@ module AdventOfCodeGenerator
65
65
  module #{@username.capitalize}
66
66
  module Year#{@year}
67
67
  class Day#{@day}
68
- def initialize(input)
69
- @input = input
70
- end
71
-
72
- def part_one
68
+ def self.part_one(input)
73
69
  raise NotImplementedError
74
70
  end
75
71
 
76
- def part_two
72
+ def self.part_two(input)
77
73
  raise NotImplementedError
78
74
  end
79
75
  end
@@ -49,15 +49,20 @@ module AdventOfCodeGenerator
49
49
 
50
50
  def process_node(node)
51
51
  case node.name
52
- when "h2"
53
- "## #{node.text}\n"
54
- when "p"
55
- "#{process_paragraph(node)}\n"
56
- when "pre"
57
- "```sh\n#{node.text.strip}\n```\n"
52
+ when "h2" then "## #{node.text}\n"
53
+ when "ul" then "#{process_list(node, "-")}\n"
54
+ when "ol" then"#{process_list(node, "1.")}\n"
55
+ when "p" then "#{process_paragraph(node)}\n"
56
+ when "pre" then "```sh\n#{node.text.strip}\n```\n"
58
57
  end
59
58
  end
60
59
 
60
+ def process_list(list_node, marker)
61
+ list_node.css("li").map do |item|
62
+ "#{marker} #{process_paragraph(item)}"
63
+ end.join("\n")
64
+ end
65
+
61
66
  def process_paragraph(para)
62
67
  para.inner_html
63
68
  .gsub(%r{<a[^>]*href="([^"]*)"[^>]*>(.*?)</a>}, '[\2](\1)')
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdventOfCodeGenerator
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
 
6
6
  class Error < StandardError; end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aoc_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Nguyen