Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lcsp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lcsp

  • 1.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

lcsp

GitHubActions codebeat badge Gem Version Gem Downloads

About

A tool for showing solutions from LeetCode.

How to use

Installation

Soon.

Run

You need to provide 3 arguments for run lcsp:

Parameter numberDescriptionExample
1GitHub user namefartem
2Repository nameleetcode-ruby
3Number of problem11

One of valid input variants be like:

$ lcsp fartem leetcode-ruby 11

How to write your own LCSPResolver

Read before start

lcsp works with custom resolvers - classes that should placed in your project and that will perform search locally.

You need to write resolver classes in Ruby because only this format accepting right now, but all work around search and parse for your repository you can place in classes/scripts/files in any other programming language.

One of the correct and working example available by this link.

Template class

path and number are default parameters that are presenting for every repository. This arguments describes user needs and gives you parameters to search.

# frozen_string_literal: true

module LCSP
  # Solutions finder.
  class LCSPFinder
    # @param {String} path
    # @param {String} number
    def initialize(path, number)
      @path = path
      @number = number
    end

    # @return {String}
    def solution
    end

    # @param {String} path
    # @param {String[]} dirs
    def fill_directories(path, dirs) end
  end
end
Reference class example
# frozen_string_literal: true

module LCSP
  # Solutions finder.
  class LCSPFinder
    # @param {String} path
    # @param {String} number
    def initialize(path, number)
      @path = path
      @number = number
    end

    # @return {String}
    def solution
      dirs = []
      fill_directories(@path, dirs)

      dirs.each do |directory|
        ::Dir.foreach(directory) do |entry|
          return "#{directory}/#{entry}" if entry.start_with?(@number)
        end
      end
    end

    # @param {String} path
    # @param {String[]} dirs
    def fill_directories(path, dirs)
      ::Dir.foreach(path).reject { |name| name.start_with?('.') }.each do |entry|
        unless ::File.file?("#{path}/#{entry}")
          dirs << "#{path}/#{entry}"
          fill_directories("#{path}/#{entry}", dirs)
        end
      end
    end
  end
end

Contributors

  • @fartem as Artem Fomchenkov

FAQs

Package last updated on 20 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc