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 +4 -4
- data/lib/arb/files/solution.rb +1 -1
- data/lib/arb/files/spec.rb +1 -1
- data/lib/arb/formatters/rubocop.rb +24 -0
- data/lib/arb/version.rb +1 -1
- metadata +2 -2
- data/lib/arb/formatter.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35a9db6d1ec1dcc7cee17157e2ed4df19f3617c9882b68d22143e36985e73239
|
4
|
+
data.tar.gz: c2ba5d624f05063b5e5c70b3a04346435d1d57964050fbb14b94a63c5323f9ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a95ced50daf64f11587136162bce59c260756e124668da1c02bb8644647126271d9063d6897b4ca67c4eec0193419de51d2e58d6994f1358804ea7ad0af78f13
|
7
|
+
data.tar.gz: 658ab7ec7e10ee74889dd94abdbfdc7e7257bacdb2cf3cba5ffdde828a2e9d98ef099fece75020a1880a8c66cfbf76b97a0b3f48edf7d7649408cff6a2aec982
|
data/lib/arb/files/solution.rb
CHANGED
data/lib/arb/files/spec.rb
CHANGED
@@ -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
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.
|
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/
|
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
|