Giter VIP home page Giter VIP logo

ntp's Introduction

NTP Mock Server

Build Status Dependency Status Gem Version

Usage

in ruby script

Install gem from github, by adding the gem line into the Gemfile as follows:

gem 'ntp-mock-server', github: 'dmcnulla/ntp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ntp-mock-server

Add to your script:

require 'ntp' # NOTE it automatically includes 'net/ntp' gem

# create a new server instance
server = NTP::Server::Control.new

# starting the server on 12345-th port.
server.start(12345)
# => "started NTP mock server on localhost:12345."

# get a time from the server
Net::NTP::get('127.0.0.1', 12345).time # => time...

# set base time for the server
server.time("2000/01/01 01:00")

# get a new rebased time from the server
Net::NTP::get('127.0.0.1', 12345).time # => "2000/01/01 01:05"

# stop the server. NOTE since the server is bind to another process, it shall be explicitly stopped.
server.stop
# => "stopped"

From a command line

You can control the server by using a command line interface as follows:

# start the server
$ ntp-mock-server start

# setb server's base time
$ ntp-mock-server time "2000/01/01 01:00"

# stop the server
$ ntp-mock-server stop

Issue the CLI application without a command to view all available ones:

$ ntp-mock-server
Usage: ntp-mock-server [start|stop|restart|status|time <time>|reset]

Contributing

  1. Fork it ( https://github.com/dmcnulla/ntp/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

See LICENSE.txt file.

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.