Class: Souls::Delete
- Inherits:
-
Thor
- Object
- Thor
- Souls::Delete
- Defined in:
- lib/souls/cli/delete/job.rb,
lib/souls/cli/delete/edge.rb,
lib/souls/cli/delete/type.rb,
lib/souls/cli/delete/index.rb,
lib/souls/cli/delete/query.rb,
lib/souls/cli/delete/job_rbs.rb,
lib/souls/cli/delete/manager.rb,
lib/souls/cli/delete/edge_rbs.rb,
lib/souls/cli/delete/mutation.rb,
lib/souls/cli/delete/resolver.rb,
lib/souls/cli/delete/type_rbs.rb,
lib/souls/cli/delete/query_rbs.rb,
lib/souls/cli/delete/rspec_job.rb,
lib/souls/cli/delete/connection.rb,
lib/souls/cli/delete/application.rb,
lib/souls/cli/delete/manager_rbs.rb,
lib/souls/cli/delete/rspec_query.rb,
lib/souls/cli/delete/mutation_rbs.rb,
lib/souls/cli/delete/resolver_rbs.rb,
lib/souls/cli/delete/rspec_factory.rb,
lib/souls/cli/delete/rspec_manager.rb,
lib/souls/cli/delete/connection_rbs.rb,
lib/souls/cli/delete/migration_file.rb,
lib/souls/cli/delete/rspec_mutation.rb,
lib/souls/cli/delete/rspec_resolver.rb
Instance Method Summary collapse
- #connection(class_name) ⇒ Object
- #connection_rbs(class_name) ⇒ Object
- #edge(class_name) ⇒ Object
- #edge_rbs(class_name) ⇒ Object
- #job(class_name) ⇒ Object
- #job_rbs(class_name) ⇒ Object
- #manager(class_name) ⇒ Object
- #manager_rbs(class_name) ⇒ Object
- #migration(class_name) ⇒ Object
- #mutation(class_name) ⇒ Object
- #mutation_rbs(class_name) ⇒ Object
- #query(class_name) ⇒ Object
- #query_rbs(class_name) ⇒ Object
- #resolver(class_name) ⇒ Object
- #resolver_rbs(class_name) ⇒ Object
- #rspec_factory(class_name) ⇒ Object
- #rspec_job(class_name) ⇒ Object
- #rspec_manager(class_name) ⇒ Object
- #rspec_mutation(class_name) ⇒ Object
- #rspec_query(class_name) ⇒ Object
- #rspec_resolver(class_name) ⇒ Object
- #scaffold(class_name) ⇒ Object
- #scaffold_all ⇒ Object
- #type(class_name) ⇒ Object
- #type_rbs(class_name) ⇒ Object
Instance Method Details
#connection(class_name) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/souls/cli/delete/connection.rb', line 4 def connection(class_name) file_dir = "./app/graphql/types/connections/" singularized_class_name = class_name.underscore.singularize file_path = "#{file_dir}#{singularized_class_name}_connection.rb" FileUtils.rm_f(file_path) puts(Paint % ["Delete file! : %{white_text}", :yellow, { white_text: [file_path.to_s, :white] }]) file_path end |
#connection_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/souls/cli/delete/connection_rbs.rb', line 4 def connection_rbs(class_name) file_path = "" Dir.chdir(Souls.get_mother_path.to_s) do singularized_class_name = class_name.underscore.singularize file_dir = "./sig/api/app/graphql/types/connections/" file_path = "#{file_dir}#{singularized_class_name}_connection.rbs" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) end file_path end |
#edge(class_name) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/souls/cli/delete/edge.rb', line 4 def edge(class_name) file_dir = "./app/graphql/types/edges/" singularized_class_name = class_name.underscore.singularize file_path = "#{file_dir}#{singularized_class_name}_edge.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#edge_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/souls/cli/delete/edge_rbs.rb', line 4 def edge_rbs(class_name) Dir.chdir(Souls.get_mother_path.to_s) do file_dir = "./sig/api/app/graphql/types/edges/" singularized_class_name = class_name.underscore.singularize file_path = "#{file_dir}#{singularized_class_name}_edge.rbs" FileUtils.rm_f(file_path) puts(Paint % ["Delete file! : %{white_text}", :yellow, { white_text: [file_path.to_s, :white] }]) file_path end end |
#job(class_name) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/souls/cli/delete/job.rb', line 5 def job(class_name) file_dir = "./app/graphql/queries/" file_path = "#{file_dir}#{class_name.singularize}.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) Souls::Delete.new.invoke(:job_rbs, [class_name], {}) Souls::Delete.new.invoke(:rspec_job, [class_name], {}) end |
#job_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/souls/cli/delete/job_rbs.rb', line 4 def job_rbs(class_name) file_path = "" worker_name = FileUtils.pwd.split("/").last if worker_name == "api" || FileUtils.pwd.split("/")[-2] != "apps" raise(Souls::CLIException, "This task must be run from within a worker directory") end Dir.chdir(Souls.get_mother_path.to_s) do singularized_class_name = class_name.underscore.singularize file_dir = "./sig/#{worker_name}/app/graphql/queries/" FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir) file_path = "#{file_dir}#{singularized_class_name}.rbs" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) end file_path end |
#manager(class_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/souls/cli/delete/manager.rb', line 5 def manager(class_name) singularized_class_name = class_name.underscore.singularize file_dir = "./app/graphql/mutations/managers/#{singularized_class_name}_manager" file_path = "#{file_dir}/#{[:mutation]}.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) Souls::Delete.new.invoke(:manager_rbs, [singularized_class_name], { mutation: [:mutation] }) Souls::Delete.new.invoke(:rspec_manager, [singularized_class_name], { mutation: [:mutation] }) file_path end |
#manager_rbs(class_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/souls/cli/delete/manager_rbs.rb', line 5 def manager_rbs(class_name) file_path = "" singularized_class_name = class_name.underscore.singularize Dir.chdir(Souls.get_mother_path.to_s) do file_dir = "./sig/api/app/graphql/mutations/managers/#{singularized_class_name}_manager" file_path = "#{file_dir}/#{[:mutation]}.rbs" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) end file_path end |
#migration(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/souls/cli/delete/migration_file.rb', line 4 def migration(class_name) singularized_class_name = class_name.underscore.singularize pluralized_class_name = class_name.underscore.pluralize Dir.chdir(Souls.get_mother_path.to_s) do file_paths = { model_file_path: "./apps/api/app/models/#{singularized_class_name}.rb", rspec_file_path: "./apps/api/spec/models/#{singularized_class_name}_spec.rb", rbs_file_path: "./sig/api/app/models/#{singularized_class_name}.rbs", migration_file_path: Dir["db/migrate/*create_#{pluralized_class_name}.rb"].first } file_paths.each do |_k, v| FileUtils.rm_f(v) Souls::Painter.delete_file(v) rescue StandardError => e puts(e) end file_paths end end |
#mutation(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/souls/cli/delete/mutation.rb', line 4 def mutation(class_name) singularized_class_name = class_name.singularize file_path = "" Dir.chdir(Souls.get_api_path.to_s) do file_path = "./app/graphql/mutations/base/#{singularized_class_name}/" FileUtils.rm_rf(file_path) end Souls::Painter.delete_file(file_path.to_s) file_path end |
#mutation_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/souls/cli/delete/mutation_rbs.rb', line 4 def mutation_rbs(class_name) singularized_class_name = class_name.underscore.singularize file_path = "" Dir.chdir(Souls.get_mother_path.to_s) do file_dir = "./sig/api/app/graphql/mutations/base/#{singularized_class_name}" FileUtils.rm_rf(file_dir) end Souls::Painter.delete_file(file_path.to_s) file_path end |
#query(class_name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/souls/cli/delete/query.rb', line 4 def query(class_name) singularized_class_name = class_name.singularize file_path = "./app/graphql/queries/#{singularized_class_name}*.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#query_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/souls/cli/delete/query_rbs.rb', line 4 def query_rbs(class_name) file_path = "" Dir.chdir(Souls.get_mother_path.to_s) do file_dir = "./sig/api/app/graphql/queries/" singularized_class_name = class_name.underscore.singularize file_path = "#{file_dir}#{singularized_class_name}*.rbs" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end end |
#resolver(class_name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/souls/cli/delete/resolver.rb', line 4 def resolver(class_name) singularized_class_name = class_name.singularize.underscore file_path = "./app/graphql/resolvers/#{singularized_class_name}_search.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#resolver_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/souls/cli/delete/resolver_rbs.rb', line 4 def resolver_rbs(class_name) singularized_class_name = class_name.underscore.singularize file_path = "" Dir.chdir(Souls.get_mother_path.to_s) do file_dir = "./sig/api/app/graphql/resolvers" file_path = "#{file_dir}/#{singularized_class_name}_search.rbs" FileUtils.rm_f(file_path) end Souls::Painter.delete_file(file_path.to_s) file_path end |
#rspec_factory(class_name) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/souls/cli/delete/rspec_factory.rb', line 4 def rspec_factory(class_name) file_path = "./spec/factories/#{class_name.pluralize}.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#rspec_job(class_name) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/souls/cli/delete/rspec_job.rb', line 4 def rspec_job(class_name) file_dir = "./spec/jobs" singularized_class_name = class_name.underscore.singularize file_path = "#{file_dir}/#{singularized_class_name}_spec.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#rspec_manager(class_name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/souls/cli/delete/rspec_manager.rb', line 5 def rspec_manager(class_name) singularized_class_name = class_name.underscore.singularize file_path = "./spec/mutations/managers/#{singularized_class_name}/#{[:mutation]}_spec.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#rspec_mutation(class_name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/souls/cli/delete/rspec_mutation.rb', line 4 def rspec_mutation(class_name) singularized_class_name = class_name.singularize file_path = "./spec/mutations/base/#{singularized_class_name}_spec.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#rspec_query(class_name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/souls/cli/delete/rspec_query.rb', line 4 def rspec_query(class_name) singularized_class_name = class_name.singularize file_path = "./spec/queries/#{singularized_class_name}_spec.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#rspec_resolver(class_name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/souls/cli/delete/rspec_resolver.rb', line 4 def rspec_resolver(class_name) singularized_class_name = class_name.singularize file_path = "./spec/resolvers/#{singularized_class_name}_search_spec.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#scaffold(class_name) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/souls/cli/delete/application.rb', line 5 def scaffold(class_name) singularized_class_name = class_name.singularize if [:rbs] run_rbs_scaffold(class_name: singularized_class_name) else run_scaffold(class_name: singularized_class_name) end true end |
#scaffold_all ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/souls/cli/delete/application.rb', line 17 def scaffold_all puts(Paint["Delete All Scaffold Files!\n", :cyan]) Souls.get_tables.each do |table| Souls::Delete.new.invoke(:scaffold, [table.singularize], { rbs: [:rbs] }) end true end |
#type(class_name) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/souls/cli/delete/type.rb', line 4 def type(class_name) singularized_class_name = class_name.singularize file_path = "./app/graphql/types/#{singularized_class_name}_type.rb" FileUtils.rm_f(file_path) Souls::Painter.delete_file(file_path.to_s) file_path end |
#type_rbs(class_name) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/souls/cli/delete/type_rbs.rb', line 4 def type_rbs(class_name) singularized_class_name = class_name.underscore.singularize file_path = "" Dir.chdir(Souls.get_mother_path.to_s) do file_dir = "./sig/api/app/graphql/types" file_path = "#{file_dir}/#{singularized_class_name}_type.rbs" FileUtils.rm_f(file_path) end Souls::Painter.delete_file(file_path.to_s) file_path end |