fix filesystem

This commit is contained in:
VetheonGames 2024-06-14 22:59:20 -06:00
parent cbb8aa685d
commit 8784d70807
12 changed files with 164 additions and 0 deletions

3
.rspec Normal file
View File

@ -0,0 +1,3 @@
--format documentation
--color
--require spec_helper

12
Gemfile Normal file
View File

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

12
Rakefile Normal file
View File

@ -0,0 +1,12 @@
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
require "rubocop/rake_task"
RuboCop::RakeTask.new
task default: %i[spec rubocop]

11
bin/console Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "todo_marker"
# 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.
require "irb"
IRB.start(__FILE__)

8
bin/setup Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here

18
bin/todo_marker Executable file
View File

@ -0,0 +1,18 @@
# bin/todo_marker
#!/usr/bin/env ruby
require "todo_marker"
if ARGV.empty?
puts "Usage: todo_marker <directory>"
exit 1
end
directory = ARGV[0]
unless Dir.exist?(directory)
puts "Directory #{directory} does not exist"
exit 1
end
TodoMarker.generate_todo_md(directory)
puts "TODO.md has been generated in the #{directory} directory."

38
lib/todo_marker.rb Normal file
View File

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

View File

@ -0,0 +1,6 @@
# frozen_string_literal: true
# lib/todo_marker/version.rb
module TodoMarker
VERSION = "0.1.0"
end

4
sig/todo_marker.rbs Normal file
View File

@ -0,0 +1,4 @@
module TodoMarker
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
end

15
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
require "todo_marker"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
end

11
spec/todo_marker_spec.rb Normal file
View File

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

26
todo_marker.gemspec Normal file
View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
require_relative "lib/todo_marker/version"
Gem::Specification.new do |spec|
spec.name = "todo_marker"
spec.version = TodoMarker::VERSION
spec.authors = ["VetheonGames"]
spec.email = ["connor@pixelridgesoftworks.com"]
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
them.
mark things to add to the TODO.md with the `# !!TODO!!` magic comment"
spec.homepage = "https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Todo_Marker"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.2"
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Todo_Marker"
spec.files = Dir["lib/**/*.rb", "bin/*"]
spec.bindir = "bin"
spec.executables = ["todo_marker"]
spec.require_paths = ["lib"]
end