advent_of_ruby 0.3.3 → 0.3.4

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: 7157738053e4ec2024b29f3e309d1b8629bf82a72b5478cba1391bb581770ba4
4
- data.tar.gz: 47fcaf827ea7994744420bcb300739eba636396d7c0510391e2baa517b3b7e3f
3
+ metadata.gz: 35a9db6d1ec1dcc7cee17157e2ed4df19f3617c9882b68d22143e36985e73239
4
+ data.tar.gz: c2ba5d624f05063b5e5c70b3a04346435d1d57964050fbb14b94a63c5323f9ca
5
5
  SHA512:
6
- metadata.gz: c6210bc305da01a6b3ada2b2394e162e3c57762f2a6fac902b787be3d117a3857fc8889d3c1428d32ae455a7fe96f02778461517018d4dede39418468591ab4c
7
- data.tar.gz: 77b145c6665bff896e9816c3930f53e06878c6b90fbe5fee05fe28e326e91c3e78e1d3922599472dc2f2901bc28f49fd7d8ea78cd88daa5d5b6809fc3376e62e
6
+ metadata.gz: a95ced50daf64f11587136162bce59c260756e124668da1c02bb8644647126271d9063d6897b4ca67c4eec0193419de51d2e58d6994f1358804ea7ad0af78f13
7
+ data.tar.gz: 658ab7ec7e10ee74889dd94abdbfdc7e7257bacdb2cf3cba5ffdde828a2e9d98ef099fece75020a1880a8c66cfbf76b97a0b3f48edf7d7649408cff6a2aec982
@@ -13,7 +13,7 @@ module Arb
13
13
  File.write(file_path, template(year:, day:))
14
14
  end
15
15
 
16
- Formatter.format(file_path)
16
+ Formatters::RuboCop.format(file_path)
17
17
 
18
18
  file_path
19
19
  end
@@ -13,7 +13,7 @@ module Arb
13
13
  File.write(file_path, template(year:, day:))
14
14
  end
15
15
 
16
- Formatter.format(file_path)
16
+ Formatters::RuboCop.format(file_path)
17
17
 
18
18
  file_path
19
19
  end
@@ -0,0 +1,24 @@
1
+ module Formatters
2
+ module RuboCop
3
+ # Formats newly created files using RuboCop if it is bundled at the top
4
+ # level, i.e. as `gem "rubocop"` in the Gemfile. Does nothing if RuboCop
5
+ # isn't bundled or is just a dependency, e.g. of Standard.
6
+ def self.format(file_path)
7
+ return unless rubocop_bundled_at_top_level?
8
+
9
+ begin
10
+ require "rubocop"
11
+ RuboCop::CLI.new.run(["-A", file_path, "--out", File::NULL])
12
+ rescue LoadError
13
+ # Do nothing if RuboCop is bundled but not actually installed.
14
+ end
15
+ end
16
+
17
+ private_class_method def self.rubocop_bundled_at_top_level?
18
+ require "bundler"
19
+ Bundler.definition.dependencies.any? { it.name == "rubocop" }
20
+ rescue LoadError, Bundler::GemfileNotFound
21
+ false
22
+ end
23
+ end
24
+ end
data/lib/arb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arb
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advent_of_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Vogel
@@ -2705,7 +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
+ - lib/arb/formatters/rubocop.rb
2709
2709
  - lib/arb/version.rb
2710
2710
  - lib/download_solutions/api/github.rb
2711
2711
  - lib/download_solutions/api/github/repos.rb
data/lib/arb/formatter.rb DELETED
@@ -1,22 +0,0 @@
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