Sha256: 9c2459e11d346aedbf63250c2f05ca464ce78f2d87c2fb544b7430dfd8860b13

Contents?: true

Size: 827 Bytes

Versions: 7

Compression:

Stored size: 827 Bytes

Contents

module RocketApi
  module Commands
    module Files
      # @param [String] dir_name
      def is_exist?(dir_name)
        File.exist?(dir_name)
      end

      # @param [String] name
      def class_name_camel(name)
        name.split('_').map(&:capitalize).join
      end

      # @param [String] name
      # @param [String] text
      # @param [Hash] options
      # ...
      # @raise [StandardError] error
      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
        raise e, "#{name} err: #{e.message}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rocket_api-0.0.2.0 lib/rocket_api/commands/files.rb
rocket_api-0.0.1.9 lib/rocket_api/commands/files.rb
rocket_api-0.0.1.8 lib/rocket_api/commands/files.rb
rocket_api-0.0.1.7 lib/rocket_api/commands/files.rb
rocket_api-0.0.1.6 lib/rocket_api/commands/files.rb
rocket_api-0.0.1.5 lib/rocket_api/commands/files.rb
rocket_api-0.0.1.4 lib/rocket_api/commands/files.rb