Sha256: 7b3f3d6297ab334116825b0963d5df9f4168f326ca7e945fda01c58a5447fbc6

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

module RocketApi
  module Commands
    module Files
      def is_exist?(dir_name)
        File.exist?(dir_name)
      end

      def class_name_camel(name)
        name.split('_').map(&:capitalize).join
      end

      def create_single_file(name, text, **options)
        raise "#{RocketApi::FILE_EXIST} #{name}" if is_exist?(name)

        out_file = File.new(name, "w")
        out_file.chmod(001) if options[:exe]
        out_file.puts(text)
        out_file.close

        puts "#{RocketApi::CREATE_SUCCESS} #{name}"
      rescue StandardError => e
        puts "#{RocketApi::CREATE_FAILED} #{name} err: #{e.message}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocket_api-0.0.1.1 lib/rocket_api/commands/files.rb