Giter Site home page Giter Site logo

cron-expression-parser's Introduction

Cron Expression Parser

This project has been built in Java. Gradle is used for dependency management and JUnit5 is used for Unit Testing.

How to Setup Locally

  1. Open this project in IntelliJ IDEA

  2. Run Gradle -> Tasks -> build -> jar to create a jar in the build/libs/ folder

  3. Run the following command to execute the JAR file with the custom parameters:

    java -jar cron-expression-parser-1.0-SNAPSHOT.jar "*/15 0 1,15 * 1-5 /usr/bin/find"
    
  4. The above command will generate an output like this:

    $ java -jar cron-expression-parser-1.0-SNAPSHOT.jar "*/15 0 1,15 * 1-5 /usr/bin/find"
    minute        0 15 30 45
    hour          0
    day of month  1 15
    month         1 2 3 4 5 6 7 8 9 10 11 12
    day of week   1 2 3 4 5
    command       /usr/bin/find
    

How to Run Tests

  1. Run Gradle -> Tasks -> verification -> test to run all the tests

  2. It should run all the tests and will look like this:

    Screenshot 2024-03-04 at 3 23 04 AM

Problem Statement

Write a command line application or script which parses a cron string and expands each field to show the times at which it will run. You may use whichever language you feel most comfortable with.

You should only consider the standard cron format with five time fields (minute, hour, day of month, month, and day of week) plus a command, and you do not need to handle the special time strings such as "@yearly". The input will be on a single line.

The cron string will be passed to your application as a single argument.

~$ your-program "*/15 0 1,15 * 1-5 /usr/bin/find"

The output should be formatted as a table with the field name taking the first 14 columns and the times as a space-separated list following it.

For example, the following input argument:

*/15 0 1,15 * 1-5 /usr/bin/find

Should yield the following output:

minute          0 15 30 45
hour            0
day of month    1 15
month           1 2 3 4 5 6 7 8 9 10 11 12
dayofweek       1 2 3 4 5
command         /usr/bin/find

You should spend no more than three hours on this exercise. If you do not have time to handle all possible cron strings then an app which handles a subset of them correctly is better than one which does not run or produces incorrect results. You ​will be asked to extend the solution with additional features while onsite.

You should see your project reviewer as a new team member you are handing the project over to. Provide everything you feel would be relevant for them to ramp up quickly, such as tests, a README and instructions for how to run your project in a clean OS X/Linux environment.

cron-expression-parser's People

Contributors

rajatgoyal715 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.