Fix some rubocop warnings

This commit is contained in:
VetheonGames 2024-06-14 23:00:56 -06:00
parent 8784d70807
commit 7697f49799
9 changed files with 40 additions and 37 deletions

View File

@ -1,12 +1,12 @@
# frozen_string_literal: true # frozen_string_literal: true
source "https://rubygems.org" source 'https://rubygems.org'
# Specify your gem's dependencies in todo_marker.gemspec # Specify your gem's dependencies in todo_marker.gemspec
gemspec gemspec
gem "rake", "~> 13.0" gem 'rake', '~> 13.0'
gem "rspec", "~> 3.0" gem 'rspec', '~> 3.0'
gem "rubocop", "~> 1.21" gem 'rubocop', '~> 1.21'

View File

@ -1,11 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/gem_tasks" require 'bundler/gem_tasks'
require "rspec/core/rake_task" require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) RSpec::Core::RakeTask.new(:spec)
require "rubocop/rake_task" require 'rubocop/rake_task'
RuboCop::RakeTask.new RuboCop::RakeTask.new

View File

@ -1,11 +1,11 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/setup" require 'bundler/setup'
require "todo_marker" require 'todo_marker'
# You can add fixtures and/or initialization code here to make experimenting # You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like. # with your gem easier. You can also use a different console, if you like.
require "irb" require 'irb'
IRB.start(__FILE__) IRB.start(__FILE__)

View File

@ -1,10 +1,12 @@
# bin/todo_marker # frozen_string_literal: true
#!/usr/bin/env ruby
require "todo_marker" # bin/todo_marker
# !/usr/bin/env ruby
require 'todo_marker'
if ARGV.empty? if ARGV.empty?
puts "Usage: todo_marker <directory>" puts 'Usage: todo_marker <directory>'
exit 1 exit 1
end end

View File

@ -1,8 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
# lib/todo_marker.rb # lib/todo_marker.rb
require "todo_marker/version" require 'todo_marker/version'
require "find" require 'find'
module TodoMarker module TodoMarker
TODO_REGEX = /# !!TODO!! "(.*?)"/ TODO_REGEX = /# !!TODO!! "(.*?)"/
@ -11,7 +11,7 @@ module TodoMarker
todos = [] todos = []
Find.find(directory) do |path| Find.find(directory) do |path|
next unless path.end_with?(".rb") next unless path.end_with?('.rb')
File.readlines(path).each_with_index do |line, index| File.readlines(path).each_with_index do |line, index|
next unless line.match(TODO_REGEX) next unless line.match(TODO_REGEX)
@ -28,7 +28,7 @@ module TodoMarker
end end
def self.create_todo_file(directory, todos) def self.create_todo_file(directory, todos)
File.open(File.join(directory, "TODO.md"), "w") do |file| File.open(File.join(directory, 'TODO.md'), 'w') do |file|
file.puts "# TODO List\n\n" file.puts "# TODO List\n\n"
todos.each do |todo| todos.each do |todo|
file.puts "- #{todo[:message]} (#{todo[:file]}:#{todo[:line]})" file.puts "- #{todo[:message]} (#{todo[:file]}:#{todo[:line]})"

View File

@ -2,5 +2,5 @@
# lib/todo_marker/version.rb # lib/todo_marker/version.rb
module TodoMarker module TodoMarker
VERSION = "0.1.0" VERSION = '0.1.0'
end end

View File

@ -1,10 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
require "todo_marker" require 'todo_marker'
RSpec.configure do |config| RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure # Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status" config.example_status_persistence_file_path = '.rspec_status'
# Disable RSpec exposing methods globally on `Module` and `main` # Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching! config.disable_monkey_patching!

View File

@ -1,11 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe TodoMarker do RSpec.describe TodoMarker do
it "has a version number" do it 'has a version number' do
expect(TodoMarker::VERSION).not_to be nil expect(TodoMarker::VERSION).not_to be nil
end end
it "does something useful" do it 'does something useful' do
expect(false).to eq(true) expect(false).to eq(true)
end end
end end

View File

@ -1,26 +1,27 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative "lib/todo_marker/version" require_relative 'lib/todo_marker/version'
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = "todo_marker" spec.name = 'todo_marker'
spec.version = TodoMarker::VERSION spec.version = TodoMarker::VERSION
spec.authors = ["VetheonGames"] spec.authors = ['VetheonGames']
spec.email = ["connor@pixelridgesoftworks.com"] spec.email = ['connor@pixelridgesoftworks.com']
spec.summary = "Standalone gem for generating TODO.md files" spec.summary = 'Standalone gem for generating TODO.md files'
spec.description = "This standalone gem takes in source code files written in Ruby, and generates a TODO.md file from spec.description = "This standalone gem takes in source code files written in Ruby, and generates a TODO.md file from
them. them.
mark things to add to the TODO.md with the `# !!TODO!!` magic comment" mark things to add to the TODO.md with the `# !!TODO!!` magic comment"
spec.homepage = "https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Todo_Marker" spec.homepage = 'https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Todo_Marker'
spec.license = "MIT" spec.license = 'MIT'
spec.required_ruby_version = ">= 3.2" spec.required_ruby_version = '>= 3.2'
spec.metadata["homepage_uri"] = spec.homepage spec.metadata['homepage_uri'] = spec.homepage
spec.metadata["source_code_uri"] = "https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Todo_Marker" spec.metadata['source_code_uri'] = 'https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Todo_Marker'
spec.files = Dir["lib/**/*.rb", "bin/*"] spec.files = Dir['lib/**/*.rb', 'bin/*']
spec.bindir = "bin" spec.bindir = 'bin'
spec.executables = ["todo_marker"] spec.executables = ['todo_marker']
spec.require_paths = ["lib"] spec.require_paths = ['lib']
spec.metadata['rubygems_mfa_required'] = 'true'
end end