Class: SOULs::Delete

Inherits:
Thor
  • Object
show all
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/manager.rb,
lib/souls/cli/delete/mutation.rb,
lib/souls/cli/delete/resolver.rb,
lib/souls/cli/delete/rspec_job.rb,
lib/souls/cli/delete/connection.rb,
lib/souls/cli/delete/application.rb,
lib/souls/cli/delete/rspec_query.rb,
lib/souls/cli/delete/rspec_factory.rb,
lib/souls/cli/delete/rspec_manager.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

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)
  SOULs::Painter.delete_file(file_path)
  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

#job(class_name) ⇒ Object



5
6
7
8
9
10
11
12
# 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(:rspec_job, [class_name], {})
end

#manager(class_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# 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}/#{options[:mutation]}.rb"

  FileUtils.rm_f(file_path)
  SOULs::Painter.delete_file(file_path.to_s)
  SOULs::Delete.new.invoke(:rspec_manager, [singularized_class_name], { mutation: options[:mutation] })
  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
# 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",
      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

#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

#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

#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/queries/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}/#{options[: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



4
5
6
7
8
# File 'lib/souls/cli/delete/application.rb', line 4

def scaffold(class_name)
  singularized_class_name = class_name.singularize
  run_scaffold(class_name: singularized_class_name)
  true
end

#scaffold_allObject



11
12
13
14
15
16
17
# File 'lib/souls/cli/delete/application.rb', line 11

def scaffold_all
  puts(Paint["Delete All Scaffold Files!\n", :cyan])
  SOULs.get_tables.each do |table|
    SOULs::Delete.new.invoke(:scaffold, [table.singularize], {})
  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