advent_of_ruby 0.3.2 → 0.3.3

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: 5ced52377239ccf4263bbca0ee7711f31640d41bc48938285f899fea20349c26
4
- data.tar.gz: fe2692a5d8966673315d9c24a51ada3b37e84b11b18485d97298e6526eec2db6
3
+ metadata.gz: 7157738053e4ec2024b29f3e309d1b8629bf82a72b5478cba1391bb581770ba4
4
+ data.tar.gz: 47fcaf827ea7994744420bcb300739eba636396d7c0510391e2baa517b3b7e3f
5
5
  SHA512:
6
- metadata.gz: 186f0d35ac1fa7654711f66db97973559286990de4271d600e455f516d00b7cd4b70dd6275194e245aa5211d4a0f7f3fd32ecf482ed699cd54fe4df069372a01
7
- data.tar.gz: efb48cc15cfa78e6f880cb783c9e2a6b426d7e387aa292ec607ce7b6a713d6843be876ba5542d8fc9636fbb3cb810a4a64c3983052038dc0efa2d85b222bd256
6
+ metadata.gz: c6210bc305da01a6b3ada2b2394e162e3c57762f2a6fac902b787be3d117a3857fc8889d3c1428d32ae455a7fe96f02778461517018d4dede39418468591ab4c
7
+ data.tar.gz: 77b145c6665bff896e9816c3930f53e06878c6b90fbe5fee05fe28e326e91c3e78e1d3922599472dc2f2901bc28f49fd7d8ea78cd88daa5d5b6809fc3376e62e
@@ -48,10 +48,6 @@
48
48
 
49
49
  This solution doesn't work for all inputs right, wouldn't `c -> b` throw a `NameError`?
50
50
  :replies: []
51
- - :author: "[deleted]"
52
- :url: https://www.reddit.com/r/adventofcode/comments/3vr4m4/day_7_solutions/cxr1w6y
53
- :body: "[deleted]"
54
- :replies: []
55
51
  - :author: gnuconsulting
56
52
  :url: https://www.reddit.com/r/adventofcode/comments/3vr4m4/day_7_solutions/cxq2b7s
57
53
  :body: |-
@@ -10,11 +10,7 @@
10
10
  ```
11
11
 
12
12
  Just change the argument to rotate to 1 for part 1.
13
- :replies:
14
- - :author: "[deleted]"
15
- :url: https://www.reddit.com/r/adventofcode/comments/7gsrc2/2017_day_1_solutions/dqltuo8
16
- :body: "[deleted]"
17
- :replies: []
13
+ :replies: []
18
14
  - :author: jschulenklopper
19
15
  :url: https://www.reddit.com/r/adventofcode/comments/7gsrc2/2017_day_1_solutions/dqlq7z2
20
16
  :body: |-
@@ -47,14 +47,14 @@ module Arb
47
47
  "# #{(solutions.count > 1) ? "Solutions" : "Solution"} by #{author}\n" +
48
48
  solutions
49
49
  .map { |solution|
50
- <<~SOLUTION
50
+ <<~END
51
51
  #{"## #{solution[:name]}\n" if solutions.count > 1}#{solution[:url]}
52
52
 
53
53
  ```ruby
54
54
  #{solution[:solution]}
55
55
  ```
56
56
 
57
- SOLUTION
57
+ END
58
58
  }
59
59
  .join
60
60
  }
@@ -79,14 +79,14 @@ module Arb
79
79
  reddit_comment_to_markdown(reply, level: level + 1)
80
80
  }.join("\n\n")
81
81
 
82
- <<~COMMENT.gsub(/(?:\n\s*){3,}/, "\n\n")
82
+ <<~END.gsub(/(?:\n\s*){3,}/, "\n\n")
83
83
  #{"#" * (level + 1)} #{"↳" * level}#{level.zero? ? "Solution by" : "Reply by"} #{comment[:author]}
84
84
  #{comment[:url]}
85
85
 
86
86
  #{comment[:body]}
87
87
 
88
88
  #{replies unless replies.empty?}
89
- COMMENT
89
+ END
90
90
  end
91
91
  end
92
92
  end
@@ -2,18 +2,18 @@ module Arb
2
2
  module Cli
3
3
  class WorkingDirectory
4
4
  FILES = {
5
- ".gitignore" => <<~FILE,
5
+ ".gitignore" => <<~END,
6
6
  input/**/*
7
7
  instructions/**/*
8
8
  others/**/*
9
9
  .env
10
- FILE
10
+ END
11
11
  ".ruby-version" => "3.3.0\n",
12
- "Gemfile" => <<~FILE,
12
+ "Gemfile" => <<~END,
13
13
  source "https://rubygems.org"
14
14
  ruby file: ".ruby-version"
15
- FILE
16
- File.join("spec", "spec_helper.rb") => <<~FILE
15
+ END
16
+ File.join("spec", "spec_helper.rb") => <<~END
17
17
  require "debug"
18
18
 
19
19
  Dir[File.join(__dir__, "..", "src", "**", "*.rb")].each do |file|
@@ -21,7 +21,7 @@ module Arb
21
21
  end
22
22
 
23
23
 
24
- FILE
24
+ END
25
25
  }
26
26
 
27
27
  ENV_KEYS = ["EDITOR_COMMAND", "AOC_COOKIE"]
@@ -71,7 +71,7 @@ module Arb
71
71
  end
72
72
 
73
73
  year = Integer(year, exception: false) || (raise InputError, "Year must be a number.")
74
- day = Integer(day, exception: false) || (raise InputError, "Day must be a number.")
74
+ day = Integer(day.delete_prefix("0"), exception: false) || (raise InputError, "Day must be a number.")
75
75
 
76
76
  unless year.between?(2015, Date.today.year)
77
77
  raise InputError, "Year must be between 2015 and this year."
@@ -13,11 +13,13 @@ module Arb
13
13
  File.write(file_path, template(year:, day:))
14
14
  end
15
15
 
16
+ Formatter.format(file_path)
17
+
16
18
  file_path
17
19
  end
18
20
 
19
21
  def self.template(year:, day:)
20
- <<~SRC
22
+ <<~END
21
23
  # https://adventofcode.com/#{year}/day/#{day.delete_prefix("0")}
22
24
  module Year#{year}
23
25
  class Day#{day}
@@ -34,7 +36,7 @@ module Arb
34
36
  end
35
37
  end
36
38
  end
37
- SRC
39
+ END
38
40
  end
39
41
  end
40
42
  end
@@ -13,19 +13,21 @@ module Arb
13
13
  File.write(file_path, template(year:, day:))
14
14
  end
15
15
 
16
+ Formatter.format(file_path)
17
+
16
18
  file_path
17
19
  end
18
20
 
19
21
  def self.template(year:, day:)
20
- <<~SPECS
22
+ <<~END_OUTER
21
23
  RSpec.describe Year#{year}::Day#{day} do
22
- let(:input) {
24
+ let(:input) do
23
25
  StringIO.new(
24
- <<~IN
26
+ <<~END
25
27
  something
26
- IN
28
+ END
27
29
  )
28
- }
30
+ end
29
31
 
30
32
  it "solves Part One" do
31
33
  expect(subject.part_1(input)).to eq(:todo)
@@ -35,7 +37,7 @@ module Arb
35
37
  expect(subject.part_2(input)).to eq(:todo)
36
38
  end
37
39
  end
38
- SPECS
40
+ END_OUTER
39
41
  end
40
42
  end
41
43
  end
@@ -0,0 +1,22 @@
1
+ begin
2
+ gem "rubocop"
3
+ require "rubocop"
4
+ rescue LoadError
5
+ # If RuboCop isn't available, no formatting will be done
6
+ end
7
+
8
+ module Formatter
9
+ class << self
10
+ def format(file_path)
11
+ return unless rubocop_loaded?
12
+
13
+ RuboCop::CLI.new.run(["-A", file_path, "--out", File::NULL])
14
+ end
15
+
16
+ private
17
+
18
+ def rubocop_loaded?
19
+ defined?(RuboCop)
20
+ end
21
+ end
22
+ end
data/lib/arb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arb
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -49,39 +49,6 @@ module DownloadSolutions
49
49
  }
50
50
  }
51
51
  }
52
-
53
- # def other_solutions(year:, day:, part:)
54
- # "# #{year} Day #{day} Part #{part}\n\n" +
55
- # PATHS
56
- # .map { |username, path_builder|
57
- # actual_path = nil
58
- # solution = nil
59
- # paths = path_builder.call(year:, day:, part:)
60
-
61
- # paths.each do |path|
62
- # next if solution
63
- # response = connection.get("/#{username}/#{path.sub("/tree/", "/")}")
64
- # next if response.status == 404
65
-
66
- # actual_path = path
67
- # solution = (EDITS[username] || :itself.to_proc).call(response.body)
68
- # end
69
-
70
- # if solution
71
- # <<~SOLUTION
72
- # # ------------------------------------------------------------------------------
73
- # # #{username}: #{UI_URI}/#{username}/#{actual_path}
74
- # # ------------------------------------------------------------------------------
75
-
76
- # #{solution}
77
-
78
- # SOLUTION
79
- # end
80
- # }
81
- # .compact
82
- # .join
83
- # .strip + "\n"
84
- # end
85
52
  end
86
53
  end
87
54
  end
@@ -3,7 +3,7 @@ module DownloadSolutions
3
3
  class Reddit
4
4
  class RejectUnwantedReplies
5
5
  # Filters out replies that are not gennerally relevant for posterity:
6
- # - removed with no replies
6
+ # - removed/deleted with no replies
7
7
  # - by moderators
8
8
  # - by bots
9
9
  #
@@ -21,7 +21,7 @@ module DownloadSolutions
21
21
  end
22
22
 
23
23
  comment[:replies].reject! do
24
- (it[:body].strip == "[removed]" && it[:replies].empty?) ||
24
+ (["[removed]", "[deleted]"].include?(it[:body].strip) && it[:replies].empty?) ||
25
25
  %w[AutoModerator daggerdragon backtickbot].include?(it[:author])
26
26
  end
27
27
  end
@@ -12,7 +12,7 @@ module DownloadSolutions
12
12
  repos = Api::Github::REPOS
13
13
  if author
14
14
  if repos.key?(author)
15
- repos = repos.select { _1 == author }
15
+ repos = repos.select { it == author }
16
16
  else
17
17
  raise InputError, "Repo author #{PASTEL.blue(author)} not found."
18
18
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advent_of_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Vogel
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: benchmark
@@ -2705,6 +2705,7 @@ files:
2705
2705
  - lib/arb/files/other_solutions.rb
2706
2706
  - lib/arb/files/solution.rb
2707
2707
  - lib/arb/files/spec.rb
2708
+ - lib/arb/formatter.rb
2708
2709
  - lib/arb/version.rb
2709
2710
  - lib/download_solutions/api/github.rb
2710
2711
  - lib/download_solutions/api/github/repos.rb
@@ -2739,14 +2740,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
2739
2740
  requirements:
2740
2741
  - - "~>"
2741
2742
  - !ruby/object:Gem::Version
2742
- version: 3.4.1
2743
+ version: 3.4.4
2743
2744
  required_rubygems_version: !ruby/object:Gem::Requirement
2744
2745
  requirements:
2745
2746
  - - ">="
2746
2747
  - !ruby/object:Gem::Version
2747
2748
  version: '0'
2748
2749
  requirements: []
2749
- rubygems_version: 3.6.2
2750
+ rubygems_version: 3.6.7
2750
2751
  specification_version: 4
2751
2752
  summary: CLI for Advent of Code in Ruby, via the `arb` command.
2752
2753
  test_files: []