Sha256: bb1ee3c27f086df1b97a63b6fb56efe365dd65aea1ddda0b1af6ca6ff48878f0

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require "rocket_api/commands/files"
require "rocket_api/commands/dirs"
require "rocket_api/commands/gems_dir"
require "rocket_api/library/gem_repo_plain_text"

module RocketApi
  class RocketCommands
    extend RocketApi::Commands::Files
    extend RocketApi::Commands::Dirs
    extend RocketApi::Commands::GemsDir
    extend RocketApi::Library::GemRepoPlainText

    # @raise [RocketApi::CreateDirError]
    def self.init_gem_dir
      create_repo(RocketApi::GEM_PROJECTS_DIR)
    rescue StandardError => e
      raise RocketApi::CreateDirError,
            "#{RocketApi::CREATE_FAILED} #{e.message}"
    end

    # @param [String] project_name
    # ...
    # @raise [RocketApi::InitFilesError] error
    def self.init_gem_files(project_name)
      raise RocketApi::EMPTY_NAME if project_name.nil?

      init_bin!(project_name)
      init_gemspec!(project_name)
      init_gems_main_file!(project_name)
      init_gems_version!(project_name)
      init_gitignore!
    rescue StandardError => e
      raise RocketApi::InitFilesError,
            "#{RocketApi::INIT_FAIL} #{e.message}"
    end

    def self.init_bin!(name)
      dir_name = "bin/#{name}"
      create_single_file(
        dir_name,
        "",
        exe: true
      )
    end

    def self.init_gitignore!
      file_name = ".gitignore"
      create_single_file(
        file_name,
        gitignore_text
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocket_api-0.0.1.5 lib/rocket_api/rocket_commands.rb